1
0
Fork 0

Codechange: Make functions for click and confirm beeps. (#14484)

Avoids repetition.
pull/14487/head
Peter Nelson 2025-07-27 21:54:32 +01:00 committed by GitHub
parent f51067f9f5
commit 614a01907a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
17 changed files with 73 additions and 54 deletions

View File

@ -509,7 +509,7 @@ public:
this->SetWidgetLoweredState(WID_AP_BTN_DONTHILIGHT, !_settings_client.gui.station_show_coverage); this->SetWidgetLoweredState(WID_AP_BTN_DONTHILIGHT, !_settings_client.gui.station_show_coverage);
this->SetWidgetLoweredState(WID_AP_BTN_DOHILIGHT, _settings_client.gui.station_show_coverage); this->SetWidgetLoweredState(WID_AP_BTN_DOHILIGHT, _settings_client.gui.station_show_coverage);
this->SetDirty(); this->SetDirty();
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); SndClickBeep();
this->UpdateSelectSize(); this->UpdateSelectSize();
SetViewportCatchmentStation(nullptr, true); SetViewportCatchmentStation(nullptr, true);
break; break;

View File

@ -469,7 +469,7 @@ public:
this->RaiseWidget(_settings_client.gui.station_show_coverage + BDSW_LT_OFF); this->RaiseWidget(_settings_client.gui.station_show_coverage + BDSW_LT_OFF);
_settings_client.gui.station_show_coverage = (widget != BDSW_LT_OFF); _settings_client.gui.station_show_coverage = (widget != BDSW_LT_OFF);
this->LowerWidget(_settings_client.gui.station_show_coverage + BDSW_LT_OFF); this->LowerWidget(_settings_client.gui.station_show_coverage + BDSW_LT_OFF);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); SndClickBeep();
this->SetDirty(); this->SetDirty();
SetViewportCatchmentStation(nullptr, true); SetViewportCatchmentStation(nullptr, true);
break; break;
@ -580,7 +580,7 @@ public:
this->RaiseWidget(WID_BDD_X + _ship_depot_direction); this->RaiseWidget(WID_BDD_X + _ship_depot_direction);
_ship_depot_direction = (widget == WID_BDD_X ? AXIS_X : AXIS_Y); _ship_depot_direction = (widget == WID_BDD_X ? AXIS_X : AXIS_Y);
this->LowerWidget(WID_BDD_X + _ship_depot_direction); this->LowerWidget(WID_BDD_X + _ship_depot_direction);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); SndClickBeep();
UpdateDocksDirection(); UpdateDocksDirection();
this->SetDirty(); this->SetDirty();
break; break;

View File

@ -323,7 +323,7 @@ static void StartGeneratingLandscape(GenerateLandscapeWindowMode mode)
MakeNewgameSettingsLive(); MakeNewgameSettingsLive();
ResetGRFConfig(true); ResetGRFConfig(true);
if (_settings_client.sound.confirm) SndPlayFx(SND_15_BEEP); SndConfirmBeep();
switch (mode) { switch (mode) {
case GLWM_GENERATE: _switch_mode = (_game_mode == GM_EDITOR) ? SM_GENRANDLAND : SM_NEWGAME; break; case GLWM_GENERATE: _switch_mode = (_game_mode == GM_EDITOR) ? SM_GENRANDLAND : SM_NEWGAME; break;
case GLWM_HEIGHTMAP: _switch_mode = (_game_mode == GM_EDITOR) ? SM_LOAD_HEIGHTMAP : SM_START_HEIGHTMAP; break; case GLWM_HEIGHTMAP: _switch_mode = (_game_mode == GM_EDITOR) ? SM_LOAD_HEIGHTMAP : SM_START_HEIGHTMAP; break;

View File

@ -3076,7 +3076,7 @@ struct IndustryCargoesWindow : public Window {
case WID_IC_NOTIFY: case WID_IC_NOTIFY:
this->ToggleWidgetLoweredState(WID_IC_NOTIFY); this->ToggleWidgetLoweredState(WID_IC_NOTIFY);
this->SetWidgetDirty(WID_IC_NOTIFY); this->SetWidgetDirty(WID_IC_NOTIFY);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); SndClickBeep();
if (this->IsWidgetLowered(WID_IC_NOTIFY)) { if (this->IsWidgetLowered(WID_IC_NOTIFY)) {
if (FindWindowByClass(WC_SMALLMAP) == nullptr) ShowSmallMap(); if (FindWindowByClass(WC_SMALLMAP) == nullptr) ShowSmallMap();

View File

@ -64,7 +64,7 @@ bool HandlePlacePushButton(Window *w, WidgetID widget, CursorID cursor, HighLigh
{ {
if (w->IsWidgetDisabled(widget)) return false; if (w->IsWidgetDisabled(widget)) return false;
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); SndClickBeep();
w->SetDirty(); w->SetDirty();
if (w->IsWidgetLowered(widget)) { if (w->IsWidgetLowered(widget)) {

View File

@ -319,7 +319,7 @@ public:
if (_object_gui.sel_type != std::numeric_limits<uint16_t>::max()) { if (_object_gui.sel_type != std::numeric_limits<uint16_t>::max()) {
_object_gui.sel_view = this->GetWidget<NWidgetBase>(widget)->GetParentWidget<NWidgetMatrix>()->GetCurrentElement(); _object_gui.sel_view = this->GetWidget<NWidgetBase>(widget)->GetParentWidget<NWidgetMatrix>()->GetCurrentElement();
this->InvalidateData(PickerInvalidation::Position); this->InvalidateData(PickerInvalidation::Position);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); SndClickBeep();
} }
break; break;

View File

@ -384,7 +384,7 @@ void PickerWindow::OnClick(Point pt, WidgetID widget, int)
this->callbacks.SetSelectedClass(*it); this->callbacks.SetSelectedClass(*it);
this->InvalidateData({PickerInvalidation::Type, PickerInvalidation::Position, PickerInvalidation::Validate}); this->InvalidateData({PickerInvalidation::Type, PickerInvalidation::Position, PickerInvalidation::Validate});
} }
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); SndClickBeep();
CloseWindowById(WC_SELECT_STATION, 0); CloseWindowById(WC_SELECT_STATION, 0);
break; break;
} }
@ -434,7 +434,7 @@ void PickerWindow::OnClick(Point pt, WidgetID widget, int)
this->callbacks.SetSelectedType(item.index); this->callbacks.SetSelectedType(item.index);
this->InvalidateData(PickerInvalidation::Position); this->InvalidateData(PickerInvalidation::Position);
} }
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); SndClickBeep();
CloseWindowById(WC_SELECT_STATION, 0); CloseWindowById(WC_SELECT_STATION, 0);
break; break;
} }

View File

@ -357,7 +357,7 @@ static void BuildRailClick_Remove(Window *w)
{ {
if (w->IsWidgetDisabled(WID_RAT_REMOVE)) return; if (w->IsWidgetDisabled(WID_RAT_REMOVE)) return;
ToggleRailButton_Remove(w); ToggleRailButton_Remove(w);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); SndClickBeep();
/* handle station builder */ /* handle station builder */
if (w->IsWidgetLowered(WID_RAT_BUILD_STATION)) { if (w->IsWidgetLowered(WID_RAT_BUILD_STATION)) {
@ -1239,7 +1239,7 @@ public:
this->RaiseWidget(WID_BRAS_PLATFORM_DIR_X + _station_gui.axis); this->RaiseWidget(WID_BRAS_PLATFORM_DIR_X + _station_gui.axis);
_station_gui.axis = (Axis)(widget - WID_BRAS_PLATFORM_DIR_X); _station_gui.axis = (Axis)(widget - WID_BRAS_PLATFORM_DIR_X);
this->LowerWidget(WID_BRAS_PLATFORM_DIR_X + _station_gui.axis); this->LowerWidget(WID_BRAS_PLATFORM_DIR_X + _station_gui.axis);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); SndClickBeep();
this->SetDirty(); this->SetDirty();
CloseWindowById(WC_SELECT_STATION, 0); CloseWindowById(WC_SELECT_STATION, 0);
break; break;
@ -1271,7 +1271,7 @@ public:
this->LowerWidget(_settings_client.gui.station_numtracks + WID_BRAS_PLATFORM_NUM_BEGIN); this->LowerWidget(_settings_client.gui.station_numtracks + WID_BRAS_PLATFORM_NUM_BEGIN);
this->LowerWidget(_settings_client.gui.station_platlength + WID_BRAS_PLATFORM_LEN_BEGIN); this->LowerWidget(_settings_client.gui.station_platlength + WID_BRAS_PLATFORM_LEN_BEGIN);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); SndClickBeep();
this->SetDirty(); this->SetDirty();
CloseWindowById(WC_SELECT_STATION, 0); CloseWindowById(WC_SELECT_STATION, 0);
break; break;
@ -1304,7 +1304,7 @@ public:
this->LowerWidget(_settings_client.gui.station_numtracks + WID_BRAS_PLATFORM_NUM_BEGIN); this->LowerWidget(_settings_client.gui.station_numtracks + WID_BRAS_PLATFORM_NUM_BEGIN);
this->LowerWidget(_settings_client.gui.station_platlength + WID_BRAS_PLATFORM_LEN_BEGIN); this->LowerWidget(_settings_client.gui.station_platlength + WID_BRAS_PLATFORM_LEN_BEGIN);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); SndClickBeep();
this->SetDirty(); this->SetDirty();
CloseWindowById(WC_SELECT_STATION, 0); CloseWindowById(WC_SELECT_STATION, 0);
break; break;
@ -1338,7 +1338,7 @@ public:
this->SetWidgetLoweredState(_settings_client.gui.station_numtracks + WID_BRAS_PLATFORM_NUM_BEGIN, !_settings_client.gui.station_dragdrop); this->SetWidgetLoweredState(_settings_client.gui.station_numtracks + WID_BRAS_PLATFORM_NUM_BEGIN, !_settings_client.gui.station_dragdrop);
this->SetWidgetLoweredState(_settings_client.gui.station_platlength + WID_BRAS_PLATFORM_LEN_BEGIN, !_settings_client.gui.station_dragdrop); this->SetWidgetLoweredState(_settings_client.gui.station_platlength + WID_BRAS_PLATFORM_LEN_BEGIN, !_settings_client.gui.station_dragdrop);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); SndClickBeep();
this->SetDirty(); this->SetDirty();
CloseWindowById(WC_SELECT_STATION, 0); CloseWindowById(WC_SELECT_STATION, 0);
break; break;
@ -1350,7 +1350,7 @@ public:
this->SetWidgetLoweredState(WID_BRAS_HIGHLIGHT_OFF, !_settings_client.gui.station_show_coverage); this->SetWidgetLoweredState(WID_BRAS_HIGHLIGHT_OFF, !_settings_client.gui.station_show_coverage);
this->SetWidgetLoweredState(WID_BRAS_HIGHLIGHT_ON, _settings_client.gui.station_show_coverage); this->SetWidgetLoweredState(WID_BRAS_HIGHLIGHT_ON, _settings_client.gui.station_show_coverage);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); SndClickBeep();
this->SetDirty(); this->SetDirty();
SetViewportCatchmentStation(nullptr, true); SetViewportCatchmentStation(nullptr, true);
break; break;
@ -1743,7 +1743,7 @@ struct BuildRailDepotWindow : public PickerWindowBase {
this->RaiseWidget(WID_BRAD_DEPOT_NE + _build_depot_direction); this->RaiseWidget(WID_BRAD_DEPOT_NE + _build_depot_direction);
_build_depot_direction = (DiagDirection)(widget - WID_BRAD_DEPOT_NE); _build_depot_direction = (DiagDirection)(widget - WID_BRAD_DEPOT_NE);
this->LowerWidget(WID_BRAD_DEPOT_NE + _build_depot_direction); this->LowerWidget(WID_BRAD_DEPOT_NE + _build_depot_direction);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); SndClickBeep();
this->SetDirty(); this->SetDirty();
break; break;
} }

View File

@ -582,7 +582,7 @@ struct BuildRoadToolbarWindow : Window {
CloseWindowById(WC_SELECT_STATION, 0); CloseWindowById(WC_SELECT_STATION, 0);
ToggleRoadButton_Remove(this); ToggleRoadButton_Remove(this);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); SndClickBeep();
break; break;
case WID_ROT_CONVERT_ROAD: case WID_ROT_CONVERT_ROAD:
@ -1145,7 +1145,7 @@ struct BuildRoadDepotWindow : public PickerWindowBase {
this->RaiseWidget(WID_BROD_DEPOT_NE + _road_depot_orientation); this->RaiseWidget(WID_BROD_DEPOT_NE + _road_depot_orientation);
_road_depot_orientation = (DiagDirection)(widget - WID_BROD_DEPOT_NE); _road_depot_orientation = (DiagDirection)(widget - WID_BROD_DEPOT_NE);
this->LowerWidget(WID_BROD_DEPOT_NE + _road_depot_orientation); this->LowerWidget(WID_BROD_DEPOT_NE + _road_depot_orientation);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); SndClickBeep();
this->SetDirty(); this->SetDirty();
break; break;
@ -1477,7 +1477,7 @@ public:
this->RaiseWidget(WID_BROS_STATION_NE + _roadstop_gui.orientation); this->RaiseWidget(WID_BROS_STATION_NE + _roadstop_gui.orientation);
_roadstop_gui.orientation = (DiagDirection)(widget - WID_BROS_STATION_NE); _roadstop_gui.orientation = (DiagDirection)(widget - WID_BROS_STATION_NE);
this->LowerWidget(WID_BROS_STATION_NE + _roadstop_gui.orientation); this->LowerWidget(WID_BROS_STATION_NE + _roadstop_gui.orientation);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); SndClickBeep();
this->SetDirty(); this->SetDirty();
CloseWindowById(WC_SELECT_STATION, 0); CloseWindowById(WC_SELECT_STATION, 0);
break; break;
@ -1487,7 +1487,7 @@ public:
this->RaiseWidget(_settings_client.gui.station_show_coverage + WID_BROS_LT_OFF); this->RaiseWidget(_settings_client.gui.station_show_coverage + WID_BROS_LT_OFF);
_settings_client.gui.station_show_coverage = (widget != WID_BROS_LT_OFF); _settings_client.gui.station_show_coverage = (widget != WID_BROS_LT_OFF);
this->LowerWidget(_settings_client.gui.station_show_coverage + WID_BROS_LT_OFF); this->LowerWidget(_settings_client.gui.station_show_coverage + WID_BROS_LT_OFF);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); SndClickBeep();
this->SetDirty(); this->SetDirty();
SetViewportCatchmentStation(nullptr, true); SetViewportCatchmentStation(nullptr, true);
break; break;

View File

@ -1717,7 +1717,7 @@ public:
const NWidgetBase *wid = this->GetWidget<NWidgetBase>(WID_SM_MAP); const NWidgetBase *wid = this->GetWidget<NWidgetBase>(WID_SM_MAP);
Point zoom_pt = { (int)wid->current_x / 2, (int)wid->current_y / 2}; Point zoom_pt = { (int)wid->current_x / 2, (int)wid->current_y / 2};
this->SetZoomLevel((widget == WID_SM_ZOOM_IN) ? ZLC_ZOOM_IN : ZLC_ZOOM_OUT, &zoom_pt); this->SetZoomLevel((widget == WID_SM_ZOOM_IN) ? ZLC_ZOOM_IN : ZLC_ZOOM_OUT, &zoom_pt);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); SndClickBeep();
break; break;
} }
@ -1729,13 +1729,13 @@ public:
case WID_SM_VEGETATION: // Show vegetation case WID_SM_VEGETATION: // Show vegetation
case WID_SM_OWNERS: // Show land owners case WID_SM_OWNERS: // Show land owners
this->SwitchMapType((SmallMapType)(widget - WID_SM_CONTOUR)); this->SwitchMapType((SmallMapType)(widget - WID_SM_CONTOUR));
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); SndClickBeep();
break; break;
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); SndClickBeep();
break; break;
case WID_SM_TOGGLETOWNNAME: // Toggle town names case WID_SM_TOGGLETOWNNAME: // Toggle town names
@ -1743,7 +1743,7 @@ public:
this->SetWidgetLoweredState(WID_SM_TOGGLETOWNNAME, this->show_towns); this->SetWidgetLoweredState(WID_SM_TOGGLETOWNNAME, this->show_towns);
this->SetDirty(); this->SetDirty();
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); SndClickBeep();
break; break;
case WID_SM_SHOW_IND_NAMES: // Toggle industry names case WID_SM_SHOW_IND_NAMES: // Toggle industry names
@ -1751,7 +1751,7 @@ public:
this->SetWidgetLoweredState(WID_SM_SHOW_IND_NAMES, this->show_ind_names); this->SetWidgetLoweredState(WID_SM_SHOW_IND_NAMES, this->show_ind_names);
this->SetDirty(); this->SetDirty();
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); SndClickBeep();
break; break;
case WID_SM_LEGEND: // Legend case WID_SM_LEGEND: // Legend

View File

@ -247,6 +247,22 @@ void SndPlayFx(SoundID sound)
StartSound(sound, 0.5, UINT8_MAX); StartSound(sound, 0.5, UINT8_MAX);
} }
/**
* Play a beep sound for a click event if enabled in settings.
*/
void SndClickBeep()
{
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
}
/**
* Play a beep sound for a confirm event if enabled in settings.
*/
void SndConfirmBeep()
{
if (_settings_client.sound.confirm) SndPlayFx(SND_15_BEEP);
}
/** Names corresponding to the sound set's files */ /** Names corresponding to the sound set's files */
static const std::string_view _sound_file_names[] = { "samples" }; static const std::string_view _sound_file_names[] = { "samples" };

View File

@ -21,4 +21,7 @@ void SndPlayVehicleFx(SoundID sound, const Vehicle *v);
void SndPlayFx(SoundID sound); void SndPlayFx(SoundID sound);
void SndCopyToPool(); void SndCopyToPool();
void SndClickBeep();
void SndConfirmBeep();
#endif /* SOUND_FUNC_H */ #endif /* SOUND_FUNC_H */

View File

@ -621,7 +621,7 @@ 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); SndClickBeep();
this->SetDirty(); this->SetDirty();
break; break;
} }

View File

@ -117,7 +117,7 @@ public:
static void PopupMainToolbarMenu(Window *w, WidgetID widget, DropDownList &&list, int def) static void PopupMainToolbarMenu(Window *w, WidgetID widget, DropDownList &&list, int def)
{ {
ShowDropDownList(w, std::move(list), def, widget, 0, true); ShowDropDownList(w, std::move(list), def, widget, 0, true);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); SndClickBeep();
} }
/** /**
@ -204,7 +204,7 @@ static CallBackFunction ToolbarPauseClick(Window *)
if (_networking && !_network_server) return CBF_NONE; // only server can pause the game if (_networking && !_network_server) return CBF_NONE; // only server can pause the game
if (Command<CMD_PAUSE>::Post(PauseMode::Normal, _pause_mode.None())) { if (Command<CMD_PAUSE>::Post(PauseMode::Normal, _pause_mode.None())) {
if (_settings_client.sound.confirm) SndPlayFx(SND_15_BEEP); SndConfirmBeep();
} }
return CBF_NONE; return CBF_NONE;
} }
@ -220,7 +220,7 @@ static CallBackFunction ToolbarFastForwardClick(Window *)
ChangeGameSpeed(_game_speed == 100); ChangeGameSpeed(_game_speed == 100);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); SndClickBeep();
return CBF_NONE; return CBF_NONE;
} }
@ -291,7 +291,7 @@ static CallBackFunction ToolbarOptionsClick(Window *w)
list.push_back(MakeDropDownListCheckedItem(IsTransparencySet(TO_SIGNS), STR_SETTINGS_MENU_TRANSPARENT_SIGNS, OME_SHOW_STATIONSIGNS)); 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, true); ShowDropDownList(w, std::move(list), 0, WID_TN_SETTINGS, 140, true);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); SndClickBeep();
return CBF_NONE; return CBF_NONE;
} }
@ -684,7 +684,7 @@ static CallBackFunction ToolbarGraphsClick(Window *w)
if (_toolbar_mode != TB_NORMAL) AddDropDownLeagueTableOptions(list); if (_toolbar_mode != TB_NORMAL) AddDropDownLeagueTableOptions(list);
ShowDropDownList(w, std::move(list), GRMN_OPERATING_PROFIT_GRAPH, WID_TN_GRAPHS, 140, true); ShowDropDownList(w, std::move(list), GRMN_OPERATING_PROFIT_GRAPH, WID_TN_GRAPHS, 140, true);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); SndClickBeep();
return CBF_NONE; return CBF_NONE;
} }
@ -697,7 +697,7 @@ static CallBackFunction ToolbarLeagueClick(Window *w)
int selected = list[0]->result; int selected = list[0]->result;
ShowDropDownList(w, std::move(list), selected, WID_TN_LEAGUE, 140, true); ShowDropDownList(w, std::move(list), selected, WID_TN_LEAGUE, 140, true);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); SndClickBeep();
return CBF_NONE; return CBF_NONE;
} }
@ -857,7 +857,7 @@ 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); SndClickBeep();
} }
return CBF_NONE; return CBF_NONE;
} }
@ -868,7 +868,7 @@ 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); SndClickBeep();
} }
return CBF_NONE; return CBF_NONE;
} }
@ -878,7 +878,7 @@ static CallBackFunction ToolbarZoomOutClick(Window *w)
static CallBackFunction ToolbarBuildRailClick(Window *w) static CallBackFunction ToolbarBuildRailClick(Window *w)
{ {
ShowDropDownList(w, GetRailTypeDropDownList(), _last_built_railtype, WID_TN_RAILS, 140, true); ShowDropDownList(w, GetRailTypeDropDownList(), _last_built_railtype, WID_TN_RAILS, 140, true);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); SndClickBeep();
return CBF_NONE; return CBF_NONE;
} }
@ -900,7 +900,7 @@ static CallBackFunction MenuClickBuildRail(int index)
static CallBackFunction ToolbarBuildRoadClick(Window *w) static CallBackFunction ToolbarBuildRoadClick(Window *w)
{ {
ShowDropDownList(w, GetRoadTypeDropDownList(RTTB_ROAD), _last_built_roadtype, WID_TN_ROADS, 140, true); ShowDropDownList(w, GetRoadTypeDropDownList(RTTB_ROAD), _last_built_roadtype, WID_TN_ROADS, 140, true);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); SndClickBeep();
return CBF_NONE; return CBF_NONE;
} }
@ -922,7 +922,7 @@ static CallBackFunction MenuClickBuildRoad(int index)
static CallBackFunction ToolbarBuildTramClick(Window *w) static CallBackFunction ToolbarBuildTramClick(Window *w)
{ {
ShowDropDownList(w, GetRoadTypeDropDownList(RTTB_TRAM), _last_built_tramtype, WID_TN_TRAMS, 140, true); ShowDropDownList(w, GetRoadTypeDropDownList(RTTB_TRAM), _last_built_tramtype, WID_TN_TRAMS, 140, true);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); SndClickBeep();
return CBF_NONE; return CBF_NONE;
} }
@ -946,7 +946,7 @@ static CallBackFunction ToolbarBuildWaterClick(Window *w)
DropDownList list; DropDownList list;
list.push_back(MakeDropDownListIconItem(SPR_IMG_BUILD_CANAL, PAL_NONE, STR_WATERWAYS_MENU_WATERWAYS_CONSTRUCTION, 0)); 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, true); ShowDropDownList(w, std::move(list), 0, WID_TN_WATER, 140, true);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); SndClickBeep();
return CBF_NONE; return CBF_NONE;
} }
@ -968,7 +968,7 @@ static CallBackFunction ToolbarBuildAirClick(Window *w)
DropDownList list; DropDownList list;
list.push_back(MakeDropDownListIconItem(SPR_IMG_AIRPORT, PAL_NONE, STR_AIRCRAFT_MENU_AIRPORT_CONSTRUCTION, 0)); 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, true); ShowDropDownList(w, std::move(list), 0, WID_TN_AIR, 140, true);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); SndClickBeep();
return CBF_NONE; return CBF_NONE;
} }
@ -992,7 +992,7 @@ 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_PLANTTREES, PAL_NONE, STR_LANDSCAPING_MENU_PLANT_TREES, 1));
list.push_back(MakeDropDownListIconItem(SPR_IMG_SIGN, PAL_NONE, STR_LANDSCAPING_MENU_PLACE_SIGN, 2)); 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, true); ShowDropDownList(w, std::move(list), 0, WID_TN_LANDSCAPE, 100, true);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); SndClickBeep();
return CBF_NONE; return CBF_NONE;
} }
@ -1188,7 +1188,7 @@ static CallBackFunction ToolbarSwitchClick(Window *w)
w->ReInit(); w->ReInit();
w->SetWidgetLoweredState(_game_mode == GM_EDITOR ? (WidgetID)WID_TE_SWITCH_BAR : (WidgetID)WID_TN_SWITCH_BAR, _toolbar_mode == TB_LOWER); w->SetWidgetLoweredState(_game_mode == GM_EDITOR ? (WidgetID)WID_TE_SWITCH_BAR : (WidgetID)WID_TN_SWITCH_BAR, _toolbar_mode == TB_LOWER);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); SndClickBeep();
return CBF_NONE; return CBF_NONE;
} }
@ -1232,7 +1232,7 @@ 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); SndClickBeep();
ShowEditorTerraformToolbar(); ShowEditorTerraformToolbar();
return CBF_NONE; return CBF_NONE;
@ -1256,7 +1256,7 @@ 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); SndClickBeep();
ShowBuildIndustryWindow(); ShowBuildIndustryWindow();
return CBF_NONE; return CBF_NONE;
} }
@ -1264,7 +1264,7 @@ static CallBackFunction ToolbarScenGenIndustry(Window *w)
static CallBackFunction ToolbarScenBuildRoadClick(Window *w) static CallBackFunction ToolbarScenBuildRoadClick(Window *w)
{ {
ShowDropDownList(w, GetScenRoadTypeDropDownList(RTTB_ROAD), _last_built_roadtype, WID_TE_ROADS, 140, true); ShowDropDownList(w, GetScenRoadTypeDropDownList(RTTB_ROAD), _last_built_roadtype, WID_TE_ROADS, 140, true);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); SndClickBeep();
return CBF_NONE; return CBF_NONE;
} }
@ -1284,7 +1284,7 @@ static CallBackFunction ToolbarScenBuildRoad(int index)
static CallBackFunction ToolbarScenBuildTramClick(Window *w) static CallBackFunction ToolbarScenBuildTramClick(Window *w)
{ {
ShowDropDownList(w, GetScenRoadTypeDropDownList(RTTB_TRAM), _last_built_tramtype, WID_TE_TRAMS, 140, true); ShowDropDownList(w, GetScenRoadTypeDropDownList(RTTB_TRAM), _last_built_tramtype, WID_TE_TRAMS, 140, true);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); SndClickBeep();
return CBF_NONE; return CBF_NONE;
} }
@ -1304,7 +1304,7 @@ 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); SndClickBeep();
ShowBuildDocksScenToolbar(); ShowBuildDocksScenToolbar();
return CBF_NONE; return CBF_NONE;
} }
@ -1312,7 +1312,7 @@ 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); SndClickBeep();
ShowBuildTreesToolbar(); ShowBuildTreesToolbar();
return CBF_NONE; return CBF_NONE;
} }
@ -1320,7 +1320,7 @@ 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); SndClickBeep();
return SelectSignTool(); return SelectSignTool();
} }
@ -2407,7 +2407,7 @@ struct ScenarioEditorToolbarWindow : Window {
{ {
CallBackFunction cbf = _scen_toolbar_dropdown_procs[widget](index); CallBackFunction cbf = _scen_toolbar_dropdown_procs[widget](index);
if (cbf != CBF_NONE) _last_started_action = cbf; if (cbf != CBF_NONE) _last_started_action = cbf;
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); SndClickBeep();
} }
EventState OnHotkey(int hotkey) override EventState OnHotkey(int hotkey) override

View File

@ -1739,7 +1739,7 @@ struct BuildHouseWindow : public PickerWindow {
this->SetWidgetLoweredState(WID_BH_PROTECT_OFF, !BuildHouseWindow::house_protected); this->SetWidgetLoweredState(WID_BH_PROTECT_OFF, !BuildHouseWindow::house_protected);
this->SetWidgetLoweredState(WID_BH_PROTECT_ON, BuildHouseWindow::house_protected); this->SetWidgetLoweredState(WID_BH_PROTECT_ON, BuildHouseWindow::house_protected);
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); SndClickBeep();
this->SetDirty(); this->SetDirty();
break; break;

View File

@ -80,7 +80,7 @@ public:
} else { } else {
/* toggle the bit of the transparencies variable and play a sound */ /* toggle the bit of the transparencies variable and play a sound */
ToggleTransparency((TransparencyOption)(widget - WID_TT_BEGIN)); ToggleTransparency((TransparencyOption)(widget - WID_TT_BEGIN));
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); SndClickBeep();
MarkWholeScreenDirty(); MarkWholeScreenDirty();
} }
} else if (widget == WID_TT_BUTTONS) { } else if (widget == WID_TT_BUTTONS) {
@ -94,7 +94,7 @@ public:
if (i == WID_TT_TEXT|| i == WID_TT_END) return; if (i == WID_TT_TEXT|| i == WID_TT_END) return;
ToggleInvisibility((TransparencyOption)(i - WID_TT_BEGIN)); ToggleInvisibility((TransparencyOption)(i - WID_TT_BEGIN));
if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); SndClickBeep();
/* Redraw whole screen only if transparency is set */ /* Redraw whole screen only if transparency is set */
if (IsTransparencySet((TransparencyOption)(i - WID_TT_BEGIN))) { if (IsTransparencySet((TransparencyOption)(i - WID_TT_BEGIN))) {

View File

@ -102,7 +102,7 @@ class BuildTreesWindow : public Window
if (this->tree_to_plant >= 0) { if (this->tree_to_plant >= 0) {
/* Activate placement */ /* Activate placement */
if (_settings_client.sound.confirm) SndPlayFx(SND_15_BEEP); SndConfirmBeep();
SetObjectToPlace(SPR_CURSOR_TREE, PAL_NONE, HT_RECT | HT_DIAGONAL, this->window_class, this->window_number); SetObjectToPlace(SPR_CURSOR_TREE, PAL_NONE, HT_RECT | HT_DIAGONAL, this->window_class, this->window_number);
this->tree_to_plant = current_tree; // SetObjectToPlace may call ResetObjectToPlace which may reset tree_to_plant to -1 this->tree_to_plant = current_tree; // SetObjectToPlace may call ResetObjectToPlace which may reset tree_to_plant to -1
} else { } else {
@ -180,7 +180,7 @@ public:
break; break;
case WID_BT_MANY_RANDOM: // place trees randomly over the landscape case WID_BT_MANY_RANDOM: // place trees randomly over the landscape
if (_settings_client.sound.confirm) SndPlayFx(SND_15_BEEP); SndConfirmBeep();
PlaceTreesRandomly(); PlaceTreesRandomly();
MarkWholeScreenDirty(); MarkWholeScreenDirty();
break; break;