From cbe710b549ddaf2259b55b89cfe651a111c426d8 Mon Sep 17 00:00:00 2001 From: Marcus Minhorst Date: Sun, 27 Jul 2025 06:34:51 -0400 Subject: [PATCH] Added option to disable sound when moving cursor by using scrollwheel. --- src/common/menu/optionmenu.cpp | 6 +++++- wadsrc/static/zscript/engine/ui/menu/optionmenu.zs | 10 ++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/common/menu/optionmenu.cpp b/src/common/menu/optionmenu.cpp index 99069d176..83aba73e6 100644 --- a/src/common/menu/optionmenu.cpp +++ b/src/common/menu/optionmenu.cpp @@ -32,10 +32,14 @@ ** */ +#include "c_cvars.h" #include "v_video.h" #include "menu.h" #include "vm.h" +// by request of Nash +CVARD(Bool, silence_menu_scroll, false, CVAR_GLOBALCONFIG | CVAR_ARCHIVE, "Silences cursor movement when scrolling"); + //============================================================================= // @@ -65,4 +69,4 @@ DEFINE_ACTION_FUNCTION_NATIVE(_OptionMenuItemOption, SetCVarDescription, SetCVar PARAM_STRING(label); SetCVarDescription(cv, &label); return 0; -} \ No newline at end of file +} diff --git a/wadsrc/static/zscript/engine/ui/menu/optionmenu.zs b/wadsrc/static/zscript/engine/ui/menu/optionmenu.zs index e6c477018..e555492d1 100644 --- a/wadsrc/static/zscript/engine/ui/menu/optionmenu.zs +++ b/wadsrc/static/zscript/engine/ui/menu/optionmenu.zs @@ -225,9 +225,10 @@ class OptionMenu : Menu { if (ev.type == UIEvent.Type_WheelUp) { - if (MenuScrollViewport(-2, true)) + if (MenuScrollViewport(-2, true) ) { - MenuSound ("menu/cursor"); + bool silence = Cvar.FindCVar("silence_menu_scroll").getInt(); + if (!silence) MenuSound ("menu/cursor"); } return true; } @@ -235,7 +236,8 @@ class OptionMenu : Menu { if (MenuScrollViewport(2, true)) { - MenuSound ("menu/cursor"); + bool silence = Cvar.FindCVar("silence_menu_scroll").getInt(); + if (!silence) MenuSound ("menu/cursor"); } return true; } @@ -489,7 +491,7 @@ class OptionMenu : Menu if (!mDesc.mItems[i].Selectable()) continue; lastSelectable = i; } - if (lastSelectable != -1 && mDesc.mSelectedItem > lastSelectable) + if (cursor && lastSelectable != -1 && mDesc.mSelectedItem > lastSelectable) { mDesc.mSelectedItem = lastSelectable; }