diff --git a/bin/ai/compat_0.7.nut b/bin/ai/compat_0.7.nut index c40308592c..341b543bd3 100644 --- a/bin/ai/compat_0.7.nut +++ b/bin/ai/compat_0.7.nut @@ -379,3 +379,16 @@ AIGroup.CreateGroup <- function(vehicle_type) { return AIGroup._CreateGroup(vehicle_type, AIGroup.GROUP_INVALID); } + +/* 13 really checks RoadType against RoadType */ +AIRoad._HasRoadType <- AIRoad.HasRoadType; +AIRoad.HasRoadType <- function(tile, road_type) +{ + local list = AIRoadTypeList(AIRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (AIRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/ai/compat_1.0.nut b/bin/ai/compat_1.0.nut index b8da71a194..6b76f11534 100644 --- a/bin/ai/compat_1.0.nut +++ b/bin/ai/compat_1.0.nut @@ -131,3 +131,16 @@ AIGroup.CreateGroup <- function(vehicle_type) { return AIGroup._CreateGroup(vehicle_type, AIGroup.GROUP_INVALID); } + +/* 13 really checks RoadType against RoadType */ +AIRoad._HasRoadType <- AIRoad.HasRoadType; +AIRoad.HasRoadType <- function(tile, road_type) +{ + local list = AIRoadTypeList(AIRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (AIRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/ai/compat_1.1.nut b/bin/ai/compat_1.1.nut index f1bda9c7fe..9c568a7006 100644 --- a/bin/ai/compat_1.1.nut +++ b/bin/ai/compat_1.1.nut @@ -68,3 +68,16 @@ AIGroup.CreateGroup <- function(vehicle_type) { return AIGroup._CreateGroup(vehicle_type, AIGroup.GROUP_INVALID); } + +/* 13 really checks RoadType against RoadType */ +AIRoad._HasRoadType <- AIRoad.HasRoadType; +AIRoad.HasRoadType <- function(tile, road_type) +{ + local list = AIRoadTypeList(AIRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (AIRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/ai/compat_1.10.nut b/bin/ai/compat_1.10.nut index 2baaddb836..44bc2542ce 100644 --- a/bin/ai/compat_1.10.nut +++ b/bin/ai/compat_1.10.nut @@ -6,3 +6,16 @@ */ AILog.Info("1.10 API compatibility in effect."); + +/* 13 really checks RoadType against RoadType */ +AIRoad._HasRoadType <- AIRoad.HasRoadType; +AIRoad.HasRoadType <- function(tile, road_type) +{ + local list = AIRoadTypeList(AIRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (AIRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/ai/compat_1.11.nut b/bin/ai/compat_1.11.nut index 887f3f7fd9..3d8370ffc6 100644 --- a/bin/ai/compat_1.11.nut +++ b/bin/ai/compat_1.11.nut @@ -6,3 +6,16 @@ */ AILog.Info("1.11 API compatibility in effect."); + +/* 13 really checks RoadType against RoadType */ +AIRoad._HasRoadType <- AIRoad.HasRoadType; +AIRoad.HasRoadType <- function(tile, road_type) +{ + local list = AIRoadTypeList(AIRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (AIRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/ai/compat_1.2.nut b/bin/ai/compat_1.2.nut index 550f79969c..fc52b04935 100644 --- a/bin/ai/compat_1.2.nut +++ b/bin/ai/compat_1.2.nut @@ -20,3 +20,16 @@ AIGroup.CreateGroup <- function(vehicle_type) { return AIGroup._CreateGroup(vehicle_type, AIGroup.GROUP_INVALID); } + +/* 13 really checks RoadType against RoadType */ +AIRoad._HasRoadType <- AIRoad.HasRoadType; +AIRoad.HasRoadType <- function(tile, road_type) +{ + local list = AIRoadTypeList(AIRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (AIRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/ai/compat_1.3.nut b/bin/ai/compat_1.3.nut index 6b2c7e8a71..a06e98d2dd 100644 --- a/bin/ai/compat_1.3.nut +++ b/bin/ai/compat_1.3.nut @@ -20,3 +20,16 @@ AIGroup.CreateGroup <- function(vehicle_type) { return AIGroup._CreateGroup(vehicle_type, AIGroup.GROUP_INVALID); } + +/* 13 really checks RoadType against RoadType */ +AIRoad._HasRoadType <- AIRoad.HasRoadType; +AIRoad.HasRoadType <- function(tile, road_type) +{ + local list = AIRoadTypeList(AIRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (AIRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/ai/compat_1.4.nut b/bin/ai/compat_1.4.nut index a9ab5a4757..6de24bf80c 100644 --- a/bin/ai/compat_1.4.nut +++ b/bin/ai/compat_1.4.nut @@ -20,3 +20,16 @@ AIGroup.CreateGroup <- function(vehicle_type) { return AIGroup._CreateGroup(vehicle_type, AIGroup.GROUP_INVALID); } + +/* 13 really checks RoadType against RoadType */ +AIRoad._HasRoadType <- AIRoad.HasRoadType; +AIRoad.HasRoadType <- function(tile, road_type) +{ + local list = AIRoadTypeList(AIRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (AIRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/ai/compat_1.5.nut b/bin/ai/compat_1.5.nut index 23944149f6..8ff5a39d15 100644 --- a/bin/ai/compat_1.5.nut +++ b/bin/ai/compat_1.5.nut @@ -20,3 +20,16 @@ AIGroup.CreateGroup <- function(vehicle_type) { return AIGroup._CreateGroup(vehicle_type, AIGroup.GROUP_INVALID); } + +/* 13 really checks RoadType against RoadType */ +AIRoad._HasRoadType <- AIRoad.HasRoadType; +AIRoad.HasRoadType <- function(tile, road_type) +{ + local list = AIRoadTypeList(AIRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (AIRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/ai/compat_1.6.nut b/bin/ai/compat_1.6.nut index bcbe91455c..91744512a7 100644 --- a/bin/ai/compat_1.6.nut +++ b/bin/ai/compat_1.6.nut @@ -20,3 +20,16 @@ AIGroup.CreateGroup <- function(vehicle_type) { return AIGroup._CreateGroup(vehicle_type, AIGroup.GROUP_INVALID); } + +/* 13 really checks RoadType against RoadType */ +AIRoad._HasRoadType <- AIRoad.HasRoadType; +AIRoad.HasRoadType <- function(tile, road_type) +{ + local list = AIRoadTypeList(AIRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (AIRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/ai/compat_1.7.nut b/bin/ai/compat_1.7.nut index 7c2fd9b825..584a970f60 100644 --- a/bin/ai/compat_1.7.nut +++ b/bin/ai/compat_1.7.nut @@ -20,3 +20,16 @@ AIGroup.CreateGroup <- function(vehicle_type) { return AIGroup._CreateGroup(vehicle_type, AIGroup.GROUP_INVALID); } + +/* 13 really checks RoadType against RoadType */ +AIRoad._HasRoadType <- AIRoad.HasRoadType; +AIRoad.HasRoadType <- function(tile, road_type) +{ + local list = AIRoadTypeList(AIRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (AIRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/ai/compat_1.8.nut b/bin/ai/compat_1.8.nut index a118a63b57..f57a0eab27 100644 --- a/bin/ai/compat_1.8.nut +++ b/bin/ai/compat_1.8.nut @@ -20,3 +20,16 @@ AIGroup.CreateGroup <- function(vehicle_type) { return AIGroup._CreateGroup(vehicle_type, AIGroup.GROUP_INVALID); } + +/* 13 really checks RoadType against RoadType */ +AIRoad._HasRoadType <- AIRoad.HasRoadType; +AIRoad.HasRoadType <- function(tile, road_type) +{ + local list = AIRoadTypeList(AIRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (AIRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/ai/compat_1.9.nut b/bin/ai/compat_1.9.nut index a3d0941327..0dde6dc6da 100644 --- a/bin/ai/compat_1.9.nut +++ b/bin/ai/compat_1.9.nut @@ -6,3 +6,16 @@ */ AILog.Info("1.9 API compatibility in effect."); + +/* 13 really checks RoadType against RoadType */ +AIRoad._HasRoadType <- AIRoad.HasRoadType; +AIRoad.HasRoadType <- function(tile, road_type) +{ + local list = AIRoadTypeList(AIRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (AIRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/ai/compat_12.nut b/bin/ai/compat_12.nut index 2ff41f8b4f..d54895632f 100644 --- a/bin/ai/compat_12.nut +++ b/bin/ai/compat_12.nut @@ -6,3 +6,16 @@ */ AILog.Info("12 API compatibility in effect."); + +/* 13 really checks RoadType against RoadType */ +AIRoad._HasRoadType <- AIRoad.HasRoadType; +AIRoad.HasRoadType <- function(tile, road_type) +{ + local list = AIRoadTypeList(AIRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (AIRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/game/compat_1.10.nut b/bin/game/compat_1.10.nut index 92cef84c53..2559ff0a9c 100644 --- a/bin/game/compat_1.10.nut +++ b/bin/game/compat_1.10.nut @@ -13,3 +13,16 @@ GSCompany.ChangeBankBalance <- function(company, delta, expenses_type) { return GSCompany._ChangeBankBalance(company, delta, expenses_type, GSMap.TILE_INVALID); } + +/* 13 really checks RoadType against RoadType */ +GSRoad._HasRoadType <- GSRoad.HasRoadType; +GSRoad.HasRoadType <- function(tile, road_type) +{ + local list = GSRoadTypeList(GSRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (GSRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/game/compat_1.11.nut b/bin/game/compat_1.11.nut index fa240b5d2d..eac9a05d36 100644 --- a/bin/game/compat_1.11.nut +++ b/bin/game/compat_1.11.nut @@ -6,3 +6,16 @@ */ GSLog.Info("1.11 API compatibility in effect."); + +/* 13 really checks RoadType against RoadType */ +GSRoad._HasRoadType <- GSRoad.HasRoadType; +GSRoad.HasRoadType <- function(tile, road_type) +{ + local list = GSRoadTypeList(GSRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (GSRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/game/compat_1.2.nut b/bin/game/compat_1.2.nut index 5fb29efedf..66e2ca5d62 100644 --- a/bin/game/compat_1.2.nut +++ b/bin/game/compat_1.2.nut @@ -35,3 +35,16 @@ GSCompany.ChangeBankBalance <- function(company, delta, expenses_type) { return GSCompany._ChangeBankBalance(company, delta, expenses_type, GSMap.TILE_INVALID); } + +/* 13 really checks RoadType against RoadType */ +GSRoad._HasRoadType <- GSRoad.HasRoadType; +GSRoad.HasRoadType <- function(tile, road_type) +{ + local list = GSRoadTypeList(GSRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (GSRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/game/compat_1.3.nut b/bin/game/compat_1.3.nut index 7546e54c69..9986ea03e5 100644 --- a/bin/game/compat_1.3.nut +++ b/bin/game/compat_1.3.nut @@ -35,3 +35,16 @@ GSCompany.ChangeBankBalance <- function(company, delta, expenses_type) { return GSCompany._ChangeBankBalance(company, delta, expenses_type, GSMap.TILE_INVALID); } + +/* 13 really checks RoadType against RoadType */ +GSRoad._HasRoadType <- GSRoad.HasRoadType; +GSRoad.HasRoadType <- function(tile, road_type) +{ + local list = GSRoadTypeList(GSRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (GSRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/game/compat_1.4.nut b/bin/game/compat_1.4.nut index c90b3e550b..b3ec5c45cb 100644 --- a/bin/game/compat_1.4.nut +++ b/bin/game/compat_1.4.nut @@ -28,3 +28,15 @@ GSCompany.ChangeBankBalance <- function(company, delta, expenses_type) return GSCompany._ChangeBankBalance(company, delta, expenses_type, GSMap.TILE_INVALID); } +/* 13 really checks RoadType against RoadType */ +GSRoad._HasRoadType <- GSRoad.HasRoadType; +GSRoad.HasRoadType <- function(tile, road_type) +{ + local list = GSRoadTypeList(GSRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (GSRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/game/compat_1.5.nut b/bin/game/compat_1.5.nut index 0c62e56462..2d25d7acf0 100644 --- a/bin/game/compat_1.5.nut +++ b/bin/game/compat_1.5.nut @@ -20,3 +20,16 @@ GSCompany.ChangeBankBalance <- function(company, delta, expenses_type) { return GSCompany._ChangeBankBalance(company, delta, expenses_type, GSMap.TILE_INVALID); } + +/* 13 really checks RoadType against RoadType */ +GSRoad._HasRoadType <- GSRoad.HasRoadType; +GSRoad.HasRoadType <- function(tile, road_type) +{ + local list = GSRoadTypeList(GSRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (GSRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/game/compat_1.6.nut b/bin/game/compat_1.6.nut index 198b863a77..d205832209 100644 --- a/bin/game/compat_1.6.nut +++ b/bin/game/compat_1.6.nut @@ -20,3 +20,16 @@ GSCompany.ChangeBankBalance <- function(company, delta, expenses_type) { return GSCompany._ChangeBankBalance(company, delta, expenses_type, GSMap.TILE_INVALID); } + +/* 13 really checks RoadType against RoadType */ +GSRoad._HasRoadType <- GSRoad.HasRoadType; +GSRoad.HasRoadType <- function(tile, road_type) +{ + local list = GSRoadTypeList(GSRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (GSRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/game/compat_1.7.nut b/bin/game/compat_1.7.nut index 76dc424353..1108f41a7c 100644 --- a/bin/game/compat_1.7.nut +++ b/bin/game/compat_1.7.nut @@ -20,3 +20,16 @@ GSCompany.ChangeBankBalance <- function(company, delta, expenses_type) { return GSCompany._ChangeBankBalance(company, delta, expenses_type, GSMap.TILE_INVALID); } + +/* 13 really checks RoadType against RoadType */ +GSRoad._HasRoadType <- GSRoad.HasRoadType; +GSRoad.HasRoadType <- function(tile, road_type) +{ + local list = GSRoadTypeList(GSRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (GSRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/game/compat_1.8.nut b/bin/game/compat_1.8.nut index b9d27458a9..139f91214b 100644 --- a/bin/game/compat_1.8.nut +++ b/bin/game/compat_1.8.nut @@ -20,3 +20,16 @@ GSCompany.ChangeBankBalance <- function(company, delta, expenses_type) { return GSCompany._ChangeBankBalance(company, delta, expenses_type, GSMap.TILE_INVALID); } + +/* 13 really checks RoadType against RoadType */ +GSRoad._HasRoadType <- GSRoad.HasRoadType; +GSRoad.HasRoadType <- function(tile, road_type) +{ + local list = GSRoadTypeList(GSRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (GSRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/game/compat_1.9.nut b/bin/game/compat_1.9.nut index 32eec114af..053e377d4c 100644 --- a/bin/game/compat_1.9.nut +++ b/bin/game/compat_1.9.nut @@ -13,3 +13,16 @@ GSCompany.ChangeBankBalance <- function(company, delta, expenses_type) { return GSCompany._ChangeBankBalance(company, delta, expenses_type, GSMap.TILE_INVALID); } + +/* 13 really checks RoadType against RoadType */ +GSRoad._HasRoadType <- GSRoad.HasRoadType; +GSRoad.HasRoadType <- function(tile, road_type) +{ + local list = GSRoadTypeList(GSRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (GSRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/bin/game/compat_12.nut b/bin/game/compat_12.nut index df08583914..a11cd04a23 100644 --- a/bin/game/compat_12.nut +++ b/bin/game/compat_12.nut @@ -6,3 +6,16 @@ */ GSLog.Info("12 API compatibility in effect."); + +/* 13 really checks RoadType against RoadType */ +GSRoad._HasRoadType <- GSRoad.HasRoadType; +GSRoad.HasRoadType <- function(tile, road_type) +{ + local list = GSRoadTypeList(GSRoad.GetRoadTramType(road_type)); + foreach (rt, _ in list) { + if (GSRoad._HasRoadType(tile, rt)) { + return true; + } + } + return false; +} diff --git a/media/baseset/openttd.grf b/media/baseset/openttd.grf index 837e4b12d2..e3ebf2dd67 100644 Binary files a/media/baseset/openttd.grf and b/media/baseset/openttd.grf differ diff --git a/media/baseset/openttd/flags.nfo b/media/baseset/openttd/flags.nfo deleted file mode 100644 index 3c125ec79a..0000000000 --- a/media/baseset/openttd/flags.nfo +++ /dev/null @@ -1,43 +0,0 @@ -// This file is part of OpenTTD. -// OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. -// OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . -// - -1 * 0 0C "Flag graphics" - -1 * 3 05 14 24 - -1 sprites/flags.png 8bpp 34 8 11 8 0 0 normal - -1 sprites/flags.png 8bpp 50 8 11 8 0 0 normal - -1 sprites/flags.png 8bpp 66 8 11 8 0 0 normal - -1 sprites/flags.png 8bpp 82 8 11 8 0 0 normal - -1 sprites/flags.png 8bpp 98 8 11 8 0 0 normal - -1 sprites/flags.png 8bpp 114 8 11 8 0 0 normal - -1 sprites/flags.png 8bpp 130 8 11 8 0 0 normal - -1 sprites/flags.png 8bpp 146 8 11 8 0 0 normal - -1 sprites/flags.png 8bpp 162 8 11 8 0 0 normal - -1 sprites/flags.png 8bpp 178 8 11 8 0 0 normal - -1 sprites/flags.png 8bpp 194 8 11 8 0 0 normal - -1 sprites/flags.png 8bpp 210 8 11 8 0 0 normal - -1 sprites/flags.png 8bpp 226 8 11 8 0 0 normal - -1 sprites/flags.png 8bpp 242 8 11 8 0 0 normal - -1 sprites/flags.png 8bpp 258 8 11 8 0 0 normal - -1 sprites/flags.png 8bpp 274 8 11 8 0 0 normal - -1 sprites/flags.png 8bpp 290 8 11 8 0 0 normal - -1 sprites/flags.png 8bpp 306 8 11 8 0 0 normal - -1 sprites/flags.png 8bpp 322 8 11 8 0 0 normal - -1 sprites/flags.png 8bpp 338 8 11 8 0 0 normal - -1 sprites/flags.png 8bpp 354 8 11 8 0 0 normal - -1 sprites/flags.png 8bpp 370 8 11 8 0 0 normal - -1 sprites/flags.png 8bpp 386 8 11 8 0 0 normal - -1 sprites/flags.png 8bpp 402 8 11 8 0 0 normal - -1 sprites/flags.png 8bpp 418 8 11 8 0 0 normal - -1 sprites/flags.png 8bpp 434 8 11 8 0 0 normal - -1 sprites/flags.png 8bpp 450 8 11 8 0 0 normal - -1 sprites/flags.png 8bpp 466 8 11 8 0 0 normal - -1 sprites/flags.png 8bpp 482 8 11 8 0 0 normal - -1 sprites/flags.png 8bpp 498 8 11 8 0 0 normal - -1 sprites/flags.png 8bpp 514 8 11 8 0 0 normal - -1 sprites/flags.png 8bpp 530 8 11 8 0 0 normal - -1 sprites/flags.png 8bpp 546 8 11 8 0 0 normal - -1 sprites/flags.png 8bpp 562 8 11 8 0 0 normal - -1 sprites/flags.png 8bpp 578 8 11 8 0 0 normal - -1 sprites/flags.png 8bpp 594 8 11 8 0 0 normal diff --git a/media/baseset/openttd/flags.png b/media/baseset/openttd/flags.png deleted file mode 100644 index 2e0401ffce..0000000000 Binary files a/media/baseset/openttd/flags.png and /dev/null differ diff --git a/media/baseset/openttd/openttd.nfo b/media/baseset/openttd/openttd.nfo index b0d80824e8..c1ed751c55 100644 --- a/media/baseset/openttd/openttd.nfo +++ b/media/baseset/openttd/openttd.nfo @@ -92,7 +92,6 @@ #include "roadstops.nfo" #include "aqueduct.nfo" #include "autorail.nfo" -#include "flags.nfo" #include "openttdgui.nfo" #include "airport_preview.nfo" #include "chars.nfo" diff --git a/os/windows/openttd.manifest b/os/windows/openttd.manifest index ee1c7ea224..cb536a819d 100644 --- a/os/windows/openttd.manifest +++ b/os/windows/openttd.manifest @@ -10,6 +10,7 @@ True/PM + PerMonitorV2,PerMonitor diff --git a/regression/regression/main.nut b/regression/regression/main.nut index 9b68226953..05d6f275bd 100644 --- a/regression/regression/main.nut +++ b/regression/regression/main.nut @@ -341,6 +341,7 @@ function Regression::Cargo() print(" GetCargoIncome(10, 10): " + AICargo.GetCargoIncome(i, 10, 10)); print(" GetCargoIncome(100, 10): " + AICargo.GetCargoIncome(i, 100, 10)); print(" GetCargoIncome(10, 100): " + AICargo.GetCargoIncome(i, 10, 100)); + print(" GetWeight(100): " + AICargo.GetWeight(i, 100)); print(" GetRoadVehicleTypeForCargo(): " + AIRoad.GetRoadVehicleTypeForCargo(i)); } } diff --git a/regression/regression/result.txt b/regression/regression/result.txt index cca295fa01..27f90220dc 100644 --- a/regression/regression/result.txt +++ b/regression/regression/result.txt @@ -1118,6 +1118,7 @@ ERROR: IsEnd() is invalid as Begin() is never called GetCargoIncome(10, 10): -1 GetCargoIncome(100, 10): -1 GetCargoIncome(10, 100): -1 + GetWeight(100): -1 GetRoadVehicleTypeForCargo(): 1 Cargo 0 IsValidCargo(): true @@ -1130,6 +1131,7 @@ ERROR: IsEnd() is invalid as Begin() is never called GetCargoIncome(10, 10): 3 GetCargoIncome(100, 10): 38 GetCargoIncome(10, 100): 3 + GetWeight(100): 6 GetRoadVehicleTypeForCargo(): 0 Cargo 1 IsValidCargo(): true @@ -1142,6 +1144,7 @@ ERROR: IsEnd() is invalid as Begin() is never called GetCargoIncome(10, 10): 7 GetCargoIncome(100, 10): 71 GetCargoIncome(10, 100): 6 + GetWeight(100): 100 GetRoadVehicleTypeForCargo(): 1 Cargo 2 IsValidCargo(): true @@ -1154,6 +1157,7 @@ ERROR: IsEnd() is invalid as Begin() is never called GetCargoIncome(10, 10): 5 GetCargoIncome(100, 10): 55 GetCargoIncome(10, 100): 5 + GetWeight(100): 25 GetRoadVehicleTypeForCargo(): 1 Cargo 3 IsValidCargo(): true @@ -1166,6 +1170,7 @@ ERROR: IsEnd() is invalid as Begin() is never called GetCargoIncome(10, 10): 5 GetCargoIncome(100, 10): 53 GetCargoIncome(10, 100): 5 + GetWeight(100): 100 GetRoadVehicleTypeForCargo(): 1 Cargo 4 IsValidCargo(): true @@ -1178,6 +1183,7 @@ ERROR: IsEnd() is invalid as Begin() is never called GetCargoIncome(10, 10): 5 GetCargoIncome(100, 10): 52 GetCargoIncome(10, 100): 4 + GetWeight(100): 18 GetRoadVehicleTypeForCargo(): 1 Cargo 5 IsValidCargo(): true @@ -1190,6 +1196,7 @@ ERROR: IsEnd() is invalid as Begin() is never called GetCargoIncome(10, 10): 7 GetCargoIncome(100, 10): 74 GetCargoIncome(10, 100): 6 + GetWeight(100): 50 GetRoadVehicleTypeForCargo(): 1 Cargo 6 IsValidCargo(): true @@ -1202,6 +1209,7 @@ ERROR: IsEnd() is invalid as Begin() is never called GetCargoIncome(10, 10): 5 GetCargoIncome(100, 10): 58 GetCargoIncome(10, 100): 4 + GetWeight(100): 100 GetRoadVehicleTypeForCargo(): 1 Cargo 7 IsValidCargo(): true @@ -1214,6 +1222,7 @@ ERROR: IsEnd() is invalid as Begin() is never called GetCargoIncome(10, 10): 6 GetCargoIncome(100, 10): 60 GetCargoIncome(10, 100): 5 + GetWeight(100): 100 GetRoadVehicleTypeForCargo(): 1 Cargo 8 IsValidCargo(): true @@ -1226,6 +1235,7 @@ ERROR: IsEnd() is invalid as Begin() is never called GetCargoIncome(10, 10): 6 GetCargoIncome(100, 10): 62 GetCargoIncome(10, 100): 5 + GetWeight(100): 100 GetRoadVehicleTypeForCargo(): 1 Cargo 9 IsValidCargo(): true @@ -1238,6 +1248,7 @@ ERROR: IsEnd() is invalid as Begin() is never called GetCargoIncome(10, 10): 6 GetCargoIncome(100, 10): 69 GetCargoIncome(10, 100): 6 + GetWeight(100): 100 GetRoadVehicleTypeForCargo(): 1 Cargo 10 IsValidCargo(): true @@ -1250,6 +1261,7 @@ ERROR: IsEnd() is invalid as Begin() is never called GetCargoIncome(10, 10): 9 GetCargoIncome(100, 10): 90 GetCargoIncome(10, 100): 7 + GetWeight(100): 12 GetRoadVehicleTypeForCargo(): 1 Cargo 11 IsValidCargo(): false @@ -1262,6 +1274,7 @@ ERROR: IsEnd() is invalid as Begin() is never called GetCargoIncome(10, 10): -1 GetCargoIncome(100, 10): -1 GetCargoIncome(10, 100): -1 + GetWeight(100): -1 GetRoadVehicleTypeForCargo(): 1 Cargo 12 IsValidCargo(): false @@ -1274,6 +1287,7 @@ ERROR: IsEnd() is invalid as Begin() is never called GetCargoIncome(10, 10): -1 GetCargoIncome(100, 10): -1 GetCargoIncome(10, 100): -1 + GetWeight(100): -1 GetRoadVehicleTypeForCargo(): 1 Cargo 13 IsValidCargo(): false @@ -1286,6 +1300,7 @@ ERROR: IsEnd() is invalid as Begin() is never called GetCargoIncome(10, 10): -1 GetCargoIncome(100, 10): -1 GetCargoIncome(10, 100): -1 + GetWeight(100): -1 GetRoadVehicleTypeForCargo(): 1 Cargo 14 IsValidCargo(): false @@ -1298,6 +1313,7 @@ ERROR: IsEnd() is invalid as Begin() is never called GetCargoIncome(10, 10): -1 GetCargoIncome(100, 10): -1 GetCargoIncome(10, 100): -1 + GetWeight(100): -1 GetRoadVehicleTypeForCargo(): 1 --CargoList-- diff --git a/src/ai/ai.hpp b/src/ai/ai.hpp index 59886486fe..f9112fc177 100644 --- a/src/ai/ai.hpp +++ b/src/ai/ai.hpp @@ -139,9 +139,9 @@ public: static int GetStartNextTime(); /** Wrapper function for AIScanner::GetAIConsoleList */ - static char *GetConsoleList(char *p, const char *last, bool newest_only = false); + static std::string GetConsoleList(bool newest_only = false); /** Wrapper function for AIScanner::GetAIConsoleLibraryList */ - static char *GetConsoleLibraryList(char *p, const char *last); + static std::string GetConsoleLibraryList(); /** Wrapper function for AIScanner::GetAIInfoList */ static const ScriptInfoList *GetInfoList(); /** Wrapper function for AIScanner::GetUniqueAIInfoList */ diff --git a/src/ai/ai_core.cpp b/src/ai/ai_core.cpp index 7ec709a0e1..f12b9e02a5 100644 --- a/src/ai/ai_core.cpp +++ b/src/ai/ai_core.cpp @@ -313,14 +313,14 @@ return DAYS_IN_YEAR; } -/* static */ char *AI::GetConsoleList(char *p, const char *last, bool newest_only) +/* static */ std::string AI::GetConsoleList(bool newest_only) { - return AI::scanner_info->GetConsoleList(p, last, newest_only); + return AI::scanner_info->GetConsoleList(newest_only); } -/* static */ char *AI::GetConsoleLibraryList(char *p, const char *last) +/* static */ std::string AI::GetConsoleLibraryList() { - return AI::scanner_library->GetConsoleList(p, last, true); + return AI::scanner_library->GetConsoleList(true); } /* static */ const ScriptInfoList *AI::GetInfoList() diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp index 94e362bf51..6f398e78cd 100644 --- a/src/ai/ai_gui.cpp +++ b/src/ai/ai_gui.cpp @@ -694,10 +694,10 @@ static const NWidgetPart _nested_ai_config_widgets[] = { NWidget(WWT_PANEL, COLOUR_MAUVE, WID_AIC_BACKGROUND), NWidget(NWID_VERTICAL), SetPIP(4, 4, 4), NWidget(NWID_HORIZONTAL), SetPIP(7, 0, 7), - NWidget(WWT_PUSHARROWBTN, COLOUR_YELLOW, WID_AIC_DECREASE), SetFill(0, 1), SetDataTip(AWV_DECREASE, STR_NULL), - NWidget(WWT_PUSHARROWBTN, COLOUR_YELLOW, WID_AIC_INCREASE), SetFill(0, 1), SetDataTip(AWV_INCREASE, STR_NULL), + NWidget(WWT_PUSHARROWBTN, COLOUR_YELLOW, WID_AIC_DECREASE), SetDataTip(AWV_DECREASE, STR_NULL), + NWidget(WWT_PUSHARROWBTN, COLOUR_YELLOW, WID_AIC_INCREASE), SetDataTip(AWV_INCREASE, STR_NULL), NWidget(NWID_SPACER), SetMinimalSize(6, 0), - NWidget(WWT_TEXT, COLOUR_MAUVE, WID_AIC_NUMBER), SetDataTip(STR_DIFFICULTY_LEVEL_SETTING_MAXIMUM_NO_COMPETITORS, STR_NULL), SetFill(1, 0), SetPadding(1, 0, 0, 0), + NWidget(WWT_TEXT, COLOUR_MAUVE, WID_AIC_NUMBER), SetDataTip(STR_DIFFICULTY_LEVEL_SETTING_MAXIMUM_NO_COMPETITORS, STR_NULL), SetFill(1, 0), EndContainer(), NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(7, 0, 7), NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_AIC_MOVE_UP), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_AI_CONFIG_MOVE_UP, STR_AI_CONFIG_MOVE_UP_TOOLTIP), @@ -788,6 +788,11 @@ struct AIConfigWindow : public Window { void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { switch (widget) { + case WID_AIC_DECREASE: + case WID_AIC_INCREASE: + *size = maxdim(*size, NWidgetScrollbar::GetHorizontalDimension()); + break; + case WID_AIC_GAMELIST: this->line_height = FONT_HEIGHT_NORMAL + WD_MATRIX_TOP + WD_MATRIX_BOTTOM; size->height = 1 * this->line_height; diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp index 2f6c95aaad..5d9f1188d4 100644 --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -26,6 +26,7 @@ #include "hotkeys.h" #include "vehicle_func.h" #include "gui.h" +#include "zoom_func.h" #include "widgets/airport_widget.h" @@ -411,11 +412,8 @@ public: { this->DrawWidgets(); - uint16 top = this->GetWidget(WID_AP_BTN_DOHILIGHT)->pos_y + this->GetWidget(WID_AP_BTN_DOHILIGHT)->current_y + WD_PAR_VSEP_NORMAL; - NWidgetBase *panel_nwi = this->GetWidget(WID_AP_BOTTOMPANEL); - - int right = panel_nwi->pos_x + panel_nwi->current_x; - int bottom = panel_nwi->pos_y + panel_nwi->current_y; + Rect r = this->GetWidget(WID_AP_ACCEPTANCE)->GetCurrentRect(); + int top = r.top + ScaleGUITrad(WD_PAR_VSEP_NORMAL); if (_selected_airport_index != -1) { const AirportSpec *as = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index); @@ -425,20 +423,20 @@ public: if (_settings_game.economy.station_noise_level) { /* show the noise of the selected airport */ SetDParam(0, as->noise_level); - DrawString(panel_nwi->pos_x + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, STR_STATION_BUILD_NOISE); - top += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL; + DrawString(r.left, r.right, top, STR_STATION_BUILD_NOISE); + top += FONT_HEIGHT_NORMAL + ScaleGUITrad(WD_PAR_VSEP_NORMAL); } /* strings such as 'Size' and 'Coverage Area' */ - top = DrawStationCoverageAreaText(panel_nwi->pos_x + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, SCT_ALL, rad, false) + WD_PAR_VSEP_NORMAL; - top = DrawStationCoverageAreaText(panel_nwi->pos_x + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, SCT_ALL, rad, true) + WD_PAR_VSEP_NORMAL; + top = DrawStationCoverageAreaText(r.left, r.right, top, SCT_ALL, rad, false) + ScaleGUITrad(WD_PAR_VSEP_NORMAL); + top = DrawStationCoverageAreaText(r.left, r.right, top, SCT_ALL, rad, true) + ScaleGUITrad(WD_PAR_VSEP_NORMAL); } /* Resize background if the window is too small. * Never make the window smaller to avoid oscillating if the size change affects the acceptance. * (This is the case, if making the window bigger moves the mouse into the window.) */ - if (top > bottom) { - ResizeWindow(this, 0, top - bottom, false); + if (top > r.bottom) { + ResizeWindow(this, 0, top - r.bottom, false); } } @@ -584,8 +582,8 @@ static const NWidgetPart _nested_build_airport_widgets[] = { NWidget(WWT_EMPTY, COLOUR_DARK_GREEN, WID_AP_EXTRA_TEXT), SetFill(1, 0), SetMinimalSize(150, 0), EndContainer(), /* Bottom panel. */ - NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_AP_BOTTOMPANEL), SetPIP(2, 2, 2), - NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL), SetFill(1, 0), + NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_AP_BOTTOMPANEL), + NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetPadding(WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM, WD_FRAMERECT_LEFT), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL), SetFill(1, 0), NWidget(NWID_HORIZONTAL), NWidget(NWID_SPACER), SetMinimalSize(14, 0), SetFill(1, 0), NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), @@ -596,7 +594,7 @@ static const NWidgetPart _nested_build_airport_widgets[] = { EndContainer(), NWidget(NWID_SPACER), SetMinimalSize(14, 0), SetFill(1, 0), EndContainer(), - NWidget(NWID_SPACER), SetMinimalSize(0, 10), SetResize(0, 1), SetFill(1, 0), + NWidget(WWT_EMPTY, COLOUR_DARK_GREEN, WID_AP_ACCEPTANCE), SetPadding(0, WD_FRAMERECT_RIGHT, 0, WD_FRAMERECT_LEFT), SetResize(0, 1), SetFill(1, 0), EndContainer(), }; diff --git a/src/blitter/32bpp_anim_sse4.cpp b/src/blitter/32bpp_anim_sse4.cpp index ca6eb99d3e..ff6c1ea901 100644 --- a/src/blitter/32bpp_anim_sse4.cpp +++ b/src/blitter/32bpp_anim_sse4.cpp @@ -53,6 +53,7 @@ inline void Blitter_32bppSSE4_Anim::Draw(const Blitter::BlitterParams *bp, ZoomL const __m128i a_cm = ALPHA_CONTROL_MASK; const __m128i pack_low_cm = PACK_LOW_CONTROL_MASK; const __m128i tr_nom_base = TRANSPARENT_NOM_BASE; + const __m128i a_am = ALPHA_AND_MASK; for (int y = bp->height; y != 0; y--) { Colour *dst = dst_line; @@ -144,7 +145,7 @@ inline void Blitter_32bppSSE4_Anim::Draw(const Blitter::BlitterParams *bp, ZoomL /* Blend colours. */ bmno_alpha_blend: - srcABCD = AlphaBlendTwoPixels(srcABCD, dstABCD, a_cm, pack_low_cm); + srcABCD = AlphaBlendTwoPixels(srcABCD, dstABCD, a_cm, pack_low_cm, a_am); bmno_full_opacity: _mm_storel_epi64((__m128i *) dst, srcABCD); bmno_full_transparency: @@ -171,7 +172,7 @@ bmno_full_transparency: } else { srcABCD = _mm_cvtsi32_si128(src->data); } - dst->data = _mm_cvtsi128_si32(AlphaBlendTwoPixels(srcABCD, dstABCD, a_cm, pack_low_cm)); + dst->data = _mm_cvtsi128_si32(AlphaBlendTwoPixels(srcABCD, dstABCD, a_cm, pack_low_cm, a_am)); } } break; @@ -255,7 +256,7 @@ bmno_full_transparency: /* Blend colours. */ bmcr_alpha_blend: - srcABCD = AlphaBlendTwoPixels(srcABCD, dstABCD, a_cm, pack_low_cm); + srcABCD = AlphaBlendTwoPixels(srcABCD, dstABCD, a_cm, pack_low_cm, a_am); bmcr_full_opacity: _mm_storel_epi64((__m128i *) dst, srcABCD); bmcr_full_transparency: @@ -288,7 +289,7 @@ bmcr_full_transparency: if (src->a < 255) { bmcr_alpha_blend_single: __m128i dstABCD = _mm_cvtsi32_si128(dst->data); - srcABCD = AlphaBlendTwoPixels(srcABCD, dstABCD, a_cm, pack_low_cm); + srcABCD = AlphaBlendTwoPixels(srcABCD, dstABCD, a_cm, pack_low_cm, a_am); } dst->data = _mm_cvtsi128_si32(srcABCD); } @@ -371,7 +372,7 @@ bmcr_alpha_blend_single: } else { srcABCD = _mm_cvtsi32_si128(AdjustBrightneSSE(src->data, DEFAULT_BRIGHTNESS + bp->brightness_adjust).data); } - dst->data = _mm_cvtsi128_si32(AlphaBlendTwoPixels(srcABCD, dstABCD, a_cm, pack_low_cm)); + dst->data = _mm_cvtsi128_si32(AlphaBlendTwoPixels(srcABCD, dstABCD, a_cm, pack_low_cm, a_am)); } src_mv++; dst++; @@ -406,7 +407,7 @@ bmcr_alpha_blend_single: if (src->a < 255) { bmcr_alpha_blend_single_brightness: __m128i dstABCD = _mm_cvtsi32_si128(dst->data); - srcABCD = AlphaBlendTwoPixels(srcABCD, dstABCD, a_cm, pack_low_cm); + srcABCD = AlphaBlendTwoPixels(srcABCD, dstABCD, a_cm, pack_low_cm, a_am); } dst->data = _mm_cvtsi128_si32(srcABCD); } @@ -436,6 +437,12 @@ IGNORE_UNINITIALIZED_WARNING_STOP */ void Blitter_32bppSSE4_Anim::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) { + if (_screen_disable_anim) { + /* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent Draw() */ + Blitter_32bppSSE4::Draw(bp, mode, zoom); + return; + } + const BlitterSpriteFlags sprite_flags = ((const Blitter_32bppSSE_Base::SpriteData *) bp->sprite)->flags; switch (mode) { default: { diff --git a/src/blitter/32bpp_anim_sse4.hpp b/src/blitter/32bpp_anim_sse4.hpp index 8b740fd105..1b32e085c5 100644 --- a/src/blitter/32bpp_anim_sse4.hpp +++ b/src/blitter/32bpp_anim_sse4.hpp @@ -32,7 +32,7 @@ #define MARGIN_NORMAL_THRESHOLD 4 /** The SSE4 32 bpp blitter with palette animation. */ -class Blitter_32bppSSE4_Anim FINAL : public Blitter_32bppSSE2_Anim, public Blitter_32bppSSE_Base { +class Blitter_32bppSSE4_Anim FINAL : public Blitter_32bppSSE2_Anim, public Blitter_32bppSSE4 { private: public: @@ -43,13 +43,14 @@ public: return Blitter_32bppSSE_Base::Encode(sprite, allocator); } const char *GetName() override { return "32bpp-sse4-anim"; } + using Blitter_32bppSSE2_Anim::LookupColourInPalette; }; /** Factory for the SSE4 32 bpp blitter (with palette animation). */ class FBlitter_32bppSSE4_Anim: public BlitterFactory { public: FBlitter_32bppSSE4_Anim() : BlitterFactory("32bpp-sse4-anim", "32bpp SSE4 Blitter (palette animation)", HasCPUIDFlag(1, 2, 19)) {} - Blitter *CreateInstance() override { return new Blitter_32bppSSE4_Anim(); } + Blitter *CreateInstance() override { return static_cast(new Blitter_32bppSSE4_Anim()); } }; #endif /* WITH_SSE */ diff --git a/src/blitter/32bpp_sse_func.hpp b/src/blitter/32bpp_sse_func.hpp index 02abdc42bc..64f4fd75b5 100644 --- a/src/blitter/32bpp_sse_func.hpp +++ b/src/blitter/32bpp_sse_func.hpp @@ -65,27 +65,31 @@ static inline __m128i DistributeAlpha(const __m128i from, const __m128i &mask) { #if (SSE_VERSION == 2) __m128i alphaAB = _mm_shufflelo_epi16(from, 0x3F); // PSHUFLW, put alpha1 in front of each rgb1 - return _mm_shufflehi_epi16(alphaAB, 0x3F); // PSHUFHW, put alpha2 in front of each rgb2 + alphaAB = _mm_shufflehi_epi16(alphaAB, 0x3F); // PSHUFHW, put alpha2 in front of each rgb2 + return _mm_andnot_si128(mask, alphaAB); // PANDN, set alpha fields to 0 #else return _mm_shuffle_epi8(from, mask); #endif } GNU_TARGET(SSE_TARGET) -static inline __m128i AlphaBlendTwoPixels(__m128i src, __m128i dst, const __m128i &distribution_mask, const __m128i &pack_mask) +static inline __m128i AlphaBlendTwoPixels(__m128i src, __m128i dst, const __m128i &distribution_mask, const __m128i &pack_mask, const __m128i &alpha_mask) { __m128i srcAB = _mm_unpacklo_epi8(src, _mm_setzero_si128()); // PUNPCKLBW, expand each uint8 into uint16 __m128i dstAB = _mm_unpacklo_epi8(dst, _mm_setzero_si128()); - __m128i alphaAB = _mm_cmpgt_epi16(srcAB, _mm_setzero_si128()); // PCMPGTW, if (alpha > 0) a++; - alphaAB = _mm_srli_epi16(alphaAB, 15); - alphaAB = _mm_add_epi16(alphaAB, srcAB); + __m128i alphaMaskAB = _mm_cmpgt_epi16(srcAB, _mm_setzero_si128()); // PCMPGTW (alpha > 0) ? 0xFFFF : 0 + __m128i alphaAB = _mm_sub_epi16(srcAB, alphaMaskAB); // if (alpha > 0) a++; alphaAB = DistributeAlpha(alphaAB, distribution_mask); srcAB = _mm_sub_epi16(srcAB, dstAB); // PSUBW, (r - Cr) srcAB = _mm_mullo_epi16(srcAB, alphaAB); // PMULLW, a*(r - Cr) srcAB = _mm_srli_epi16(srcAB, 8); // PSRLW, a*(r - Cr)/256 srcAB = _mm_add_epi16(srcAB, dstAB); // PADDW, a*(r - Cr)/256 + Cr + + alphaMaskAB = _mm_and_si128(alphaMaskAB, alpha_mask); // PAND, set non alpha fields to 0 + srcAB = _mm_or_si128(srcAB, alphaMaskAB); // POR, set alpha fields to 0xFFFF is src alpha was > 0 + return PackUnsaturated(srcAB, pack_mask); } @@ -233,9 +237,11 @@ inline void Blitter_32bppSSE4::Draw(const Blitter::BlitterParams *bp, ZoomLevel const MapValue *src_mv = src_mv_line; /* Load these variables into register before loop. */ + const __m128i alpha_and = ALPHA_AND_MASK; + #define ALPHA_BLEND_PARAM_3 alpha_and #if (SSE_VERSION == 2) const __m128i clear_hi = CLEAR_HIGH_BYTE_MASK; - #define ALPHA_BLEND_PARAM_1 clear_hi + #define ALPHA_BLEND_PARAM_1 alpha_and #define ALPHA_BLEND_PARAM_2 clear_hi #define DARKEN_PARAM_1 tr_nom_base #define DARKEN_PARAM_2 tr_nom_base @@ -281,7 +287,7 @@ inline void Blitter_32bppSSE4::Draw(const Blitter::BlitterParams *bp, ZoomLevel for (uint x = (uint) effective_width / 2; x > 0; x--) { __m128i srcABCD = _mm_loadl_epi64((const __m128i*) src); __m128i dstABCD = _mm_loadl_epi64((__m128i*) dst); - _mm_storel_epi64((__m128i*) dst, AlphaBlendTwoPixels(srcABCD, dstABCD, ALPHA_BLEND_PARAM_1, ALPHA_BLEND_PARAM_2)); + _mm_storel_epi64((__m128i*) dst, AlphaBlendTwoPixels(srcABCD, dstABCD, ALPHA_BLEND_PARAM_1, ALPHA_BLEND_PARAM_2, ALPHA_BLEND_PARAM_3)); src += 2; dst += 2; } @@ -289,7 +295,7 @@ inline void Blitter_32bppSSE4::Draw(const Blitter::BlitterParams *bp, ZoomLevel if ((bt_last == BT_NONE && effective_width & 1) || bt_last == BT_ODD) { __m128i srcABCD = _mm_cvtsi32_si128(src->data); __m128i dstABCD = _mm_cvtsi32_si128(dst->data); - dst->data = _mm_cvtsi128_si32(AlphaBlendTwoPixels(srcABCD, dstABCD, ALPHA_BLEND_PARAM_1, ALPHA_BLEND_PARAM_2)); + dst->data = _mm_cvtsi128_si32(AlphaBlendTwoPixels(srcABCD, dstABCD, ALPHA_BLEND_PARAM_1, ALPHA_BLEND_PARAM_2, ALPHA_BLEND_PARAM_3)); } break; @@ -334,7 +340,7 @@ inline void Blitter_32bppSSE4::Draw(const Blitter::BlitterParams *bp, ZoomLevel } /* Blend colours. */ - _mm_storel_epi64((__m128i *) dst, AlphaBlendTwoPixels(srcABCD, dstABCD, ALPHA_BLEND_PARAM_1, ALPHA_BLEND_PARAM_2)); + _mm_storel_epi64((__m128i *) dst, AlphaBlendTwoPixels(srcABCD, dstABCD, ALPHA_BLEND_PARAM_1, ALPHA_BLEND_PARAM_2, ALPHA_BLEND_PARAM_3)); dst += 2; src += 2; src_mv += 2; @@ -363,7 +369,7 @@ inline void Blitter_32bppSSE4::Draw(const Blitter::BlitterParams *bp, ZoomLevel if (src->a < 255) { bmcr_alpha_blend_single: __m128i dstABCD = _mm_cvtsi32_si128(dst->data); - srcABCD = AlphaBlendTwoPixels(srcABCD, dstABCD, ALPHA_BLEND_PARAM_1, ALPHA_BLEND_PARAM_2); + srcABCD = AlphaBlendTwoPixels(srcABCD, dstABCD, ALPHA_BLEND_PARAM_1, ALPHA_BLEND_PARAM_2, ALPHA_BLEND_PARAM_3); } dst->data = _mm_cvtsi128_si32(srcABCD); } @@ -429,7 +435,7 @@ bmcr_alpha_blend_single: __m128i srcABCD = _mm_setr_epi32(AdjustBrightneSSE(src->data, DEFAULT_BRIGHTNESS + bp->brightness_adjust).data, AdjustBrightneSSE((src + 1)->data, DEFAULT_BRIGHTNESS + bp->brightness_adjust).data, 0, 0); #endif __m128i dstABCD = _mm_loadl_epi64((__m128i*) dst); - _mm_storel_epi64((__m128i*) dst, AlphaBlendTwoPixels(srcABCD, dstABCD, ALPHA_BLEND_PARAM_1, ALPHA_BLEND_PARAM_2)); + _mm_storel_epi64((__m128i*) dst, AlphaBlendTwoPixels(srcABCD, dstABCD, ALPHA_BLEND_PARAM_1, ALPHA_BLEND_PARAM_2, ALPHA_BLEND_PARAM_3)); src += 2; dst += 2; } @@ -437,7 +443,7 @@ bmcr_alpha_blend_single: if ((bt_last == BT_NONE && effective_width & 1) || bt_last == BT_ODD) { __m128i srcABCD = _mm_cvtsi32_si128(AdjustBrightneSSE(src->data, DEFAULT_BRIGHTNESS + bp->brightness_adjust).data); __m128i dstABCD = _mm_cvtsi32_si128(dst->data); - dst->data = _mm_cvtsi128_si32(AlphaBlendTwoPixels(srcABCD, dstABCD, ALPHA_BLEND_PARAM_1, ALPHA_BLEND_PARAM_2)); + dst->data = _mm_cvtsi128_si32(AlphaBlendTwoPixels(srcABCD, dstABCD, ALPHA_BLEND_PARAM_1, ALPHA_BLEND_PARAM_2, ALPHA_BLEND_PARAM_3)); } break; @@ -465,7 +471,7 @@ bmcr_alpha_blend_single: if (src->a < 255) { bmcr_alpha_blend_single_brightness: __m128i dstABCD = _mm_cvtsi32_si128(dst->data); - srcABCD = AlphaBlendTwoPixels(srcABCD, dstABCD, ALPHA_BLEND_PARAM_1, ALPHA_BLEND_PARAM_2); + srcABCD = AlphaBlendTwoPixels(srcABCD, dstABCD, ALPHA_BLEND_PARAM_1, ALPHA_BLEND_PARAM_2, ALPHA_BLEND_PARAM_3); } dst->data = _mm_cvtsi128_si32(srcABCD); } diff --git a/src/blitter/32bpp_sse_type.h b/src/blitter/32bpp_sse_type.h index 33c76d9b4d..fe91b294be 100644 --- a/src/blitter/32bpp_sse_type.h +++ b/src/blitter/32bpp_sse_type.h @@ -51,6 +51,7 @@ typedef union ALIGN(16) um128i { #define OVERBRIGHT_VALUE_MASK _mm_setr_epi8(-1, 0, -1, 0, -1, 0, 0, 0, -1, 0, -1, 0, -1, 0, 0, 0) #define OVERBRIGHT_CONTROL_MASK _mm_setr_epi8( 0, 1, 0, 1, 0, 1, 7, 7, 2, 3, 2, 3, 2, 3, 7, 7) #define TRANSPARENT_NOM_BASE _mm_setr_epi16(256, 256, 256, 256, 256, 256, 256, 256) +#define ALPHA_AND_MASK _mm_setr_epi16( 0, 0, 0, -1, 0, 0, 0, -1) #endif /* WITH_SSE */ #endif /* BLITTER_32BPP_SSE_TYPE_H */ diff --git a/src/company_gui.cpp b/src/company_gui.cpp index ad5030e7eb..187cabcda7 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -2310,7 +2310,7 @@ static const NWidgetPart _nested_company_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(NWID_SELECTION, INVALID_COLOUR, WID_C_SELECT_DESC_OWNERS), NWidget(NWID_VERTICAL), SetPIP(5, 5, 4), - NWidget(WWT_EMPTY, INVALID_COLOUR, WID_C_DESC_OWNERS), SetMinimalTextLines(3, 0), + NWidget(WWT_EMPTY, INVALID_COLOUR, WID_C_DESC_OWNERS), SetMinimalTextLines(MAX_COMPANY_SHARE_OWNERS, 0), NWidget(NWID_SPACER), SetFill(0, 1), EndContainer(), EndContainer(), diff --git a/src/company_type.h b/src/company_type.h index 740663a4cf..d6a0f17ccf 100644 --- a/src/company_type.h +++ b/src/company_type.h @@ -40,6 +40,7 @@ static const uint MAX_LENGTH_PRESIDENT_NAME_CHARS = 32; ///< The maximum length static const uint MAX_LENGTH_COMPANY_NAME_CHARS = 32; ///< The maximum length of a company name in characters including '\0' static const uint MAX_HISTORY_QUARTERS = 24; ///< The maximum number of quarters kept as performance's history +static const uint MAX_COMPANY_SHARE_OWNERS = 4; ///< The maximum number of shares of a company that can be owned by another company. /** Define basic enum properties */ template <> struct EnumPropsT : MakeEnumPropsT {}; diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index f7fd47016d..acbb9f9925 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -64,6 +64,8 @@ #include +#include + #include "safeguards.h" /* scriptfile handling */ @@ -1297,42 +1299,67 @@ static void PrintLineByLine(char *buf) }); } +/** + * Print a text buffer line by line to the console. Lines are separated by '\n'. + * @param full_string The multi-line string to print. + */ +static void PrintLineByLine(const std::string &full_string) +{ + std::istringstream in(full_string); + std::string line; + while (std::getline(in, line)) { + IConsolePrint(CC_DEFAULT, line.c_str()); + } +} + DEF_CONSOLE_CMD(ConListAILibs) { - char buf[4096]; - AI::GetConsoleLibraryList(buf, lastof(buf)); + if (argc == 0) { + IConsoleHelp("List installed AI libraries. Usage: 'list_ai_libs'."); + return true; + } - PrintLineByLine(buf); + const std::string output_str = AI::GetConsoleLibraryList(); + PrintLineByLine(output_str); return true; } DEF_CONSOLE_CMD(ConListAI) { - char buf[4096]; - AI::GetConsoleList(buf, lastof(buf)); + if (argc == 0) { + IConsoleHelp("List installed AIs. Usage: 'list_ai'."); + return true; + } - PrintLineByLine(buf); + const std::string output_str = AI::GetConsoleList(); + PrintLineByLine(output_str); return true; } DEF_CONSOLE_CMD(ConListGameLibs) { - char buf[4096]; - Game::GetConsoleLibraryList(buf, lastof(buf)); + if (argc == 0) { + IConsoleHelp("List installed Game Script libraries. Usage: 'list_game_libs'."); + return true; + } - PrintLineByLine(buf); + const std::string output_str = Game::GetConsoleLibraryList(); + PrintLineByLine(output_str); return true; } DEF_CONSOLE_CMD(ConListGame) { - char buf[4096]; - Game::GetConsoleList(buf, lastof(buf)); + if (argc == 0) { + IConsoleHelp("List installed Game Scripts. Usage: 'list_game'."); + return true; + } - PrintLineByLine(buf); + const std::string output_str = Game::GetConsoleList(); + PrintLineByLine(output_str); return true; } diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp index 3db6fa5a5e..3d24a7356d 100644 --- a/src/dock_gui.cpp +++ b/src/dock_gui.cpp @@ -413,6 +413,7 @@ enum BuildDockStationWidgets { BDSW_LT_OFF, ///< 'Off' button of coverage high light. BDSW_LT_ON, ///< 'On' button of coverage high light. BDSW_INFO, ///< 'Coverage highlight' label. + BDSW_ACCEPTANCE, ///< Acceptance info. }; struct BuildDocksStationWindow : public PickerWindowBase { @@ -442,17 +443,15 @@ public: } /* strings such as 'Size' and 'Coverage Area' */ - int top = this->GetWidget(BDSW_LT_OFF)->pos_y + this->GetWidget(BDSW_LT_OFF)->current_y + WD_PAR_VSEP_NORMAL; - NWidgetBase *back_nwi = this->GetWidget(BDSW_BACKGROUND); - int right = back_nwi->pos_x + back_nwi->current_x; - int bottom = back_nwi->pos_y + back_nwi->current_y; - top = DrawStationCoverageAreaText(back_nwi->pos_x + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, SCT_ALL, rad, false) + WD_PAR_VSEP_NORMAL; - top = DrawStationCoverageAreaText(back_nwi->pos_x + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, SCT_ALL, rad, true) + WD_PAR_VSEP_NORMAL; + Rect r = this->GetWidget(BDSW_ACCEPTANCE)->GetCurrentRect(); + int top = r.top + ScaleGUITrad(WD_PAR_VSEP_NORMAL); + top = DrawStationCoverageAreaText(r.left, r.right, top, SCT_ALL, rad, false) + ScaleGUITrad(WD_PAR_VSEP_NORMAL); + top = DrawStationCoverageAreaText(r.left, r.right, top, SCT_ALL, rad, true) + ScaleGUITrad(WD_PAR_VSEP_NORMAL); /* Resize background if the window is too small. * Never make the window smaller to avoid oscillating if the size change affects the acceptance. * (This is the case, if making the window bigger moves the mouse into the window.) */ - if (top > bottom) { - ResizeWindow(this, 0, top - bottom, false); + if (top > r.bottom) { + ResizeWindow(this, 0, top - r.bottom, false); } } @@ -484,13 +483,12 @@ static const NWidgetPart _nested_build_dock_station_widgets[] = { NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_DOCK_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), EndContainer(), NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BDSW_BACKGROUND), - NWidget(NWID_SPACER), SetMinimalSize(0, 3), - NWidget(WWT_LABEL, COLOUR_DARK_GREEN, BDSW_INFO), SetMinimalSize(148, 14), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL), - NWidget(NWID_HORIZONTAL), SetPIP(14, 0, 14), - NWidget(WWT_TEXTBTN, COLOUR_GREY, BDSW_LT_OFF), SetMinimalSize(40, 12), SetFill(1, 0), SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP), - NWidget(WWT_TEXTBTN, COLOUR_GREY, BDSW_LT_ON), SetMinimalSize(40, 12), SetFill(1, 0), SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP), + NWidget(WWT_LABEL, COLOUR_DARK_GREEN, BDSW_INFO), SetPadding(WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM, WD_FRAMERECT_LEFT), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL), SetFill(1, 0), + NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(14, 0, 14), + NWidget(WWT_TEXTBTN, COLOUR_GREY, BDSW_LT_OFF), SetMinimalSize(60, 12), SetFill(1, 0), SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP), + NWidget(WWT_TEXTBTN, COLOUR_GREY, BDSW_LT_ON), SetMinimalSize(60, 12), SetFill(1, 0), SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP), EndContainer(), - NWidget(NWID_SPACER), SetMinimalSize(0, 20), SetResize(0, 1), + NWidget(WWT_EMPTY, COLOUR_GREY, BDSW_ACCEPTANCE), SetPadding(0, WD_FRAMERECT_RIGHT, 0, WD_FRAMERECT_LEFT), SetResize(0, 1), EndContainer(), }; diff --git a/src/fios_gui.cpp b/src/fios_gui.cpp index c6f40ef851..1943254b0b 100644 --- a/src/fios_gui.cpp +++ b/src/fios_gui.cpp @@ -82,13 +82,15 @@ static const NWidgetPart _nested_load_dialog_widgets[] = { NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), /* Left side : filter box and available files */ - NWidget(WWT_PANEL, COLOUR_GREY), SetFill(1, 1), SetResize(1, 1), + NWidget(NWID_VERTICAL), /* Filter box with label */ - NWidget(NWID_HORIZONTAL), SetPadding(WD_FRAMERECT_TOP, 0, WD_FRAMERECT_BOTTOM, 0), - SetPIP(WD_FRAMETEXT_LEFT, WD_FRAMETEXT_RIGHT, 0), - NWidget(WWT_TEXT, COLOUR_GREY), SetFill(0, 1), SetDataTip(STR_SAVELOAD_FILTER_TITLE , STR_NULL), - NWidget(WWT_EDITBOX, COLOUR_GREY, WID_SL_FILTER), SetFill(1, 0), SetMinimalSize(50, 12), SetResize(1, 0), - SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP), + NWidget(WWT_PANEL, COLOUR_GREY), SetFill(1, 1), SetResize(1, 1), + NWidget(NWID_HORIZONTAL), SetPadding(WD_FRAMERECT_TOP, 0, WD_FRAMERECT_BOTTOM, 0), + SetPIP(WD_FRAMETEXT_LEFT, WD_FRAMETEXT_RIGHT, 0), + NWidget(WWT_TEXT, COLOUR_GREY), SetFill(0, 1), SetDataTip(STR_SAVELOAD_FILTER_TITLE , STR_NULL), + NWidget(WWT_EDITBOX, COLOUR_GREY, WID_SL_FILTER), SetFill(1, 0), SetMinimalSize(50, 12), SetResize(1, 0), + SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP), + EndContainer(), EndContainer(), /* Sort buttons */ NWidget(NWID_HORIZONTAL), @@ -99,22 +101,24 @@ static const NWidgetPart _nested_load_dialog_widgets[] = { NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_SL_HOME_BUTTON), SetMinimalSize(12, 12), SetDataTip(SPR_HOUSE_ICON, STR_SAVELOAD_HOME_BUTTON), EndContainer(), /* Files */ - NWidget(WWT_PANEL, COLOUR_GREY, WID_SL_FILE_BACKGROUND), - NWidget(NWID_HORIZONTAL), - NWidget(WWT_INSET, COLOUR_GREY, WID_SL_DRIVES_DIRECTORIES_LIST), SetFill(1, 1), SetPadding(2, 1, 2, 2), + NWidget(NWID_HORIZONTAL), + NWidget(WWT_PANEL, COLOUR_GREY, WID_SL_FILE_BACKGROUND), + NWidget(WWT_INSET, COLOUR_GREY, WID_SL_DRIVES_DIRECTORIES_LIST), SetFill(1, 1), SetPadding(2, 2, 2, 2), SetDataTip(0x0, STR_SAVELOAD_LIST_TOOLTIP), SetResize(1, 10), SetScrollbar(WID_SL_SCROLLBAR), EndContainer(), - NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_SL_SCROLLBAR), - EndContainer(), - NWidget(NWID_SELECTION, INVALID_COLOUR, WID_SL_CONTENT_DOWNLOAD_SEL), - NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SL_CONTENT_DOWNLOAD), SetResize(1, 0), - SetDataTip(STR_INTRO_ONLINE_CONTENT, STR_INTRO_TOOLTIP_ONLINE_CONTENT), EndContainer(), + NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_SL_SCROLLBAR), + EndContainer(), + /* Online Content button */ + NWidget(NWID_SELECTION, INVALID_COLOUR, WID_SL_CONTENT_DOWNLOAD_SEL), + NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SL_CONTENT_DOWNLOAD), SetResize(1, 0), + SetDataTip(STR_INTRO_ONLINE_CONTENT, STR_INTRO_TOOLTIP_ONLINE_CONTENT), EndContainer(), EndContainer(), /* Right side : game details */ - NWidget(WWT_PANEL, COLOUR_GREY), - NWidget(WWT_EMPTY, INVALID_COLOUR, WID_SL_DETAILS), SetResize(1, 1), SetFill(1, 1), + NWidget(NWID_VERTICAL), + NWidget(WWT_PANEL, COLOUR_GREY, WID_SL_DETAILS), SetResize(1, 1), SetFill(1, 1), + EndContainer(), NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SL_MISSING_NEWGRFS), SetDataTip(STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT_BUTTON, STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT_TOOLTIP), SetFill(1, 0), SetResize(1, 0), NWidget(NWID_HORIZONTAL), NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), @@ -137,37 +141,38 @@ static const NWidgetPart _nested_load_heightmap_dialog_widgets[] = { /* Current directory and free space */ NWidget(WWT_PANEL, COLOUR_GREY, WID_SL_BACKGROUND), SetFill(1, 0), SetResize(1, 0), EndContainer(), + /* Filter box with label */ NWidget(WWT_PANEL, COLOUR_GREY), SetFill(1, 1), SetResize(1, 1), - /* Filter box with label */ NWidget(NWID_HORIZONTAL), SetPadding(WD_FRAMERECT_TOP, 0, WD_FRAMERECT_BOTTOM, 0), SetPIP(WD_FRAMETEXT_LEFT, WD_FRAMETEXT_RIGHT, 0), NWidget(WWT_TEXT, COLOUR_GREY), SetFill(0, 1), SetDataTip(STR_SAVELOAD_FILTER_TITLE , STR_NULL), NWidget(WWT_EDITBOX, COLOUR_GREY, WID_SL_FILTER), SetFill(1, 0), SetMinimalSize(50, 12), SetResize(1, 0), SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP), EndContainer(), - /* Sort Buttons */ - NWidget(NWID_HORIZONTAL), - NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), - NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SL_SORT_BYNAME), SetDataTip(STR_SORT_BY_CAPTION_NAME, STR_TOOLTIP_SORT_ORDER), SetFill(1, 0), SetResize(1, 0), - NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SL_SORT_BYDATE), SetDataTip(STR_SORT_BY_CAPTION_DATE, STR_TOOLTIP_SORT_ORDER), SetFill(1, 0), SetResize(1, 0), - EndContainer(), - NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_SL_HOME_BUTTON), SetMinimalSize(12, 12), SetDataTip(SPR_HOUSE_ICON, STR_SAVELOAD_HOME_BUTTON), + EndContainer(), + /* Sort Buttons */ + NWidget(NWID_HORIZONTAL), + NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), + NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SL_SORT_BYNAME), SetDataTip(STR_SORT_BY_CAPTION_NAME, STR_TOOLTIP_SORT_ORDER), SetFill(1, 0), SetResize(1, 0), + NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SL_SORT_BYDATE), SetDataTip(STR_SORT_BY_CAPTION_DATE, STR_TOOLTIP_SORT_ORDER), SetFill(1, 0), SetResize(1, 0), EndContainer(), - /* Files */ + NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_SL_HOME_BUTTON), SetMinimalSize(12, 12), SetDataTip(SPR_HOUSE_ICON, STR_SAVELOAD_HOME_BUTTON), + EndContainer(), + /* Files */ + NWidget(NWID_HORIZONTAL), NWidget(WWT_PANEL, COLOUR_GREY, WID_SL_FILE_BACKGROUND), - NWidget(NWID_HORIZONTAL), - NWidget(WWT_INSET, COLOUR_GREY, WID_SL_DRIVES_DIRECTORIES_LIST), SetFill(1, 1), SetPadding(2, 1, 2, 2), - SetDataTip(0x0, STR_SAVELOAD_LIST_TOOLTIP), SetResize(1, 10), SetScrollbar(WID_SL_SCROLLBAR), EndContainer(), - NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_SL_SCROLLBAR), - EndContainer(), - NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), - NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SL_CONTENT_DOWNLOAD), SetResize(1, 0), SetFill(1, 0), - SetDataTip(STR_INTRO_ONLINE_CONTENT, STR_INTRO_TOOLTIP_ONLINE_CONTENT), - NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SL_LOAD_BUTTON), SetResize(1, 0), SetFill(1, 0), - SetDataTip(STR_SAVELOAD_LOAD_BUTTON, STR_SAVELOAD_LOAD_HEIGHTMAP_TOOLTIP), - NWidget(WWT_RESIZEBOX, COLOUR_GREY), - EndContainer(), + NWidget(WWT_INSET, COLOUR_GREY, WID_SL_DRIVES_DIRECTORIES_LIST), SetFill(1, 1), SetPadding(2, 2, 2, 2), + SetDataTip(0x0, STR_SAVELOAD_LIST_TOOLTIP), SetResize(1, 10), SetScrollbar(WID_SL_SCROLLBAR), EndContainer(), EndContainer(), + NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_SL_SCROLLBAR), + EndContainer(), + /* Online Content and Load button */ + NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), + NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SL_CONTENT_DOWNLOAD), SetResize(1, 0), SetFill(1, 0), + SetDataTip(STR_INTRO_ONLINE_CONTENT, STR_INTRO_TOOLTIP_ONLINE_CONTENT), + NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SL_LOAD_BUTTON), SetResize(1, 0), SetFill(1, 0), + SetDataTip(STR_SAVELOAD_LOAD_BUTTON, STR_SAVELOAD_LOAD_HEIGHTMAP_TOOLTIP), + NWidget(WWT_RESIZEBOX, COLOUR_GREY), EndContainer(), }; @@ -182,13 +187,15 @@ static const NWidgetPart _nested_save_dialog_widgets[] = { NWidget(WWT_PANEL, COLOUR_GREY, WID_SL_BACKGROUND), SetFill(1, 0), SetResize(1, 0), EndContainer(), NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), /* Left side : filter box and available files */ - NWidget(WWT_PANEL, COLOUR_GREY), SetFill(1, 1), SetResize(1, 1), + NWidget(NWID_VERTICAL), /* Filter box with label */ - NWidget(NWID_HORIZONTAL), SetPadding(WD_FRAMERECT_TOP, 0, WD_FRAMERECT_BOTTOM, 0), - SetPIP(WD_FRAMETEXT_LEFT, WD_FRAMETEXT_RIGHT, 0), - NWidget(WWT_TEXT, COLOUR_GREY), SetFill(0, 1), SetDataTip(STR_SAVELOAD_FILTER_TITLE , STR_NULL), - NWidget(WWT_EDITBOX, COLOUR_GREY, WID_SL_FILTER), SetFill(1, 0), SetMinimalSize(50, 12), SetResize(1, 0), - SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP), + NWidget(WWT_PANEL, COLOUR_GREY), SetFill(1, 1), SetResize(1, 1), + NWidget(NWID_HORIZONTAL), SetPadding(WD_FRAMERECT_TOP, 0, WD_FRAMERECT_BOTTOM, 0), + SetPIP(WD_FRAMETEXT_LEFT, WD_FRAMETEXT_RIGHT, 0), + NWidget(WWT_TEXT, COLOUR_GREY), SetFill(0, 1), SetDataTip(STR_SAVELOAD_FILTER_TITLE , STR_NULL), + NWidget(WWT_EDITBOX, COLOUR_GREY, WID_SL_FILTER), SetFill(1, 0), SetMinimalSize(50, 12), SetResize(1, 0), + SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP), + EndContainer(), EndContainer(), /* Sort buttons */ NWidget(NWID_HORIZONTAL), @@ -199,13 +206,15 @@ static const NWidgetPart _nested_save_dialog_widgets[] = { NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_SL_HOME_BUTTON), SetMinimalSize(12, 12), SetDataTip(SPR_HOUSE_ICON, STR_SAVELOAD_HOME_BUTTON), EndContainer(), /* Files */ - NWidget(WWT_PANEL, COLOUR_GREY, WID_SL_FILE_BACKGROUND), - NWidget(NWID_HORIZONTAL), - NWidget(WWT_INSET, COLOUR_GREY, WID_SL_DRIVES_DIRECTORIES_LIST), SetPadding(2, 1, 0, 2), + NWidget(NWID_HORIZONTAL), + NWidget(WWT_PANEL, COLOUR_GREY, WID_SL_FILE_BACKGROUND), + NWidget(WWT_INSET, COLOUR_GREY, WID_SL_DRIVES_DIRECTORIES_LIST), SetPadding(2, 2, 2, 2), SetDataTip(0x0, STR_SAVELOAD_LIST_TOOLTIP), SetResize(1, 10), SetScrollbar(WID_SL_SCROLLBAR), EndContainer(), - NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_SL_SCROLLBAR), EndContainer(), - NWidget(WWT_EDITBOX, COLOUR_GREY, WID_SL_SAVE_OSK_TITLE), SetPadding(3, 2, 2, 2), SetFill(1, 0), SetResize(1, 0), + NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_SL_SCROLLBAR), + EndContainer(), + NWidget(WWT_PANEL, COLOUR_GREY), + NWidget(WWT_EDITBOX, COLOUR_GREY, WID_SL_SAVE_OSK_TITLE), SetPadding(2, 2, 2, 2), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_SAVELOAD_OSKTITLE, STR_SAVELOAD_EDITBOX_TOOLTIP), EndContainer(), /* Save/delete buttons */ @@ -438,7 +447,7 @@ public: } case WID_SL_DRIVES_DIRECTORIES_LIST: { - GfxFillRect(r.left + 1, r.top + 1, r.right, r.bottom, PC_BLACK); + GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, PC_BLACK); uint y = r.top + WD_FRAMERECT_TOP; uint scroll_pos = this->vscroll->GetPosition(); @@ -452,9 +461,9 @@ public: const FiosItem *item = &this->fios_items[row]; if (item == this->selected) { - GfxFillRect(r.left + 1, y, r.right, y + this->resize.step_height, PC_DARK_BLUE); + GfxFillRect(r.left + 1, y, r.right - 1, y + this->resize.step_height - 1, PC_DARK_BLUE); } else if (item == this->highlighted) { - GfxFillRect(r.left + 1, y, r.right, y + this->resize.step_height, PC_VERY_DARK_BLUE); + GfxFillRect(r.left + 1, y, r.right - 1, y + this->resize.step_height - 1, PC_VERY_DARK_BLUE); } DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, item->title, _fios_colours[GetDetailedFileType(item->type)]); y += this->resize.step_height; @@ -464,8 +473,7 @@ public: } case WID_SL_DETAILS: { - GfxFillRect(r.left + WD_FRAMERECT_LEFT, r.top + WD_FRAMERECT_TOP, - r.right - WD_FRAMERECT_RIGHT, r.top + FONT_HEIGHT_NORMAL * 2 + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM, PC_GREY); + GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.top + FONT_HEIGHT_NORMAL * 2 + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM, PC_GREY); DrawString(r.left, r.right, r.top + FONT_HEIGHT_NORMAL / 2 + WD_FRAMERECT_TOP, STR_SAVELOAD_DETAIL_CAPTION, TC_FROMSTRING, SA_HOR_CENTER); if (this->selected == nullptr) break; diff --git a/src/game/game.hpp b/src/game/game.hpp index 8381a6c148..c72b081be6 100644 --- a/src/game/game.hpp +++ b/src/game/game.hpp @@ -93,9 +93,9 @@ public: static void Load(int version); /** Wrapper function for GameScanner::GetConsoleList */ - static char *GetConsoleList(char *p, const char *last, bool newest_only = false); + static std::string GetConsoleList(bool newest_only = false); /** Wrapper function for GameScanner::GetConsoleLibraryList */ - static char *GetConsoleLibraryList(char *p, const char *last); + static std::string GetConsoleLibraryList(); /** Wrapper function for GameScanner::GetInfoList */ static const ScriptInfoList *GetInfoList(); /** Wrapper function for GameScanner::GetUniqueInfoList */ diff --git a/src/game/game_core.cpp b/src/game/game_core.cpp index bb97db21d1..c220bd21de 100644 --- a/src/game/game_core.cpp +++ b/src/game/game_core.cpp @@ -222,14 +222,14 @@ } } -/* static */ char *Game::GetConsoleList(char *p, const char *last, bool newest_only) +/* static */ std::string Game::GetConsoleList(bool newest_only) { - return Game::scanner_info->GetConsoleList(p, last, newest_only); + return Game::scanner_info->GetConsoleList(newest_only); } -/* static */ char *Game::GetConsoleLibraryList(char *p, const char *last) +/* static */ std::string Game::GetConsoleLibraryList() { - return Game::scanner_library->GetConsoleList(p, last, true); + return Game::scanner_library->GetConsoleList(true); } /* static */ const ScriptInfoList *Game::GetInfoList() diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp index f54f3d81c5..ad6986735d 100644 --- a/src/genworld_gui.cpp +++ b/src/genworld_gui.cpp @@ -238,7 +238,7 @@ static const NWidgetPart _nested_heightmap_load_widgets[] = { EndContainer(), /* Widgets at the right of the labels. */ NWidget(NWID_VERTICAL), SetPIP(0, 4, 0), - NWidget(WWT_EMPTY, COLOUR_ORANGE, WID_GL_HEIGHTMAP_NAME_TEXT), SetFill(1, 0), + NWidget(WWT_TEXT, COLOUR_ORANGE, WID_GL_HEIGHTMAP_NAME_TEXT), SetTextColour(TC_ORANGE), SetDataTip(STR_JUST_RAW_STRING, STR_EMPTY), SetFill(1, 0), NWidget(NWID_HORIZONTAL), SetPIP(0, 5, 0), NWidget(NWID_VERTICAL, NC_EQUALSIZE), SetPIP(0, 4, 0), NWidget(WWT_TEXT, COLOUR_ORANGE, WID_GL_HEIGHTMAP_SIZE_TEXT), SetDataTip(STR_MAPGEN_HEIGHTMAP_SIZE, STR_NULL), SetFill(1, 0), @@ -513,6 +513,7 @@ struct GenerateLandscapeWindow : public Window { } break; + case WID_GL_HEIGHTMAP_NAME_TEXT: SetDParamStr(0, this->name); break; case WID_GL_RIVER_PULLDOWN: SetDParam(0, _rivers[_settings_newgame.game_creation.amount_of_rivers]); break; case WID_GL_SMOOTHNESS_PULLDOWN: SetDParam(0, _smoothness[_settings_newgame.game_creation.tgen_smoothness]); break; case WID_GL_VARIETY_PULLDOWN: SetDParam(0, _variety[_settings_newgame.game_creation.variety]); break; @@ -718,16 +719,6 @@ struct GenerateLandscapeWindow : public Window { size->height = std::max(size->height, (uint)(FONT_HEIGHT_NORMAL + WD_DROPDOWNTEXT_TOP + WD_DROPDOWNTEXT_BOTTOM)); } - void DrawWidget(const Rect &r, int widget) const override - { - switch (widget) { - case WID_GL_HEIGHTMAP_NAME_TEXT: { - DrawString(r.left, r.right, r.top, this->name, TC_ORANGE); - break; - } - } - } - void OnClick(Point pt, int widget, int click_count) override { switch (widget) { diff --git a/src/gfx.cpp b/src/gfx.cpp index 942abb28a3..80f564fb52 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -17,6 +17,7 @@ #include "settings_type.h" #include "network/network.h" #include "network/network_func.h" +#include "window_gui.h" #include "window_func.h" #include "newgrf_debug.h" #include "thread.h" @@ -25,6 +26,7 @@ #include "framerate_type.h" #include "transparency.h" #include "core/backup_type.hpp" +#include "viewport_func.h" #include "table/palettes.h" #include "table/string_colours.h" @@ -2336,6 +2338,38 @@ void UpdateGUIZoom() UpdateFontHeightCache(); } +/** + * Resolve GUI zoom level and adjust GUI to new zoom, if auto-suggestion is requested. + * @returns true when the zoom level has changed, caller must call ReInitAllWindows(true) + * after resizing the application's window/buffer. + */ +bool AdjustGUIZoom() +{ + auto old_zoom = _gui_zoom; + UpdateGUIZoom(); + if (old_zoom == _gui_zoom) return false; + GfxClearSpriteCache(); + VideoDriver::GetInstance()->ClearSystemSprites(); + ClearFontCache(); + GfxClearSpriteCache(); + UpdateAllVirtCoords(); + + /* Adjust all window sizes to match the new zoom level, so that they don't appear + to move around when the application is moved to a screen with different DPI. */ + auto zoom_shift = old_zoom - _gui_zoom; + for (Window *w : Window::IterateFromBack()) { + w->left = AdjustByZoom(w->left, zoom_shift); + w->top = AdjustByZoom(w->top, zoom_shift); + w->width = AdjustByZoom(w->width, zoom_shift); + w->height = AdjustByZoom(w->height, zoom_shift); + if (w->viewport != nullptr) { + w->viewport->zoom = Clamp(ZoomLevel(w->viewport->zoom - zoom_shift), _settings_client.gui.zoom_min, _settings_client.gui.zoom_max); + } + } + + return true; +} + void ChangeGameSpeed(bool enable_fast_forward) { if (enable_fast_forward) { diff --git a/src/gfx_func.h b/src/gfx_func.h index 0ac93ca059..8d1b7ed615 100644 --- a/src/gfx_func.h +++ b/src/gfx_func.h @@ -82,6 +82,7 @@ void DrawMouseCursor(); void ScreenSizeChanged(); void GameSizeChanged(); void UpdateGUIZoom(); +bool AdjustGUIZoom(); void UndrawMouseCursor(); /** Size of the buffer used for drawing strings. */ diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp index e519de2ec6..a0e83913f8 100644 --- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -115,14 +115,15 @@ struct GraphLegendWindow : Window { */ static NWidgetBase *MakeNWidgetCompanyLines(int *biggest_index) { - NWidgetVertical *vert = new NWidgetVertical(); + NWidgetVertical *vert = new NWidgetVertical(NC_EQUALSIZE); + vert->SetPadding(2, 2, 2, 2); uint sprite_height = GetSpriteSize(SPR_COMPANY_ICON, nullptr, ZOOM_LVL_OUT_4X).height; for (int widnum = WID_GL_FIRST_COMPANY; widnum <= WID_GL_LAST_COMPANY; widnum++) { NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, COLOUR_BROWN, widnum); - panel->SetMinimalSize(246, sprite_height); + panel->SetMinimalSize(246, sprite_height + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM); panel->SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM, FS_NORMAL); - panel->SetFill(1, 0); + panel->SetFill(1, 1); panel->SetDataTip(0x0, STR_GRAPH_KEY_COMPANY_SELECTION_TOOLTIP); vert->Add(panel); } @@ -138,13 +139,7 @@ static const NWidgetPart _nested_graph_legend_widgets[] = { NWidget(WWT_STICKYBOX, COLOUR_BROWN), EndContainer(), NWidget(WWT_PANEL, COLOUR_BROWN, WID_GL_BACKGROUND), - NWidget(NWID_SPACER), SetMinimalSize(0, 2), - NWidget(NWID_HORIZONTAL), - NWidget(NWID_SPACER), SetMinimalSize(2, 0), - NWidgetFunction(MakeNWidgetCompanyLines), - NWidget(NWID_SPACER), SetMinimalSize(2, 0), - EndContainer(), - NWidget(NWID_SPACER), SetMinimalSize(0, 2), + NWidgetFunction(MakeNWidgetCompanyLines), EndContainer(), }; diff --git a/src/group_gui.cpp b/src/group_gui.cpp index b38a4f4846..2fadb0a0ac 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -49,7 +49,7 @@ static const NWidgetPart _nested_group_widgets[] = { EndContainer(), NWidget(NWID_HORIZONTAL), /* left part */ - NWidget(NWID_VERTICAL), + NWidget(NWID_VERTICAL, NC_BIGFIRST), NWidget(WWT_PANEL, COLOUR_GREY, WID_GL_ALL_VEHICLES), SetFill(1, 0), EndContainer(), NWidget(WWT_PANEL, COLOUR_GREY, WID_GL_DEFAULT_VEHICLES), SetFill(1, 0), EndContainer(), NWidget(NWID_HORIZONTAL), @@ -458,26 +458,11 @@ public: void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { switch (widget) { - case WID_GL_LIST_GROUP: { + case WID_GL_LIST_GROUP: size->width = this->ComputeGroupInfoSize(); resize->height = this->tiny_step_height; - - /* Minimum height is the height of the list widget minus all and default vehicles... */ - size->height = 4 * GetVehicleListHeight(this->vli.vtype, this->tiny_step_height); - - /* ... minus the buttons at the bottom ... */ - uint max_icon_height = GetSpriteSize(this->GetWidget(WID_GL_CREATE_GROUP)->widget_data).height; - max_icon_height = std::max(max_icon_height, GetSpriteSize(this->GetWidget(WID_GL_RENAME_GROUP)->widget_data).height); - max_icon_height = std::max(max_icon_height, GetSpriteSize(this->GetWidget(WID_GL_DELETE_GROUP)->widget_data).height); - max_icon_height = std::max(max_icon_height, GetSpriteSize(this->GetWidget(WID_GL_REPLACE_PROTECTION)->widget_data).height); - - /* ... minus the height of the group info ... */ - max_icon_height += (FONT_HEIGHT_NORMAL * 3) + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM; - - /* Get a multiple of tiny_step_height of that amount */ - size->height = Ceil(size->height - max_icon_height, tiny_step_height); + fill->height = this->tiny_step_height; break; - } case WID_GL_ALL_VEHICLES: case WID_GL_DEFAULT_VEHICLES: diff --git a/src/lang/english_AU.txt b/src/lang/english_AU.txt index b822f3d56d..a6e8a36eb0 100644 --- a/src/lang/english_AU.txt +++ b/src/lang/english_AU.txt @@ -229,9 +229,9 @@ STR_UNITS_HEIGHT_METRIC :{COMMA}{NBSP}m STR_UNITS_HEIGHT_SI :{COMMA}{NBSP}m # Common window strings -STR_LIST_FILTER_TITLE :{BLACK}Filter string: -STR_LIST_FILTER_OSKTITLE :{BLACK}Enter filter string -STR_LIST_FILTER_TOOLTIP :{BLACK}Enter a keyword to filter the list for +STR_LIST_FILTER_TITLE :{BLACK}Filter: +STR_LIST_FILTER_OSKTITLE :{BLACK}Enter one or more keywords to filter the list for +STR_LIST_FILTER_TOOLTIP :{BLACK}Enter one or more keywords to filter the list for STR_TOOLTIP_GROUP_ORDER :{BLACK}Select grouping order STR_TOOLTIP_SORT_ORDER :{BLACK}Select sorting order (descending/ascending) @@ -1174,7 +1174,7 @@ STR_WARNING_NO_SUITABLE_AI :{WHITE}No suita # Settings tree window STR_CONFIG_SETTING_TREE_CAPTION :{WHITE}Settings -STR_CONFIG_SETTING_FILTER_TITLE :{BLACK}Filter string: +STR_CONFIG_SETTING_FILTER_TITLE :{BLACK}Filter: STR_CONFIG_SETTING_EXPAND_ALL :{BLACK}Expand all STR_CONFIG_SETTING_COLLAPSE_ALL :{BLACK}Collapse all STR_CONFIG_SETTING_RESET_ALL :{BLACK}Reset all values @@ -3161,7 +3161,7 @@ STR_SAVELOAD_DETAIL_CAPTION :{BLACK}Game Det STR_SAVELOAD_DETAIL_NOT_AVAILABLE :{BLACK}No information available STR_SAVELOAD_DETAIL_COMPANY_INDEX :{SILVER}{COMMA}: {WHITE}{STRING} STR_SAVELOAD_DETAIL_GRFSTATUS :{SILVER}NewGRF: {WHITE}{STRING} -STR_SAVELOAD_FILTER_TITLE :{BLACK}Filter string: +STR_SAVELOAD_FILTER_TITLE :{BLACK}Filter: STR_SAVELOAD_OVERWRITE_TITLE :{WHITE}Overwrite File STR_SAVELOAD_OVERWRITE_WARNING :{YELLOW}Are you sure you want to overwrite the existing file? STR_SAVELOAD_DIRECTORY :{STRING} (Directory) @@ -3257,7 +3257,7 @@ STR_NEWGRF_SETTINGS_INFO_TITLE :{WHITE}Detailed STR_NEWGRF_SETTINGS_ACTIVE_LIST :{WHITE}Active NewGRF files STR_NEWGRF_SETTINGS_INACTIVE_LIST :{WHITE}Inactive NewGRF files STR_NEWGRF_SETTINGS_SELECT_PRESET :{ORANGE}Select preset: -STR_NEWGRF_FILTER_TITLE :{ORANGE}Filter string: +STR_NEWGRF_FILTER_TITLE :{ORANGE}Filter: STR_NEWGRF_SETTINGS_PRESET_LIST_TOOLTIP :{BLACK}Load the selected preset STR_NEWGRF_SETTINGS_PRESET_SAVE :{BLACK}Save preset STR_NEWGRF_SETTINGS_PRESET_SAVE_TOOLTIP :{BLACK}Save the current list as a preset @@ -3682,6 +3682,7 @@ STR_FINANCES_SECTION_LOAN_INTEREST :{GOLD}Loan Inte STR_FINANCES_SECTION_OTHER :{GOLD}Other STR_FINANCES_NEGATIVE_INCOME :-{CURRENCY_LONG} +STR_FINANCES_ZERO_INCOME :{CURRENCY_LONG} STR_FINANCES_POSITIVE_INCOME :+{CURRENCY_LONG} STR_FINANCES_NET_PROFIT :{WHITE}Net Profit STR_FINANCES_BANK_BALANCE_TITLE :{WHITE}Bank Balance diff --git a/src/lang/turkish.txt b/src/lang/turkish.txt index 9bfd965cf3..ebdffdb5f5 100644 --- a/src/lang/turkish.txt +++ b/src/lang/turkish.txt @@ -230,9 +230,9 @@ STR_UNITS_HEIGHT_METRIC :{COMMA}{NBSP}m STR_UNITS_HEIGHT_SI :{COMMA}{NBSP}m # Common window strings -STR_LIST_FILTER_TITLE :{BLACK}Süzgeç metni: -STR_LIST_FILTER_OSKTITLE :{BLACK}Süzgeç metnini girin -STR_LIST_FILTER_TOOLTIP :{BLACK}Listeyi filtrelemek için bir anahtar sözcük girin +STR_LIST_FILTER_TITLE :{BLACK}Filtre: +STR_LIST_FILTER_OSKTITLE :{BLACK}Listeyi filtrelemek için anahtar sözcük girin +STR_LIST_FILTER_TOOLTIP :{BLACK}Listeyi filtrelemek için anahtar sözcük girin STR_TOOLTIP_GROUP_ORDER :{BLACK}Gruplama sırasını seç STR_TOOLTIP_SORT_ORDER :{BLACK}Sıralama türünü seçin (azalan/artan) @@ -1175,7 +1175,7 @@ STR_WARNING_NO_SUITABLE_AI :{WHITE}Uygun YZ # Settings tree window STR_CONFIG_SETTING_TREE_CAPTION :{WHITE}Ayarlar -STR_CONFIG_SETTING_FILTER_TITLE :{BLACK}Süzgeç metni: +STR_CONFIG_SETTING_FILTER_TITLE :{BLACK}Filtre: STR_CONFIG_SETTING_EXPAND_ALL :{BLACK}Tümünü genişlet STR_CONFIG_SETTING_COLLAPSE_ALL :{BLACK}Tümünü kısalt STR_CONFIG_SETTING_RESET_ALL :{BLACK}Tüm değerleri sıfırla @@ -3136,7 +3136,7 @@ STR_SAVELOAD_DETAIL_CAPTION :{BLACK}Oyun Ayr STR_SAVELOAD_DETAIL_NOT_AVAILABLE :{BLACK}Mevcut bilgi yok STR_SAVELOAD_DETAIL_COMPANY_INDEX :{SILVER}{COMMA}: {WHITE}{STRING} STR_SAVELOAD_DETAIL_GRFSTATUS :{SILVER}NewGRF: {WHITE}{STRING} -STR_SAVELOAD_FILTER_TITLE :{BLACK}Süzgeç dizgesi: +STR_SAVELOAD_FILTER_TITLE :{BLACK}Filtre: STR_SAVELOAD_OVERWRITE_TITLE :{WHITE}Dosya Üzerine Yaz STR_SAVELOAD_OVERWRITE_WARNING :{YELLOW}Mevcut dosyanın üzerine yazmak istediğinizden emin misiniz? STR_SAVELOAD_DIRECTORY :{STRING} (Dizin) @@ -3232,7 +3232,7 @@ STR_NEWGRF_SETTINGS_INFO_TITLE :{WHITE}Ayrınt STR_NEWGRF_SETTINGS_ACTIVE_LIST :{WHITE}Aktif NewGRF dosyaları STR_NEWGRF_SETTINGS_INACTIVE_LIST :{WHITE}Aktif olmayan NewGRF dosyaları STR_NEWGRF_SETTINGS_SELECT_PRESET :{ORANGE}Önceden belirlenmiş ayar seçin: -STR_NEWGRF_FILTER_TITLE :{ORANGE}Süzgeç metni: +STR_NEWGRF_FILTER_TITLE :{ORANGE}Filtre: STR_NEWGRF_SETTINGS_PRESET_LIST_TOOLTIP :{BLACK}Seçili önayarı yükle STR_NEWGRF_SETTINGS_PRESET_SAVE :{BLACK}Önayarı kaydet STR_NEWGRF_SETTINGS_PRESET_SAVE_TOOLTIP :{BLACK}Şimdiki listeyi önayar olarak kaydet @@ -3657,6 +3657,7 @@ STR_FINANCES_SECTION_LOAN_INTEREST :{GOLD}Kredi Fai STR_FINANCES_SECTION_OTHER :{GOLD}Diğer STR_FINANCES_NEGATIVE_INCOME :-{CURRENCY_LONG} +STR_FINANCES_ZERO_INCOME :{CURRENCY_LONG} STR_FINANCES_POSITIVE_INCOME :+{CURRENCY_LONG} STR_FINANCES_NET_PROFIT :{WHITE}Net Kâr STR_FINANCES_BANK_BALANCE_TITLE :{WHITE}Banka Hesabı diff --git a/src/lang/vietnamese.txt b/src/lang/vietnamese.txt index 70818810fe..57e4abf153 100644 --- a/src/lang/vietnamese.txt +++ b/src/lang/vietnamese.txt @@ -4486,7 +4486,7 @@ STR_TIMETABLE_STATUS_NOT_STARTED :{BLACK}Bảng l STR_TIMETABLE_STATUS_START_AT :{BLACK}Bảng lịch trình sẽ bắt đầu lúc {STRING} STR_TIMETABLE_STARTING_DATE :{BLACK}Ngày bắt đầu -STR_TIMETABLE_STARTING_DATE_TOOLTIP :{BLACK}Lựa chọn ngày bắt đầu trong bảng lịch trình này. Ctrl+Click chọn ngày bắt đầu trong bảng lịch trình và phân bổ nó cho tất cả các phương tiện chia sẻ lộ trình này, nếu như lộ trình đã lên lịch đầy đủ. +STR_TIMETABLE_STARTING_DATE_TOOLTIP :{BLACK}Lựa chọn ngày bắt đầu trong bảng lịch trình này. Ctrl+Click phân bổ cho tất cả các phương tiện chia sẻ lộ trình này bắt đầu từ ngày được chọn một cách đồng đều theo thứ tự tương đối giữa chúng, nếu như lộ trình đã lên lịch đầy đủ. STR_TIMETABLE_CHANGE_TIME :{BLACK}Đổi thời gian STR_TIMETABLE_WAIT_TIME_TOOLTIP :{BLACK}Thay đổi thời lượng của điểm lộ trình được phép sử dụng diff --git a/src/linkgraph/linkgraph_gui.cpp b/src/linkgraph/linkgraph_gui.cpp index 1ce9ed796e..cdc6b309c9 100644 --- a/src/linkgraph/linkgraph_gui.cpp +++ b/src/linkgraph/linkgraph_gui.cpp @@ -14,6 +14,7 @@ #include "../company_gui.h" #include "../date_func.h" #include "../viewport_func.h" +#include "../zoom_func.h" #include "../smallmap_gui.h" #include "../zoom_func.h" #include "../landscape.h" @@ -399,8 +400,9 @@ void LinkGraphOverlay::Draw(const DrawPixelInfo *dpi) */ void LinkGraphOverlay::DrawLinks(const DrawPixelInfo *dpi) const { + int width = ScaleGUITrad(this->scale); for (LinkList::const_iterator i(this->cached_links.begin()); i != this->cached_links.end(); ++i) { - if (!this->IsLinkVisible(i->from_pt, i->to_pt, dpi, this->scale + 2)) continue; + if (!this->IsLinkVisible(i->from_pt, i->to_pt, dpi, width + 2)) continue; if (!Station::IsValidID(i->from_id)) continue; if (!Station::IsValidID(i->to_id)) continue; this->DrawContent(i->from_pt, i->to_pt, i->prop); @@ -417,20 +419,21 @@ void LinkGraphOverlay::DrawContent(Point pta, Point ptb, const LinkProperties &c { uint usage_or_plan = std::min(cargo.capacity * 2 + 1, std::max(cargo.usage, cargo.planned)); int colour = LinkGraphOverlay::LINK_COLOURS[_settings_client.gui.linkgraph_colours][usage_or_plan * lengthof(LinkGraphOverlay::LINK_COLOURS[0]) / (cargo.capacity * 2 + 2)]; - int dash = cargo.shared ? this->scale * 4 : 0; + int width = ScaleGUITrad(this->scale); + int dash = cargo.shared ? width * 4 : 0; /* Move line a bit 90° against its dominant direction to prevent it from * being hidden below the grey line. */ int side = _settings_game.vehicle.road_side ? 1 : -1; if (abs(pta.x - ptb.x) < abs(pta.y - ptb.y)) { - int offset_x = (pta.y > ptb.y ? 1 : -1) * side * this->scale; - GfxDrawLine(pta.x + offset_x, pta.y, ptb.x + offset_x, ptb.y, colour, this->scale, dash); + int offset_x = (pta.y > ptb.y ? 1 : -1) * side * width; + GfxDrawLine(pta.x + offset_x, pta.y, ptb.x + offset_x, ptb.y, colour, width, dash); } else { - int offset_y = (pta.x < ptb.x ? 1 : -1) * side * this->scale; - GfxDrawLine(pta.x, pta.y + offset_y, ptb.x, ptb.y + offset_y, colour, this->scale, dash); + int offset_y = (pta.x < ptb.x ? 1 : -1) * side * width; + GfxDrawLine(pta.x, pta.y + offset_y, ptb.x, ptb.y + offset_y, colour, width, dash); } - GfxDrawLine(pta.x, pta.y, ptb.x, ptb.y, _colour_gradient[COLOUR_GREY][1], this->scale); + GfxDrawLine(pta.x, pta.y, ptb.x, ptb.y, _colour_gradient[COLOUR_GREY][1], width); } /** @@ -439,14 +442,15 @@ void LinkGraphOverlay::DrawContent(Point pta, Point ptb, const LinkProperties &c */ void LinkGraphOverlay::DrawStationDots(const DrawPixelInfo *dpi) const { + int width = ScaleGUITrad(this->scale); for (StationSupplyList::const_iterator i(this->cached_stations.begin()); i != this->cached_stations.end(); ++i) { const Point &pt = i->pt; - if (!this->IsPointVisible(pt, dpi, 3 * this->scale)) continue; + if (!this->IsPointVisible(pt, dpi, 3 * width)) continue; const Station *st = Station::GetIfValid(i->id); if (st == nullptr) continue; - uint r = this->scale * 2 + this->scale * 2 * std::min(200, i->quantity) / 200; + uint r = width * 2 + width * 2 * std::min(200, i->quantity) / 200; LinkGraphOverlay::DrawVertex(pt.x, pt.y, r, _colour_gradient[st->owner != OWNER_NONE ? diff --git a/src/network/network_chat_gui.cpp b/src/network/network_chat_gui.cpp index 447bd25c9b..123a26ece5 100644 --- a/src/network/network_chat_gui.cpp +++ b/src/network/network_chat_gui.cpp @@ -509,7 +509,7 @@ static const NWidgetPart _nested_chat_window_widgets[] = { NWidget(WWT_CLOSEBOX, COLOUR_GREY, WID_NC_CLOSE), NWidget(WWT_PANEL, COLOUR_GREY, WID_NC_BACKGROUND), NWidget(NWID_HORIZONTAL), - NWidget(WWT_TEXT, COLOUR_GREY, WID_NC_DESTINATION), SetMinimalSize(62, 12), SetPadding(1, 0, 1, 0), SetTextColour(TC_BLACK), SetAlignment(SA_TOP | SA_RIGHT), SetDataTip(STR_NULL, STR_NULL), + NWidget(WWT_TEXT, COLOUR_GREY, WID_NC_DESTINATION), SetMinimalSize(62, 12), SetPadding(1, 0, 1, 0), SetAlignment(SA_TOP | SA_RIGHT), SetDataTip(STR_NULL, STR_NULL), NWidget(WWT_EDITBOX, COLOUR_GREY, WID_NC_TEXTBOX), SetMinimalSize(100, 12), SetPadding(1, 0, 1, 0), SetResize(1, 0), SetDataTip(STR_NETWORK_CHAT_OSKTITLE, STR_NULL), NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_NC_SENDBUTTON), SetMinimalSize(62, 12), SetPadding(1, 0, 1, 0), SetDataTip(STR_NETWORK_CHAT_SEND, STR_NULL), diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp index 9bbae56bf0..0130bc9800 100644 --- a/src/network/network_content_gui.cpp +++ b/src/network/network_content_gui.cpp @@ -557,10 +557,6 @@ public: void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { switch (widget) { - case WID_NCL_FILTER_CAPT: - *size = maxdim(*size, GetStringBoundingBox(STR_CONTENT_FILTER_TITLE)); - break; - case WID_NCL_CHECKBOX: size->width = this->checkbox_size.width + WD_MATRIX_RIGHT + WD_MATRIX_LEFT; break; @@ -585,10 +581,6 @@ public: void DrawWidget(const Rect &r, int widget) const override { switch (widget) { - case WID_NCL_FILTER_CAPT: - DrawString(r.left, r.right, r.top, STR_CONTENT_FILTER_TITLE, TC_FROMSTRING, SA_RIGHT); - break; - case WID_NCL_DETAILS: this->DrawDetails(r); break; @@ -1027,7 +1019,7 @@ static const NWidgetPart _nested_network_content_list_widgets[] = { NWidget(NWID_SPACER), SetMinimalSize(0, 7), SetResize(1, 0), NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(8, 8, 8), /* Top */ - NWidget(WWT_EMPTY, COLOUR_LIGHT_BLUE, WID_NCL_FILTER_CAPT), SetFill(1, 0), SetResize(1, 0), + NWidget(WWT_TEXT, COLOUR_LIGHT_BLUE, WID_NCL_FILTER_CAPT), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_CONTENT_FILTER_TITLE, STR_NULL), SetAlignment(SA_RIGHT), NWidget(WWT_EDITBOX, COLOUR_LIGHT_BLUE, WID_NCL_FILTER), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP), EndContainer(), diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index 2079792f17..caa32c7a9c 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -104,8 +104,7 @@ public: leaf = new NWidgetLeaf(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_INFO, STR_EMPTY, STR_NETWORK_SERVER_LIST_INFO_ICONS_TOOLTIP); leaf->SetMinimalSize(14 + GetSpriteSize(SPR_LOCK, nullptr, ZOOM_LVL_OUT_4X).width - + GetSpriteSize(SPR_BLOT, nullptr, ZOOM_LVL_OUT_4X).width - + GetSpriteSize(SPR_FLAGS_BASE, nullptr, ZOOM_LVL_OUT_4X).width, 12); + + GetSpriteSize(SPR_BLOT, nullptr, ZOOM_LVL_OUT_4X).width, 12); leaf->SetFill(0, 1); this->Add(leaf); diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 49e371c80e..708fc547de 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -4267,7 +4267,7 @@ static ChangeInfoResult ObjectChangeInfo(uint id, int numinfo, int prop, const G if (*ospec == nullptr) { *ospec = CallocT(1); (*ospec)->views = 1; // Default for NewGRFs that don't set it. - (*ospec)->size = 0x11; // Default for NewGRFs that manage to not set it (1x1) + (*ospec)->size = OBJECT_SIZE_1X1; // Default for NewGRFs that manage to not set it (1x1) } /* Swap classid because we read it in BE. */ @@ -4295,7 +4295,7 @@ static ChangeInfoResult ObjectChangeInfo(uint id, int numinfo, int prop, const G spec->size = buf->ReadByte(); if (GB(spec->size, 0, 4) == 0 || GB(spec->size, 4, 4) == 0) { grfmsg(0, "ObjectChangeInfo: Invalid object size requested (0x%x) for object id %u. Ignoring.", spec->size, id + i); - spec->size = 0x11; // 1x1 + spec->size = OBJECT_SIZE_1X1; } break; @@ -7007,7 +7007,7 @@ static const Action5Type _action5_types[] = { /* 0x11 */ { A5BLOCK_ALLOW_OFFSET, SPR_ROADSTOP_BASE, 1, ROADSTOP_SPRITE_COUNT, "Road stop graphics" }, /* 0x12 */ { A5BLOCK_ALLOW_OFFSET, SPR_AQUEDUCT_BASE, 1, AQUEDUCT_SPRITE_COUNT, "Aqueduct graphics" }, /* 0x13 */ { A5BLOCK_ALLOW_OFFSET, SPR_AUTORAIL_BASE, 1, AUTORAIL_SPRITE_COUNT, "Autorail graphics" }, - /* 0x14 */ { A5BLOCK_ALLOW_OFFSET, SPR_FLAGS_BASE, 1, FLAGS_SPRITE_COUNT, "Flag graphics" }, + /* 0x14 */ { A5BLOCK_INVALID, 0, 1, 0, "Flag graphics" }, // deprecated, no longer used. /* 0x15 */ { A5BLOCK_ALLOW_OFFSET, SPR_OPENTTD_BASE, 1, OPENTTD_SPRITE_COUNT, "OpenTTD GUI graphics" }, /* 0x16 */ { A5BLOCK_ALLOW_OFFSET, SPR_AIRPORT_PREVIEW_BASE, 1, SPR_AIRPORT_PREVIEW_COUNT, "Airport preview graphics" }, /* 0x17 */ { A5BLOCK_ALLOW_OFFSET, SPR_RAILTYPE_TUNNEL_BASE, 1, RAILTYPE_TUNNEL_BASE_COUNT, "Railtype tunnel base" }, diff --git a/src/newgrf_object.h b/src/newgrf_object.h index 1ab3587b60..b44e8e3825 100644 --- a/src/newgrf_object.h +++ b/src/newgrf_object.h @@ -57,6 +57,8 @@ enum ObjectEdgeFoundationFlags { }; DECLARE_ENUM_AS_BIT_SET(ObjectEdgeFoundationFlags) +static const uint8 OBJECT_SIZE_1X1 = 0x11; ///< The value of a NewGRF's size property when the object is 1x1 tiles: low nibble for X, high nibble for Y. + void ResetObjects(); /** Class IDs for objects. */ diff --git a/src/openttd.cpp b/src/openttd.cpp index 38f4a52237..af2b72e364 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -281,12 +281,14 @@ static void ShowHelp() /* We need to initialize the AI, so it finds the AIs */ AI::Initialize(); - p = AI::GetConsoleList(p, lastof(buf), true); + const std::string ai_list = AI::GetConsoleList(true); + p = strecpy(p, ai_list.c_str(), lastof(buf)); AI::Uninitialize(true); /* We need to initialize the GameScript, so it finds the GSs */ Game::Initialize(); - p = Game::GetConsoleList(p, lastof(buf), true); + const std::string game_list = Game::GetConsoleList(true); + p = strecpy(p, game_list.c_str(), lastof(buf)); Game::Uninitialize(true); /* ShowInfo put output to stderr, but version information should go diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index 730f2664e3..9310fa1577 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -964,7 +964,7 @@ static const NWidgetPart _nested_build_rail_widgets[] = { NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_POLYRAIL), SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_AUTORAIL, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_POLYRAIL), - NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetMinimalSize(4, 22), SetDataTip(0x0, STR_NULL), EndContainer(), + NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetMinimalSize(4, 22), EndContainer(), NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_DEMOLISH), SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC), @@ -1322,18 +1322,15 @@ public: if (this->IsShaded()) return; /* 'Accepts' and 'Supplies' texts. */ - NWidgetBase *cov = this->GetWidget(WID_BRAS_COVERAGE_TEXTS); - int top = cov->pos_y + WD_PAR_VSEP_NORMAL; - int left = cov->pos_x + WD_FRAMERECT_LEFT; - int right = cov->pos_x + cov->current_x - WD_FRAMERECT_RIGHT; - int bottom = cov->pos_y + cov->current_y; - top = DrawStationCoverageAreaText(left, right, top, SCT_ALL, rad, false) + WD_PAR_VSEP_NORMAL; - top = DrawStationCoverageAreaText(left, right, top, SCT_ALL, rad, true) + WD_PAR_VSEP_NORMAL; + Rect r = this->GetWidget(WID_BRAS_COVERAGE_TEXTS)->GetCurrentRect(); + int top = r.top + ScaleGUITrad(WD_PAR_VSEP_NORMAL); + top = DrawStationCoverageAreaText(r.left, r.right, top, SCT_ALL, rad, false) + ScaleGUITrad(WD_PAR_VSEP_NORMAL); + top = DrawStationCoverageAreaText(r.left, r.right, top, SCT_ALL, rad, true) + ScaleGUITrad(WD_PAR_VSEP_NORMAL); /* Resize background if the window is too small. * Never make the window smaller to avoid oscillating if the size change affects the acceptance. * (This is the case, if making the window bigger moves the mouse into the window.) */ - if (top > bottom) { - this->coverage_height += top - bottom; + if (top > r.bottom) { + this->coverage_height += top - r.bottom; this->ReInit(); } } @@ -1756,7 +1753,7 @@ static const NWidgetPart _nested_station_builder_widgets[] = { NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_DRAG_N_DROP), SetMinimalSize(75, 12), SetDataTip(STR_STATION_BUILD_DRAG_DROP, STR_STATION_BUILD_DRAG_DROP_TOOLTIP), NWidget(NWID_SPACER), SetMinimalSize(2, 0), SetFill(1, 0), EndContainer(), - NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetMinimalSize(144, 11), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL), SetPadding(3, 2, 0, 0), + NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL), SetPadding(WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM, WD_FRAMERECT_LEFT), SetFill(1, 0), NWidget(NWID_HORIZONTAL), NWidget(NWID_SPACER), SetMinimalSize(2, 0), SetFill(1, 0), NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_HIGHLIGHT_OFF), SetMinimalSize(60, 12), @@ -1781,7 +1778,7 @@ static const NWidgetPart _nested_station_builder_widgets[] = { EndContainer(), EndContainer(), NWidget(NWID_HORIZONTAL), - NWidget(WWT_EMPTY, INVALID_COLOUR, WID_BRAS_COVERAGE_TEXTS), SetPadding(2, 5, 0, 1), SetFill(1, 1), SetResize(1, 0), + NWidget(WWT_EMPTY, INVALID_COLOUR, WID_BRAS_COVERAGE_TEXTS), SetPadding(0, WD_FRAMERECT_RIGHT, 0, WD_FRAMERECT_LEFT), SetFill(1, 1), SetResize(1, 0), NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BRAS_SHOW_NEWST_RESIZE), NWidget(NWID_VERTICAL), NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetFill(0, 1), EndContainer(), diff --git a/src/script/api/ai_changelog.hpp b/src/script/api/ai_changelog.hpp index f728ab18fe..6479393760 100644 --- a/src/script/api/ai_changelog.hpp +++ b/src/script/api/ai_changelog.hpp @@ -17,9 +17,14 @@ * * This version is not yet released. The following changes are not set in stone yet. * + * API additions: + * \li AICargo::GetWeight * \li AIIndustryType::ResolveNewGRFID * \li AIObjectType::ResolveNewGRFID * + * Other changes: + * \li AIRoad::HasRoadType now correctly checks RoadType against RoadType + * * \b 12.0 * * API additions: diff --git a/src/script/api/game_changelog.hpp b/src/script/api/game_changelog.hpp index 159671807d..592550ec1b 100644 --- a/src/script/api/game_changelog.hpp +++ b/src/script/api/game_changelog.hpp @@ -17,9 +17,14 @@ * * This version is not yet released. The following changes are not set in stone yet. * + * API additions: + * \li GSCargo::GetWeight * \li GSIndustryType::ResolveNewGRFID * \li GSObjectType::ResolveNewGRFID * + * Other changes: + * \li GSRoad::HasRoadType now correctly checks RoadType against RoadType + * * \b 12.0 * * API additions: diff --git a/src/script/api/script_cargo.cpp b/src/script/api/script_cargo.cpp index 5e092b52a0..e5a80023f7 100644 --- a/src/script/api/script_cargo.cpp +++ b/src/script/api/script_cargo.cpp @@ -81,3 +81,9 @@ if (!ScriptCargo::IsValidCargo(cargo_type)) return INVALID_DISTRIBUTION_TYPE; return (ScriptCargo::DistributionType)_settings_game.linkgraph.GetDistributionType(cargo_type); } + +/* static */ int64 ScriptCargo::GetWeight(CargoID cargo_type, uint32 amount) +{ + if (!IsValidCargo(cargo_type)) return -1; + return ::CargoSpec::Get(cargo_type)->weight * static_cast(amount) / 16; +} diff --git a/src/script/api/script_cargo.hpp b/src/script/api/script_cargo.hpp index 1bfd8c5531..67a54a3467 100644 --- a/src/script/api/script_cargo.hpp +++ b/src/script/api/script_cargo.hpp @@ -153,6 +153,16 @@ public: * @return The cargo distribution type for the given cargo. */ static DistributionType GetDistributionType(CargoID cargo_type); + + /** + * Get the weight in tonnes for the given amount of + * cargo for the specified type. + * @param cargo_type The cargo to check on. + * @param amount The quantity of cargo. + * @pre ScriptCargo::IsValidCargo(cargo_type). + * @return The weight in tonnes for that quantity of cargo. + */ + static int64 GetWeight(CargoID cargo_type, uint32 amount); }; #endif /* SCRIPT_CARGO_HPP */ diff --git a/src/script/api/script_road.cpp b/src/script/api/script_road.cpp index 8d769e1ea8..240d13722d 100644 --- a/src/script/api/script_road.cpp +++ b/src/script/api/script_road.cpp @@ -95,7 +95,7 @@ { if (!ScriptMap::IsValidTile(tile)) return false; if (!IsRoadTypeAvailable(road_type)) return false; - return ::GetAnyRoadBits(tile, ::GetRoadTramType((::RoadType)road_type), false) != ROAD_NONE; + return ::MayHaveRoad(tile) && HasBit(::GetPresentRoadTypes(tile), (::RoadType)road_type); } /* static */ bool ScriptRoad::HasRoadTramType(TileIndex tile, RoadTramTypes road_tram_type) diff --git a/src/script/script_scanner.cpp b/src/script/script_scanner.cpp index bdde99f6c3..9d4b59036c 100644 --- a/src/script/script_scanner.cpp +++ b/src/script/script_scanner.cpp @@ -145,15 +145,16 @@ void ScriptScanner::RegisterScript(ScriptInfo *info) } } -char *ScriptScanner::GetConsoleList(char *p, const char *last, bool newest_only) const +std::string ScriptScanner::GetConsoleList(bool newest_only) const { - p += seprintf(p, last, "List of %s:\n", this->GetScannerName()); + std::string p; + p += stdstr_fmt("List of %s:\n", this->GetScannerName()); const ScriptInfoList &list = newest_only ? this->info_single_list : this->info_list; for (const auto &item : list) { ScriptInfo *i = item.second; - p += seprintf(p, last, "%10s (v%d): %s\n", i->GetName(), i->GetVersion(), i->GetDescription()); + p += stdstr_fmt("%10s (v%d): %s\n", i->GetName(), i->GetVersion(), i->GetDescription()); } - p += seprintf(p, last, "\n"); + p += "\n"; return p; } diff --git a/src/script/script_scanner.hpp b/src/script/script_scanner.hpp index ca9068ca10..9781e07b69 100644 --- a/src/script/script_scanner.hpp +++ b/src/script/script_scanner.hpp @@ -57,7 +57,7 @@ public: /** * Get the list of registered scripts to print on the console. */ - char *GetConsoleList(char *p, const char *last, bool newest_only) const; + std::string GetConsoleList(bool newest_only) const; /** * Check whether we have a script with the exact characteristics as ci. diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 434a7a3f42..54faf8e3bf 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -2940,7 +2940,7 @@ static const NWidgetPart _nested_settings_selection_widgets[] = { NWidget(WWT_DEFSIZEBOX, COLOUR_MAUVE), EndContainer(), NWidget(WWT_PANEL, COLOUR_MAUVE), - NWidget(NWID_VERTICAL), SetPIP(0, WD_PAR_VSEP_NORMAL, 0), SetPadding(WD_TEXTPANEL_TOP, 0, WD_TEXTPANEL_BOTTOM, 0), + NWidget(NWID_VERTICAL), SetPIP(WD_TEXTPANEL_TOP, WD_PAR_VSEP_NORMAL, WD_TEXTPANEL_BOTTOM), NWidget(NWID_HORIZONTAL), SetPIP(WD_FRAMETEXT_LEFT, WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_RIGHT), NWidget(WWT_TEXT, COLOUR_MAUVE, WID_GS_RESTRICT_CATEGORY), SetDataTip(STR_CONFIG_SETTING_RESTRICT_CATEGORY, STR_NULL), NWidget(WWT_DROPDOWN, COLOUR_MAUVE, WID_GS_RESTRICT_DROPDOWN), SetMinimalSize(100, 12), SetDataTip(STR_BLACK_STRING, STR_CONFIG_SETTING_RESTRICT_DROPDOWN_HELPTEXT), SetFill(1, 0), SetResize(1, 0), @@ -2949,19 +2949,17 @@ static const NWidgetPart _nested_settings_selection_widgets[] = { NWidget(WWT_TEXT, COLOUR_MAUVE, WID_GS_RESTRICT_TYPE), SetDataTip(STR_CONFIG_SETTING_RESTRICT_TYPE, STR_NULL), NWidget(WWT_DROPDOWN, COLOUR_MAUVE, WID_GS_TYPE_DROPDOWN), SetMinimalSize(100, 12), SetDataTip(STR_BLACK_STRING, STR_CONFIG_SETTING_TYPE_DROPDOWN_HELPTEXT), SetFill(1, 0), SetResize(1, 0), EndContainer(), - EndContainer(), - NWidget(NWID_HORIZONTAL), SetPadding(0, 0, WD_TEXTPANEL_BOTTOM, 0), - SetPIP(WD_FRAMETEXT_LEFT, WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_RIGHT), - NWidget(WWT_TEXT, COLOUR_MAUVE), SetFill(0, 1), SetDataTip(STR_CONFIG_SETTING_FILTER_TITLE, STR_NULL), - NWidget(WWT_EDITBOX, COLOUR_MAUVE, WID_GS_FILTER), SetFill(1, 0), SetMinimalSize(50, 12), SetResize(1, 0), - SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP), + NWidget(NWID_HORIZONTAL), SetPIP(WD_FRAMETEXT_LEFT, WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_RIGHT), + NWidget(WWT_TEXT, COLOUR_MAUVE), SetFill(0, 1), SetDataTip(STR_CONFIG_SETTING_FILTER_TITLE, STR_NULL), + NWidget(WWT_EDITBOX, COLOUR_MAUVE, WID_GS_FILTER), SetMinimalSize(50, 12), SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP), SetFill(1, 0), SetResize(1, 0), + EndContainer(), EndContainer(), EndContainer(), NWidget(NWID_HORIZONTAL), NWidget(WWT_PANEL, COLOUR_MAUVE, WID_GS_OPTIONSPANEL), SetMinimalSize(400, 174), SetScrollbar(WID_GS_SCROLLBAR), EndContainer(), NWidget(NWID_VSCROLLBAR, COLOUR_MAUVE, WID_GS_SCROLLBAR), EndContainer(), - NWidget(WWT_PANEL, COLOUR_MAUVE), SetMinimalSize(400, 40), + NWidget(WWT_PANEL, COLOUR_MAUVE), NWidget(WWT_EMPTY, INVALID_COLOUR, WID_GS_HELP_TEXT), SetMinimalSize(300, 25), SetFill(1, 1), SetResize(1, 0), SetPadding(WD_FRAMETEXT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_BOTTOM, WD_FRAMETEXT_LEFT), EndContainer(), diff --git a/src/station_gui.cpp b/src/station_gui.cpp index 8b1c90fdb3..bcf9dddfc0 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -477,16 +477,6 @@ public: this->rating_width = this->rating_width * 16 / 10; break; - case WID_STL_CARGOALL: - case WID_STL_FACILALL: - case WID_STL_NOCARGOWAITING: { - Dimension d = GetStringBoundingBox(widget == WID_STL_NOCARGOWAITING ? STR_ABBREV_NONE : STR_ABBREV_ALL); - d.width += padding.width + 2; - d.height += padding.height; - *size = maxdim(*size, d); - break; - } - default: if (widget >= WID_STL_CARGOSTART) { Dimension d = GetStringBoundingBox(_sorted_cargo_specs[widget - WID_STL_CARGOSTART]->abbrev); @@ -566,24 +556,6 @@ public: break; } - case WID_STL_NOCARGOWAITING: { - int cg_ofst = this->IsWidgetLowered(widget) ? 1 : 0; - DrawString(r.left + cg_ofst, r.right + cg_ofst, r.top + (r.bottom - r.top - FONT_HEIGHT_SMALL) / 2 + cg_ofst, STR_ABBREV_NONE, TC_BLACK, SA_HOR_CENTER); - break; - } - - case WID_STL_CARGOALL: { - int cg_ofst = this->IsWidgetLowered(widget) ? 1 : 0; - DrawString(r.left + cg_ofst, r.right + cg_ofst, r.top + (r.bottom - r.top - FONT_HEIGHT_SMALL) / 2 + cg_ofst, STR_ABBREV_ALL, TC_BLACK, SA_HOR_CENTER); - break; - } - - case WID_STL_FACILALL: { - int cg_ofst = this->IsWidgetLowered(widget) ? 1 : 0; - DrawString(r.left + cg_ofst, r.right + cg_ofst, r.top + (r.bottom - r.top - FONT_HEIGHT_SMALL) / 2 + cg_ofst, STR_ABBREV_ALL, TC_BLACK, SA_HOR_CENTER); - break; - } - default: if (widget >= WID_STL_CARGOSTART) { const CargoSpec *cs = _sorted_cargo_specs[widget - WID_STL_CARGOSTART]; @@ -826,17 +798,17 @@ static const NWidgetPart _nested_company_stations_widgets[] = { NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_STL_BUS), SetMinimalSize(14, 0), SetMinimalTextLines(1, 0), SetDataTip(STR_BUS, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE), SetFill(0, 1), NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_STL_SHIP), SetMinimalSize(14, 0), SetMinimalTextLines(1, 0), SetDataTip(STR_SHIP, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE), SetFill(0, 1), NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_STL_AIRPLANE), SetMinimalSize(14, 0), SetMinimalTextLines(1, 0), SetDataTip(STR_PLANE, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE), SetFill(0, 1), - NWidget(WWT_PUSHBTN, COLOUR_GREY, WID_STL_FACILALL), SetMinimalSize(14, 0), SetMinimalTextLines(1, 0), SetDataTip(0x0, STR_STATION_LIST_SELECT_ALL_FACILITIES), SetFill(0, 1), + NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_STL_FACILALL), SetMinimalSize(14, 0), SetMinimalTextLines(1, 0), SetDataTip(STR_ABBREV_ALL, STR_STATION_LIST_SELECT_ALL_FACILITIES), SetFill(0, 1), NWidget(WWT_PANEL, COLOUR_GREY), SetMinimalSize(5, 0), SetFill(0, 1), EndContainer(), NWidgetFunction(CargoWidgets), - NWidget(WWT_PANEL, COLOUR_GREY, WID_STL_NOCARGOWAITING), SetMinimalSize(14, 0), SetMinimalTextLines(1, 0), SetDataTip(0x0, STR_STATION_LIST_NO_WAITING_CARGO), SetFill(0, 1), EndContainer(), - NWidget(WWT_PUSHBTN, COLOUR_GREY, WID_STL_CARGOALL), SetMinimalSize(14, 0), SetMinimalTextLines(1, 0), SetDataTip(0x0, STR_STATION_LIST_SELECT_ALL_TYPES), SetFill(0, 1), - NWidget(WWT_PANEL, COLOUR_GREY), SetDataTip(0x0, STR_NULL), SetResize(1, 0), SetFill(1, 1), EndContainer(), + NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_STL_NOCARGOWAITING), SetMinimalSize(14, 0), SetMinimalTextLines(1, 0), SetDataTip(STR_ABBREV_NONE, STR_STATION_LIST_NO_WAITING_CARGO), SetFill(0, 1), + NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_STL_CARGOALL), SetMinimalSize(14, 0), SetMinimalTextLines(1, 0), SetDataTip(STR_ABBREV_ALL, STR_STATION_LIST_SELECT_ALL_TYPES), SetFill(0, 1), + NWidget(WWT_PANEL, COLOUR_GREY), SetResize(1, 0), SetFill(1, 1), EndContainer(), EndContainer(), NWidget(NWID_HORIZONTAL), NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_STL_SORTBY), SetMinimalSize(81, 12), SetDataTip(STR_BUTTON_SORT_BY, STR_TOOLTIP_SORT_ORDER), NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_STL_SORTDROPBTN), SetMinimalSize(163, 12), SetDataTip(STR_SORT_BY_NAME, STR_TOOLTIP_SORT_CRITERIA), // widget_data gets overwritten. - NWidget(WWT_PANEL, COLOUR_GREY), SetDataTip(0x0, STR_NULL), SetResize(1, 0), SetFill(1, 1), EndContainer(), + NWidget(WWT_PANEL, COLOUR_GREY), SetResize(1, 0), SetFill(1, 1), EndContainer(), EndContainer(), NWidget(NWID_HORIZONTAL), NWidget(WWT_PANEL, COLOUR_GREY, WID_STL_LIST), SetMinimalSize(346, 125), SetResize(1, 10), SetDataTip(0x0, STR_STATION_LIST_TOOLTIP), SetScrollbar(WID_STL_SCROLLBAR), EndContainer(), diff --git a/src/story_gui.cpp b/src/story_gui.cpp index ccb9ccf7b8..79d949fa12 100644 --- a/src/story_gui.cpp +++ b/src/story_gui.cpp @@ -969,19 +969,15 @@ static const NWidgetPart _nested_story_book_widgets[] = { NWidget(WWT_STICKYBOX, COLOUR_BROWN), EndContainer(), NWidget(NWID_HORIZONTAL), SetFill(1, 1), - NWidget(NWID_VERTICAL), SetFill(1, 1), - NWidget(WWT_PANEL, COLOUR_BROWN, WID_SB_PAGE_PANEL), SetResize(1, 1), SetScrollbar(WID_SB_SCROLLBAR), EndContainer(), - NWidget(NWID_HORIZONTAL), - NWidget(WWT_TEXTBTN, COLOUR_BROWN, WID_SB_PREV_PAGE), SetMinimalSize(100, 0), SetFill(0, 0), SetDataTip(STR_STORY_BOOK_PREV_PAGE, STR_STORY_BOOK_PREV_PAGE_TOOLTIP), - NWidget(NWID_BUTTON_DROPDOWN, COLOUR_BROWN, WID_SB_SEL_PAGE), SetMinimalSize(93, 12), SetFill(1, 0), - SetDataTip(STR_BLACK_RAW_STRING, STR_STORY_BOOK_SEL_PAGE_TOOLTIP), SetResize(1, 0), - NWidget(WWT_TEXTBTN, COLOUR_BROWN, WID_SB_NEXT_PAGE), SetMinimalSize(100, 0), SetFill(0, 0), SetDataTip(STR_STORY_BOOK_NEXT_PAGE, STR_STORY_BOOK_NEXT_PAGE_TOOLTIP), - EndContainer(), - EndContainer(), - NWidget(NWID_VERTICAL), SetFill(0, 1), - NWidget(NWID_VSCROLLBAR, COLOUR_BROWN, WID_SB_SCROLLBAR), - NWidget(WWT_RESIZEBOX, COLOUR_BROWN), - EndContainer(), + NWidget(WWT_PANEL, COLOUR_BROWN, WID_SB_PAGE_PANEL), SetResize(1, 1), SetScrollbar(WID_SB_SCROLLBAR), EndContainer(), + NWidget(NWID_VSCROLLBAR, COLOUR_BROWN, WID_SB_SCROLLBAR), + EndContainer(), + NWidget(NWID_HORIZONTAL), + NWidget(WWT_TEXTBTN, COLOUR_BROWN, WID_SB_PREV_PAGE), SetMinimalSize(100, 0), SetFill(0, 0), SetDataTip(STR_STORY_BOOK_PREV_PAGE, STR_STORY_BOOK_PREV_PAGE_TOOLTIP), + NWidget(NWID_BUTTON_DROPDOWN, COLOUR_BROWN, WID_SB_SEL_PAGE), SetMinimalSize(93, 12), SetFill(1, 0), + SetDataTip(STR_BLACK_RAW_STRING, STR_STORY_BOOK_SEL_PAGE_TOOLTIP), SetResize(1, 0), + NWidget(WWT_TEXTBTN, COLOUR_BROWN, WID_SB_NEXT_PAGE), SetMinimalSize(100, 0), SetFill(0, 0), SetDataTip(STR_STORY_BOOK_NEXT_PAGE, STR_STORY_BOOK_NEXT_PAGE_TOOLTIP), + NWidget(WWT_RESIZEBOX, COLOUR_BROWN), EndContainer(), }; diff --git a/src/table/sprites.h b/src/table/sprites.h index fb2a47bf28..2ccdb79fd8 100644 --- a/src/table/sprites.h +++ b/src/table/sprites.h @@ -293,12 +293,8 @@ static const uint16 TRAMWAY_SPRITE_COUNT = 119; static const SpriteID SPR_ONEWAY_BASE = SPR_TRAMWAY_BASE + TRAMWAY_SPRITE_COUNT; static const uint16 ONEWAY_SPRITE_COUNT = 6; -/** Flags sprites (in same order as enum NetworkLanguage) */ -static const SpriteID SPR_FLAGS_BASE = SPR_ONEWAY_BASE + ONEWAY_SPRITE_COUNT; -static const uint16 FLAGS_SPRITE_COUNT = 36; - /** Tunnel sprites with grass only for custom railtype tunnel. */ -static const SpriteID SPR_RAILTYPE_TUNNEL_BASE = SPR_FLAGS_BASE + FLAGS_SPRITE_COUNT; +static const SpriteID SPR_RAILTYPE_TUNNEL_BASE = SPR_ONEWAY_BASE + ONEWAY_SPRITE_COUNT; static const uint16 RAILTYPE_TUNNEL_BASE_COUNT = 16; /* Not really a sprite, but an empty bounding box. Used to construct bounding boxes that help sorting the sprites, but do not have a sprite associated. */ diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index 9540f1613c..c393e0229c 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -2393,14 +2393,18 @@ struct ScenarioEditorToolbarWindow : Window { this->DrawWidgets(); } - void DrawWidget(const Rect &r, int widget) const override + void SetStringParameters(int widget) const override { switch (widget) { case WID_TE_DATE: SetDParam(0, ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1)); - DrawString(r.left, r.right, (this->height - FONT_HEIGHT_NORMAL) / 2, STR_WHITE_DATE_LONG, TC_FROMSTRING, SA_HOR_CENTER); break; + } + } + void DrawWidget(const Rect &r, int widget) const override + { + switch (widget) { case WID_TE_SPACER: { int height = r.bottom - r.top; if (height > 2 * FONT_HEIGHT_NORMAL) { @@ -2424,7 +2428,6 @@ struct ScenarioEditorToolbarWindow : Window { case WID_TE_DATE: SetDParam(0, ConvertYMDToDate(MAX_YEAR, 0, 1)); *size = GetStringBoundingBox(STR_WHITE_DATE_LONG); - size->height = std::max(size->height, GetSpriteSize(SPR_IMG_SAVE).height + WD_IMGBTN_TOP + WD_IMGBTN_BOTTOM); break; } } @@ -2587,10 +2590,10 @@ static const NWidgetPart _nested_toolb_scen_inner_widgets[] = { NWidget(WWT_PANEL, COLOUR_GREY, WID_TE_SPACER), EndContainer(), NWidget(NWID_SPACER), NWidget(WWT_PANEL, COLOUR_GREY, WID_TE_DATE_PANEL), - NWidget(NWID_HORIZONTAL), SetPIP(3, 2, 3), - NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_DATE_BACKWARD), SetDataTip(SPR_ARROW_DOWN, STR_SCENEDIT_TOOLBAR_TOOLTIP_MOVE_THE_STARTING_DATE_BACKWARD), - NWidget(WWT_EMPTY, COLOUR_GREY, WID_TE_DATE), SetDataTip(STR_NULL, STR_SCENEDIT_TOOLBAR_TOOLTIP_SET_DATE), - NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_DATE_FORWARD), SetDataTip(SPR_ARROW_UP, STR_SCENEDIT_TOOLBAR_TOOLTIP_MOVE_THE_STARTING_DATE_FORWARD), + NWidget(NWID_HORIZONTAL), SetPIP(2, 2, 2), SetPadding(1), + NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_DATE_BACKWARD), SetDataTip(SPR_ARROW_DOWN, STR_SCENEDIT_TOOLBAR_TOOLTIP_MOVE_THE_STARTING_DATE_BACKWARD), SetFill(0, 1), + NWidget(WWT_TEXT, COLOUR_GREY, WID_TE_DATE), SetDataTip(STR_WHITE_DATE_LONG, STR_SCENEDIT_TOOLBAR_TOOLTIP_SET_DATE), SetAlignment(SA_CENTER), SetFill(0, 1), + NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_DATE_FORWARD), SetDataTip(SPR_ARROW_UP, STR_SCENEDIT_TOOLBAR_TOOLTIP_MOVE_THE_STARTING_DATE_FORWARD), SetFill(0, 1), EndContainer(), EndContainer(), NWidget(NWID_SPACER), diff --git a/src/video/cocoa/cocoa_wnd.mm b/src/video/cocoa/cocoa_wnd.mm index 861f8c1352..a457bfb09f 100644 --- a/src/video/cocoa/cocoa_wnd.mm +++ b/src/video/cocoa/cocoa_wnd.mm @@ -1271,8 +1271,12 @@ void CocoaDialog(const char *title, const char *message, const char *buttonLabel /** Screen the window is on changed. */ - (void)windowDidChangeBackingProperties:(NSNotification *)notification { + bool did_adjust = AdjustGUIZoom(); + /* Reallocate screen buffer if necessary. */ driver->AllocateBackingStore(); + + if (did_adjust) ReInitAllWindows(true); } /** Presentation options to use for full screen mode. */ diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp index 0e9c45c3d1..bde95f3c43 100644 --- a/src/video/win32_v.cpp +++ b/src/video/win32_v.cpp @@ -39,6 +39,10 @@ #define PM_QS_INPUT 0x20000 #endif +#ifndef WM_DPICHANGED +#define WM_DPICHANGED 0x02E0 +#endif + bool _window_maximize; static Dimension _bck_resolution; DWORD _imm_props; @@ -672,6 +676,24 @@ LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) return TRUE; } + case WM_DPICHANGED: { + auto did_adjust = AdjustGUIZoom(); + + /* Resize the window to match the new DPI setting. */ + RECT *prcNewWindow = (RECT *)lParam; + SetWindowPos(hwnd, + NULL, + prcNewWindow->left, + prcNewWindow->top, + prcNewWindow->right - prcNewWindow->left, + prcNewWindow->bottom - prcNewWindow->top, + SWP_NOZORDER | SWP_NOACTIVATE); + + if (did_adjust) ReInitAllWindows(true); + + return 0; + } + /* needed for wheel */ #if !defined(WM_MOUSEWHEEL) # define WM_MOUSEWHEEL 0x020A diff --git a/src/widget.cpp b/src/widget.cpp index 087bdcc47a..6d5680983b 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -939,7 +939,7 @@ NWidgetCore::NWidgetCore(WidgetType tp, Colours colour, uint fill_x, uint fill_y this->widget_data = widget_data; this->tool_tip = tool_tip; this->scrollbar_index = -1; - this->text_colour = TC_FROMSTRING; + this->text_colour = TC_BLACK; this->align = SA_CENTER; } @@ -1390,7 +1390,7 @@ void NWidgetHorizontal::AssignSizePosition(SizingType sizing, uint x, uint y, ui for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { uint hor_step = child_wid->GetHorizontalStepSize(sizing); if (hor_step > 0) { - num_changing_childs++; + if (!(flags & NC_BIGFIRST)) num_changing_childs++; biggest_stepsize = std::max(biggest_stepsize, hor_step); } else { child_wid->current_x = child_wid->smallest_x; @@ -1400,6 +1400,16 @@ void NWidgetHorizontal::AssignSizePosition(SizingType sizing, uint x, uint y, ui child_wid->current_y = ComputeMaxSize(child_wid->smallest_y, given_height - child_wid->padding_top - child_wid->padding_bottom, vert_step); } + /* First.5 loop: count how many children are of the biggest step size. */ + if ((flags & NC_BIGFIRST) && biggest_stepsize > 0) { + for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + uint hor_step = child_wid->GetHorizontalStepSize(sizing); + if (hor_step == biggest_stepsize) { + num_changing_childs++; + } + } + } + /* Second loop: Allocate the additional horizontal space over the resizing children, starting with the biggest resize steps. */ while (biggest_stepsize > 0) { uint next_biggest_stepsize = 0; @@ -1417,6 +1427,16 @@ void NWidgetHorizontal::AssignSizePosition(SizingType sizing, uint x, uint y, ui next_biggest_stepsize = std::max(next_biggest_stepsize, hor_step); } biggest_stepsize = next_biggest_stepsize; + + if (num_changing_childs == 0 && (flags & NC_BIGFIRST) && biggest_stepsize > 0) { + /* Second.5 loop: count how many children are of the updated biggest step size. */ + for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + uint hor_step = child_wid->GetHorizontalStepSize(sizing); + if (hor_step == biggest_stepsize) { + num_changing_childs++; + } + } + } } assert(num_changing_childs == 0); @@ -1546,7 +1566,7 @@ void NWidgetVertical::AssignSizePosition(SizingType sizing, uint x, uint y, uint for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { uint vert_step = child_wid->GetVerticalStepSize(sizing); if (vert_step > 0) { - num_changing_childs++; + if (!(flags & NC_BIGFIRST)) num_changing_childs++; biggest_stepsize = std::max(biggest_stepsize, vert_step); } else { child_wid->current_y = child_wid->smallest_y; @@ -1556,6 +1576,16 @@ void NWidgetVertical::AssignSizePosition(SizingType sizing, uint x, uint y, uint child_wid->current_x = ComputeMaxSize(child_wid->smallest_x, given_width - child_wid->padding_left - child_wid->padding_right, hor_step); } + /* First.5 loop: count how many children are of the biggest step size. */ + if ((this->flags & NC_BIGFIRST) && biggest_stepsize > 0) { + for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + uint vert_step = child_wid->GetVerticalStepSize(sizing); + if (vert_step == biggest_stepsize) { + num_changing_childs++; + } + } + } + /* Second loop: Allocate the additional vertical space over the resizing children, starting with the biggest resize steps. */ while (biggest_stepsize > 0) { uint next_biggest_stepsize = 0; @@ -1573,6 +1603,16 @@ void NWidgetVertical::AssignSizePosition(SizingType sizing, uint x, uint y, uint next_biggest_stepsize = std::max(next_biggest_stepsize, vert_step); } biggest_stepsize = next_biggest_stepsize; + + if (num_changing_childs == 0 && (flags & NC_BIGFIRST) && biggest_stepsize > 0) { + /* Second.5 loop: count how many children are of the updated biggest step size. */ + for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + uint vert_step = child_wid->GetVerticalStepSize(sizing); + if (vert_step == biggest_stepsize) { + num_changing_childs++; + } + } + } } assert(num_changing_childs == 0); diff --git a/src/widget_type.h b/src/widget_type.h index b7b94c1813..e7870ed889 100644 --- a/src/widget_type.h +++ b/src/widget_type.h @@ -480,9 +480,11 @@ public: /** Nested widget container flags, */ enum NWidContainerFlags { NCB_EQUALSIZE = 0, ///< Containers should keep all their (resizing) children equally large. + NCB_BIGFIRST = 1, ///< Allocate space to biggest resize first. NC_NONE = 0, ///< All flags cleared. NC_EQUALSIZE = 1 << NCB_EQUALSIZE, ///< Value of the #NCB_EQUALSIZE flag. + NC_BIGFIRST = 1 << NCB_BIGFIRST, ///< Value of the #NCB_BIGFIRST flag. }; DECLARE_ENUM_AS_BIT_SET(NWidContainerFlags) diff --git a/src/widgets/airport_widget.h b/src/widgets/airport_widget.h index da0770bcb9..75b805031c 100644 --- a/src/widgets/airport_widget.h +++ b/src/widgets/airport_widget.h @@ -30,6 +30,7 @@ enum AirportPickerWidgets { WID_AP_COVERAGE_LABEL, ///< Label if you want to see the coverage. WID_AP_BTN_DONTHILIGHT, ///< Don't show the coverage button. WID_AP_BTN_DOHILIGHT, ///< Show the coverage button. + WID_AP_ACCEPTANCE, ///< Acceptance info. }; #endif /* WIDGETS_AIRPORT_WIDGET_H */ diff --git a/src/window.cpp b/src/window.cpp index b1600811d7..697de3490b 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -3530,6 +3530,13 @@ void HideVitalWindows() DeleteWindowById(WC_STATUS_BAR, 0); } +void ReInitWindow(Window *w, bool zoom_changed) +{ + if (w == nullptr) return; + if (zoom_changed) w->nested_root->AdjustPaddingForZoom(); + w->ReInit(); +} + /** Re-initialize all windows. */ void ReInitAllWindows(bool zoom_changed) { @@ -3539,9 +3546,13 @@ void ReInitAllWindows(bool zoom_changed) extern void InitDepotWindowBlockSizes(); InitDepotWindowBlockSizes(); + /* When _gui_zoom has changed, we need to resize toolbar and statusbar first, + * so EnsureVisibleCaption uses the updated size information. */ + ReInitWindow(FindWindowById(WC_MAIN_TOOLBAR, 0), zoom_changed); + ReInitWindow(FindWindowById(WC_STATUS_BAR, 0), zoom_changed); for (Window *w : Window::IterateFromBack()) { - if (zoom_changed) w->nested_root->AdjustPaddingForZoom(); - w->ReInit(); + if (w->window_class == WC_MAIN_TOOLBAR || w->window_class == WC_STATUS_BAR) continue; + ReInitWindow(w, zoom_changed); } void NetworkReInitChatBoxSize(); diff --git a/src/zoom_func.h b/src/zoom_func.h index e3f239f89b..5b2b972bea 100644 --- a/src/zoom_func.h +++ b/src/zoom_func.h @@ -36,6 +36,17 @@ static inline int UnScaleByZoom(int value, ZoomLevel zoom) return (value + (1 << zoom) - 1) >> zoom; } +/** + * Adjust by zoom level; zoom < 0 shifts right, zoom >= 0 shifts left + * @param value value to shift + * @param zoom zoom level to shift to + * @return shifted value + */ +static inline int AdjustByZoom(int value, int zoom) +{ + return zoom < 0 ? UnScaleByZoom(value, ZoomLevel(-zoom)) : ScaleByZoom(value, ZoomLevel(zoom)); +} + /** * Scale by zoom level, usually shift left (when zoom > ZOOM_LVL_NORMAL) * @param value value to shift