From ce6bc216419c074a58cae2d412899f4bc197c592 Mon Sep 17 00:00:00 2001 From: Tyler Trahan Date: Sun, 20 Jul 2025 20:50:20 -0400 Subject: [PATCH 1/4] Codechange: Handle "beep" sound within Window::HandleButtonClick() --- src/smallmap_gui.cpp | 1 - src/terraform_gui.cpp | 1 - src/toolbar_gui.cpp | 7 ------- src/window.cpp | 2 ++ 4 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index 9c4220c42a..8dfa5172a2 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -1735,7 +1735,6 @@ public: case WID_SM_CENTERMAP: // Center the smallmap again this->SmallMapCenterOnCurrentPos(); this->HandleButtonClick(WID_SM_CENTERMAP); - if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); break; case WID_SM_TOGGLETOWNNAME: // Toggle town names diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp index 346b728cc6..ab81c7004f 100644 --- a/src/terraform_gui.cpp +++ b/src/terraform_gui.cpp @@ -621,7 +621,6 @@ struct ScenarioEditorLandscapeGenerationWindow : Window { if (!IsInsideMM(size, 1, 8 + 1)) return; _terraform_size = size; - if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); this->SetDirty(); break; } diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index a82d581990..b74bff1ace 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -857,7 +857,6 @@ static CallBackFunction ToolbarZoomInClick(Window *w) { if (DoZoomInOutWindow(ZOOM_IN, GetMainWindow())) { 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; } @@ -868,7 +867,6 @@ static CallBackFunction ToolbarZoomOutClick(Window *w) { if (DoZoomInOutWindow(ZOOM_OUT, GetMainWindow())) { 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; } @@ -1232,7 +1230,6 @@ static CallBackFunction ToolbarScenDateForward(Window *w) static CallBackFunction ToolbarScenGenLand(Window *w) { w->HandleButtonClick(WID_TE_LAND_GENERATE); - if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); ShowEditorTerraformToolbar(); return CBF_NONE; @@ -1256,7 +1253,6 @@ static CallBackFunction ToolbarScenGenTown(int index) static CallBackFunction ToolbarScenGenIndustry(Window *w) { w->HandleButtonClick(WID_TE_INDUSTRY); - if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); ShowBuildIndustryWindow(); return CBF_NONE; } @@ -1304,7 +1300,6 @@ static CallBackFunction ToolbarScenBuildTram(int index) static CallBackFunction ToolbarScenBuildDocks(Window *w) { w->HandleButtonClick(WID_TE_WATER); - if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); ShowBuildDocksScenToolbar(); return CBF_NONE; } @@ -1312,7 +1307,6 @@ static CallBackFunction ToolbarScenBuildDocks(Window *w) static CallBackFunction ToolbarScenPlantTrees(Window *w) { w->HandleButtonClick(WID_TE_TREES); - if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); ShowBuildTreesToolbar(); return CBF_NONE; } @@ -1320,7 +1314,6 @@ static CallBackFunction ToolbarScenPlantTrees(Window *w) static CallBackFunction ToolbarScenPlaceSign(Window *w) { w->HandleButtonClick(WID_TE_SIGNS); - if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); return SelectSignTool(); } diff --git a/src/window.cpp b/src/window.cpp index 6ae18eda28..4a4dedf938 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -36,6 +36,7 @@ #include "framerate_type.h" #include "network/network_func.h" #include "news_func.h" +#include "sound_func.h" #include "timer/timer.h" #include "timer/timer_window.h" @@ -596,6 +597,7 @@ void Window::HandleButtonClick(WidgetID widget) this->LowerWidget(widget); this->SetTimeout(); this->SetWidgetDirty(widget); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); } static void StartWindowDrag(Window *w); From 621d7cc44d8c63861f55eac7c2e71bcc588aef8e Mon Sep 17 00:00:00 2001 From: Tyler Trahan Date: Sun, 20 Jul 2025 21:44:40 -0400 Subject: [PATCH 2/4] Codechange: Handle dropdown clicks in wrapper functions that go beep --- src/airport_gui.cpp | 2 +- src/autoreplace_gui.cpp | 8 ++++---- src/bridge_gui.cpp | 2 +- src/build_vehicle_gui.cpp | 6 +++--- src/company_gui.cpp | 2 +- src/date_gui.cpp | 2 +- src/dropdown_type.h | 1 - src/genworld_gui.cpp | 26 +++++++++++++------------- src/group_gui.cpp | 8 ++++---- src/industry_gui.cpp | 10 +++++----- src/music_gui.cpp | 2 +- src/network/network_gui.cpp | 4 ++-- src/newgrf_badge_gui.h | 1 + src/newgrf_gui.cpp | 2 +- src/order_gui.cpp | 16 ++++++++-------- src/picker_gui.cpp | 4 ++-- src/settingentry_gui.cpp | 1 + src/settings_gui.cpp | 6 +++--- src/station_gui.cpp | 8 ++++---- src/story_gui.cpp | 2 +- src/textfile_gui.cpp | 2 +- src/town_gui.cpp | 2 +- src/vehicle_gui.cpp | 10 +++++----- src/window.cpp | 33 +++++++++++++++++++++++++++++++++ src/window_gui.h | 3 +++ 25 files changed, 100 insertions(+), 63 deletions(-) diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp index de467e0a5c..76cf31c3dc 100644 --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -493,7 +493,7 @@ public: { switch (widget) { 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; case WID_AP_AIRPORT_LIST: { diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp index 73ed7b0846..9d27db9a3a 100644 --- a/src/autoreplace_gui.cpp +++ b/src/autoreplace_gui.cpp @@ -534,16 +534,16 @@ public: DropDownList list; list.push_back(MakeDropDownListStringItem(STR_REPLACE_ENGINES, 1)); 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; } 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; 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; case WID_RV_TRAIN_WAGONREMOVE_TOGGLE: { @@ -563,7 +563,7 @@ public: ReplaceClick_StartReplace(false); } else { 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; } diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp index f77337014e..b760d4aa06 100644 --- a/src/bridge_gui.cpp +++ b/src/bridge_gui.cpp @@ -278,7 +278,7 @@ public: break; 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; } } diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index 1e76cfb8b1..4054e54fe1 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -1675,12 +1675,12 @@ struct BuildVehicleWindow : Window { break; 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; case WID_BV_CONFIGURE_BADGES: 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; case WID_BV_SHOW_HIDE: { @@ -1706,7 +1706,7 @@ struct BuildVehicleWindow : Window { default: if (IsInsideMM(widget, this->badge_filters.first, this->badge_filters.second)) { - ShowDropDownList(this, this->GetWidget(widget)->GetDropDownList(), -1, widget, 0, false); + this->HandleDropdownListButtonClick(this->GetWidget(widget)->GetDropDownList(), -1, widget, 0, false); } break; } diff --git a/src/company_gui.cpp b/src/company_gui.cpp index 9debd59c5b..dc658b60c8 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -660,7 +660,7 @@ private: } else { sel = default_col; } - ShowDropDownList(this, std::move(list), sel, widget); + this->HandleDropdownListButtonClick(std::move(list), sel, widget); } void BuildGroupList(CompanyID owner) diff --git a/src/date_gui.cpp b/src/date_gui.cpp index 02ab436d63..830d67a2b1 100644 --- a/src/date_gui.cpp +++ b/src/date_gui.cpp @@ -96,7 +96,7 @@ struct SetDateWindow : Window { 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 diff --git a/src/dropdown_type.h b/src/dropdown_type.h index 5e6057d1ee..1e24af03da 100644 --- a/src/dropdown_type.h +++ b/src/dropdown_type.h @@ -14,7 +14,6 @@ #include "gfx_func.h" #include "gfx_type.h" #include "palette_func.h" -#include "window_gui.h" /** * Base list item class from which others are derived. diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp index bcda461abe..94caa25914 100644 --- a/src/genworld_gui.cpp +++ b/src/genworld_gui.cpp @@ -657,23 +657,23 @@ struct GenerateLandscapeWindow : public Window { break; 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; 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; 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; 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; 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; case WID_GL_GENERATE_BUTTON: { // Generate @@ -773,12 +773,12 @@ struct GenerateLandscapeWindow : public Window { break; 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; case WID_GL_TERRAIN_PULLDOWN: // Terrain type /* 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; case WID_GL_WATER_PULLDOWN: { // Water quantity @@ -787,20 +787,20 @@ struct GenerateLandscapeWindow : public Window { if (_settings_newgame.game_creation.land_generator == LG_ORIGINAL) { 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; } 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; 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; 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; /* Freetype map borders */ @@ -1134,11 +1134,11 @@ struct CreateScenarioWindow : public Window break; 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; 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; case WID_CS_EMPTY_WORLD: // Empty world / flat world diff --git a/src/group_gui.cpp b/src/group_gui.cpp index df081be946..0aa6a4bcf1 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -700,15 +700,15 @@ public: break; 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; 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; 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; case WID_GL_ALL_VEHICLES: // All vehicles button @@ -849,7 +849,7 @@ public: break; 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; } diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index 0c69a29927..75370ec074 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -1798,15 +1798,15 @@ public: break; 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; 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; 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; case WID_ID_INDUSTRY_LIST: { @@ -3092,7 +3092,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); + this->HandleDropdownListButtonClick(std::move(lst), selected, WID_IC_CARGO_DROPDOWN); } break; } @@ -3106,7 +3106,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); + this->HandleDropdownListButtonClick(std::move(lst), selected, WID_IC_IND_DROPDOWN); } break; } diff --git a/src/music_gui.cpp b/src/music_gui.cpp index cddd9c08db..5b3f1c8ea0 100644 --- a/src/music_gui.cpp +++ b/src/music_gui.cpp @@ -595,7 +595,7 @@ struct MusicTrackSelectionWindow : public Window { case WID_MTS_MUSICSET: { int selected = 0; - ShowDropDownList(this, BuildSetDropDownList(&selected), selected, widget); + this->HandleDropdownListButtonClick(BuildSetDropDownList(&selected), selected, widget); break; } diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index d6c77dce1f..45e5675872 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -1019,7 +1019,7 @@ struct NetworkStartServerWindow : public Window { break; 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; 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: 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; case WID_CL_MATRIX: { diff --git a/src/newgrf_badge_gui.h b/src/newgrf_badge_gui.h index e73186d951..dc9f3ac2e5 100644 --- a/src/newgrf_badge_gui.h +++ b/src/newgrf_badge_gui.h @@ -15,6 +15,7 @@ #include "newgrf_badge.h" #include "newgrf_badge_type.h" #include "timer/timer_game_calendar.h" +#include "widget_type.h" class GUIBadgeClasses : public UsedBadgeClasses { public: diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp index da30cac7ee..80a54ba547 100644 --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -941,7 +941,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { } 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; } diff --git a/src/order_gui.cpp b/src/order_gui.cpp index b09f97588d..f973bf80e7 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -1254,7 +1254,7 @@ public: } else { const Order *o = this->vehicle->GetOrder(this->OrderGetSel()); 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)); } break; @@ -1275,7 +1275,7 @@ public: case OPOS_SHARE: sel = 3; break; 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; @@ -1283,7 +1283,7 @@ public: if (this->GetWidget(widget)->ButtonHit(pt)) { this->OrderClick_FullLoad(OLF_FULL_LOAD_ANY, true); } 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; @@ -1291,7 +1291,7 @@ public: if (this->GetWidget(widget)->ButtonHit(pt)) { this->OrderClick_Unload(OUFB_UNLOAD, true); } 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; @@ -1300,14 +1300,14 @@ public: break; 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; case WID_O_REFIT_DROPDOWN: if (this->GetWidget(widget)->ButtonHit(pt)) { this->OrderClick_Refit(0, true); } 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; @@ -1320,14 +1320,14 @@ public: for (const auto &ocv : _order_conditional_variable) { 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; } case WID_O_COND_COMPARATOR: { const Order *o = this->vehicle->GetOrder(this->OrderGetSel()); 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; } diff --git a/src/picker_gui.cpp b/src/picker_gui.cpp index 196d5d7b9d..ca6f5b2d02 100644 --- a/src/picker_gui.cpp +++ b/src/picker_gui.cpp @@ -441,12 +441,12 @@ void PickerWindow::OnClick(Point pt, WidgetID widget, int) case WID_PW_CONFIGURE_BADGES: 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; default: if (IsInsideMM(widget, this->badge_filters.first, this->badge_filters.second)) { - ShowDropDownList(this, this->GetWidget(widget)->GetDropDownList(), -1, widget, 0, false); + this->HandleDropdownListButtonClick(this->GetWidget(widget)->GetDropDownList(), -1, widget, 0, false); } break; } diff --git a/src/settingentry_gui.cpp b/src/settingentry_gui.cpp index 1aece65330..309b38588a 100644 --- a/src/settingentry_gui.cpp +++ b/src/settingentry_gui.cpp @@ -20,6 +20,7 @@ #include "table/strings.h" #include "safeguards.h" +#include "window_gui.h" /* == BaseSettingEntry methods == */ diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 8aedbb0fd9..15610565ab 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1148,7 +1148,7 @@ struct GameOptionsWindow : Window { int selected; DropDownList list = this->BuildDropDownList(widget, &selected); if (!list.empty()) { - ShowDropDownList(this, std::move(list), selected, widget); + this->HandleDropdownListButtonClick(std::move(list), selected, widget); } else { if (widget == WID_GO_RESOLUTION_DROPDOWN) ShowErrorMessage(GetEncodedString(STR_ERROR_RESOLUTION_LIST_FAILED), {}, WL_ERROR); } @@ -1180,7 +1180,7 @@ struct GameOptionsWindow : Window { int selected; DropDownList list = this->BuildDropDownList(widget, &selected); if (!list.empty()) { - ShowDropDownList(this, std::move(list), this->filter.mode, widget); + this->HandleDropdownListButtonClick(std::move(list), this->filter.mode, widget); } break; } @@ -1189,7 +1189,7 @@ struct GameOptionsWindow : Window { int selected; DropDownList list = this->BuildDropDownList(widget, &selected); if (!list.empty()) { - ShowDropDownList(this, std::move(list), this->filter.type, widget); + this->HandleDropdownListButtonClick(std::move(list), this->filter.type, widget); } break; } diff --git a/src/station_gui.cpp b/src/station_gui.cpp index f3b1b1aacd..680a4c3cc9 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -658,12 +658,12 @@ public: break; 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; case WID_STL_CARGODROPDOWN: 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; } } @@ -2005,14 +2005,14 @@ struct StationViewWindow : public Window { * sorting criteria for columns 1, 2, and 3. Column 0 is always * sorted by cargo type. The others can theoretically be sorted * 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), WID_SV_SORT_BY, 0, 0); break; } 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; } diff --git a/src/story_gui.cpp b/src/story_gui.cpp index f3c1d4feb0..d4c1eae560 100644 --- a/src/story_gui.cpp +++ b/src/story_gui.cpp @@ -805,7 +805,7 @@ public: selected++; } - ShowDropDownList(this, std::move(list), selected, widget); + this->HandleDropdownListButtonClick(std::move(list), selected, widget); } break; } diff --git a/src/textfile_gui.cpp b/src/textfile_gui.cpp index f474ead9c9..826ea3b132 100644 --- a/src/textfile_gui.cpp +++ b/src/textfile_gui.cpp @@ -514,7 +514,7 @@ void TextfileWindow::AfterLoadMarkdown() for (size_t line : this->jumplist) { 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; } diff --git a/src/town_gui.cpp b/src/town_gui.cpp index e1f85e8024..ccf6d51472 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -937,7 +937,7 @@ public: break; 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; case WID_TD_LIST: { // Click on Town Matrix diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 344911ac76..85c39f8312 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -2101,16 +2101,16 @@ public: break; 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; 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)); return; 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; case WID_VL_LIST: { // Matrix to show vehicles @@ -2159,7 +2159,7 @@ public: break; 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; } @@ -2727,7 +2727,7 @@ struct VehicleDetailsWindow : Window { case WID_VD_SERVICE_INTERVAL_DROPDOWN: { const Vehicle *v = Vehicle::Get(this->window_number); - ShowDropDownMenu(this, + this->HandleDropdownMenuButtonClick( TimerGameEconomy::UsingWallclockUnits() ? _service_interval_dropdown_wallclock : _service_interval_dropdown_calendar, v->ServiceIntervalIsCustom() ? (v->ServiceIntervalIsPercent() ? 2 : 1) : 0, widget, 0, 0); break; diff --git a/src/window.cpp b/src/window.cpp index 4a4dedf938..1e1df56a43 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -30,6 +30,7 @@ #include "hotkeys.h" #include "toolbar_gui.h" #include "statusbar_gui.h" +#include "dropdown_func.h" #include "error.h" #include "game/game.hpp" #include "video/video_driver.hpp" @@ -587,6 +588,38 @@ EventState Window::OnHotkey(int hotkey) 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(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 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 * unclicked in a few ticks. diff --git a/src/window_gui.h b/src/window_gui.h index edfbf94da8..1aaa3e560b 100644 --- a/src/window_gui.h +++ b/src/window_gui.h @@ -13,6 +13,7 @@ #include "vehiclelist.h" #include "vehicle_type.h" #include "viewport_type.h" +#include "dropdown_type.h" #include "company_type.h" #include "tile_type.h" #include "widget_type.h" @@ -499,6 +500,8 @@ public: EventState HandleEditBoxKey(WidgetID wid, char32_t key, uint16_t keycode); virtual void InsertTextString(WidgetID wid, std::string_view str, bool marked, std::optional caret, std::optional insert_location, std::optional replacement_end); + void HandleDropdownListButtonClick(DropDownList &&list, int selected, WidgetID button, uint width = 0, bool instant_close = false, bool persist = false); + void HandleDropdownMenuButtonClick(std::span strings, int selected, WidgetID button, uint32_t disabled_mask, uint32_t hidden_mask, uint width = 0); void HandleButtonClick(WidgetID widget); int GetRowFromWidget(int clickpos, WidgetID widget, int padding, int line_height = -1) const; From ef4514862bb8e0d29fe4a1f80c77b1cdfe524d88 Mon Sep 17 00:00:00 2001 From: Tyler Trahan Date: Sun, 20 Jul 2025 22:00:08 -0400 Subject: [PATCH 3/4] Fix: Missing beeps for various buttons --- src/depot_gui.cpp | 3 +++ src/genworld_gui.cpp | 9 +++++++++ src/picker_gui.cpp | 2 ++ src/rail_gui.cpp | 3 +++ src/town_gui.cpp | 2 ++ 5 files changed, 19 insertions(+) diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index c1f5963542..fbf1ef17a9 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -19,6 +19,7 @@ #include "depot_base.h" #include "spritecache.h" #include "strings_func.h" +#include "sound_func.h" #include "vehicle_func.h" #include "company_func.h" #include "tilehighlight_func.h" @@ -815,6 +816,8 @@ struct DepotWindow : Window { } else { ResetObjectToPlace(); } + + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); break; case WID_D_LOCATION: diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp index 94caa25914..67ae01a3fd 100644 --- a/src/genworld_gui.cpp +++ b/src/genworld_gui.cpp @@ -654,6 +654,7 @@ struct GenerateLandscapeWindow : public Window { case WID_GL_TROPICAL: case WID_GL_TOYLAND: SetNewLandscapeType(LandscapeType(widget - WID_GL_TEMPERATE)); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); break; case WID_GL_MAPSIZE_X_PULLDOWN: // Mapsize X @@ -718,6 +719,7 @@ struct GenerateLandscapeWindow : public Window { case WID_GL_HEIGHTMAP_HEIGHT_TEXT: // Height level 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); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); break; @@ -753,6 +755,7 @@ struct GenerateLandscapeWindow : public Window { case WID_GL_SNOW_COVERAGE_TEXT: // 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); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); break; case WID_GL_DESERT_COVERAGE_DOWN: @@ -770,6 +773,7 @@ struct GenerateLandscapeWindow : public Window { case WID_GL_DESERT_COVERAGE_TEXT: // Desert line 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); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); break; case WID_GL_HEIGHTMAP_ROTATION_PULLDOWN: // Heightmap rotation @@ -806,26 +810,31 @@ struct GenerateLandscapeWindow : public Window { /* Freetype map borders */ case WID_GL_WATER_NW: _settings_newgame.game_creation.water_borders.Flip(BorderFlag::NorthWest); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); this->InvalidateData(); break; case WID_GL_WATER_NE: _settings_newgame.game_creation.water_borders.Flip(BorderFlag::NorthEast); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); this->InvalidateData(); break; case WID_GL_WATER_SE: _settings_newgame.game_creation.water_borders.Flip(BorderFlag::SouthEast); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); this->InvalidateData(); break; case WID_GL_WATER_SW: _settings_newgame.game_creation.water_borders.Flip(BorderFlag::SouthWest); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); this->InvalidateData(); break; case WID_GL_BORDERS_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(); break; diff --git a/src/picker_gui.cpp b/src/picker_gui.cpp index ca6f5b2d02..2fe9471404 100644 --- a/src/picker_gui.cpp +++ b/src/picker_gui.cpp @@ -398,6 +398,8 @@ void PickerWindow::OnClick(Point pt, WidgetID widget, int) SetBit(this->callbacks.mode, PFM_ALL); } this->InvalidateData({PickerInvalidation::Class, PickerInvalidation::Type, PickerInvalidation::Position}); + + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); break; case WID_PW_SHRINK: diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index 291039204a..4005d12f7f 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -1580,10 +1580,13 @@ public: if (w != nullptr) ToggleRailButton_Remove(w); } + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); + break; case WID_BS_CONVERT: _convert_signal_button = !_convert_signal_button; + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); break; case WID_BS_DRAG_SIGNALS_DENSITY_DECREASE: diff --git a/src/town_gui.cpp b/src/town_gui.cpp index ccf6d51472..b68c22e37f 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -286,6 +286,8 @@ public: 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->SetWidgetLoweredState(widget, new_show_state); MarkWholeScreenDirty(); From 47d8f722054e1b9e13f1b48c50d4478675565e4d Mon Sep 17 00:00:00 2001 From: Tyler Trahan Date: Sun, 20 Jul 2025 22:00:42 -0400 Subject: [PATCH 4/4] Fix: Missing beeps for graph selectors --- src/graph_gui.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp index f3f6f6ab3d..f680953c9d 100644 --- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -17,6 +17,7 @@ #include "cargotype.h" #include "strings_func.h" #include "window_func.h" +#include "sound_func.h" #include "gfx_func.h" #include "core/geometry_func.hpp" #include "currency.h" @@ -90,6 +91,8 @@ struct GraphLegendWindow : Window { InvalidateWindowData(WC_DELIVERED_CARGO, 0); InvalidateWindowData(WC_PERFORMANCE_HISTORY, 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: { 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; ToggleBit(this->excluded_range, row); this->SetDirty(); @@ -1255,6 +1260,8 @@ struct BaseCargoGraphWindow : BaseGraphWindow { int row = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_GRAPH_MATRIX); if (row >= this->vscroll->GetCount()) return; + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); + for (const CargoSpec *cs : _sorted_cargo_specs) { if (!HasBit(this->cargo_types, cs->Index())) continue; if (row-- > 0) continue;