Codechange: Replace drop down list's default bools with DropDownOptions. (#14837)
Improves maintainability and avoids positional ambiguity.
This commit is contained in:
@@ -120,6 +120,12 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
static DropDownOptions GetToolbarDropDownOptions()
|
||||
{
|
||||
if (_settings_client.gui.toolbar_dropdown_autoselect) return DropDownOption::InstantClose;
|
||||
return {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Pop up a generic text only menu.
|
||||
* @param w Toolbar
|
||||
@@ -129,7 +135,7 @@ public:
|
||||
*/
|
||||
static void PopupMainToolbarMenu(Window *w, WidgetID widget, DropDownList &&list, int def)
|
||||
{
|
||||
ShowDropDownList(w, std::move(list), def, widget, 0, _settings_client.gui.toolbar_dropdown_autoselect);
|
||||
ShowDropDownList(w, std::move(list), def, widget, 0, GetToolbarDropDownOptions());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -319,7 +325,7 @@ static CallBackFunction ToolbarOptionsClick(Window *w)
|
||||
list.push_back(MakeDropDownListCheckedItem(IsTransparencySet(TO_HOUSES), STR_SETTINGS_MENU_TRANSPARENT_BUILDINGS, OME_TRANSPARENTBUILDINGS));
|
||||
list.push_back(MakeDropDownListCheckedItem(IsTransparencySet(TO_SIGNS), STR_SETTINGS_MENU_TRANSPARENT_SIGNS, OME_SHOW_STATIONSIGNS));
|
||||
|
||||
ShowDropDownList(w, std::move(list), 0, WID_TN_SETTINGS, 140, _settings_client.gui.toolbar_dropdown_autoselect);
|
||||
ShowDropDownList(w, std::move(list), 0, WID_TN_SETTINGS, 140, GetToolbarDropDownOptions());
|
||||
return CBF_NONE;
|
||||
}
|
||||
|
||||
@@ -749,7 +755,7 @@ static CallBackFunction ToolbarGraphsClick(Window *w)
|
||||
|
||||
if (_toolbar_mode != TB_NORMAL) AddDropDownLeagueTableOptions(list);
|
||||
|
||||
ShowDropDownList(w, std::move(list), GRMN_OPERATING_PROFIT_GRAPH, WID_TN_GRAPHS, 140, _settings_client.gui.toolbar_dropdown_autoselect);
|
||||
ShowDropDownList(w, std::move(list), GRMN_OPERATING_PROFIT_GRAPH, WID_TN_GRAPHS, 140, GetToolbarDropDownOptions());
|
||||
return CBF_NONE;
|
||||
}
|
||||
|
||||
@@ -760,7 +766,7 @@ static CallBackFunction ToolbarLeagueClick(Window *w)
|
||||
AddDropDownLeagueTableOptions(list);
|
||||
|
||||
int selected = list[0]->result;
|
||||
ShowDropDownList(w, std::move(list), selected, WID_TN_LEAGUE, 140, _settings_client.gui.toolbar_dropdown_autoselect);
|
||||
ShowDropDownList(w, std::move(list), selected, WID_TN_LEAGUE, 140, GetToolbarDropDownOptions());
|
||||
return CBF_NONE;
|
||||
}
|
||||
|
||||
@@ -938,7 +944,7 @@ static CallBackFunction ToolbarZoomOutClick(Window *w)
|
||||
|
||||
static CallBackFunction ToolbarBuildRailClick(Window *w)
|
||||
{
|
||||
ShowDropDownList(w, GetRailTypeDropDownList(), _last_built_railtype, WID_TN_RAILS, 140, _settings_client.gui.toolbar_dropdown_autoselect);
|
||||
ShowDropDownList(w, GetRailTypeDropDownList(), _last_built_railtype, WID_TN_RAILS, 140, GetToolbarDropDownOptions());
|
||||
return CBF_NONE;
|
||||
}
|
||||
|
||||
@@ -959,7 +965,7 @@ static CallBackFunction MenuClickBuildRail(int index)
|
||||
|
||||
static CallBackFunction ToolbarBuildRoadClick(Window *w)
|
||||
{
|
||||
ShowDropDownList(w, GetRoadTypeDropDownList(RTTB_ROAD), _last_built_roadtype, WID_TN_ROADS, 140, _settings_client.gui.toolbar_dropdown_autoselect);
|
||||
ShowDropDownList(w, GetRoadTypeDropDownList(RTTB_ROAD), _last_built_roadtype, WID_TN_ROADS, 140, GetToolbarDropDownOptions());
|
||||
return CBF_NONE;
|
||||
}
|
||||
|
||||
@@ -980,7 +986,7 @@ static CallBackFunction MenuClickBuildRoad(int index)
|
||||
|
||||
static CallBackFunction ToolbarBuildTramClick(Window *w)
|
||||
{
|
||||
ShowDropDownList(w, GetRoadTypeDropDownList(RTTB_TRAM), _last_built_tramtype, WID_TN_TRAMS, 140, _settings_client.gui.toolbar_dropdown_autoselect);
|
||||
ShowDropDownList(w, GetRoadTypeDropDownList(RTTB_TRAM), _last_built_tramtype, WID_TN_TRAMS, 140, GetToolbarDropDownOptions());
|
||||
return CBF_NONE;
|
||||
}
|
||||
|
||||
@@ -1003,7 +1009,7 @@ static CallBackFunction ToolbarBuildWaterClick(Window *w)
|
||||
{
|
||||
DropDownList list;
|
||||
list.push_back(MakeDropDownListIconItem(SPR_IMG_BUILD_CANAL, PAL_NONE, STR_WATERWAYS_MENU_WATERWAYS_CONSTRUCTION, 0));
|
||||
ShowDropDownList(w, std::move(list), 0, WID_TN_WATER, 140, _settings_client.gui.toolbar_dropdown_autoselect);
|
||||
ShowDropDownList(w, std::move(list), 0, WID_TN_WATER, 140, GetToolbarDropDownOptions());
|
||||
return CBF_NONE;
|
||||
}
|
||||
|
||||
@@ -1024,7 +1030,7 @@ static CallBackFunction ToolbarBuildAirClick(Window *w)
|
||||
{
|
||||
DropDownList list;
|
||||
list.push_back(MakeDropDownListIconItem(SPR_IMG_AIRPORT, PAL_NONE, STR_AIRCRAFT_MENU_AIRPORT_CONSTRUCTION, 0));
|
||||
ShowDropDownList(w, std::move(list), 0, WID_TN_AIR, 140, _settings_client.gui.toolbar_dropdown_autoselect);
|
||||
ShowDropDownList(w, std::move(list), 0, WID_TN_AIR, 140, GetToolbarDropDownOptions());
|
||||
return CBF_NONE;
|
||||
}
|
||||
|
||||
@@ -1047,7 +1053,7 @@ static CallBackFunction ToolbarForestClick(Window *w)
|
||||
list.push_back(MakeDropDownListIconItem(SPR_IMG_LANDSCAPING, PAL_NONE, STR_LANDSCAPING_MENU_LANDSCAPING, 0));
|
||||
list.push_back(MakeDropDownListIconItem(SPR_IMG_PLANTTREES, PAL_NONE, STR_LANDSCAPING_MENU_PLANT_TREES, 1));
|
||||
list.push_back(MakeDropDownListIconItem(SPR_IMG_SIGN, PAL_NONE, STR_LANDSCAPING_MENU_PLACE_SIGN, 2));
|
||||
ShowDropDownList(w, std::move(list), 0, WID_TN_LANDSCAPE, 100, _settings_client.gui.toolbar_dropdown_autoselect);
|
||||
ShowDropDownList(w, std::move(list), 0, WID_TN_LANDSCAPE, 100, GetToolbarDropDownOptions());
|
||||
return CBF_NONE;
|
||||
}
|
||||
|
||||
@@ -1318,7 +1324,7 @@ static CallBackFunction ToolbarScenGenIndustry(Window *w)
|
||||
|
||||
static CallBackFunction ToolbarScenBuildRoadClick(Window *w)
|
||||
{
|
||||
ShowDropDownList(w, GetScenRoadTypeDropDownList(RTTB_ROAD), _last_built_roadtype, WID_TE_ROADS, 140, _settings_client.gui.toolbar_dropdown_autoselect);
|
||||
ShowDropDownList(w, GetScenRoadTypeDropDownList(RTTB_ROAD), _last_built_roadtype, WID_TE_ROADS, 140, GetToolbarDropDownOptions());
|
||||
return CBF_NONE;
|
||||
}
|
||||
|
||||
@@ -1337,7 +1343,7 @@ static CallBackFunction ToolbarScenBuildRoad(int index)
|
||||
|
||||
static CallBackFunction ToolbarScenBuildTramClick(Window *w)
|
||||
{
|
||||
ShowDropDownList(w, GetScenRoadTypeDropDownList(RTTB_TRAM), _last_built_tramtype, WID_TE_TRAMS, 140, _settings_client.gui.toolbar_dropdown_autoselect);
|
||||
ShowDropDownList(w, GetScenRoadTypeDropDownList(RTTB_TRAM), _last_built_tramtype, WID_TE_TRAMS, 140, GetToolbarDropDownOptions());
|
||||
return CBF_NONE;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user