Skip to content

Commit bb146d7

Browse files
Fix button placement in minimized in-game windows
Some windows position their buttons based on GetSize().y, which results in incorrect placement if the window is persisted and minimized. Replace uses of GetSize().y with the full window height. Affected windows: * iwBuildings * iwDistribution * iwWares
1 parent 5907058 commit bb146d7

3 files changed

Lines changed: 22 additions & 14 deletions

File tree

libs/s25main/ingameWindows/iwBuildings.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@
2525
#include "gameData/BuildingProperties.h"
2626
#include "gameData/const_gui_ids.h"
2727

28+
namespace {
2829
/// Reihenfolge der Gebäude
29-
const std::array<BuildingType, 32> bts = {
30+
constexpr std::array<BuildingType, 32> bts = {
3031
BuildingType::Barracks, BuildingType::Guardhouse, BuildingType::Watchtower, BuildingType::Fortress,
3132
BuildingType::GraniteMine, BuildingType::CoalMine, BuildingType::IronMine, BuildingType::GoldMine,
3233
BuildingType::LookoutTower, BuildingType::Catapult, BuildingType::Woodcutter, BuildingType::Fishery,
@@ -41,14 +42,17 @@ const std::array<BuildingType, 32> bts = {
4142
};
4243

4344
// Abstand des ersten Icons vom linken oberen Fensterrand
44-
const DrawPoint iconPadding(30, 40);
45+
constexpr DrawPoint iconPadding(30, 40);
4546
// Abstand der einzelnen Symbole untereinander
46-
const DrawPoint iconSpacing(40, 48);
47+
constexpr DrawPoint iconSpacing(40, 48);
4748
// Abstand der Schriften unter den Icons
48-
const unsigned short font_distance_y = 20;
49+
constexpr unsigned short font_distance_y = 20;
50+
51+
constexpr auto BuildingsWindowSize = Extent(185, 480);
52+
} // namespace
4953

5054
iwBuildings::iwBuildings(GameWorldView& gwv, GameCommandFactory& gcFactory)
51-
: IngameWindow(CGI_BUILDINGS, IngameWindow::posLastOrCenter, Extent(185, 480), _("Buildings"),
55+
: IngameWindow(CGI_BUILDINGS, IngameWindow::posLastOrCenter, BuildingsWindowSize, _("Buildings"),
5256
LOADER.GetImageN("resource", 41)),
5357
gwv(gwv), gcFactory(gcFactory)
5458
{
@@ -69,8 +73,8 @@ iwBuildings::iwBuildings(GameWorldView& gwv, GameCommandFactory& gcFactory)
6973

7074
// Hilfe-Button
7175
Extent btSize = Extent(30, 32);
72-
AddImageButton(32, GetSize() - DrawPoint(14, 20) - btSize, btSize, TextureColor::Grey, LOADER.GetImageN("io", 225),
73-
_("Help"));
76+
AddImageButton(32, BuildingsWindowSize - DrawPoint(14, 20) - btSize, btSize, TextureColor::Grey,
77+
LOADER.GetImageN("io", 225), _("Help"));
7478
}
7579

7680
/// Anzahlen der Gebäude zeichnen

libs/s25main/ingameWindows/iwDistribution.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,15 @@ struct iwDistribution::DistributionGroup
2727
};
2828
std::vector<iwDistribution::DistributionGroup> iwDistribution::groups;
2929

30+
namespace {
3031
/// Dertermines width of the progress bars: distance to the window borders
31-
const unsigned PROGRESS_BORDER_DISTANCE = 20;
32+
constexpr unsigned PROGRESS_BORDER_DISTANCE = 20;
33+
34+
constexpr auto DistributionWindowSize = Extent(290, 312);
35+
} // namespace
3236

3337
iwDistribution::iwDistribution(const GameWorldViewer& gwv, GameCommandFactory& gcFactory)
34-
: TransmitSettingsIgwAdapter(CGI_DISTRIBUTION, IngameWindow::posLastOrCenter, Extent(290, 312),
38+
: TransmitSettingsIgwAdapter(CGI_DISTRIBUTION, IngameWindow::posLastOrCenter, DistributionWindowSize,
3539
_("Distribution of goods"), LOADER.GetImageN("resource", 41)),
3640
gwv(gwv), gcFactory(gcFactory)
3741
{
@@ -63,11 +67,11 @@ iwDistribution::iwDistribution(const GameWorldViewer& gwv, GameCommandFactory& g
6367

6468
const Extent btSize(32, 32);
6569
// Hilfe
66-
AddImageButton(2, DrawPoint(15, GetSize().y - 15 - btSize.y), btSize, TextureColor::Grey,
70+
AddImageButton(2, DrawPoint(15, DistributionWindowSize.y - 15 - btSize.y), btSize, TextureColor::Grey,
6771
LOADER.GetImageN("io", 225), _("Help"));
6872
// Standardbelegung
69-
AddImageButton(10, GetSize() - DrawPoint::all(15) - btSize, btSize, TextureColor::Grey, LOADER.GetImageN("io", 191),
70-
_("Default"));
73+
AddImageButton(10, DistributionWindowSize - DrawPoint::all(15) - btSize, btSize, TextureColor::Grey,
74+
LOADER.GetImageN("io", 191), _("Default"));
7175

7276
iwDistribution::UpdateSettings();
7377
}

libs/s25main/ingameWindows/iwWares.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,10 @@ iwWares::iwWares(unsigned id, const DrawPoint& pos, const Extent& size, const st
131131
}
132132

133133
// "Blättern"
134-
AddImageButton(0, DrawPoint(52, GetSize().y - 47), Extent(66, 32), TextureColor::Grey, LOADER.GetImageN("io", 84),
134+
AddImageButton(0, DrawPoint(52, size.y - 47), Extent(66, 32), TextureColor::Grey, LOADER.GetImageN("io", 84),
135135
_("Next page"));
136136
// Hilfe
137-
AddImageButton(12, DrawPoint(16, GetSize().y - 47), Extent(32, 32), TextureColor::Grey, LOADER.GetImageN("io", 225),
137+
AddImageButton(12, DrawPoint(16, size.y - 47), Extent(32, 32), TextureColor::Grey, LOADER.GetImageN("io", 225),
138138
_("Help"));
139139

140140
waresPage.SetVisible(true);

0 commit comments

Comments
 (0)