From ce6bc216419c074a58cae2d412899f4bc197c592 Mon Sep 17 00:00:00 2001 From: Tyler Trahan Date: Sun, 20 Jul 2025 20:50:20 -0400 Subject: [PATCH] Codechange: Handle "beep" sound within Window::HandleButtonClick() --- src/smallmap_gui.cpp | 1 - src/terraform_gui.cpp | 1 - src/toolbar_gui.cpp | 7 ------- src/window.cpp | 2 ++ 4 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index 9c4220c42a..8dfa5172a2 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -1735,7 +1735,6 @@ public: case WID_SM_CENTERMAP: // Center the smallmap again this->SmallMapCenterOnCurrentPos(); this->HandleButtonClick(WID_SM_CENTERMAP); - if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); break; case WID_SM_TOGGLETOWNNAME: // Toggle town names diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp index 346b728cc6..ab81c7004f 100644 --- a/src/terraform_gui.cpp +++ b/src/terraform_gui.cpp @@ -621,7 +621,6 @@ struct ScenarioEditorLandscapeGenerationWindow : Window { if (!IsInsideMM(size, 1, 8 + 1)) return; _terraform_size = size; - if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); this->SetDirty(); break; } diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index a82d581990..b74bff1ace 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -857,7 +857,6 @@ static CallBackFunction ToolbarZoomInClick(Window *w) { if (DoZoomInOutWindow(ZOOM_IN, GetMainWindow())) { w->HandleButtonClick((_game_mode == GM_EDITOR) ? (WidgetID)WID_TE_ZOOM_IN : (WidgetID)WID_TN_ZOOM_IN); - if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); } return CBF_NONE; } @@ -868,7 +867,6 @@ static CallBackFunction ToolbarZoomOutClick(Window *w) { if (DoZoomInOutWindow(ZOOM_OUT, GetMainWindow())) { w->HandleButtonClick((_game_mode == GM_EDITOR) ? (WidgetID)WID_TE_ZOOM_OUT : (WidgetID)WID_TN_ZOOM_OUT); - if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); } return CBF_NONE; } @@ -1232,7 +1230,6 @@ static CallBackFunction ToolbarScenDateForward(Window *w) static CallBackFunction ToolbarScenGenLand(Window *w) { w->HandleButtonClick(WID_TE_LAND_GENERATE); - if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); ShowEditorTerraformToolbar(); return CBF_NONE; @@ -1256,7 +1253,6 @@ static CallBackFunction ToolbarScenGenTown(int index) static CallBackFunction ToolbarScenGenIndustry(Window *w) { w->HandleButtonClick(WID_TE_INDUSTRY); - if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); ShowBuildIndustryWindow(); return CBF_NONE; } @@ -1304,7 +1300,6 @@ static CallBackFunction ToolbarScenBuildTram(int index) static CallBackFunction ToolbarScenBuildDocks(Window *w) { w->HandleButtonClick(WID_TE_WATER); - if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); ShowBuildDocksScenToolbar(); return CBF_NONE; } @@ -1312,7 +1307,6 @@ static CallBackFunction ToolbarScenBuildDocks(Window *w) static CallBackFunction ToolbarScenPlantTrees(Window *w) { w->HandleButtonClick(WID_TE_TREES); - if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); ShowBuildTreesToolbar(); return CBF_NONE; } @@ -1320,7 +1314,6 @@ static CallBackFunction ToolbarScenPlantTrees(Window *w) static CallBackFunction ToolbarScenPlaceSign(Window *w) { w->HandleButtonClick(WID_TE_SIGNS); - if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); return SelectSignTool(); } diff --git a/src/window.cpp b/src/window.cpp index 6ae18eda28..4a4dedf938 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -36,6 +36,7 @@ #include "framerate_type.h" #include "network/network_func.h" #include "news_func.h" +#include "sound_func.h" #include "timer/timer.h" #include "timer/timer_window.h" @@ -596,6 +597,7 @@ void Window::HandleButtonClick(WidgetID widget) this->LowerWidget(widget); this->SetTimeout(); this->SetWidgetDirty(widget); + if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); } static void StartWindowDrag(Window *w);