From 5f99c8c4aa42da8ecfa596a81ba94579572eee31 Mon Sep 17 00:00:00 2001 From: PeterN Date: Wed, 12 Apr 2023 20:14:48 +0100 Subject: [PATCH 1/7] Fix: Extra viewport cannot be scrolled with right-click-close. (#10644) --- src/viewport_gui.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/viewport_gui.cpp b/src/viewport_gui.cpp index df670cc152..c8bf96157b 100644 --- a/src/viewport_gui.cpp +++ b/src/viewport_gui.cpp @@ -134,6 +134,11 @@ public: this->viewport->dest_scrollpos_y = this->viewport->scrollpos_y; } + bool OnRightClick(Point pt, int widget) override + { + return widget == WID_EV_VIEWPORT; + } + void OnMouseWheel(int wheel) override { if (_settings_client.gui.scrollwheel_scrolling != 2) { From ff55bfb78747a9a31e40b926ab04abc83b4346b7 Mon Sep 17 00:00:00 2001 From: PeterN Date: Wed, 12 Apr 2023 22:30:03 +0100 Subject: [PATCH 2/7] Fix #10343: Don't extend town-disallowed roadtypes. (#10347) Towns currently don't build disallowed roadtypes, however they should also not extend disallowed roadtypes as well. If the roadtype that cannot be extended happens to be the roadtype that the town was going to build then this restriction is ignored. --- src/town_cmd.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index 9d3ae90188..81732f3941 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -1362,6 +1362,20 @@ static inline bool RoadTypesAllowHouseHere(TileIndex t) return !allow; } +/** Test if town can grow road onto a specific tile. + * @param town Town that is building. + * @param tile Tile to build upon. + * @return true iff the tile's road type don't prevent extending the road. + */ +static bool TownCanGrowRoad(const Town *town, TileIndex tile) +{ + if (!IsTileType(tile, MP_ROAD)) return true; + + /* Allow extending on roadtypes which can be built by town, or if the road type matches the type the town will build. */ + RoadType rt = GetRoadTypeRoad(tile); + return HasBit(GetRoadTypeInfo(rt)->flags, ROTF_TOWN_BUILD) || GetTownRoadType(town) == rt; +} + /** * Grows the given town. * There are at the moment 3 possible way's for @@ -1438,6 +1452,8 @@ static void GrowTownInTile(TileIndex *tile_ptr, RoadBits cur_rb, DiagDirection t } } else if (target_dir < DIAGDIR_END && !(cur_rb & DiagDirToRoadBits(ReverseDiagDir(target_dir)))) { + if (!TownCanGrowRoad(t1, tile)) return; + /* Continue building on a partial road. * Should be always OK, so we only generate * the fitting RoadBits */ @@ -1557,6 +1573,8 @@ static void GrowTownInTile(TileIndex *tile_ptr, RoadBits cur_rb, DiagDirection t return; } + if (!TownCanGrowRoad(t1, tile)) return; + _grow_town_result = GROWTH_SEARCH_STOPPED; } From d04aae8428f597287b7868a9cfbbac6fd67157dc Mon Sep 17 00:00:00 2001 From: translators Date: Thu, 13 Apr 2023 18:40:16 +0000 Subject: [PATCH 3/7] Update: Translations from eints danish: 18 changes by bscargo --- src/lang/danish.txt | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/lang/danish.txt b/src/lang/danish.txt index 995bcba77f..12d6e49f83 100644 --- a/src/lang/danish.txt +++ b/src/lang/danish.txt @@ -195,6 +195,7 @@ STR_UNITS_VELOCITY_IMPERIAL :{COMMA} miles/t STR_UNITS_VELOCITY_METRIC :{COMMA} km/t STR_UNITS_VELOCITY_SI :{COMMA} m/s STR_UNITS_VELOCITY_GAMEUNITS :{DECIMAL}{NBSP}felter/dag +STR_UNITS_VELOCITY_KNOTS :{COMMA}{NBSP}knob STR_UNITS_POWER_IMPERIAL :{COMMA}hk STR_UNITS_POWER_METRIC :{COMMA}hk @@ -343,9 +344,9 @@ STR_GOTO_ORDER_VIEW_TOOLTIP :{BLACK}Åbn ord ###length 31 STR_TOOLBAR_TOOLTIP_PAUSE_GAME :{BLACK}Sæt spillet på pause STR_TOOLBAR_TOOLTIP_FORWARD :{BLACK}Kør spillet hurtigere -STR_TOOLBAR_TOOLTIP_OPTIONS :{BLACK}Valg +STR_TOOLBAR_TOOLTIP_OPTIONS :{BLACK}Valgmuligheder og indstillinger STR_TOOLBAR_TOOLTIP_SAVE_GAME_ABANDON_GAME :{BLACK}Gem spillet, forlad spillet, afslut -STR_TOOLBAR_TOOLTIP_DISPLAY_MAP :{BLACK}Vis kortet +STR_TOOLBAR_TOOLTIP_DISPLAY_MAP :{BLACK}Vis kort, ekstra viewport eller liste over skilte STR_TOOLBAR_TOOLTIP_DISPLAY_TOWN_DIRECTORY :{BLACK}Vis byoversigten STR_TOOLBAR_TOOLTIP_DISPLAY_SUBSIDIES :{BLACK}Vis tilskudsordninger STR_TOOLBAR_TOOLTIP_DISPLAY_LIST_OF_COMPANY_STATIONS :{BLACK}Vis liste over selskabets stationer @@ -369,8 +370,8 @@ STR_TOOLBAR_TOOLTIP_BUILD_SHIP_DOCKS :{BLACK}Byg havn STR_TOOLBAR_TOOLTIP_BUILD_AIRPORTS :{BLACK}Byg lufthavne STR_TOOLBAR_TOOLTIP_LANDSCAPING :{BLACK}Åbn landskabsværktøjslinjen for at hæve/sænke terræn, plante træer, osv. STR_TOOLBAR_TOOLTIP_SHOW_SOUND_MUSIC_WINDOW :{BLACK}Vis lyd-/musikvindue -STR_TOOLBAR_TOOLTIP_SHOW_LAST_MESSAGE_NEWS :{BLACK}Vis seneste besked/nyhedsrapport, vis beskedvalg -STR_TOOLBAR_TOOLTIP_LAND_BLOCK_INFORMATION :{BLACK}Information om landområde, konsol, debug af script, skærmbillede, om OpenTTD +STR_TOOLBAR_TOOLTIP_SHOW_LAST_MESSAGE_NEWS :{BLACK}Vis sidste besked/nyhedsrapport, beskedhistorik eller slet alle beskeder +STR_TOOLBAR_TOOLTIP_LAND_BLOCK_INFORMATION :{BLACK}Landområde information, konsol, script debug, skærmbilleder, om OpenTTD STR_TOOLBAR_TOOLTIP_SWITCH_TOOLBAR :{BLACK}Skift værktøjslinier # Extra tooltips for the scenario editor toolbar @@ -863,7 +864,7 @@ STR_NEWS_BEGIN_OF_RECESSION :{BIG_FONT}{BLAC STR_NEWS_END_OF_RECESSION :{BIG_FONT}{BLACK}Økonomisk krise overvundet!{}{}Stigning i forbrug giver industrien selvtilliden tilbage, produktionen øges! STR_NEWS_INDUSTRY_PRODUCTION_INCREASE_GENERAL :{BIG_FONT}{BLACK}{INDUSTRY} øger produktionen! -STR_NEWS_INDUSTRY_PRODUCTION_INCREASE_COAL :{BIG_FONT}{BLACK}Ny kulåre fundet tæt på {INDUSTRY}!{}Produktionen forventes fordoblet! +STR_NEWS_INDUSTRY_PRODUCTION_INCREASE_COAL :{BIG_FONT}{BLACK}Ny kulmine fundet tæt på {INDUSTRY}!{}Produktionen forventes fordoblet! STR_NEWS_INDUSTRY_PRODUCTION_INCREASE_OIL :{BIG_FONT}{BLACK}Nye oliereserver fundet tæt ved {INDUSTRY}!{}Produktionen forventes fordoblet! STR_NEWS_INDUSTRY_PRODUCTION_INCREASE_FARM :{BIG_FONT}{BLACK}Forbedrede landbrugsmetoder ved {INDUSTRY} gør at produktionen forventes fordoblet! STR_NEWS_INDUSTRY_PRODUCTION_INCREASE_SMOOTH :{BIG_FONT}{BLACK}{STRING}produktionen på {INDUSTRY} vokser med {COMMA}%! @@ -872,7 +873,7 @@ STR_NEWS_INDUSTRY_PRODUCTION_DECREASE_FARM :{BIG_FONT}{BLAC STR_NEWS_INDUSTRY_PRODUCTION_DECREASE_SMOOTH :{BIG_FONT}{BLACK}{STRING}produktionen på {INDUSTRY} sænkes med {COMMA}%! ###length VEHICLE_TYPES -STR_NEWS_TRAIN_IS_WAITING :{WHITE}{VEHICLE} afventer i remisen +STR_NEWS_TRAIN_IS_WAITING :{WHITE}{VEHICLE} afventer i depotet STR_NEWS_ROAD_VEHICLE_IS_WAITING :{WHITE}{VEHICLE} venter på værkstedet STR_NEWS_SHIP_IS_WAITING :{WHITE}{VEHICLE} venter i skibsdokken STR_NEWS_AIRCRAFT_IS_WAITING :{WHITE}{VEHICLE} venter i hangaren @@ -883,7 +884,7 @@ STR_NEWS_VEHICLE_HAS_TOO_FEW_ORDERS :{WHITE}{VEHICLE STR_NEWS_VEHICLE_HAS_VOID_ORDER :{WHITE}{VEHICLE} har en ugyldig ordre STR_NEWS_VEHICLE_HAS_DUPLICATE_ENTRY :{WHITE}{VEHICLE} har dublerede ordrer STR_NEWS_VEHICLE_HAS_INVALID_ENTRY :{WHITE}{VEHICLE} har en ugyldig station i sine ordrer -STR_NEWS_PLANE_USES_TOO_SHORT_RUNWAY :{WHITE}{VEHICLE} har i sine ordrer en lufthavn, hvis bane er for kort +STR_NEWS_PLANE_USES_TOO_SHORT_RUNWAY :{WHITE}{VEHICLE} har en lufthavn i sine ordrer, hvis bane er for kort STR_NEWS_VEHICLE_IS_GETTING_OLD :{WHITE}{VEHICLE} er gammel STR_NEWS_VEHICLE_IS_GETTING_VERY_OLD :{WHITE}{VEHICLE} er meget gammel @@ -1808,7 +1809,9 @@ STR_CONFIG_SETTING_ALLOW_SHARES_HELPTEXT :Hvis aktiveret, STR_CONFIG_SETTING_MIN_YEARS_FOR_SHARES :Mindste selskabsalder for aktiehandel: {STRING} STR_CONFIG_SETTING_MIN_YEARS_FOR_SHARES_HELPTEXT :Indstil mindste alder på selskaber, før andre kan købe og sælge aktier i dem. +STR_CONFIG_SETTING_MIN_YEARS_FOR_SHARES_VALUE :{COMMA} år{P "" s} ###setting-zero-is-special +STR_CONFIG_SETTING_MIN_YEARS_FOR_SHARES_NO_MIN :Intet minimum STR_CONFIG_SETTING_FEEDER_PAYMENT_SHARE :Procentdel af deloverskud som skal betales i hovedsystemer: {STRING} STR_CONFIG_SETTING_FEEDER_PAYMENT_SHARE_HELPTEXT :Procentdel af indkomst givet til de mellemliggende dele i hovedsystemer, giver mere kontrol over indkomst @@ -1953,12 +1956,14 @@ STR_CONFIG_SETTING_SHORT_PATH_SATURATION :Mætning af kor STR_CONFIG_SETTING_SHORT_PATH_SATURATION_HELPTEXT :Der er ofte flere veje mellem to givne stationer. Cargodist vil mætte den korteste vej først, så bruge den næstkorteste vej indtil den er mættet, osv.. Mætning bestemmes af en vurdering af kapacitet og planlagt brug. Når den har mættet alle veje, og hvis der stadig er efterspørgsel tilbage, vil den overbelaste alle veje, og foretrække vejene med høj kapacitet. Det meste af tiden vil algoritmen dog ikke vurdere kapaciteten nøjagtigt. Denne indstilling giver dig mulighed for at bestemme op til hvilken procentdel en kortere vej skal være mættet i første omgang før den næste, længere vej vælges. Sæt denne indstilling til mindre end 100% for at undgå overfyldte stationer i tilfælde af overvurderet kapacitet. STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY :Hastighedsenheder: {STRING} +STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_NAUTICAL :Hastighedsenheder (nautisk): {STRING} STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_HELPTEXT :Når en hastighed er vist i brugergrænsefladen, så vis dem i de valgte enheder ###length 5 STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_IMPERIAL :Imperisk (mph) STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_METRIC :Metrisk (km/t) STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_SI :SI (m/s) STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_GAMEUNITS :Spil-enheder (felter/dag) +STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_KNOTS :Knob STR_CONFIG_SETTING_LOCALISATION_UNITS_POWER :Køretøjskraftenheder: {STRING} STR_CONFIG_SETTING_LOCALISATION_UNITS_POWER_HELPTEXT :Når et køretøjs kraft er vist i brugergrænsefladen, så vis dem i de valgte enheder @@ -2526,7 +2531,7 @@ STR_CONTENT_OPEN_URL_TOOLTIP :{BLACK}Besøg h STR_CONTENT_DOWNLOAD_CAPTION :{BLACK}Download STR_CONTENT_DOWNLOAD_CAPTION_TOOLTIP :{BLACK}Download det valgte indhold STR_CONTENT_TOTAL_DOWNLOAD_SIZE :{SILVER}Total størrelse af download: {WHITE}{BYTES} -STR_CONTENT_DETAIL_TITLE :{SILVER}INDHOLDSINFO +STR_CONTENT_DETAIL_TITLE :{SILVER}INDHOLDS INFORMATION ###length 5 STR_CONTENT_DETAIL_SUBTITLE_UNSELECTED :{SILVER}Du har ikke valgt denne til download @@ -3199,7 +3204,7 @@ STR_MAPGEN_BORDER_FREEFORM :{BLACK}Fri udfo STR_MAPGEN_BORDER_WATER :{BLACK}Vand STR_MAPGEN_BORDER_RANDOM :{BLACK}Tilfældige STR_MAPGEN_BORDER_RANDOMIZE :{BLACK}Tilfældige -STR_MAPGEN_BORDER_MANUAL :{BLACK}Manuelle +STR_MAPGEN_BORDER_MANUAL :{BLACK}Manuel STR_MAPGEN_HEIGHTMAP_ROTATION :{BLACK}Højdekortets rotation: STR_MAPGEN_HEIGHTMAP_NAME :{BLACK}Højdekortets navn: @@ -3986,8 +3991,8 @@ STR_QUERY_RENAME_AIRCRAFT_TYPE_CAPTION :{WHITE}Ømdøb # Depot window STR_DEPOT_CAPTION :{WHITE}{DEPOT} -STR_DEPOT_RENAME_TOOLTIP :{BLACK}Ændere depotets navn -STR_DEPOT_RENAME_DEPOT_CAPTION :Omdøb depot +STR_DEPOT_RENAME_TOOLTIP :{BLACK}Skift navn på depot +STR_DEPOT_RENAME_DEPOT_CAPTION :Omdøb værksted STR_DEPOT_NO_ENGINE :{BLACK}- STR_DEPOT_VEHICLE_TOOLTIP :{BLACK}{ENGINE}{STRING} @@ -4585,6 +4590,7 @@ STR_AI_CONFIG_AILIST_TOOLTIP :{BLACK}AI`er de STR_AI_CONFIG_HUMAN_PLAYER :Menneskelig spiller STR_AI_CONFIG_RANDOM_AI :Tilfældig computerspiller STR_AI_CONFIG_NONE :(ingen) +STR_AI_CONFIG_NAME_VERSION :{STRING} {YELLOW}v{NUM} STR_AI_CONFIG_MAX_COMPETITORS :{LTBLUE}Maksimalt antal modstandere: {ORANGE}{COMMA} STR_AI_CONFIG_MOVE_UP :{BLACK}Flyt op @@ -4598,7 +4604,7 @@ STR_AI_CONFIG_AI :{SILVER}AI'er STR_AI_CONFIG_CHANGE_AI :{BLACK}Vælg AI STR_AI_CONFIG_CHANGE_GAMESCRIPT :{BLACK}Vælg Spilscript -STR_AI_CONFIG_CHANGE_TOOLTIP :{BLACK}Indlæs et andet script +STR_AI_CONFIG_CHANGE_TOOLTIP :{BLACK}Indlæs et andet script. Ctrl+klik for at vise alle tilgængelige versioner STR_AI_CONFIG_CONFIGURE :{BLACK}Konfigurer computerspiller STR_AI_CONFIG_CONFIGURE_TOOLTIP :{BLACK}Konfigurer parametre for script'et From bb988f940eaf910d8d4826d7f654636c2869e99b Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Wed, 12 Apr 2023 00:18:32 +0100 Subject: [PATCH 4/7] Fix #10638: Incorrect water infra total when building canal over object In the case where the object is on an unowned canal tile and the new canal tile is owned --- src/water_cmd.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp index 7faf6ba11b..bc719df099 100644 --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -481,6 +481,14 @@ CommandCost CmdBuildCanal(DoCommandFlag flags, TileIndex tile, TileIndex start_t if (!water) cost.AddCost(ret); if (flags & DC_EXEC) { + if (IsTileType(current_tile, MP_WATER) && IsCanal(current_tile)) { + Owner owner = GetTileOwner(current_tile); + if (Company::IsValidID(owner)) { + Company::Get(owner)->infrastructure.water--; + DirtyCompanyInfrastructureWindows(owner); + } + } + switch (wc) { case WATER_CLASS_RIVER: MakeRiver(current_tile, Random()); @@ -498,14 +506,11 @@ CommandCost CmdBuildCanal(DoCommandFlag flags, TileIndex tile, TileIndex start_t FALLTHROUGH; default: - /* If we overbuild a water object with a canal, don't update the infrastructure total. */ - bool is_existing_canal = IsTileType(current_tile, MP_WATER) && IsCanal(current_tile); - if (Company::IsValidID(_current_company) && !is_existing_canal) { + MakeCanal(current_tile, _current_company, Random()); + if (Company::IsValidID(_current_company)) { Company::Get(_current_company)->infrastructure.water++; DirtyCompanyInfrastructureWindows(_current_company); } - - MakeCanal(current_tile, _current_company, Random()); break; } MarkTileDirtyByTile(current_tile); From 701092003dfa1eb8f9f5ccf7ab2ae1d3f0bafc53 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Wed, 12 Apr 2023 12:20:07 +0100 Subject: [PATCH 5/7] Fix: DropDownListColourItem didn't provide width nor scale vertical padding. --- src/company_gui.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/company_gui.cpp b/src/company_gui.cpp index ea0c9df394..dfb1415fcf 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -592,9 +592,14 @@ public: return this->result >= COLOUR_END ? STR_COLOUR_DEFAULT : _colour_dropdown[this->result]; } + uint Width() const override + { + return ScaleGUITrad(28) + WidgetDimensions::scaled.hsep_normal + GetStringBoundingBox(this->String()).width + WidgetDimensions::scaled.dropdowntext.Horizontal(); + } + uint Height(uint width) const override { - return std::max(FONT_HEIGHT_NORMAL, ScaleGUITrad(12) + 2); + return std::max(FONT_HEIGHT_NORMAL, ScaleGUITrad(12) + WidgetDimensions::scaled.vsep_normal); } bool Selectable() const override From 5bc9d007358ebc860544baaf94eec4adfe7fc8ab Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Wed, 12 Apr 2023 12:21:07 +0100 Subject: [PATCH 6/7] Cleanup: Let GetStringBoundingBox deal with buffer. --- src/widgets/dropdown.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp index b9cc1c8b9b..165c2b2f52 100644 --- a/src/widgets/dropdown.cpp +++ b/src/widgets/dropdown.cpp @@ -33,9 +33,7 @@ void DropDownListItem::Draw(const Rect &r, bool sel, Colours bg_colour) const uint DropDownListStringItem::Width() const { - char buffer[512]; - GetString(buffer, this->String(), lastof(buffer)); - return GetStringBoundingBox(buffer).width + WidgetDimensions::scaled.dropdowntext.Horizontal(); + return GetStringBoundingBox(this->String()).width + WidgetDimensions::scaled.dropdowntext.Horizontal(); } void DropDownListStringItem::Draw(const Rect &r, bool sel, Colours bg_colour) const From e5af5907ecfe3845adc613a3312695ed8b40bffc Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Tue, 11 Apr 2023 20:07:50 +0100 Subject: [PATCH 7/7] Change: Make all dropdown lists extend width if necessary. This removes the auto_width parameter from ShowDropDown(At). --- src/game/game_gui.cpp | 2 +- src/industry_gui.cpp | 4 ++-- src/music_gui.cpp | 2 +- src/network/network_gui.cpp | 4 ++-- src/newgrf_gui.cpp | 2 +- src/script/script_gui.cpp | 2 +- src/settings_gui.cpp | 2 +- src/toolbar_gui.cpp | 24 ++++++++++++------------ src/widgets/dropdown.cpp | 21 +++++++++------------ src/widgets/dropdown_type.h | 4 ++-- 10 files changed, 32 insertions(+), 35 deletions(-) diff --git a/src/game/game_gui.cpp b/src/game/game_gui.cpp index cdac18e94c..fc53f9a43a 100644 --- a/src/game/game_gui.cpp +++ b/src/game/game_gui.cpp @@ -314,7 +314,7 @@ struct GSConfigWindow : public Window { list.emplace_back(new DropDownListCharStringItem(config_item.labels->Find(i)->second, i, false)); } - ShowDropDownListAt(this, std::move(list), old_val, -1, wi_rect, COLOUR_ORANGE, true); + ShowDropDownListAt(this, std::move(list), old_val, -1, wi_rect, COLOUR_ORANGE); } } } else if (IsInsideMM(x, 0, SETTING_BUTTON_WIDTH)) { diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index 0508acd5a7..b1aa3dc4e1 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -3078,7 +3078,7 @@ struct IndustryCargoesWindow : public Window { } if (!lst.empty()) { int selected = (this->ind_cargo >= NUM_INDUSTRYTYPES) ? (int)(this->ind_cargo - NUM_INDUSTRYTYPES) : -1; - ShowDropDownList(this, std::move(lst), selected, WID_IC_CARGO_DROPDOWN, 0, true); + ShowDropDownList(this, std::move(lst), selected, WID_IC_CARGO_DROPDOWN); } break; } @@ -3092,7 +3092,7 @@ struct IndustryCargoesWindow : public Window { } if (!lst.empty()) { int selected = (this->ind_cargo < NUM_INDUSTRYTYPES) ? (int)this->ind_cargo : -1; - ShowDropDownList(this, std::move(lst), selected, WID_IC_IND_DROPDOWN, 0, true); + ShowDropDownList(this, std::move(lst), selected, WID_IC_IND_DROPDOWN); } break; } diff --git a/src/music_gui.cpp b/src/music_gui.cpp index 7841bbf0d2..c10979041e 100644 --- a/src/music_gui.cpp +++ b/src/music_gui.cpp @@ -577,7 +577,7 @@ struct MusicTrackSelectionWindow : public Window { case WID_MTS_MUSICSET: { int selected = 0; - ShowDropDownList(this, BuildMusicSetDropDownList(&selected), selected, widget, 0, true, false); + ShowDropDownList(this, BuildMusicSetDropDownList(&selected), selected, widget); break; } diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index 40f1bb64e6..cf79efea32 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -1571,7 +1571,7 @@ private: wi_rect.bottom = pt.y; w->dd_client_id = client_id; - ShowDropDownListAt(w, std::move(list), -1, WID_CL_MATRIX, wi_rect, COLOUR_GREY, true, true); + ShowDropDownListAt(w, std::move(list), -1, WID_CL_MATRIX, wi_rect, COLOUR_GREY, true); } /** @@ -1593,7 +1593,7 @@ private: wi_rect.bottom = pt.y; w->dd_company_id = company_id; - ShowDropDownListAt(w, std::move(list), -1, WID_CL_MATRIX, wi_rect, COLOUR_GREY, true, true); + ShowDropDownListAt(w, std::move(list), -1, WID_CL_MATRIX, wi_rect, COLOUR_GREY, true); } /** * Chat button on a Client is clicked. diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp index bb671f1e2a..23f8816ec1 100644 --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -382,7 +382,7 @@ struct NewGRFParametersWindow : public Window { list.emplace_back(new DropDownListCharStringItem(GetGRFStringFromGRFText(par_info->value_names.Find(i)->second), i, false)); } - ShowDropDownListAt(this, std::move(list), old_val, -1, wi_rect, COLOUR_ORANGE, true); + ShowDropDownListAt(this, std::move(list), old_val, -1, wi_rect, COLOUR_ORANGE); } } } else if (IsInsideMM(x, 0, SETTING_BUTTON_WIDTH)) { diff --git a/src/script/script_gui.cpp b/src/script/script_gui.cpp index 78f34f7646..fd4017c48b 100644 --- a/src/script/script_gui.cpp +++ b/src/script/script_gui.cpp @@ -477,7 +477,7 @@ struct ScriptSettingsWindow : public Window { list.emplace_back(new DropDownListCharStringItem(config_item.labels->Find(i)->second, i, false)); } - ShowDropDownListAt(this, std::move(list), old_val, -1, wi_rect, COLOUR_ORANGE, true); + ShowDropDownListAt(this, std::move(list), old_val, -1, wi_rect, COLOUR_ORANGE); } } } else if (IsInsideMM(x, 0, SETTING_BUTTON_WIDTH)) { diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 36318d0a94..f5f1002164 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -2257,7 +2257,7 @@ struct GameSettingsWindow : Window { list.emplace_back(new DropDownListStringItem(sd->str_val + i - sd->min, i, false)); } - ShowDropDownListAt(this, std::move(list), value, -1, wi_rect, COLOUR_ORANGE, true); + ShowDropDownListAt(this, std::move(list), value, -1, wi_rect, COLOUR_ORANGE); } } this->SetDirty(); diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index 554adf9ba5..b00a8154c2 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -190,7 +190,7 @@ public: */ static void PopupMainToolbMenu(Window *w, int widget, DropDownList &&list, int def) { - ShowDropDownList(w, std::move(list), def, widget, 0, true, true); + ShowDropDownList(w, std::move(list), def, widget, 0, true); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); } @@ -344,7 +344,7 @@ static CallBackFunction ToolbarOptionsClick(Window *w) list.emplace_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_TRANSPARENT_BUILDINGS, OME_TRANSPARENTBUILDINGS, false, IsTransparencySet(TO_HOUSES))); list.emplace_back(new DropDownListCheckedItem(STR_SETTINGS_MENU_TRANSPARENT_SIGNS, OME_SHOW_STATIONSIGNS, false, IsTransparencySet(TO_SIGNS))); - ShowDropDownList(w, std::move(list), 0, WID_TN_SETTINGS, 140, true, true); + ShowDropDownList(w, std::move(list), 0, WID_TN_SETTINGS, 140, true); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); return CBF_NONE; } @@ -715,7 +715,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, true); + ShowDropDownList(w, std::move(list), GRMN_OPERATING_PROFIT_GRAPH, WID_TN_GRAPHS, 140, true); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); return CBF_NONE; @@ -728,7 +728,7 @@ static CallBackFunction ToolbarLeagueClick(Window *w) AddDropDownLeagueTableOptions(list); int selected = list[0]->result; - ShowDropDownList(w, std::move(list), selected, WID_TN_LEAGUE, 140, true, true); + ShowDropDownList(w, std::move(list), selected, WID_TN_LEAGUE, 140, true); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); return CBF_NONE; @@ -905,7 +905,7 @@ static CallBackFunction ToolbarZoomOutClick(Window *w) static CallBackFunction ToolbarBuildRailClick(Window *w) { - ShowDropDownList(w, GetRailTypeDropDownList(), _last_built_railtype, WID_TN_RAILS, 140, true, true); + ShowDropDownList(w, GetRailTypeDropDownList(), _last_built_railtype, WID_TN_RAILS, 140, true); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); return CBF_NONE; } @@ -927,7 +927,7 @@ static CallBackFunction MenuClickBuildRail(int index) static CallBackFunction ToolbarBuildRoadClick(Window *w) { - ShowDropDownList(w, GetRoadTypeDropDownList(RTTB_ROAD), _last_built_roadtype, WID_TN_ROADS, 140, true, true); + ShowDropDownList(w, GetRoadTypeDropDownList(RTTB_ROAD), _last_built_roadtype, WID_TN_ROADS, 140, true); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); return CBF_NONE; } @@ -949,7 +949,7 @@ static CallBackFunction MenuClickBuildRoad(int index) static CallBackFunction ToolbarBuildTramClick(Window *w) { - ShowDropDownList(w, GetRoadTypeDropDownList(RTTB_TRAM), _last_built_tramtype, WID_TN_TRAMS, 140, true, true); + ShowDropDownList(w, GetRoadTypeDropDownList(RTTB_TRAM), _last_built_tramtype, WID_TN_TRAMS, 140, true); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); return CBF_NONE; } @@ -973,7 +973,7 @@ static CallBackFunction ToolbarBuildWaterClick(Window *w) { DropDownList list; list.emplace_back(new DropDownListIconItem(SPR_IMG_BUILD_CANAL, PAL_NONE, STR_WATERWAYS_MENU_WATERWAYS_CONSTRUCTION, 0, false)); - ShowDropDownList(w, std::move(list), 0, WID_TN_WATER, 140, true, true); + ShowDropDownList(w, std::move(list), 0, WID_TN_WATER, 140, true); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); return CBF_NONE; } @@ -996,7 +996,7 @@ static CallBackFunction ToolbarBuildAirClick(Window *w) { DropDownList list; list.emplace_back(new DropDownListIconItem(SPR_IMG_AIRPORT, PAL_NONE, STR_AIRCRAFT_MENU_AIRPORT_CONSTRUCTION, 0, false)); - ShowDropDownList(w, std::move(list), 0, WID_TN_AIR, 140, true, true); + ShowDropDownList(w, std::move(list), 0, WID_TN_AIR, 140, true); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); return CBF_NONE; } @@ -1021,7 +1021,7 @@ static CallBackFunction ToolbarForestClick(Window *w) list.emplace_back(new DropDownListIconItem(SPR_IMG_LANDSCAPING, PAL_NONE, STR_LANDSCAPING_MENU_LANDSCAPING, 0, false)); list.emplace_back(new DropDownListIconItem(SPR_IMG_PLANTTREES, PAL_NONE, STR_LANDSCAPING_MENU_PLANT_TREES, 1, false)); list.emplace_back(new DropDownListIconItem(SPR_IMG_SIGN, PAL_NONE, STR_LANDSCAPING_MENU_PLACE_SIGN, 2, false)); - ShowDropDownList(w, std::move(list), 0, WID_TN_LANDSCAPE, 100, true, true); + ShowDropDownList(w, std::move(list), 0, WID_TN_LANDSCAPE, 100, true); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); return CBF_NONE; } @@ -1255,7 +1255,7 @@ static CallBackFunction ToolbarScenGenIndustry(Window *w) static CallBackFunction ToolbarScenBuildRoadClick(Window *w) { - ShowDropDownList(w, GetScenRoadTypeDropDownList(RTTB_ROAD), _last_built_roadtype, WID_TE_ROADS, 140, true, true); + ShowDropDownList(w, GetScenRoadTypeDropDownList(RTTB_ROAD), _last_built_roadtype, WID_TE_ROADS, 140, true); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); return CBF_NONE; } @@ -1275,7 +1275,7 @@ static CallBackFunction ToolbarScenBuildRoad(int index) static CallBackFunction ToolbarScenBuildTramClick(Window *w) { - ShowDropDownList(w, GetScenRoadTypeDropDownList(RTTB_TRAM), _last_built_tramtype, WID_TE_TRAMS, 140, true, true); + ShowDropDownList(w, GetScenRoadTypeDropDownList(RTTB_TRAM), _last_built_tramtype, WID_TE_TRAMS, 140, true); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); return CBF_NONE; } diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp index 165c2b2f52..d036f3f694 100644 --- a/src/widgets/dropdown.cpp +++ b/src/widgets/dropdown.cpp @@ -351,12 +351,10 @@ struct DropdownWindow : Window { * @param button The widget which is passed to Window::OnDropdownSelect and OnDropdownClose. * Unless you override those functions, this should be then widget index of the dropdown button. * @param wi_rect Coord of the parent drop down button, used to position the dropdown menu. - * @param auto_width The width is determined by the widest item in the list, - * in this case only one of \a left or \a right is used (depending on text direction). * @param instant_close Set to true if releasing mouse button should close the * list regardless of where the cursor is. */ -void ShowDropDownListAt(Window *w, DropDownList &&list, int selected, int button, Rect wi_rect, Colours wi_colour, bool auto_width, bool instant_close) +void ShowDropDownListAt(Window *w, DropDownList &&list, int selected, int button, Rect wi_rect, Colours wi_colour, bool instant_close) { CloseWindowById(WC_DROPDOWN_MENU, 0); @@ -366,7 +364,7 @@ void ShowDropDownListAt(Window *w, DropDownList &&list, int selected, int button /* The preferred width equals the calling widget */ uint width = wi_rect.Width(); - /* Longest item in the list, if auto_width is enabled */ + /* Longest item in the list */ uint max_item_width = 0; /* Total height of list */ @@ -374,10 +372,10 @@ void ShowDropDownListAt(Window *w, DropDownList &&list, int selected, int button for (const auto &item : list) { height += item->Height(width); - if (auto_width) max_item_width = std::max(max_item_width, item->Width()); + max_item_width = std::max(max_item_width, item->Width()); } - if (auto_width) max_item_width += WidgetDimensions::scaled.fullbevel.Horizontal(); + max_item_width += WidgetDimensions::scaled.fullbevel.Horizontal(); /* Scrollbar needed? */ bool scroll = false; @@ -421,7 +419,7 @@ void ShowDropDownListAt(Window *w, DropDownList &&list, int selected, int button } } - if (auto_width) width = std::max(width, max_item_width); + width = std::max(width, max_item_width); Point dw_pos = { w->left + (_current_text_dir == TD_RTL ? wi_rect.right + 1 - (int)width : wi_rect.left), top}; Dimension dw_size = {width, height}; @@ -440,12 +438,11 @@ void ShowDropDownListAt(Window *w, DropDownList &&list, int selected, int button * @param selected The initially selected list item. * @param button The widget within the parent window that is used to determine * the list's location. - * @param width Override the width determined by the selected widget. - * @param auto_width Maximum width is determined by the widest item in the list. + * @param width Override the minimum width determined by the selected widget and list contents. * @param instant_close Set to true if releasing mouse button should close the * list regardless of where the cursor is. */ -void ShowDropDownList(Window *w, DropDownList &&list, int selected, int button, uint width, bool auto_width, bool instant_close) +void ShowDropDownList(Window *w, DropDownList &&list, int selected, int button, uint width, bool instant_close) { /* Our parent's button widget is used to determine where to place the drop * down list window. */ @@ -468,7 +465,7 @@ void ShowDropDownList(Window *w, DropDownList &&list, int selected, int button, } } - ShowDropDownListAt(w, std::move(list), selected, button, wi_rect, wi_colour, auto_width, instant_close); + ShowDropDownListAt(w, std::move(list), selected, button, wi_rect, wi_colour, instant_close); } /** @@ -480,7 +477,7 @@ void ShowDropDownList(Window *w, DropDownList &&list, int selected, int button, * @param button Button widget number of the parent window \a w that wants the dropdown menu. * @param disabled_mask Bitmask for disabled items (items with their bit set are displayed, but not selectable in the dropdown list). * @param hidden_mask Bitmask for hidden items (items with their bit set are not copied to the dropdown list). - * @param width Width of the dropdown menu. If \c 0, use the width of parent widget \a button. + * @param width Minimum width of the dropdown menu. */ void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32 disabled_mask, uint32 hidden_mask, uint width) { diff --git a/src/widgets/dropdown_type.h b/src/widgets/dropdown_type.h index 2e95b407d7..1414a03080 100644 --- a/src/widgets/dropdown_type.h +++ b/src/widgets/dropdown_type.h @@ -98,8 +98,8 @@ public: */ typedef std::vector> DropDownList; -void ShowDropDownListAt(Window *w, DropDownList &&list, int selected, int button, Rect wi_rect, Colours wi_colour, bool auto_width = false, bool instant_close = false); +void ShowDropDownListAt(Window *w, DropDownList &&list, int selected, int button, Rect wi_rect, Colours wi_colour, bool instant_close = false); -void ShowDropDownList(Window *w, DropDownList &&list, int selected, int button, uint width = 0, bool auto_width = false, bool instant_close = false); +void ShowDropDownList(Window *w, DropDownList &&list, int selected, int button, uint width = 0, bool instant_close = false); #endif /* WIDGETS_DROPDOWN_TYPE_H */