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

Avoids repetition.
This commit is contained in:
Peter Nelson
2025-07-27 21:54:32 +01:00
committed by GitHub
parent f51067f9f5
commit 614a01907a
17 changed files with 73 additions and 54 deletions

View File

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