From 8780edda6d39a717591a355950c306745c03752a Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 23 Dec 2023 08:27:07 -0800 Subject: [PATCH] Sound options: merge volume slider with toggle via Z button prompt --- src/menus/options-sound.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/menus/options-sound.cpp b/src/menus/options-sound.cpp index ade008c79..fe13eca61 100644 --- a/src/menus/options-sound.cpp +++ b/src/menus/options-sound.cpp @@ -47,6 +47,8 @@ struct Slider arrows.x(-10 - ofs).text("\x1C"); arrows.x(kWidth + 2 + ofs).text("\x1D"); + + h.xy(kWidth + 9, -3).small_button(Draw::Button::z, false); } h = h.y(1); @@ -152,20 +154,30 @@ void tick_routine(void) } } +boolean input_routine(INT32) +{ + UINT8 pid = 0; // todo: Add ability for any splitscreen player to bring up the menu. + + const menuitem_t& it = currentMenu->menuitems[itemOn]; + + if (M_MenuButtonPressed(pid, MBT_Z) && (it.status & IT_TYPE) == IT_ARROWS) + { + sliders.at(it.mvar2).toggle_(true); + return true; + } + + return false; +} + }; // namespace menuitem_t OPTIONS_Sound[] = { - {IT_STRING | IT_CVAR, "SFX", "Enable or disable sound effect playback.", - NULL, {.cvar = &cv_gamesounds}, 0, 0}, {IT_STRING | IT_ARROWS | IT_CV_SLIDER, "SFX Volume", "Adjust the volume of sound effects.", NULL, {.routine = slider_routine}, 0, Slider::kSfxVolume}, - {IT_STRING | IT_CVAR, "Music", "Enable or disable music playback.", - NULL, {.cvar = &cv_gamedigimusic}, 0, 0}, - {IT_STRING | IT_ARROWS | IT_CV_SLIDER, "Music Volume", "Adjust the volume of music playback.", NULL, {.routine = slider_routine}, 0, Slider::kMusicVolume}, @@ -211,5 +223,5 @@ menu_t OPTIONS_SoundDef = { tick_routine, NULL, NULL, - NULL, + input_routine, };