Fix 8c58fb1efd: Doubled beep sounds when clicking toolbar buttons.

* ShowDropDownList() now issues a beep, so individual toolbar buttons no longer need to do it.
* HandleButtonClick() may be called twice for some buttons, as it is called by automatically for PUSH buttons.

This caused some beeps to sound louder than others.
This commit is contained in:
Peter Nelson
2025-09-21 01:00:20 +01:00
committed by dP
parent c606a3e630
commit 83bd4b6d0f
2 changed files with 3 additions and 14 deletions

View File

@@ -130,7 +130,6 @@ public:
static void PopupMainToolbarMenu(Window *w, WidgetID widget, DropDownList &&list, int def)
{
ShowDropDownList(w, std::move(list), def, widget, 0, _settings_client.gui.toolbar_dropdown_autoselect);
SndClickBeep();
}
/**
@@ -321,7 +320,6 @@ static CallBackFunction ToolbarOptionsClick(Window *w)
list.push_back(MakeDropDownListCheckedItem(IsTransparencySet(TO_SIGNS), STR_SETTINGS_MENU_TRANSPARENT_SIGNS, OME_SHOW_STATIONSIGNS));
ShowDropDownList(w, std::move(list), 0, WID_TN_SETTINGS, 140, _settings_client.gui.toolbar_dropdown_autoselect);
SndClickBeep();
return CBF_NONE;
}
@@ -752,8 +750,6 @@ static CallBackFunction ToolbarGraphsClick(Window *w)
if (_toolbar_mode != TB_NORMAL) AddDropDownLeagueTableOptions(list);
ShowDropDownList(w, std::move(list), GRMN_OPERATING_PROFIT_GRAPH, WID_TN_GRAPHS, 140, _settings_client.gui.toolbar_dropdown_autoselect);
SndClickBeep();
return CBF_NONE;
}
@@ -765,8 +761,6 @@ static CallBackFunction ToolbarLeagueClick(Window *w)
int selected = list[0]->result;
ShowDropDownList(w, std::move(list), selected, WID_TN_LEAGUE, 140, _settings_client.gui.toolbar_dropdown_autoselect);
SndClickBeep();
return CBF_NONE;
}
@@ -945,7 +939,6 @@ static CallBackFunction ToolbarZoomOutClick(Window *w)
static CallBackFunction ToolbarBuildRailClick(Window *w)
{
ShowDropDownList(w, GetRailTypeDropDownList(), _last_built_railtype, WID_TN_RAILS, 140, _settings_client.gui.toolbar_dropdown_autoselect);
SndClickBeep();
return CBF_NONE;
}
@@ -967,7 +960,6 @@ static CallBackFunction MenuClickBuildRail(int index)
static CallBackFunction ToolbarBuildRoadClick(Window *w)
{
ShowDropDownList(w, GetRoadTypeDropDownList(RTTB_ROAD), _last_built_roadtype, WID_TN_ROADS, 140, _settings_client.gui.toolbar_dropdown_autoselect);
SndClickBeep();
return CBF_NONE;
}
@@ -989,7 +981,6 @@ static CallBackFunction MenuClickBuildRoad(int index)
static CallBackFunction ToolbarBuildTramClick(Window *w)
{
ShowDropDownList(w, GetRoadTypeDropDownList(RTTB_TRAM), _last_built_tramtype, WID_TN_TRAMS, 140, _settings_client.gui.toolbar_dropdown_autoselect);
SndClickBeep();
return CBF_NONE;
}
@@ -1013,7 +1004,6 @@ static CallBackFunction ToolbarBuildWaterClick(Window *w)
DropDownList list;
list.push_back(MakeDropDownListIconItem(SPR_IMG_BUILD_CANAL, PAL_NONE, STR_WATERWAYS_MENU_WATERWAYS_CONSTRUCTION, 0));
ShowDropDownList(w, std::move(list), 0, WID_TN_WATER, 140, _settings_client.gui.toolbar_dropdown_autoselect);
SndClickBeep();
return CBF_NONE;
}
@@ -1035,7 +1025,6 @@ static CallBackFunction ToolbarBuildAirClick(Window *w)
DropDownList list;
list.push_back(MakeDropDownListIconItem(SPR_IMG_AIRPORT, PAL_NONE, STR_AIRCRAFT_MENU_AIRPORT_CONSTRUCTION, 0));
ShowDropDownList(w, std::move(list), 0, WID_TN_AIR, 140, _settings_client.gui.toolbar_dropdown_autoselect);
SndClickBeep();
return CBF_NONE;
}
@@ -1059,7 +1048,6 @@ static CallBackFunction ToolbarForestClick(Window *w)
list.push_back(MakeDropDownListIconItem(SPR_IMG_PLANTTREES, PAL_NONE, STR_LANDSCAPING_MENU_PLANT_TREES, 1));
list.push_back(MakeDropDownListIconItem(SPR_IMG_SIGN, PAL_NONE, STR_LANDSCAPING_MENU_PLACE_SIGN, 2));
ShowDropDownList(w, std::move(list), 0, WID_TN_LANDSCAPE, 100, _settings_client.gui.toolbar_dropdown_autoselect);
SndClickBeep();
return CBF_NONE;
}
@@ -1331,7 +1319,6 @@ static CallBackFunction ToolbarScenGenIndustry(Window *w)
static CallBackFunction ToolbarScenBuildRoadClick(Window *w)
{
ShowDropDownList(w, GetScenRoadTypeDropDownList(RTTB_ROAD), _last_built_roadtype, WID_TE_ROADS, 140, _settings_client.gui.toolbar_dropdown_autoselect);
SndClickBeep();
return CBF_NONE;
}
@@ -1351,7 +1338,6 @@ static CallBackFunction ToolbarScenBuildRoad(int index)
static CallBackFunction ToolbarScenBuildTramClick(Window *w)
{
ShowDropDownList(w, GetScenRoadTypeDropDownList(RTTB_TRAM), _last_built_tramtype, WID_TE_TRAMS, 140, _settings_client.gui.toolbar_dropdown_autoselect);
SndClickBeep();
return CBF_NONE;
}

View File

@@ -603,6 +603,9 @@ EventState Window::OnHotkey(int hotkey)
*/
void Window::HandleButtonClick(WidgetID widget)
{
/* Button click for this widget may already have been handled. */
if (this->IsWidgetLowered(widget) && this->timeout_timer == TIMEOUT_DURATION) return;
this->LowerWidget(widget);
this->SetTimeout();
this->SetWidgetDirty(widget);