1
0
Fork 0

Compare commits

...

7 Commits

Author SHA1 Message Date
Tyler Trahan 22224fdeca
Merge 47d8f72205 into 10eeba86a6 2025-07-23 19:33:27 +00:00
Peter Nelson 10eeba86a6 Codechange: Simplify/breakout logic for selecting bridge table sprites.
Move various base offsets to separate functions where they can be reused and documented.

No longer rely on coincidences to select the correct data between bridges and aqueducts.
2025-07-23 20:31:15 +01:00
Peter Nelson d99dad9e9e Codechange: Pass bridge pillar palette/sprite by reference. 2025-07-23 20:31:15 +01:00
Tyler Trahan 47d8f72205 Fix: Missing beeps for graph selectors 2025-07-20 22:10:56 -04:00
Tyler Trahan ef4514862b Fix: Missing beeps for various buttons 2025-07-20 22:00:08 -04:00
Tyler Trahan 621d7cc44d Codechange: Handle dropdown clicks in wrapper functions that go beep 2025-07-20 21:44:40 -04:00
Tyler Trahan ce6bc21641 Codechange: Handle "beep" sound within Window::HandleButtonClick() 2025-07-20 20:50:20 -04:00
33 changed files with 211 additions and 136 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

@ -36,9 +36,14 @@
# define MW(a) {a, PALETTE_TO_STRUCT_WHITE} # define MW(a) {a, PALETTE_TO_STRUCT_WHITE}
# define MC(a) {a, PALETTE_TO_STRUCT_CONCRETE} # define MC(a) {a, PALETTE_TO_STRUCT_CONCRETE}
static const PalSpriteID _aqueduct_sprites[] = { /* Sprite table for middle part of aqueduct. */
{ SPR_AQUEDUCT_MIDDLE_X, PAL_NONE }, { 0x0, PAL_NONE }, { SPR_AQUEDUCT_PILLAR_X, PAL_NONE }, { 0x0, PAL_NONE }, static const PalSpriteID _aqueduct_sprite_table_middle[] = {
{ SPR_AQUEDUCT_MIDDLE_Y, PAL_NONE }, { 0x0, PAL_NONE }, { SPR_AQUEDUCT_PILLAR_Y, PAL_NONE }, { 0x0, PAL_NONE }, {SPR_AQUEDUCT_MIDDLE_X, PAL_NONE}, {0x0, PAL_NONE}, {SPR_AQUEDUCT_PILLAR_X, PAL_NONE}, {0x0, PAL_NONE}, // AXIS_X
{SPR_AQUEDUCT_MIDDLE_Y, PAL_NONE}, {0x0, PAL_NONE}, {SPR_AQUEDUCT_PILLAR_Y, PAL_NONE}, {0x0, PAL_NONE}, // AIXS_Y
};
/* Sprite table for head part of aqueduct. */
static const PalSpriteID _aqueduct_sprite_table_heads[] = {
{SPR_AQUEDUCT_RAMP_SW, PAL_NONE}, {SPR_AQUEDUCT_RAMP_SE, PAL_NONE}, {SPR_AQUEDUCT_RAMP_NE, PAL_NONE}, {SPR_AQUEDUCT_RAMP_NW, PAL_NONE}, {SPR_AQUEDUCT_RAMP_SW, PAL_NONE}, {SPR_AQUEDUCT_RAMP_SE, PAL_NONE}, {SPR_AQUEDUCT_RAMP_NE, PAL_NONE}, {SPR_AQUEDUCT_RAMP_NW, PAL_NONE},
}; };

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

@ -138,15 +138,58 @@ bool HasBridgeFlatRamp(Slope tileh, Axis axis)
return (tileh != SLOPE_FLAT); return (tileh != SLOPE_FLAT);
} }
static inline std::span<const PalSpriteID> GetBridgeSpriteTable(int index, BridgePieces table) /**
* Get the sprite table for a rail/road bridge piece.
* @param bridge_type Bridge type.
* @param piece Bridge piece.
* @return Sprite table for the bridge piece.
*/
static std::span<const PalSpriteID> GetBridgeSpriteTable(BridgeType bridge_type, BridgePieces piece)
{ {
const BridgeSpec *bridge = GetBridgeSpec(index); assert(piece < NUM_BRIDGE_PIECES);
assert(table < NUM_BRIDGE_PIECES);
if (table < bridge->sprite_table.size() && !bridge->sprite_table[table].empty()) return bridge->sprite_table[table];
return _bridge_sprite_table[index][table]; const BridgeSpec *bridge = GetBridgeSpec(bridge_type);
if (piece < bridge->sprite_table.size() && !bridge->sprite_table[piece].empty()) return bridge->sprite_table[piece];
return _bridge_sprite_table[bridge_type][piece];
} }
/**
* Get the sprite table transport type base offset for a rail/road bridge.
* @param transport_type Transport type of bridge.
* @param ramp Tile of bridge ramp.
* @return Offset for transport type.
*/
static uint8_t GetBridgeSpriteTableBaseOffset(TransportType transport_type, TileIndex ramp)
{
switch (transport_type) {
case TRANSPORT_RAIL: return GetRailTypeInfo(GetRailType(ramp))->bridge_offset;
case TRANSPORT_ROAD: return 8;
default: NOT_REACHED();
}
}
/**
* Get bridge sprite table base offset for the ramp part of bridge.
* @param diagdir Direction of ramp.
* @return Offset for direction.
*/
static uint8_t GetBridgeRampDirectionBaseOffset(DiagDirection diagdir)
{
/* Bridge ramps are ordered SW, SE, NE, NW instead of NE, SE, SW, NW. */
static constexpr uint8_t ramp_offsets[DIAGDIR_END] = {2, 1, 0, 3};
return ramp_offsets[diagdir];
}
/**
* Get bridge sprite table base offset for the middle part of bridge.
* @param axis Axis of bridge.
* @return Offset for axis.
*/
static uint8_t GetBridgeMiddleAxisBaseOffset(Axis axis)
{
return axis == AXIS_X ? 0 : 4;
}
/** /**
* Determines the foundation for the bridge head, and tests if the resulting slope is valid. * Determines the foundation for the bridge head, and tests if the resulting slope is valid.
@ -1017,10 +1060,10 @@ static CommandCost ClearTile_TunnelBridge(TileIndex tile, DoCommandFlags flags)
* @param h Bounding box size in Y direction * @param h Bounding box size in Y direction
* @param subsprite Optional subsprite for drawing halfpillars * @param subsprite Optional subsprite for drawing halfpillars
*/ */
static inline void DrawPillar(const PalSpriteID *psid, int x, int y, int z, uint8_t w, uint8_t h, const SubSprite *subsprite) static inline void DrawPillar(const PalSpriteID &psid, int x, int y, int z, uint8_t w, uint8_t h, const SubSprite *subsprite)
{ {
static const int PILLAR_Z_OFFSET = TILE_HEIGHT - BRIDGE_Z_START; ///< Start offset of pillar wrt. bridge (downwards) static const int PILLAR_Z_OFFSET = TILE_HEIGHT - BRIDGE_Z_START; ///< Start offset of pillar wrt. bridge (downwards)
AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, z, {{0, 0, -PILLAR_Z_OFFSET}, {w, h, BB_HEIGHT_UNDER_BRIDGE}, {0, 0, PILLAR_Z_OFFSET}}, IsTransparencySet(TO_BRIDGES), subsprite); AddSortableSpriteToDraw(psid.sprite, psid.pal, x, y, z, {{0, 0, -PILLAR_Z_OFFSET}, {w, h, BB_HEIGHT_UNDER_BRIDGE}, {0, 0, PILLAR_Z_OFFSET}}, IsTransparencySet(TO_BRIDGES), subsprite);
} }
/** /**
@ -1034,7 +1077,7 @@ static inline void DrawPillar(const PalSpriteID *psid, int x, int y, int z, uint
* @param h Bounding box size in Y direction * @param h Bounding box size in Y direction
* @return Reached Z at the bottom * @return Reached Z at the bottom
*/ */
static int DrawPillarColumn(int z_bottom, int z_top, const PalSpriteID *psid, int x, int y, int w, int h) static int DrawPillarColumn(int z_bottom, int z_top, const PalSpriteID &psid, int x, int y, int w, int h)
{ {
int cur_z; int cur_z;
for (cur_z = z_top; cur_z >= z_bottom; cur_z -= TILE_HEIGHT) { for (cur_z = z_top; cur_z >= z_bottom; cur_z -= TILE_HEIGHT) {
@ -1054,7 +1097,7 @@ static int DrawPillarColumn(int z_bottom, int z_top, const PalSpriteID *psid, in
* @param y Sprite Y position of front pillar. * @param y Sprite Y position of front pillar.
* @param z_bridge Absolute height of bridge bottom. * @param z_bridge Absolute height of bridge bottom.
*/ */
static void DrawBridgePillars(const PalSpriteID *psid, const TileInfo *ti, Axis axis, bool drawfarpillar, int x, int y, int z_bridge) static void DrawBridgePillars(const PalSpriteID &psid, const TileInfo *ti, Axis axis, bool drawfarpillar, int x, int y, int z_bridge)
{ {
static const int bounding_box_size[2] = {16, 2}; ///< bounding box size of pillars along bridge direction static const int bounding_box_size[2] = {16, 2}; ///< bounding box size of pillars along bridge direction
static const int back_pillar_offset[2] = { 0, 9}; ///< sprite position offset of back facing pillar static const int back_pillar_offset[2] = { 0, 9}; ///< sprite position offset of back facing pillar
@ -1065,7 +1108,7 @@ static void DrawBridgePillars(const PalSpriteID *psid, const TileInfo *ti, Axis
{ { -INF, -INF, 15, INF }, { 16, -INF, INF, INF } }, // Y axis, north and south { { -INF, -INF, 15, INF }, { 16, -INF, INF, INF } }, // Y axis, north and south
}; };
if (psid->sprite == 0) return; if (psid.sprite == 0) return;
/* Determine ground height under pillars */ /* Determine ground height under pillars */
DiagDirection south_dir = AxisToDiagDir(axis); DiagDirection south_dir = AxisToDiagDir(axis);
@ -1404,34 +1447,20 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
DrawBridgeMiddle(ti); DrawBridgeMiddle(ti);
} else { // IsBridge(ti->tile) } else { // IsBridge(ti->tile)
const PalSpriteID *psid;
int base_offset;
bool ice = HasTunnelBridgeSnowOrDesert(ti->tile);
if (transport_type == TRANSPORT_RAIL) {
base_offset = GetRailTypeInfo(GetRailType(ti->tile))->bridge_offset;
assert(base_offset != 8); // This one is used for roads
} else {
base_offset = 8;
}
/* as the lower 3 bits are used for other stuff, make sure they are clear */
assert( (base_offset & 0x07) == 0x00);
DrawFoundation(ti, GetBridgeFoundation(ti->tileh, DiagDirToAxis(tunnelbridge_direction))); DrawFoundation(ti, GetBridgeFoundation(ti->tileh, DiagDirToAxis(tunnelbridge_direction)));
/* HACK Wizardry to convert the bridge ramp direction into a sprite offset */ uint base_offset = GetBridgeRampDirectionBaseOffset(tunnelbridge_direction);
base_offset += (6 - tunnelbridge_direction) % 4; std::span<const PalSpriteID> psid;
/* Table number BRIDGE_PIECE_HEAD always refers to the bridge heads for any bridge type */
if (transport_type != TRANSPORT_WATER) { if (transport_type != TRANSPORT_WATER) {
if (ti->tileh == SLOPE_FLAT) base_offset += 4; // sloped bridge head if (ti->tileh == SLOPE_FLAT) base_offset += 4; // sloped bridge head
psid = &GetBridgeSpriteTable(GetBridgeType(ti->tile), BRIDGE_PIECE_HEAD)[base_offset]; base_offset += GetBridgeSpriteTableBaseOffset(transport_type, ti->tile);
psid = GetBridgeSpriteTable(GetBridgeType(ti->tile), BRIDGE_PIECE_HEAD);
} else { } else {
psid = _aqueduct_sprites + base_offset; psid = _aqueduct_sprite_table_heads;
} }
psid = psid.subspan(base_offset, 1);
if (!ice) { if (!HasTunnelBridgeSnowOrDesert(ti->tile)) {
TileIndex next = ti->tile + TileOffsByDiagDir(tunnelbridge_direction); TileIndex next = ti->tile + TileOffsByDiagDir(tunnelbridge_direction);
if (ti->tileh != SLOPE_FLAT && ti->z == 0 && HasTileWaterClass(next) && GetWaterClass(next) == WATER_CLASS_SEA) { if (ti->tileh != SLOPE_FLAT && ti->z == 0 && HasTileWaterClass(next) && GetWaterClass(next) == WATER_CLASS_SEA) {
DrawShoreTile(ti->tileh); DrawShoreTile(ti->tileh);
@ -1451,7 +1480,7 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
* it doesn't disappear behind it * it doesn't disappear behind it
*/ */
/* Bridge heads are drawn solid no matter how invisibility/transparency is set */ /* Bridge heads are drawn solid no matter how invisibility/transparency is set */
AddSortableSpriteToDraw(psid->sprite, psid->pal, *ti, {{}, {TILE_SIZE, TILE_SIZE, static_cast<uint8_t>(ti->tileh == SLOPE_FLAT ? 0 : TILE_HEIGHT)}, {}}); AddSortableSpriteToDraw(psid[0].sprite, psid[0].pal, *ti, {{}, {TILE_SIZE, TILE_SIZE, static_cast<uint8_t>(ti->tileh == SLOPE_FLAT ? 0 : TILE_HEIGHT)}, {}});
if (transport_type == TRANSPORT_ROAD) { if (transport_type == TRANSPORT_ROAD) {
uint offset = tunnelbridge_direction; uint offset = tunnelbridge_direction;
@ -1572,33 +1601,21 @@ void DrawBridgeMiddle(const TileInfo *ti)
TileIndex rampnorth = GetNorthernBridgeEnd(ti->tile); TileIndex rampnorth = GetNorthernBridgeEnd(ti->tile);
TileIndex rampsouth = GetSouthernBridgeEnd(ti->tile); TileIndex rampsouth = GetSouthernBridgeEnd(ti->tile);
TransportType transport_type = GetTunnelBridgeTransportType(rampsouth); TransportType transport_type = GetTunnelBridgeTransportType(rampsouth);
Axis axis = GetBridgeAxis(ti->tile); Axis axis = GetBridgeAxis(ti->tile);
BridgePieces piece = CalcBridgePiece(
GetTunnelBridgeLength(ti->tile, rampnorth) + 1,
GetTunnelBridgeLength(ti->tile, rampsouth) + 1
);
const PalSpriteID *psid; uint base_offset = GetBridgeMiddleAxisBaseOffset(axis);
std::span<const PalSpriteID> psid;
bool drawfarpillar; bool drawfarpillar;
if (transport_type != TRANSPORT_WATER) { if (transport_type != TRANSPORT_WATER) {
BridgeType type = GetBridgeType(rampsouth); BridgeType bridge_type = GetBridgeType(rampsouth);
drawfarpillar = !HasBit(GetBridgeSpec(type)->flags, 0); drawfarpillar = !HasBit(GetBridgeSpec(bridge_type)->flags, 0);
base_offset += GetBridgeSpriteTableBaseOffset(transport_type, rampsouth);
uint base_offset; psid = GetBridgeSpriteTable(bridge_type, CalcBridgePiece(GetTunnelBridgeLength(ti->tile, rampnorth) + 1, GetTunnelBridgeLength(ti->tile, rampsouth) + 1));
if (transport_type == TRANSPORT_RAIL) {
base_offset = GetRailTypeInfo(GetRailType(rampsouth))->bridge_offset;
} else {
base_offset = 8;
}
psid = &GetBridgeSpriteTable(type, piece)[base_offset];
} else { } else {
drawfarpillar = true; drawfarpillar = true;
psid = _aqueduct_sprites; psid = _aqueduct_sprite_table_middle;
} }
psid = psid.subspan(base_offset, 3);
if (axis != AXIS_X) psid += 4;
int x = ti->x; int x = ti->x;
int y = ti->y; int y = ti->y;
@ -1614,14 +1631,12 @@ void DrawBridgeMiddle(const TileInfo *ti)
/* Draw floor and far part of bridge*/ /* Draw floor and far part of bridge*/
if (!IsInvisibilitySet(TO_BRIDGES)) { if (!IsInvisibilitySet(TO_BRIDGES)) {
if (axis == AXIS_X) { if (axis == AXIS_X) {
AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, z, {{0, 0, BRIDGE_Z_START}, {TILE_SIZE, 1, 40}, {0, 0, -BRIDGE_Z_START}}, IsTransparencySet(TO_BRIDGES)); AddSortableSpriteToDraw(psid[0].sprite, psid[0].pal, x, y, z, {{0, 0, BRIDGE_Z_START}, {TILE_SIZE, 1, 40}, {0, 0, -BRIDGE_Z_START}}, IsTransparencySet(TO_BRIDGES));
} else { } else {
AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, z, {{0, 0, BRIDGE_Z_START}, {1, TILE_SIZE, 40}, {0, 0, -BRIDGE_Z_START}}, IsTransparencySet(TO_BRIDGES)); AddSortableSpriteToDraw(psid[0].sprite, psid[0].pal, x, y, z, {{0, 0, BRIDGE_Z_START}, {1, TILE_SIZE, 40}, {0, 0, -BRIDGE_Z_START}}, IsTransparencySet(TO_BRIDGES));
} }
} }
psid++;
if (transport_type == TRANSPORT_ROAD) { if (transport_type == TRANSPORT_ROAD) {
/* DrawBridgeRoadBits() calls EndSpriteCombine() and StartSpriteCombine() */ /* DrawBridgeRoadBits() calls EndSpriteCombine() and StartSpriteCombine() */
DrawBridgeRoadBits(rampsouth, x, y, bridge_z, axis ^ 1, false); DrawBridgeRoadBits(rampsouth, x, y, bridge_z, axis ^ 1, false);
@ -1654,10 +1669,10 @@ void DrawBridgeMiddle(const TileInfo *ti)
if (!IsInvisibilitySet(TO_BRIDGES)) { if (!IsInvisibilitySet(TO_BRIDGES)) {
if (axis == AXIS_X) { if (axis == AXIS_X) {
y += 12; y += 12;
if (psid->sprite & SPRITE_MASK) AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, z, {{0, 3, BRIDGE_Z_START}, {TILE_SIZE, 1, 40}, {0, -3, -BRIDGE_Z_START}}, IsTransparencySet(TO_BRIDGES)); if (psid[1].sprite & SPRITE_MASK) AddSortableSpriteToDraw(psid[1].sprite, psid[1].pal, x, y, z, {{0, 3, BRIDGE_Z_START}, {TILE_SIZE, 1, 40}, {0, -3, -BRIDGE_Z_START}}, IsTransparencySet(TO_BRIDGES));
} else { } else {
x += 12; x += 12;
if (psid->sprite & SPRITE_MASK) AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, z, {{3, 0, BRIDGE_Z_START}, {1, TILE_SIZE, 40}, {-3, 0, -BRIDGE_Z_START}}, IsTransparencySet(TO_BRIDGES)); if (psid[1].sprite & SPRITE_MASK) AddSortableSpriteToDraw(psid[1].sprite, psid[1].pal, x, y, z, {{3, 0, BRIDGE_Z_START}, {1, TILE_SIZE, 40}, {-3, 0, -BRIDGE_Z_START}}, IsTransparencySet(TO_BRIDGES));
} }
} }
@ -1667,8 +1682,7 @@ void DrawBridgeMiddle(const TileInfo *ti)
/* Do not draw anything more if bridges are invisible */ /* Do not draw anything more if bridges are invisible */
if (IsInvisibilitySet(TO_BRIDGES)) return; if (IsInvisibilitySet(TO_BRIDGES)) return;
psid++; DrawBridgePillars(psid[2], ti, axis, drawfarpillar, x, y, z);
DrawBridgePillars(psid, ti, axis, drawfarpillar, x, y, z);
} }

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;