Skip to content

Commit 819edc8

Browse files
FlamefireFlow86
authored andcommitted
Use .value() for getting control selection
1 parent fa343c5 commit 819edc8

6 files changed

Lines changed: 17 additions & 16 deletions

File tree

libs/s25main/desktops/dskCampaignSelection.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ void dskCampaignSelection::showCampaignInfo(const bool show)
153153

154154
void dskCampaignSelection::showCampaignMissionSelectionScreen()
155155
{
156-
const auto& campaign = campaigns_.at(*GetCtrl<ctrlTable>(ID_Table)->GetSelection());
156+
const auto& campaign = campaigns_.at(GetCtrl<ctrlTable>(ID_Table)->GetSelection().value());
157157
WINDOWMANAGER.Switch(std::make_unique<dskCampaignMissionSelection>(csi_, campaign));
158158
}
159159

libs/s25main/desktops/dskGameLobby.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -946,10 +946,10 @@ void dskGameLobby::UpdateGGS()
946946

947947
GlobalGameSettings& ggs = gameLobby_->getSettings();
948948

949-
ggs.speed = static_cast<GameSpeed>(*GetCtrl<ctrlComboBox>(ID_cbSpeed)->GetSelection());
950-
ggs.objective = static_cast<GameObjective>(*GetCtrl<ctrlComboBox>(ID_cbGoals)->GetSelection());
951-
ggs.startWares = static_cast<StartWares>(*GetCtrl<ctrlComboBox>(ID_cbGoods)->GetSelection());
952-
ggs.exploration = static_cast<Exploration>(*GetCtrl<ctrlComboBox>(ID_cbExploration)->GetSelection());
949+
ggs.speed = static_cast<GameSpeed>(GetCtrl<ctrlComboBox>(ID_cbSpeed)->GetSelection().value());
950+
ggs.objective = static_cast<GameObjective>(GetCtrl<ctrlComboBox>(ID_cbGoals)->GetSelection().value());
951+
ggs.startWares = static_cast<StartWares>(GetCtrl<ctrlComboBox>(ID_cbGoods)->GetSelection().value());
952+
ggs.exploration = static_cast<Exploration>(GetCtrl<ctrlComboBox>(ID_cbExploration)->GetSelection().value());
953953
ggs.lockedTeams = GetCtrl<ctrlCheck>(ID_chkLockTeams)->isChecked();
954954
ggs.teamView = GetCtrl<ctrlCheck>(ID_chkSharedView)->isChecked();
955955
ggs.randomStartPosition = GetCtrl<ctrlCheck>(ID_chkRandomSpawn)->isChecked();

libs/s25main/ingameWindows/iwDiplomacy.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ iwSuggestPact::iwSuggestPact(const PactType pt, const GamePlayer& player, GameCo
243243
void iwSuggestPact::Msg_ButtonClick(const unsigned /*ctrl_id*/)
244244
{
245245
/// Dauer auswählen (wenn id == NUM_DURATIONS, dann "für alle Ewigkeit" ausgewählt)
246-
const unsigned selected_id = *GetCtrl<ctrlComboBox>(6)->GetSelection();
246+
const unsigned selected_id = GetCtrl<ctrlComboBox>(6)->GetSelection().value();
247247
const unsigned duration = (selected_id == NUM_DURATIONS) ? DURATION_INFINITE : DURATIONS[selected_id];
248248
if(gcFactory.SuggestPact(player.GetPlayerId(), this->pt, duration))
249249
Close();

libs/s25main/ingameWindows/iwMapGenerator.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ void iwMapGenerator::Msg_ButtonClick(const unsigned ctrl_id)
133133

134134
void iwMapGenerator::Apply()
135135
{
136-
mapSettings.numPlayers = *GetCtrl<ctrlComboBox>(ID_cbNumPlayers)->GetSelection() + 2;
136+
mapSettings.numPlayers = GetCtrl<ctrlComboBox>(ID_cbNumPlayers)->GetSelection().value() + 2;
137137
mapSettings.ratioGold = GetCtrl<ctrlProgress>(ID_pgGoldRatio)->GetPosition();
138138
mapSettings.ratioIron = GetCtrl<ctrlProgress>(ID_pgIronRatio)->GetPosition();
139139
mapSettings.ratioCoal = GetCtrl<ctrlProgress>(ID_pgCoalRatio)->GetPosition();
@@ -142,14 +142,14 @@ void iwMapGenerator::Apply()
142142
mapSettings.trees = GetCtrl<ctrlProgress>(ID_pgTrees)->GetPosition();
143143
mapSettings.stonePiles = GetCtrl<ctrlProgress>(ID_pgStonePiles)->GetPosition();
144144

145-
switch(*GetCtrl<ctrlComboBox>(ID_cbMountainDist)->GetSelection())
145+
switch(GetCtrl<ctrlComboBox>(ID_cbMountainDist)->GetSelection().value())
146146
{
147147
case 0: mapSettings.mountainDistance = MountainDistance::Close; break;
148148
case 1: mapSettings.mountainDistance = MountainDistance::Normal; break;
149149
case 2: mapSettings.mountainDistance = MountainDistance::Far; break;
150150
case 3: mapSettings.mountainDistance = MountainDistance::VeryFar; break;
151151
}
152-
switch(*GetCtrl<ctrlComboBox>(ID_cbMapStyle)->GetSelection())
152+
switch(GetCtrl<ctrlComboBox>(ID_cbMapStyle)->GetSelection().value())
153153
{
154154
case 0: mapSettings.style = MapStyle::Water; break;
155155
case 1: mapSettings.style = MapStyle::Land; break;
@@ -159,7 +159,7 @@ void iwMapGenerator::Apply()
159159
s25util::fromStringClassic<unsigned>(GetCtrl<ctrlComboBox>(ID_cbMapSizeX)->GetSelectedText().value_or("128"));
160160
mapSettings.size.y =
161161
s25util::fromStringClassic<unsigned>(GetCtrl<ctrlComboBox>(ID_cbMapSizeY)->GetSelectedText().value_or("128"));
162-
switch(*GetCtrl<ctrlComboBox>(ID_cbIslands)->GetSelection())
162+
switch(GetCtrl<ctrlComboBox>(ID_cbIslands)->GetSelection().value())
163163
{
164164
case 0: mapSettings.islands = IslandAmount::Few; break;
165165
case 1: mapSettings.islands = IslandAmount::Normal; break;

libs/s25main/ingameWindows/iwSettings.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,14 @@ void iwSettings::Msg_ButtonClick(unsigned ctrl_id)
130130
SETTINGS.global.smartCursor = GetCtrl<ctrlCheck>(ID_cbSmartCursor)->isChecked();
131131
VIDEODRIVER.SetMouseWarping(SETTINGS.global.smartCursor);
132132
SETTINGS.ingame.scaleStatistics = GetCtrl<ctrlCheck>(ID_cbStatisticScale)->isChecked();
133-
SETTINGS.video.displayMode = DisplayMode(*GetCtrl<ctrlComboBox>(ID_cbDisplayMode)->GetSelection());
133+
SETTINGS.video.displayMode = DisplayMode(GetCtrl<ctrlComboBox>(ID_cbDisplayMode)->GetSelection().value());
134134
SETTINGS.video.displayMode.resizeable = !grpWindowSize.GetCtrl<ctrlCheck>(ID_cbLockWindowSize)->isChecked();
135135
SETTINGS.interface.mapScrollMode =
136-
static_cast<MapScrollMode>(*GetCtrl<ctrlComboBox>(ID_cbMapScrollMode)->GetSelection());
136+
static_cast<MapScrollMode>(GetCtrl<ctrlComboBox>(ID_cbMapScrollMode)->GetSelection().value());
137137
SETTINGS.video.fullscreenSize = supportedResolutions_
138-
[*GetCtrl<ctrlGroup>(ID_grpResolution)->GetCtrl<ctrlComboBox>(ID_cbResolution)->GetSelection()];
139-
const unsigned windowSizeSelection = *grpWindowSize.GetCtrl<ctrlComboBox>(ID_cbWindowSize)->GetSelection();
138+
[GetCtrl<ctrlGroup>(ID_grpResolution)->GetCtrl<ctrlComboBox>(ID_cbResolution)->GetSelection().value()];
139+
const unsigned windowSizeSelection =
140+
grpWindowSize.GetCtrl<ctrlComboBox>(ID_cbWindowSize)->GetSelection().value();
140141
if(windowSizeSelection > 0)
141142
SETTINGS.video.windowedSize = windowSizes_[windowSizeSelection - 1];
142143
else if(VIDEODRIVER.GetDisplayMode() == DisplayMode::Windowed)
@@ -220,5 +221,5 @@ void iwSettings::updateResolutionGroups()
220221

221222
DisplayMode iwSettings::getDisplayModeSelection() const
222223
{
223-
return DisplayMode(*GetCtrl<ctrlComboBox>(ID_cbDisplayMode)->GetSelection());
224+
return static_cast<DisplayMode>(GetCtrl<ctrlComboBox>(ID_cbDisplayMode)->GetSelection().value());
224225
}

libs/s25main/ingameWindows/iwTrade.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ iwTrade::iwTrade(const nobBaseWarehouse& wh, const GameWorldViewer& gwv, GameCom
7777
void iwTrade::Msg_ButtonClick(const unsigned /*ctrl_id*/)
7878
{
7979
// pressed the send button
80-
const unsigned short ware_figure_selection = *GetCtrl<ctrlComboBox>(4)->GetSelection();
80+
const unsigned ware_figure_selection = GetCtrl<ctrlComboBox>(4)->GetSelection().value();
8181
const bool isJob = this->GetCtrl<ctrlComboBox>(2)->GetSelection() == 1u;
8282
boost_variant2<GoodType, Job> what;
8383
if(isJob)

0 commit comments

Comments
 (0)