From 3b10cff3d20990da18a280b918b2aaae4f71247a Mon Sep 17 00:00:00 2001 From: Miguel Horta Date: Mon, 8 Apr 2024 10:17:44 +0100 Subject: [PATCH] fix: ShowDropDownList*() signature changed, update usages --- src/toolbar_gui.cpp | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index 67d0ad2e21..8c6580db57 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -115,7 +115,7 @@ public: static void PopupMainToolbarMenu(Window *w, WidgetID widget, DropDownList &&list, int def) { if (!_settings_client.gui.vertical_toolbar) { - ShowDropDownList(w, std::move(list), def, widget, 0, true); + ShowDropDownList(w, std::move(list), def, widget, 0, list.size() <= 1); } else { Rect wi_rect; NWidgetCore *nwi = w->GetWidget(widget); @@ -123,7 +123,7 @@ static void PopupMainToolbarMenu(Window *w, WidgetID widget, DropDownList &&list wi_rect.right = nwi->pos_x + nwi->current_x; wi_rect.top = nwi->pos_y; wi_rect.bottom = nwi->pos_y + nwi->current_y; - ShowDropDownListAt(w, std::move(list), def, widget, wi_rect, nwi->colour, true, list.size() <= 1); + ShowDropDownListAt(w, std::move(list), def, widget, wi_rect, nwi->colour, list.size() <= 1); } if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); } @@ -292,7 +292,7 @@ static CallBackFunction ToolbarOptionsClick(Window *w) list.push_back(std::make_unique(IsTransparencySet(TO_HOUSES), STR_SETTINGS_MENU_TRANSPARENT_BUILDINGS, OME_TRANSPARENTBUILDINGS, false)); list.push_back(std::make_unique(IsTransparencySet(TO_SIGNS), STR_SETTINGS_MENU_TRANSPARENT_SIGNS, OME_SHOW_STATIONSIGNS, false)); - ShowDropDownList(w, std::move(list), 0, WID_TN_SETTINGS, 140, true); + ShowDropDownList(w, std::move(list), 0, WID_TN_SETTINGS, 140, false); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); return CBF_NONE; } @@ -677,7 +677,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, true, false); + ShowDropDownList(w, std::move(list), GRMN_OPERATING_PROFIT_GRAPH, WID_TN_GRAPHS, 140, false); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); return CBF_NONE; @@ -690,7 +690,7 @@ static CallBackFunction ToolbarLeagueClick(Window *w) AddDropDownLeagueTableOptions(list); int selected = list[0]->result; - ShowDropDownList(w, std::move(list), selected, WID_TN_LEAGUE, 140, true, false); + ShowDropDownList(w, std::move(list), selected, WID_TN_LEAGUE, 140, false); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); return CBF_NONE; @@ -894,7 +894,7 @@ static CallBackFunction ToolbarBuildRailClick(Window *w) list.emplace_back(new DropDownListIconItem(SPR_IMG_BUILDWATER, PAL_NONE, STR_WATERWAYS_MENU_WATERWAYS_CONSTRUCTION, MENU_IDX_WATER, false)); list.emplace_back(new DropDownListIconItem(SPR_IMG_BUILDAIR, PAL_NONE, STR_AIRCRAFT_MENU_AIRPORT_CONSTRUCTION, MENU_IDX_AIR, false)); } - ShowDropDownList(w, std::move(list), _last_built_railtype, WID_TN_RAILS, 140, true); + ShowDropDownList(w, std::move(list), _last_built_railtype, WID_TN_RAILS, false); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); return CBF_NONE; } @@ -933,7 +933,9 @@ static CallBackFunction MenuClickBuildRail(int index) static CallBackFunction ToolbarBuildRoadClick(Window *w) { - ShowDropDownList(w, GetRoadTypeDropDownList(RTTB_ROAD), _last_built_roadtype, WID_TN_ROADS, 140, true); + auto list = GetScenRoadTypeDropDownList(RTTB_ROAD); + auto has_choices = list.size() <= 1; + ShowDropDownList(w, std::move(list), _last_built_roadtype, WID_TN_ROADS, 140, has_choices); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); return CBF_NONE; } @@ -955,7 +957,9 @@ static CallBackFunction MenuClickBuildRoad(int index) static CallBackFunction ToolbarBuildTramClick(Window *w) { - ShowDropDownList(w, GetRoadTypeDropDownList(RTTB_TRAM), _last_built_tramtype, WID_TN_TRAMS, 140, true); + auto list = GetScenRoadTypeDropDownList(RTTB_TRAM); + auto has_choices = list.size() <= 1; + ShowDropDownList(w, std::move(list), _last_built_tramtype, WID_TN_TRAMS, 140, has_choices); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); return CBF_NONE; } @@ -979,7 +983,7 @@ static CallBackFunction ToolbarBuildWaterClick(Window *w) { DropDownList list; list.push_back(std::make_unique(SPR_IMG_BUILD_CANAL, PAL_NONE, STR_WATERWAYS_MENU_WATERWAYS_CONSTRUCTION, 0, false)); - ShowDropDownList(w, std::move(list), 0, WID_TN_WATER, 140, true); + ShowDropDownList(w, std::move(list), 0, WID_TN_WATER, 140, list.size() <= 1); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); return CBF_NONE; } @@ -1001,7 +1005,7 @@ static CallBackFunction ToolbarBuildAirClick(Window *w) { DropDownList list; list.push_back(std::make_unique(SPR_IMG_AIRPORT, PAL_NONE, STR_AIRCRAFT_MENU_AIRPORT_CONSTRUCTION, 0, false)); - ShowDropDownList(w, std::move(list), 0, WID_TN_AIR, 140, true); + ShowDropDownList(w, std::move(list), 0, WID_TN_AIR, 140, list.size() <= 1); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); return CBF_NONE; } @@ -1025,7 +1029,7 @@ static CallBackFunction ToolbarForestClick(Window *w) list.push_back(std::make_unique(SPR_IMG_LANDSCAPING, PAL_NONE, STR_LANDSCAPING_MENU_LANDSCAPING, 0, false)); list.push_back(std::make_unique(SPR_IMG_PLANTTREES, PAL_NONE, STR_LANDSCAPING_MENU_PLANT_TREES, 1, false)); list.push_back(std::make_unique(SPR_IMG_SIGN, PAL_NONE, STR_LANDSCAPING_MENU_PLACE_SIGN, 2, false)); - ShowDropDownList(w, std::move(list), 0, WID_TN_LANDSCAPE, 100, true); + ShowDropDownList(w, std::move(list), 0, WID_TN_LANDSCAPE, 100, false); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); return CBF_NONE; } @@ -1326,7 +1330,9 @@ static CallBackFunction ToolbarScenGenIndustry(Window *w) static CallBackFunction ToolbarScenBuildRoadClick(Window *w) { - ShowDropDownList(w, GetScenRoadTypeDropDownList(RTTB_ROAD), _last_built_roadtype, WID_TE_ROADS, 140, true); + auto list = GetScenRoadTypeDropDownList(RTTB_ROAD); + auto has_choices = list.size() <= 1; + ShowDropDownList(w, std::move(list), _last_built_roadtype, WID_TE_ROADS, 140, has_choices); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); return CBF_NONE; } @@ -1346,7 +1352,9 @@ static CallBackFunction ToolbarScenBuildRoad(int index) static CallBackFunction ToolbarScenBuildTramClick(Window *w) { - ShowDropDownList(w, GetScenRoadTypeDropDownList(RTTB_TRAM), _last_built_tramtype, WID_TE_TRAMS, 140, true); + auto list = GetScenRoadTypeDropDownList(RTTB_TRAM); + auto has_choices = list.size() <= 1; + ShowDropDownList(w, std::move(list), _last_built_tramtype, WID_TE_TRAMS, 140, has_choices); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); return CBF_NONE; }