1
0
Fork 0
Tyler Trahan 2025-07-23 19:33:27 +00:00 committed by GitHub
commit 22224fdeca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
31 changed files with 128 additions and 72 deletions

View File

@ -493,7 +493,7 @@ public:
{ {
switch (widget) { switch (widget) {
case WID_AP_CLASS_DROPDOWN: case WID_AP_CLASS_DROPDOWN:
ShowDropDownList(this, BuildAirportClassDropDown(), _selected_airport_class, WID_AP_CLASS_DROPDOWN); this->HandleDropdownListButtonClick(BuildAirportClassDropDown(), _selected_airport_class, WID_AP_CLASS_DROPDOWN);
break; break;
case WID_AP_AIRPORT_LIST: { case WID_AP_AIRPORT_LIST: {

View File

@ -534,16 +534,16 @@ public:
DropDownList list; DropDownList list;
list.push_back(MakeDropDownListStringItem(STR_REPLACE_ENGINES, 1)); list.push_back(MakeDropDownListStringItem(STR_REPLACE_ENGINES, 1));
list.push_back(MakeDropDownListStringItem(STR_REPLACE_WAGONS, 0)); list.push_back(MakeDropDownListStringItem(STR_REPLACE_WAGONS, 0));
ShowDropDownList(this, std::move(list), this->replace_engines ? 1 : 0, WID_RV_TRAIN_ENGINEWAGON_DROPDOWN); this->HandleDropdownListButtonClick(std::move(list), this->replace_engines ? 1 : 0, WID_RV_TRAIN_ENGINEWAGON_DROPDOWN);
break; break;
} }
case WID_RV_RAIL_TYPE_DROPDOWN: // Railtype selection dropdown menu case WID_RV_RAIL_TYPE_DROPDOWN: // Railtype selection dropdown menu
ShowDropDownList(this, GetRailTypeDropDownList(true, true), this->sel_railtype, widget); this->HandleDropdownListButtonClick(GetRailTypeDropDownList(true, true), this->sel_railtype, widget);
break; break;
case WID_RV_ROAD_TYPE_DROPDOWN: // Roadtype selection dropdown menu case WID_RV_ROAD_TYPE_DROPDOWN: // Roadtype selection dropdown menu
ShowDropDownList(this, GetRoadTypeDropDownList(RTTB_ROAD | RTTB_TRAM, true, true), this->sel_roadtype, widget); this->HandleDropdownListButtonClick(GetRoadTypeDropDownList(RTTB_ROAD | RTTB_TRAM, true, true), this->sel_roadtype, widget);
break; break;
case WID_RV_TRAIN_WAGONREMOVE_TOGGLE: { case WID_RV_TRAIN_WAGONREMOVE_TOGGLE: {
@ -563,7 +563,7 @@ public:
ReplaceClick_StartReplace(false); ReplaceClick_StartReplace(false);
} else { } else {
bool replacment_when_old = EngineHasReplacementWhenOldForCompany(Company::Get(_local_company), this->sel_engine[0], this->sel_group); bool replacment_when_old = EngineHasReplacementWhenOldForCompany(Company::Get(_local_company), this->sel_engine[0], this->sel_group);
ShowDropDownMenu(this, _start_replace_dropdown, replacment_when_old ? 1 : 0, WID_RV_START_REPLACE, !this->replace_engines ? 1 << 1 : 0, 0); this->HandleDropdownMenuButtonClick(_start_replace_dropdown, replacment_when_old ? 1 : 0, WID_RV_START_REPLACE, !this->replace_engines ? 1 << 1 : 0, 0);
} }
break; break;
} }

View File

@ -278,7 +278,7 @@ public:
break; break;
case WID_BBS_DROPDOWN_CRITERIA: case WID_BBS_DROPDOWN_CRITERIA:
ShowDropDownMenu(this, BuildBridgeWindow::sorter_names, this->bridges.SortType(), WID_BBS_DROPDOWN_CRITERIA, 0, 0); this->HandleDropdownMenuButtonClick(BuildBridgeWindow::sorter_names, this->bridges.SortType(), WID_BBS_DROPDOWN_CRITERIA, 0, 0);
break; break;
} }
} }

View File

@ -1675,12 +1675,12 @@ struct BuildVehicleWindow : Window {
break; break;
case WID_BV_CARGO_FILTER_DROPDOWN: // Select cargo filtering criteria dropdown menu case WID_BV_CARGO_FILTER_DROPDOWN: // Select cargo filtering criteria dropdown menu
ShowDropDownList(this, this->BuildCargoDropDownList(), this->cargo_filter_criteria, widget); this->HandleDropdownListButtonClick(this->BuildCargoDropDownList(), this->cargo_filter_criteria, widget);
break; break;
case WID_BV_CONFIGURE_BADGES: case WID_BV_CONFIGURE_BADGES:
if (this->badge_classes.GetClasses().empty()) break; if (this->badge_classes.GetClasses().empty()) break;
ShowDropDownList(this, this->BuildBadgeConfigurationList(), -1, widget, 0, false, true); this->HandleDropdownListButtonClick(this->BuildBadgeConfigurationList(), -1, widget, 0, false, true);
break; break;
case WID_BV_SHOW_HIDE: { case WID_BV_SHOW_HIDE: {
@ -1706,7 +1706,7 @@ struct BuildVehicleWindow : Window {
default: default:
if (IsInsideMM(widget, this->badge_filters.first, this->badge_filters.second)) { if (IsInsideMM(widget, this->badge_filters.first, this->badge_filters.second)) {
ShowDropDownList(this, this->GetWidget<NWidgetBadgeFilter>(widget)->GetDropDownList(), -1, widget, 0, false); this->HandleDropdownListButtonClick(this->GetWidget<NWidgetBadgeFilter>(widget)->GetDropDownList(), -1, widget, 0, false);
} }
break; break;
} }

View File

@ -660,7 +660,7 @@ private:
} else { } else {
sel = default_col; sel = default_col;
} }
ShowDropDownList(this, std::move(list), sel, widget); this->HandleDropdownListButtonClick(std::move(list), sel, widget);
} }
void BuildGroupList(CompanyID owner) void BuildGroupList(CompanyID owner)

View File

@ -96,7 +96,7 @@ struct SetDateWindow : Window {
break; break;
} }
ShowDropDownList(this, std::move(list), selected, widget); this->HandleDropdownListButtonClick(std::move(list), selected, widget);
} }
void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override

View File

@ -19,6 +19,7 @@
#include "depot_base.h" #include "depot_base.h"
#include "spritecache.h" #include "spritecache.h"
#include "strings_func.h" #include "strings_func.h"
#include "sound_func.h"
#include "vehicle_func.h" #include "vehicle_func.h"
#include "company_func.h" #include "company_func.h"
#include "tilehighlight_func.h" #include "tilehighlight_func.h"
@ -815,6 +816,8 @@ struct DepotWindow : Window {
} else { } else {
ResetObjectToPlace(); ResetObjectToPlace();
} }
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
break; break;
case WID_D_LOCATION: case WID_D_LOCATION:

View File

@ -14,7 +14,6 @@
#include "gfx_func.h" #include "gfx_func.h"
#include "gfx_type.h" #include "gfx_type.h"
#include "palette_func.h" #include "palette_func.h"
#include "window_gui.h"
/** /**
* Base list item class from which others are derived. * Base list item class from which others are derived.

View File

@ -654,26 +654,27 @@ struct GenerateLandscapeWindow : public Window {
case WID_GL_TROPICAL: case WID_GL_TROPICAL:
case WID_GL_TOYLAND: case WID_GL_TOYLAND:
SetNewLandscapeType(LandscapeType(widget - WID_GL_TEMPERATE)); SetNewLandscapeType(LandscapeType(widget - WID_GL_TEMPERATE));
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
break; break;
case WID_GL_MAPSIZE_X_PULLDOWN: // Mapsize X case WID_GL_MAPSIZE_X_PULLDOWN: // Mapsize X
ShowDropDownList(this, BuildMapsizeDropDown(), _settings_newgame.game_creation.map_x, WID_GL_MAPSIZE_X_PULLDOWN); this->HandleDropdownListButtonClick(BuildMapsizeDropDown(), _settings_newgame.game_creation.map_x, WID_GL_MAPSIZE_X_PULLDOWN);
break; break;
case WID_GL_MAPSIZE_Y_PULLDOWN: // Mapsize Y case WID_GL_MAPSIZE_Y_PULLDOWN: // Mapsize Y
ShowDropDownList(this, BuildMapsizeDropDown(), _settings_newgame.game_creation.map_y, WID_GL_MAPSIZE_Y_PULLDOWN); this->HandleDropdownListButtonClick(BuildMapsizeDropDown(), _settings_newgame.game_creation.map_y, WID_GL_MAPSIZE_Y_PULLDOWN);
break; break;
case WID_GL_TOWN_PULLDOWN: // Number of towns case WID_GL_TOWN_PULLDOWN: // Number of towns
ShowDropDownMenu(this, _num_towns, _settings_newgame.difficulty.number_towns, WID_GL_TOWN_PULLDOWN, 0, 0); this->HandleDropdownMenuButtonClick(_num_towns, _settings_newgame.difficulty.number_towns, WID_GL_TOWN_PULLDOWN, 0, 0);
break; break;
case WID_GL_TOWNNAME_DROPDOWN: // Townname generator case WID_GL_TOWNNAME_DROPDOWN: // Townname generator
ShowDropDownList(this, BuildTownNameDropDown(), _settings_newgame.game_creation.town_name, WID_GL_TOWNNAME_DROPDOWN); this->HandleDropdownListButtonClick(BuildTownNameDropDown(), _settings_newgame.game_creation.town_name, WID_GL_TOWNNAME_DROPDOWN);
break; break;
case WID_GL_INDUSTRY_PULLDOWN: // Number of industries case WID_GL_INDUSTRY_PULLDOWN: // Number of industries
ShowDropDownMenu(this, _num_inds, _settings_newgame.difficulty.industry_density, WID_GL_INDUSTRY_PULLDOWN, 0, 0); this->HandleDropdownMenuButtonClick(_num_inds, _settings_newgame.difficulty.industry_density, WID_GL_INDUSTRY_PULLDOWN, 0, 0);
break; break;
case WID_GL_GENERATE_BUTTON: { // Generate case WID_GL_GENERATE_BUTTON: { // Generate
@ -718,6 +719,7 @@ struct GenerateLandscapeWindow : public Window {
case WID_GL_HEIGHTMAP_HEIGHT_TEXT: // Height level text case WID_GL_HEIGHTMAP_HEIGHT_TEXT: // Height level text
this->widget_id = WID_GL_HEIGHTMAP_HEIGHT_TEXT; this->widget_id = WID_GL_HEIGHTMAP_HEIGHT_TEXT;
ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.heightmap_height), STR_MAPGEN_HEIGHTMAP_HEIGHT_QUERY_CAPT, 4, this, CS_NUMERAL, QueryStringFlag::EnableDefault); ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.heightmap_height), STR_MAPGEN_HEIGHTMAP_HEIGHT_QUERY_CAPT, 4, this, CS_NUMERAL, QueryStringFlag::EnableDefault);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
break; break;
@ -753,6 +755,7 @@ struct GenerateLandscapeWindow : public Window {
case WID_GL_SNOW_COVERAGE_TEXT: // Snow coverage text case WID_GL_SNOW_COVERAGE_TEXT: // Snow coverage text
this->widget_id = WID_GL_SNOW_COVERAGE_TEXT; this->widget_id = WID_GL_SNOW_COVERAGE_TEXT;
ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.snow_coverage), STR_MAPGEN_SNOW_COVERAGE_QUERY_CAPT, 4, this, CS_NUMERAL, QueryStringFlag::EnableDefault); ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.snow_coverage), STR_MAPGEN_SNOW_COVERAGE_QUERY_CAPT, 4, this, CS_NUMERAL, QueryStringFlag::EnableDefault);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
break; break;
case WID_GL_DESERT_COVERAGE_DOWN: case WID_GL_DESERT_COVERAGE_DOWN:
@ -770,15 +773,16 @@ struct GenerateLandscapeWindow : public Window {
case WID_GL_DESERT_COVERAGE_TEXT: // Desert line text case WID_GL_DESERT_COVERAGE_TEXT: // Desert line text
this->widget_id = WID_GL_DESERT_COVERAGE_TEXT; this->widget_id = WID_GL_DESERT_COVERAGE_TEXT;
ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.desert_coverage), STR_MAPGEN_DESERT_COVERAGE_QUERY_CAPT, 4, this, CS_NUMERAL, QueryStringFlag::EnableDefault); ShowQueryString(GetString(STR_JUST_INT, _settings_newgame.game_creation.desert_coverage), STR_MAPGEN_DESERT_COVERAGE_QUERY_CAPT, 4, this, CS_NUMERAL, QueryStringFlag::EnableDefault);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
break; break;
case WID_GL_HEIGHTMAP_ROTATION_PULLDOWN: // Heightmap rotation case WID_GL_HEIGHTMAP_ROTATION_PULLDOWN: // Heightmap rotation
ShowDropDownMenu(this, _rotation, _settings_newgame.game_creation.heightmap_rotation, WID_GL_HEIGHTMAP_ROTATION_PULLDOWN, 0, 0); this->HandleDropdownMenuButtonClick(_rotation, _settings_newgame.game_creation.heightmap_rotation, WID_GL_HEIGHTMAP_ROTATION_PULLDOWN, 0, 0);
break; break;
case WID_GL_TERRAIN_PULLDOWN: // Terrain type case WID_GL_TERRAIN_PULLDOWN: // Terrain type
/* For the original map generation only the first four are valid. */ /* For the original map generation only the first four are valid. */
ShowDropDownMenu(this, _elevations, _settings_newgame.difficulty.terrain_type, WID_GL_TERRAIN_PULLDOWN, 0, _settings_newgame.game_creation.land_generator == LG_ORIGINAL ? ~0xF : 0); this->HandleDropdownMenuButtonClick(_elevations, _settings_newgame.difficulty.terrain_type, WID_GL_TERRAIN_PULLDOWN, 0, _settings_newgame.game_creation.land_generator == LG_ORIGINAL ? ~0xF : 0);
break; break;
case WID_GL_WATER_PULLDOWN: { // Water quantity case WID_GL_WATER_PULLDOWN: { // Water quantity
@ -787,45 +791,50 @@ struct GenerateLandscapeWindow : public Window {
if (_settings_newgame.game_creation.land_generator == LG_ORIGINAL) { if (_settings_newgame.game_creation.land_generator == LG_ORIGINAL) {
SetBit(hidden_mask, CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY); SetBit(hidden_mask, CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY);
} }
ShowDropDownMenu(this, _sea_lakes, _settings_newgame.difficulty.quantity_sea_lakes, WID_GL_WATER_PULLDOWN, 0, hidden_mask); this->HandleDropdownMenuButtonClick(_sea_lakes, _settings_newgame.difficulty.quantity_sea_lakes, WID_GL_WATER_PULLDOWN, 0, hidden_mask);
break; break;
} }
case WID_GL_RIVER_PULLDOWN: // Amount of rivers case WID_GL_RIVER_PULLDOWN: // Amount of rivers
ShowDropDownMenu(this, _rivers, _settings_newgame.game_creation.amount_of_rivers, WID_GL_RIVER_PULLDOWN, 0, 0); this->HandleDropdownMenuButtonClick(_rivers, _settings_newgame.game_creation.amount_of_rivers, WID_GL_RIVER_PULLDOWN, 0, 0);
break; break;
case WID_GL_SMOOTHNESS_PULLDOWN: // Map smoothness case WID_GL_SMOOTHNESS_PULLDOWN: // Map smoothness
ShowDropDownMenu(this, _smoothness, _settings_newgame.game_creation.tgen_smoothness, WID_GL_SMOOTHNESS_PULLDOWN, 0, 0); this->HandleDropdownMenuButtonClick(_smoothness, _settings_newgame.game_creation.tgen_smoothness, WID_GL_SMOOTHNESS_PULLDOWN, 0, 0);
break; break;
case WID_GL_VARIETY_PULLDOWN: // Map variety case WID_GL_VARIETY_PULLDOWN: // Map variety
ShowDropDownMenu(this, _variety, _settings_newgame.game_creation.variety, WID_GL_VARIETY_PULLDOWN, 0, 0); this->HandleDropdownMenuButtonClick(_variety, _settings_newgame.game_creation.variety, WID_GL_VARIETY_PULLDOWN, 0, 0);
break; break;
/* Freetype map borders */ /* Freetype map borders */
case WID_GL_WATER_NW: case WID_GL_WATER_NW:
_settings_newgame.game_creation.water_borders.Flip(BorderFlag::NorthWest); _settings_newgame.game_creation.water_borders.Flip(BorderFlag::NorthWest);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
this->InvalidateData(); this->InvalidateData();
break; break;
case WID_GL_WATER_NE: case WID_GL_WATER_NE:
_settings_newgame.game_creation.water_borders.Flip(BorderFlag::NorthEast); _settings_newgame.game_creation.water_borders.Flip(BorderFlag::NorthEast);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
this->InvalidateData(); this->InvalidateData();
break; break;
case WID_GL_WATER_SE: case WID_GL_WATER_SE:
_settings_newgame.game_creation.water_borders.Flip(BorderFlag::SouthEast); _settings_newgame.game_creation.water_borders.Flip(BorderFlag::SouthEast);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
this->InvalidateData(); this->InvalidateData();
break; break;
case WID_GL_WATER_SW: case WID_GL_WATER_SW:
_settings_newgame.game_creation.water_borders.Flip(BorderFlag::SouthWest); _settings_newgame.game_creation.water_borders.Flip(BorderFlag::SouthWest);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
this->InvalidateData(); this->InvalidateData();
break; break;
case WID_GL_BORDERS_RANDOM: case WID_GL_BORDERS_RANDOM:
_settings_newgame.game_creation.water_borders = (_settings_newgame.game_creation.water_borders == BorderFlag::Random) ? BorderFlag{} : BorderFlag::Random; _settings_newgame.game_creation.water_borders = (_settings_newgame.game_creation.water_borders == BorderFlag::Random) ? BorderFlag{} : BorderFlag::Random;
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
this->InvalidateData(); this->InvalidateData();
break; break;
@ -1134,11 +1143,11 @@ struct CreateScenarioWindow : public Window
break; break;
case WID_CS_MAPSIZE_X_PULLDOWN: // Mapsize X case WID_CS_MAPSIZE_X_PULLDOWN: // Mapsize X
ShowDropDownList(this, BuildMapsizeDropDown(), _settings_newgame.game_creation.map_x, WID_CS_MAPSIZE_X_PULLDOWN); this->HandleDropdownListButtonClick(BuildMapsizeDropDown(), _settings_newgame.game_creation.map_x, WID_CS_MAPSIZE_X_PULLDOWN);
break; break;
case WID_CS_MAPSIZE_Y_PULLDOWN: // Mapsize Y case WID_CS_MAPSIZE_Y_PULLDOWN: // Mapsize Y
ShowDropDownList(this, BuildMapsizeDropDown(), _settings_newgame.game_creation.map_y, WID_CS_MAPSIZE_Y_PULLDOWN); this->HandleDropdownListButtonClick(BuildMapsizeDropDown(), _settings_newgame.game_creation.map_y, WID_CS_MAPSIZE_Y_PULLDOWN);
break; break;
case WID_CS_EMPTY_WORLD: // Empty world / flat world case WID_CS_EMPTY_WORLD: // Empty world / flat world

View File

@ -17,6 +17,7 @@
#include "cargotype.h" #include "cargotype.h"
#include "strings_func.h" #include "strings_func.h"
#include "window_func.h" #include "window_func.h"
#include "sound_func.h"
#include "gfx_func.h" #include "gfx_func.h"
#include "core/geometry_func.hpp" #include "core/geometry_func.hpp"
#include "currency.h" #include "currency.h"
@ -90,6 +91,8 @@ struct GraphLegendWindow : Window {
InvalidateWindowData(WC_DELIVERED_CARGO, 0); InvalidateWindowData(WC_DELIVERED_CARGO, 0);
InvalidateWindowData(WC_PERFORMANCE_HISTORY, 0); InvalidateWindowData(WC_PERFORMANCE_HISTORY, 0);
InvalidateWindowData(WC_COMPANY_VALUE, 0); InvalidateWindowData(WC_COMPANY_VALUE, 0);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
} }
/** /**
@ -716,6 +719,8 @@ public:
case WID_GRAPH_RANGE_MATRIX: { case WID_GRAPH_RANGE_MATRIX: {
int row = GetRowFromWidget(pt.y, widget, 0, GetCharacterHeight(FS_SMALL) + WidgetDimensions::scaled.framerect.Vertical()); int row = GetRowFromWidget(pt.y, widget, 0, GetCharacterHeight(FS_SMALL) + WidgetDimensions::scaled.framerect.Vertical());
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
if (HasBit(this->masked_range, row)) break; if (HasBit(this->masked_range, row)) break;
ToggleBit(this->excluded_range, row); ToggleBit(this->excluded_range, row);
this->SetDirty(); this->SetDirty();
@ -1255,6 +1260,8 @@ struct BaseCargoGraphWindow : BaseGraphWindow {
int row = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_GRAPH_MATRIX); int row = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_GRAPH_MATRIX);
if (row >= this->vscroll->GetCount()) return; if (row >= this->vscroll->GetCount()) return;
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
for (const CargoSpec *cs : _sorted_cargo_specs) { for (const CargoSpec *cs : _sorted_cargo_specs) {
if (!HasBit(this->cargo_types, cs->Index())) continue; if (!HasBit(this->cargo_types, cs->Index())) continue;
if (row-- > 0) continue; if (row-- > 0) continue;

View File

@ -700,15 +700,15 @@ public:
break; break;
case WID_GL_GROUP_BY_DROPDOWN: // Select grouping option dropdown menu case WID_GL_GROUP_BY_DROPDOWN: // Select grouping option dropdown menu
ShowDropDownMenu(this, this->vehicle_group_by_names, this->grouping, WID_GL_GROUP_BY_DROPDOWN, 0, 0); this->HandleDropdownMenuButtonClick(this->vehicle_group_by_names, this->grouping, WID_GL_GROUP_BY_DROPDOWN, 0, 0);
return; return;
case WID_GL_SORT_BY_DROPDOWN: // Select sorting criteria dropdown menu case WID_GL_SORT_BY_DROPDOWN: // Select sorting criteria dropdown menu
ShowDropDownMenu(this, this->GetVehicleSorterNames(), this->vehgroups.SortType(), WID_GL_SORT_BY_DROPDOWN, 0, (this->vli.vtype == VEH_TRAIN || this->vli.vtype == VEH_ROAD) ? 0 : (1 << 10)); this->HandleDropdownMenuButtonClick(this->GetVehicleSorterNames(), this->vehgroups.SortType(), WID_GL_SORT_BY_DROPDOWN, 0, (this->vli.vtype == VEH_TRAIN || this->vli.vtype == VEH_ROAD) ? 0 : (1 << 10));
return; return;
case WID_GL_FILTER_BY_CARGO: // Select filtering criteria dropdown menu case WID_GL_FILTER_BY_CARGO: // Select filtering criteria dropdown menu
ShowDropDownList(this, this->BuildCargoDropDownList(false), this->cargo_filter_criteria, widget); this->HandleDropdownListButtonClick(this->BuildCargoDropDownList(false), this->cargo_filter_criteria, widget);
break; break;
case WID_GL_ALL_VEHICLES: // All vehicles button case WID_GL_ALL_VEHICLES: // All vehicles button
@ -849,7 +849,7 @@ public:
break; break;
case WID_GL_MANAGE_VEHICLES_DROPDOWN: { case WID_GL_MANAGE_VEHICLES_DROPDOWN: {
ShowDropDownList(this, this->BuildActionDropdownList(true, Group::IsValidID(this->vli.ToGroupID()), IsDefaultGroupID(this->vli.ToGroupID())), -1, WID_GL_MANAGE_VEHICLES_DROPDOWN); this->HandleDropdownListButtonClick(this->BuildActionDropdownList(true, Group::IsValidID(this->vli.ToGroupID()), IsDefaultGroupID(this->vli.ToGroupID())), -1, WID_GL_MANAGE_VEHICLES_DROPDOWN);
break; break;
} }

View File

@ -1798,15 +1798,15 @@ public:
break; break;
case WID_ID_DROPDOWN_CRITERIA: case WID_ID_DROPDOWN_CRITERIA:
ShowDropDownMenu(this, IndustryDirectoryWindow::sorter_names, this->industries.SortType(), WID_ID_DROPDOWN_CRITERIA, 0, 0); this->HandleDropdownMenuButtonClick(IndustryDirectoryWindow::sorter_names, this->industries.SortType(), WID_ID_DROPDOWN_CRITERIA, 0, 0);
break; break;
case WID_ID_FILTER_BY_ACC_CARGO: // Cargo filter dropdown case WID_ID_FILTER_BY_ACC_CARGO: // Cargo filter dropdown
ShowDropDownList(this, this->BuildCargoDropDownList(), this->accepted_cargo_filter_criteria, widget); this->HandleDropdownListButtonClick(this->BuildCargoDropDownList(), this->accepted_cargo_filter_criteria, widget);
break; break;
case WID_ID_FILTER_BY_PROD_CARGO: // Cargo filter dropdown case WID_ID_FILTER_BY_PROD_CARGO: // Cargo filter dropdown
ShowDropDownList(this, this->BuildCargoDropDownList(), this->produced_cargo_filter_criteria, widget); this->HandleDropdownListButtonClick(this->BuildCargoDropDownList(), this->produced_cargo_filter_criteria, widget);
break; break;
case WID_ID_INDUSTRY_LIST: { case WID_ID_INDUSTRY_LIST: {
@ -3092,7 +3092,7 @@ struct IndustryCargoesWindow : public Window {
} }
if (!lst.empty()) { if (!lst.empty()) {
int selected = (this->ind_cargo >= NUM_INDUSTRYTYPES) ? (int)(this->ind_cargo - NUM_INDUSTRYTYPES) : -1; int selected = (this->ind_cargo >= NUM_INDUSTRYTYPES) ? (int)(this->ind_cargo - NUM_INDUSTRYTYPES) : -1;
ShowDropDownList(this, std::move(lst), selected, WID_IC_CARGO_DROPDOWN); this->HandleDropdownListButtonClick(std::move(lst), selected, WID_IC_CARGO_DROPDOWN);
} }
break; break;
} }
@ -3106,7 +3106,7 @@ struct IndustryCargoesWindow : public Window {
} }
if (!lst.empty()) { if (!lst.empty()) {
int selected = (this->ind_cargo < NUM_INDUSTRYTYPES) ? (int)this->ind_cargo : -1; int selected = (this->ind_cargo < NUM_INDUSTRYTYPES) ? (int)this->ind_cargo : -1;
ShowDropDownList(this, std::move(lst), selected, WID_IC_IND_DROPDOWN); this->HandleDropdownListButtonClick(std::move(lst), selected, WID_IC_IND_DROPDOWN);
} }
break; break;
} }

View File

@ -595,7 +595,7 @@ struct MusicTrackSelectionWindow : public Window {
case WID_MTS_MUSICSET: { case WID_MTS_MUSICSET: {
int selected = 0; int selected = 0;
ShowDropDownList(this, BuildSetDropDownList<BaseMusic>(&selected), selected, widget); this->HandleDropdownListButtonClick(BuildSetDropDownList<BaseMusic>(&selected), selected, widget);
break; break;
} }

View File

@ -1019,7 +1019,7 @@ struct NetworkStartServerWindow : public Window {
break; break;
case WID_NSS_CONNTYPE_BTN: // Connection type case WID_NSS_CONNTYPE_BTN: // Connection type
ShowDropDownList(this, BuildVisibilityDropDownList(), _settings_client.network.server_game_type, WID_NSS_CONNTYPE_BTN); this->HandleDropdownListButtonClick(BuildVisibilityDropDownList(), _settings_client.network.server_game_type, WID_NSS_CONNTYPE_BTN);
break; break;
case WID_NSS_CLIENTS_BTND: case WID_NSS_CLIENTS_BTNU: // Click on up/down button for number of clients case WID_NSS_CLIENTS_BTND: case WID_NSS_CLIENTS_BTNU: // Click on up/down button for number of clients
@ -1714,7 +1714,7 @@ public:
case WID_CL_SERVER_VISIBILITY: case WID_CL_SERVER_VISIBILITY:
if (!_network_server) break; if (!_network_server) break;
ShowDropDownList(this, BuildVisibilityDropDownList(), _settings_client.network.server_game_type, WID_CL_SERVER_VISIBILITY); this->HandleDropdownListButtonClick(BuildVisibilityDropDownList(), _settings_client.network.server_game_type, WID_CL_SERVER_VISIBILITY);
break; break;
case WID_CL_MATRIX: { case WID_CL_MATRIX: {

View File

@ -15,6 +15,7 @@
#include "newgrf_badge.h" #include "newgrf_badge.h"
#include "newgrf_badge_type.h" #include "newgrf_badge_type.h"
#include "timer/timer_game_calendar.h" #include "timer/timer_game_calendar.h"
#include "widget_type.h"
class GUIBadgeClasses : public UsedBadgeClasses { class GUIBadgeClasses : public UsedBadgeClasses {
public: public:

View File

@ -941,7 +941,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
} }
this->CloseChildWindows(WC_QUERY_STRING); // Remove the parameter query window this->CloseChildWindows(WC_QUERY_STRING); // Remove the parameter query window
ShowDropDownList(this, std::move(list), this->preset, WID_NS_PRESET_LIST); this->HandleDropdownListButtonClick(std::move(list), this->preset, WID_NS_PRESET_LIST);
break; break;
} }

View File

@ -1254,7 +1254,7 @@ public:
} else { } else {
const Order *o = this->vehicle->GetOrder(this->OrderGetSel()); const Order *o = this->vehicle->GetOrder(this->OrderGetSel());
assert(o != nullptr); assert(o != nullptr);
ShowDropDownMenu(this, _order_non_stop_drowdown, o->GetNonStopType(), WID_O_NON_STOP, 0, this->HandleDropdownMenuButtonClick(_order_non_stop_drowdown, o->GetNonStopType(), WID_O_NON_STOP, 0,
o->IsType(OT_GOTO_STATION) ? 0 : (o->IsType(OT_GOTO_WAYPOINT) ? 3 : 12)); o->IsType(OT_GOTO_STATION) ? 0 : (o->IsType(OT_GOTO_WAYPOINT) ? 3 : 12));
} }
break; break;
@ -1275,7 +1275,7 @@ public:
case OPOS_SHARE: sel = 3; break; case OPOS_SHARE: sel = 3; break;
default: NOT_REACHED(); default: NOT_REACHED();
} }
ShowDropDownMenu(this, this->vehicle->type == VEH_AIRCRAFT ? _order_goto_dropdown_aircraft : _order_goto_dropdown, sel, WID_O_GOTO, 0, 0); this->HandleDropdownMenuButtonClick(this->vehicle->type == VEH_AIRCRAFT ? _order_goto_dropdown_aircraft : _order_goto_dropdown, sel, WID_O_GOTO, 0, 0);
} }
break; break;
@ -1283,7 +1283,7 @@ public:
if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) { if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) {
this->OrderClick_FullLoad(OLF_FULL_LOAD_ANY, true); this->OrderClick_FullLoad(OLF_FULL_LOAD_ANY, true);
} else { } else {
ShowDropDownMenu(this, _order_full_load_drowdown, this->vehicle->GetOrder(this->OrderGetSel())->GetLoadType(), WID_O_FULL_LOAD, 0, 2); this->HandleDropdownMenuButtonClick(_order_full_load_drowdown, this->vehicle->GetOrder(this->OrderGetSel())->GetLoadType(), WID_O_FULL_LOAD, 0, 2);
} }
break; break;
@ -1291,7 +1291,7 @@ public:
if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) { if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) {
this->OrderClick_Unload(OUFB_UNLOAD, true); this->OrderClick_Unload(OUFB_UNLOAD, true);
} else { } else {
ShowDropDownMenu(this, _order_unload_drowdown, this->vehicle->GetOrder(this->OrderGetSel())->GetUnloadType(), WID_O_UNLOAD, 0, 8); this->HandleDropdownMenuButtonClick(_order_unload_drowdown, this->vehicle->GetOrder(this->OrderGetSel())->GetUnloadType(), WID_O_UNLOAD, 0, 8);
} }
break; break;
@ -1300,14 +1300,14 @@ public:
break; break;
case WID_O_DEPOT_ACTION: case WID_O_DEPOT_ACTION:
ShowDropDownMenu(this, _order_depot_action_dropdown, DepotActionStringIndex(this->vehicle->GetOrder(this->OrderGetSel())), WID_O_DEPOT_ACTION, 0, 0); this->HandleDropdownMenuButtonClick(_order_depot_action_dropdown, DepotActionStringIndex(this->vehicle->GetOrder(this->OrderGetSel())), WID_O_DEPOT_ACTION, 0, 0);
break; break;
case WID_O_REFIT_DROPDOWN: case WID_O_REFIT_DROPDOWN:
if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) { if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) {
this->OrderClick_Refit(0, true); this->OrderClick_Refit(0, true);
} else { } else {
ShowDropDownMenu(this, _order_refit_action_dropdown, 0, WID_O_REFIT_DROPDOWN, 0, 0); this->HandleDropdownMenuButtonClick(_order_refit_action_dropdown, 0, WID_O_REFIT_DROPDOWN, 0, 0);
} }
break; break;
@ -1320,14 +1320,14 @@ public:
for (const auto &ocv : _order_conditional_variable) { for (const auto &ocv : _order_conditional_variable) {
list.push_back(MakeDropDownListStringItem(STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE + ocv, ocv)); list.push_back(MakeDropDownListStringItem(STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE + ocv, ocv));
} }
ShowDropDownList(this, std::move(list), this->vehicle->GetOrder(this->OrderGetSel())->GetConditionVariable(), WID_O_COND_VARIABLE); this->HandleDropdownListButtonClick(std::move(list), this->vehicle->GetOrder(this->OrderGetSel())->GetConditionVariable(), WID_O_COND_VARIABLE);
break; break;
} }
case WID_O_COND_COMPARATOR: { case WID_O_COND_COMPARATOR: {
const Order *o = this->vehicle->GetOrder(this->OrderGetSel()); const Order *o = this->vehicle->GetOrder(this->OrderGetSel());
assert(o != nullptr); assert(o != nullptr);
ShowDropDownMenu(this, _order_conditional_condition, o->GetConditionComparator(), WID_O_COND_COMPARATOR, 0, (o->GetConditionVariable() == OCV_REQUIRES_SERVICE) ? 0x3F : 0xC0); this->HandleDropdownMenuButtonClick(_order_conditional_condition, o->GetConditionComparator(), WID_O_COND_COMPARATOR, 0, (o->GetConditionVariable() == OCV_REQUIRES_SERVICE) ? 0x3F : 0xC0);
break; break;
} }

View File

@ -398,6 +398,8 @@ void PickerWindow::OnClick(Point pt, WidgetID widget, int)
SetBit(this->callbacks.mode, PFM_ALL); SetBit(this->callbacks.mode, PFM_ALL);
} }
this->InvalidateData({PickerInvalidation::Class, PickerInvalidation::Type, PickerInvalidation::Position}); this->InvalidateData({PickerInvalidation::Class, PickerInvalidation::Type, PickerInvalidation::Position});
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
break; break;
case WID_PW_SHRINK: case WID_PW_SHRINK:
@ -441,12 +443,12 @@ void PickerWindow::OnClick(Point pt, WidgetID widget, int)
case WID_PW_CONFIGURE_BADGES: case WID_PW_CONFIGURE_BADGES:
if (this->badge_classes.GetClasses().empty()) break; if (this->badge_classes.GetClasses().empty()) break;
ShowDropDownList(this, BuildBadgeClassConfigurationList(this->badge_classes, 1, {}), -1, widget, 0, false, true); this->HandleDropdownListButtonClick(BuildBadgeClassConfigurationList(this->badge_classes, 1, {}), -1, widget, 0, false, true);
break; break;
default: default:
if (IsInsideMM(widget, this->badge_filters.first, this->badge_filters.second)) { if (IsInsideMM(widget, this->badge_filters.first, this->badge_filters.second)) {
ShowDropDownList(this, this->GetWidget<NWidgetBadgeFilter>(widget)->GetDropDownList(), -1, widget, 0, false); this->HandleDropdownListButtonClick(this->GetWidget<NWidgetBadgeFilter>(widget)->GetDropDownList(), -1, widget, 0, false);
} }
break; break;
} }

View File

@ -1580,10 +1580,13 @@ public:
if (w != nullptr) ToggleRailButton_Remove(w); if (w != nullptr) ToggleRailButton_Remove(w);
} }
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
break; break;
case WID_BS_CONVERT: case WID_BS_CONVERT:
_convert_signal_button = !_convert_signal_button; _convert_signal_button = !_convert_signal_button;
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
break; break;
case WID_BS_DRAG_SIGNALS_DENSITY_DECREASE: case WID_BS_DRAG_SIGNALS_DENSITY_DECREASE:

View File

@ -20,6 +20,7 @@
#include "table/strings.h" #include "table/strings.h"
#include "safeguards.h" #include "safeguards.h"
#include "window_gui.h"
/* == BaseSettingEntry methods == */ /* == BaseSettingEntry methods == */

View File

@ -1148,7 +1148,7 @@ struct GameOptionsWindow : Window {
int selected; int selected;
DropDownList list = this->BuildDropDownList(widget, &selected); DropDownList list = this->BuildDropDownList(widget, &selected);
if (!list.empty()) { if (!list.empty()) {
ShowDropDownList(this, std::move(list), selected, widget); this->HandleDropdownListButtonClick(std::move(list), selected, widget);
} else { } else {
if (widget == WID_GO_RESOLUTION_DROPDOWN) ShowErrorMessage(GetEncodedString(STR_ERROR_RESOLUTION_LIST_FAILED), {}, WL_ERROR); if (widget == WID_GO_RESOLUTION_DROPDOWN) ShowErrorMessage(GetEncodedString(STR_ERROR_RESOLUTION_LIST_FAILED), {}, WL_ERROR);
} }
@ -1180,7 +1180,7 @@ struct GameOptionsWindow : Window {
int selected; int selected;
DropDownList list = this->BuildDropDownList(widget, &selected); DropDownList list = this->BuildDropDownList(widget, &selected);
if (!list.empty()) { if (!list.empty()) {
ShowDropDownList(this, std::move(list), this->filter.mode, widget); this->HandleDropdownListButtonClick(std::move(list), this->filter.mode, widget);
} }
break; break;
} }
@ -1189,7 +1189,7 @@ struct GameOptionsWindow : Window {
int selected; int selected;
DropDownList list = this->BuildDropDownList(widget, &selected); DropDownList list = this->BuildDropDownList(widget, &selected);
if (!list.empty()) { if (!list.empty()) {
ShowDropDownList(this, std::move(list), this->filter.type, widget); this->HandleDropdownListButtonClick(std::move(list), this->filter.type, widget);
} }
break; break;
} }

View File

@ -1735,7 +1735,6 @@ public:
case WID_SM_CENTERMAP: // Center the smallmap again case WID_SM_CENTERMAP: // Center the smallmap again
this->SmallMapCenterOnCurrentPos(); this->SmallMapCenterOnCurrentPos();
this->HandleButtonClick(WID_SM_CENTERMAP); this->HandleButtonClick(WID_SM_CENTERMAP);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
break; break;
case WID_SM_TOGGLETOWNNAME: // Toggle town names case WID_SM_TOGGLETOWNNAME: // Toggle town names

View File

@ -658,12 +658,12 @@ public:
break; break;
case WID_STL_SORTDROPBTN: // select sorting criteria dropdown menu case WID_STL_SORTDROPBTN: // select sorting criteria dropdown menu
ShowDropDownMenu(this, CompanyStationsWindow::sorter_names, this->stations.SortType(), WID_STL_SORTDROPBTN, 0, 0); this->HandleDropdownMenuButtonClick(CompanyStationsWindow::sorter_names, this->stations.SortType(), WID_STL_SORTDROPBTN, 0, 0);
break; break;
case WID_STL_CARGODROPDOWN: case WID_STL_CARGODROPDOWN:
this->filter_expanded = false; this->filter_expanded = false;
ShowDropDownList(this, this->BuildCargoDropDownList(this->filter_expanded), -1, widget, 0, false, true); this->HandleDropdownListButtonClick(this->BuildCargoDropDownList(this->filter_expanded), -1, widget, 0, false, true);
break; break;
} }
} }
@ -2005,14 +2005,14 @@ struct StationViewWindow : public Window {
* sorting criteria for columns 1, 2, and 3. Column 0 is always * sorting criteria for columns 1, 2, and 3. Column 0 is always
* sorted by cargo type. The others can theoretically be sorted * sorted by cargo type. The others can theoretically be sorted
* by different things but there is no UI for that. */ * by different things but there is no UI for that. */
ShowDropDownMenu(this, StationViewWindow::sort_names, this->HandleDropdownMenuButtonClick(StationViewWindow::sort_names,
this->current_mode * 2 + (this->sortings[1] == CargoSortType::Count ? 1 : 0), this->current_mode * 2 + (this->sortings[1] == CargoSortType::Count ? 1 : 0),
WID_SV_SORT_BY, 0, 0); WID_SV_SORT_BY, 0, 0);
break; break;
} }
case WID_SV_GROUP_BY: { case WID_SV_GROUP_BY: {
ShowDropDownMenu(this, StationViewWindow::group_names, this->grouping_index, WID_SV_GROUP_BY, 0, 0); this->HandleDropdownMenuButtonClick(StationViewWindow::group_names, this->grouping_index, WID_SV_GROUP_BY, 0, 0);
break; break;
} }

View File

@ -805,7 +805,7 @@ public:
selected++; selected++;
} }
ShowDropDownList(this, std::move(list), selected, widget); this->HandleDropdownListButtonClick(std::move(list), selected, widget);
} }
break; break;
} }

View File

@ -621,7 +621,6 @@ struct ScenarioEditorLandscapeGenerationWindow : Window {
if (!IsInsideMM(size, 1, 8 + 1)) return; if (!IsInsideMM(size, 1, 8 + 1)) return;
_terraform_size = size; _terraform_size = size;
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
this->SetDirty(); this->SetDirty();
break; break;
} }

View File

@ -514,7 +514,7 @@ void TextfileWindow::AfterLoadMarkdown()
for (size_t line : this->jumplist) { for (size_t line : this->jumplist) {
list.push_back(MakeDropDownListStringItem(GetString(STR_TEXTFILE_JUMPLIST_ITEM, this->lines[line].text), (int)line)); list.push_back(MakeDropDownListStringItem(GetString(STR_TEXTFILE_JUMPLIST_ITEM, this->lines[line].text), (int)line));
} }
ShowDropDownList(this, std::move(list), -1, widget); this->HandleDropdownListButtonClick(std::move(list), -1, widget);
break; break;
} }

View File

@ -857,7 +857,6 @@ static CallBackFunction ToolbarZoomInClick(Window *w)
{ {
if (DoZoomInOutWindow(ZOOM_IN, GetMainWindow())) { if (DoZoomInOutWindow(ZOOM_IN, GetMainWindow())) {
w->HandleButtonClick((_game_mode == GM_EDITOR) ? (WidgetID)WID_TE_ZOOM_IN : (WidgetID)WID_TN_ZOOM_IN); w->HandleButtonClick((_game_mode == GM_EDITOR) ? (WidgetID)WID_TE_ZOOM_IN : (WidgetID)WID_TN_ZOOM_IN);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
} }
return CBF_NONE; return CBF_NONE;
} }
@ -868,7 +867,6 @@ static CallBackFunction ToolbarZoomOutClick(Window *w)
{ {
if (DoZoomInOutWindow(ZOOM_OUT, GetMainWindow())) { if (DoZoomInOutWindow(ZOOM_OUT, GetMainWindow())) {
w->HandleButtonClick((_game_mode == GM_EDITOR) ? (WidgetID)WID_TE_ZOOM_OUT : (WidgetID)WID_TN_ZOOM_OUT); w->HandleButtonClick((_game_mode == GM_EDITOR) ? (WidgetID)WID_TE_ZOOM_OUT : (WidgetID)WID_TN_ZOOM_OUT);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
} }
return CBF_NONE; return CBF_NONE;
} }
@ -1232,7 +1230,6 @@ static CallBackFunction ToolbarScenDateForward(Window *w)
static CallBackFunction ToolbarScenGenLand(Window *w) static CallBackFunction ToolbarScenGenLand(Window *w)
{ {
w->HandleButtonClick(WID_TE_LAND_GENERATE); w->HandleButtonClick(WID_TE_LAND_GENERATE);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
ShowEditorTerraformToolbar(); ShowEditorTerraformToolbar();
return CBF_NONE; return CBF_NONE;
@ -1256,7 +1253,6 @@ static CallBackFunction ToolbarScenGenTown(int index)
static CallBackFunction ToolbarScenGenIndustry(Window *w) static CallBackFunction ToolbarScenGenIndustry(Window *w)
{ {
w->HandleButtonClick(WID_TE_INDUSTRY); w->HandleButtonClick(WID_TE_INDUSTRY);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
ShowBuildIndustryWindow(); ShowBuildIndustryWindow();
return CBF_NONE; return CBF_NONE;
} }
@ -1304,7 +1300,6 @@ static CallBackFunction ToolbarScenBuildTram(int index)
static CallBackFunction ToolbarScenBuildDocks(Window *w) static CallBackFunction ToolbarScenBuildDocks(Window *w)
{ {
w->HandleButtonClick(WID_TE_WATER); w->HandleButtonClick(WID_TE_WATER);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
ShowBuildDocksScenToolbar(); ShowBuildDocksScenToolbar();
return CBF_NONE; return CBF_NONE;
} }
@ -1312,7 +1307,6 @@ static CallBackFunction ToolbarScenBuildDocks(Window *w)
static CallBackFunction ToolbarScenPlantTrees(Window *w) static CallBackFunction ToolbarScenPlantTrees(Window *w)
{ {
w->HandleButtonClick(WID_TE_TREES); w->HandleButtonClick(WID_TE_TREES);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
ShowBuildTreesToolbar(); ShowBuildTreesToolbar();
return CBF_NONE; return CBF_NONE;
} }
@ -1320,7 +1314,6 @@ static CallBackFunction ToolbarScenPlantTrees(Window *w)
static CallBackFunction ToolbarScenPlaceSign(Window *w) static CallBackFunction ToolbarScenPlaceSign(Window *w)
{ {
w->HandleButtonClick(WID_TE_SIGNS); w->HandleButtonClick(WID_TE_SIGNS);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
return SelectSignTool(); return SelectSignTool();
} }

View File

@ -286,6 +286,8 @@ public:
new_show_state ? _town_local_authority_kdtree.Insert(index) : _town_local_authority_kdtree.Remove(index); new_show_state ? _town_local_authority_kdtree.Insert(index) : _town_local_authority_kdtree.Remove(index);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
this->town->show_zone = new_show_state; this->town->show_zone = new_show_state;
this->SetWidgetLoweredState(widget, new_show_state); this->SetWidgetLoweredState(widget, new_show_state);
MarkWholeScreenDirty(); MarkWholeScreenDirty();
@ -937,7 +939,7 @@ public:
break; break;
case WID_TD_SORT_CRITERIA: // Click on sort criteria dropdown case WID_TD_SORT_CRITERIA: // Click on sort criteria dropdown
ShowDropDownMenu(this, TownDirectoryWindow::sorter_names, this->towns.SortType(), WID_TD_SORT_CRITERIA, 0, 0); this->HandleDropdownMenuButtonClick(TownDirectoryWindow::sorter_names, this->towns.SortType(), WID_TD_SORT_CRITERIA, 0, 0);
break; break;
case WID_TD_LIST: { // Click on Town Matrix case WID_TD_LIST: { // Click on Town Matrix

View File

@ -2101,16 +2101,16 @@ public:
break; break;
case WID_VL_GROUP_BY_PULLDOWN: // Select sorting criteria dropdown menu case WID_VL_GROUP_BY_PULLDOWN: // Select sorting criteria dropdown menu
ShowDropDownMenu(this, this->vehicle_group_by_names, this->grouping, WID_VL_GROUP_BY_PULLDOWN, 0, 0); this->HandleDropdownMenuButtonClick(this->vehicle_group_by_names, this->grouping, WID_VL_GROUP_BY_PULLDOWN, 0, 0);
return; return;
case WID_VL_SORT_BY_PULLDOWN: // Select sorting criteria dropdown menu case WID_VL_SORT_BY_PULLDOWN: // Select sorting criteria dropdown menu
ShowDropDownMenu(this, this->GetVehicleSorterNames(), this->vehgroups.SortType(), WID_VL_SORT_BY_PULLDOWN, 0, this->HandleDropdownMenuButtonClick(this->GetVehicleSorterNames(), this->vehgroups.SortType(), WID_VL_SORT_BY_PULLDOWN, 0,
(this->vli.vtype == VEH_TRAIN || this->vli.vtype == VEH_ROAD) ? 0 : (1 << 10)); (this->vli.vtype == VEH_TRAIN || this->vli.vtype == VEH_ROAD) ? 0 : (1 << 10));
return; return;
case WID_VL_FILTER_BY_CARGO: // Cargo filter dropdown case WID_VL_FILTER_BY_CARGO: // Cargo filter dropdown
ShowDropDownList(this, this->BuildCargoDropDownList(false), this->cargo_filter_criteria, widget); this->HandleDropdownListButtonClick(this->BuildCargoDropDownList(false), this->cargo_filter_criteria, widget);
break; break;
case WID_VL_LIST: { // Matrix to show vehicles case WID_VL_LIST: { // Matrix to show vehicles
@ -2159,7 +2159,7 @@ public:
break; break;
case WID_VL_MANAGE_VEHICLES_DROPDOWN: { case WID_VL_MANAGE_VEHICLES_DROPDOWN: {
ShowDropDownList(this, this->BuildActionDropdownList(this->vli.type == VL_STANDARD, false, true), 0, WID_VL_MANAGE_VEHICLES_DROPDOWN); this->HandleDropdownListButtonClick(this->BuildActionDropdownList(this->vli.type == VL_STANDARD, false, true), 0, WID_VL_MANAGE_VEHICLES_DROPDOWN);
break; break;
} }
@ -2727,7 +2727,7 @@ struct VehicleDetailsWindow : Window {
case WID_VD_SERVICE_INTERVAL_DROPDOWN: { case WID_VD_SERVICE_INTERVAL_DROPDOWN: {
const Vehicle *v = Vehicle::Get(this->window_number); const Vehicle *v = Vehicle::Get(this->window_number);
ShowDropDownMenu(this, this->HandleDropdownMenuButtonClick(
TimerGameEconomy::UsingWallclockUnits() ? _service_interval_dropdown_wallclock : _service_interval_dropdown_calendar, TimerGameEconomy::UsingWallclockUnits() ? _service_interval_dropdown_wallclock : _service_interval_dropdown_calendar,
v->ServiceIntervalIsCustom() ? (v->ServiceIntervalIsPercent() ? 2 : 1) : 0, widget, 0, 0); v->ServiceIntervalIsCustom() ? (v->ServiceIntervalIsPercent() ? 2 : 1) : 0, widget, 0, 0);
break; break;

View File

@ -30,12 +30,14 @@
#include "hotkeys.h" #include "hotkeys.h"
#include "toolbar_gui.h" #include "toolbar_gui.h"
#include "statusbar_gui.h" #include "statusbar_gui.h"
#include "dropdown_func.h"
#include "error.h" #include "error.h"
#include "game/game.hpp" #include "game/game.hpp"
#include "video/video_driver.hpp" #include "video/video_driver.hpp"
#include "framerate_type.h" #include "framerate_type.h"
#include "network/network_func.h" #include "network/network_func.h"
#include "news_func.h" #include "news_func.h"
#include "sound_func.h"
#include "timer/timer.h" #include "timer/timer.h"
#include "timer/timer_window.h" #include "timer/timer_window.h"
@ -586,6 +588,38 @@ EventState Window::OnHotkey(int hotkey)
return ES_HANDLED; return ES_HANDLED;
} }
/**
* Handle the player clicking on a dropdown list.
* @param list Prepopulated DropDownList.
* @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 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.
* @param persist Set if this dropdown should stay open after an option is selected.
*/
void Window::HandleDropdownListButtonClick(DropDownList &&list, int selected, WidgetID button, uint width, bool instant_close, bool persist)
{
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
ShowDropDownList(this, std::forward<DropDownList>(list), selected, button, width, instant_close, persist);
}
/**
* Handle the player clicking on a dropdown menu.
* @param strings Menu list.
* @param selected Index of initial selected item.
* @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 Minimum width of the dropdown menu.
*/
void Window::HandleDropdownMenuButtonClick(std::span<const StringID> strings, int selected, WidgetID button, uint32_t disabled_mask, uint32_t hidden_mask, uint width)
{
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
ShowDropDownMenu(this, strings, selected, button, disabled_mask, hidden_mask, width);
}
/** /**
* Do all things to make a button look clicked and mark it to be * Do all things to make a button look clicked and mark it to be
* unclicked in a few ticks. * unclicked in a few ticks.
@ -596,6 +630,7 @@ void Window::HandleButtonClick(WidgetID widget)
this->LowerWidget(widget); this->LowerWidget(widget);
this->SetTimeout(); this->SetTimeout();
this->SetWidgetDirty(widget); this->SetWidgetDirty(widget);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
} }
static void StartWindowDrag(Window *w); static void StartWindowDrag(Window *w);

View File

@ -13,6 +13,7 @@
#include "vehiclelist.h" #include "vehiclelist.h"
#include "vehicle_type.h" #include "vehicle_type.h"
#include "viewport_type.h" #include "viewport_type.h"
#include "dropdown_type.h"
#include "company_type.h" #include "company_type.h"
#include "tile_type.h" #include "tile_type.h"
#include "widget_type.h" #include "widget_type.h"
@ -499,6 +500,8 @@ public:
EventState HandleEditBoxKey(WidgetID wid, char32_t key, uint16_t keycode); EventState HandleEditBoxKey(WidgetID wid, char32_t key, uint16_t keycode);
virtual void InsertTextString(WidgetID wid, std::string_view str, bool marked, std::optional<size_t> caret, std::optional<size_t> insert_location, std::optional<size_t> replacement_end); virtual void InsertTextString(WidgetID wid, std::string_view str, bool marked, std::optional<size_t> caret, std::optional<size_t> insert_location, std::optional<size_t> replacement_end);
void HandleDropdownListButtonClick(DropDownList &&list, int selected, WidgetID button, uint width = 0, bool instant_close = false, bool persist = false);
void HandleDropdownMenuButtonClick(std::span<const StringID> strings, int selected, WidgetID button, uint32_t disabled_mask, uint32_t hidden_mask, uint width = 0);
void HandleButtonClick(WidgetID widget); void HandleButtonClick(WidgetID widget);
int GetRowFromWidget(int clickpos, WidgetID widget, int padding, int line_height = -1) const; int GetRowFromWidget(int clickpos, WidgetID widget, int padding, int line_height = -1) const;