From 48fcc38691df8c578b3b7158e8027e6682bd1246 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 24 Dec 2023 06:48:28 -0800 Subject: [PATCH 1/3] Profile card: add Accessibility menu - Move "Toggles" from Controls to Accessibility --- src/k_menu.h | 6 ++ src/k_menudraw.c | 21 +++-- src/menus/CMakeLists.txt | 1 + src/menus/options-profiles-edit-1.c | 7 +- .../options-profiles-edit-accessibility.cpp | 86 +++++++++++++++++++ src/menus/options-profiles-edit-controls.c | 15 ---- 6 files changed, 111 insertions(+), 25 deletions(-) create mode 100644 src/menus/options-profiles-edit-accessibility.cpp diff --git a/src/k_menu.h b/src/k_menu.h index 9260acb92..d62c29d11 100644 --- a/src/k_menu.h +++ b/src/k_menu.h @@ -347,6 +347,7 @@ typedef enum { popt_profilename = 0, popt_controls, + popt_accessibility, popt_char, popt_profilepname, popt_confirm, @@ -360,6 +361,9 @@ void M_StartEditProfile(INT32 c); extern menuitem_t OPTIONS_ProfileControls[]; extern menu_t OPTIONS_ProfileControlsDef; +extern menuitem_t OPTIONS_ProfileAccessibility[]; +extern menu_t OPTIONS_ProfileAccessibilityDef; + extern menuitem_t OPTIONS_Video[]; extern menu_t OPTIONS_VideoDef; @@ -1226,7 +1230,9 @@ void M_DrawOptionsCogs(void); void M_DrawOptionsMovingButton(void); // for sick transitions... void M_DrawOptions(void); void M_DrawGenericOptions(void); +void M_DrawProfileCard(INT32 x, INT32 y, boolean greyedout, profile_t *p); void M_DrawProfileSelect(void); +void M_DrawEditProfileTooltips(void); void M_DrawEditProfile(void); void M_DrawProfileControls(void); void M_DrawVideoModes(void); diff --git a/src/k_menudraw.c b/src/k_menudraw.c index 290d367d8..e9605ae8a 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -2205,7 +2205,7 @@ static void M_DrawCharSelectCursor(UINT8 num) // Draw character profile card. // Moved here because in the case of profile edition this is drawn in the charsel menu. -static void M_DrawProfileCard(INT32 x, INT32 y, boolean greyedout, profile_t *p) +void M_DrawProfileCard(INT32 x, INT32 y, boolean greyedout, profile_t *p) { setup_player_t *sp = &setup_player[0]; // When editing profile character, we'll always be checking for what P1 is doing. patch_t *card = W_CachePatchName("PR_CARD", PU_CACHE); @@ -4321,6 +4321,17 @@ void M_DrawProfileSelect(void) } +void M_DrawEditProfileTooltips(void) +{ + // Tooltip + // The text is slightly shifted hence why we don't just use M_DrawMenuTooltips() + V_DrawFixedPatch(0, 0, FRACUNIT, 0, W_CachePatchName("MENUHINT", PU_CACHE), NULL); + if (currentMenu->menuitems[itemOn].tooltip != NULL) + { + V_DrawCenteredThinString(224, 12, 0, currentMenu->menuitems[itemOn].tooltip); + } +} + // Profile edition menu void M_DrawEditProfile(void) { @@ -4329,13 +4340,7 @@ void M_DrawEditProfile(void) INT32 x = (145 + (menutransition.tics*32)); INT32 i; - // Tooltip - // The text is slightly shifted hence why we don't just use M_DrawMenuTooltips() - V_DrawFixedPatch(0, 0, FRACUNIT, 0, W_CachePatchName("MENUHINT", PU_CACHE), NULL); - if (currentMenu->menuitems[itemOn].tooltip != NULL) - { - V_DrawCenteredThinString(224, 12, 0, currentMenu->menuitems[itemOn].tooltip); - } + M_DrawEditProfileTooltips(); // Draw the menu options... for (i = 0; i < currentMenu->numitems; i++) diff --git a/src/menus/CMakeLists.txt b/src/menus/CMakeLists.txt index f0d8dc4f0..736758a3d 100644 --- a/src/menus/CMakeLists.txt +++ b/src/menus/CMakeLists.txt @@ -22,6 +22,7 @@ target_sources(SRB2SDL2 PRIVATE options-hud-online.c options-profiles-1.c options-profiles-edit-1.c + options-profiles-edit-accessibility.cpp options-profiles-edit-controls.c options-server-1.c options-server-advanced.c diff --git a/src/menus/options-profiles-edit-1.c b/src/menus/options-profiles-edit-1.c index c7f66d889..f3b8cf322 100644 --- a/src/menus/options-profiles-edit-1.c +++ b/src/menus/options-profiles-edit-1.c @@ -12,10 +12,13 @@ menuitem_t OPTIONS_EditProfile[] = { NULL, {.cvar = &cv_dummyprofilename}, 0, 41}, {IT_STRING | IT_CALL, "Controls", "Select the button mappings for this Profile.", - NULL, {.routine = M_ProfileDeviceSelect}, 0, 81}, + NULL, {.routine = M_ProfileDeviceSelect}, 0, 71}, + + {IT_STRING | IT_SUBMENU, "Accessibility", "Acccessibility and quality of life options.", + NULL, {.submenu = &OPTIONS_ProfileAccessibilityDef}, 0, 91}, {IT_STRING | IT_CALL, "Character", "Default character and color for this Profile.", - NULL, {.routine = M_CharacterSelect}, 0, 101}, + NULL, {.routine = M_CharacterSelect}, 0, 111}, {IT_STRING | IT_CVAR | IT_CV_STRING, "Player Tag", "Name displayed online when using this Profile.", NULL, {.cvar = &cv_dummyprofileplayername}, 0, 141}, diff --git a/src/menus/options-profiles-edit-accessibility.cpp b/src/menus/options-profiles-edit-accessibility.cpp new file mode 100644 index 000000000..686949302 --- /dev/null +++ b/src/menus/options-profiles-edit-accessibility.cpp @@ -0,0 +1,86 @@ +/// \file menus/options-profiles-edit-accessibility.c +/// \brief Profile Accessibibility Options + +#include "../v_draw.hpp" + +#include "../k_menu.h" + +using srb2::Draw; + +namespace +{ + +void draw_routine() +{ + Draw row = Draw(0, currentMenu->y).font(Draw::Font::kConsole); + + M_DrawEditProfileTooltips(); + + for (int i = 0; i < currentMenu->numitems; ++i) + { + const menuitem_t& it = currentMenu->menuitems[i]; + + bool selected = i == itemOn; + Draw h = row.flags(selected ? highlightflags : 0); + + if ((it.status & IT_TYPE) == IT_CVAR) + { + auto val = Draw::TextElement(it.itemaction.cvar->string).font(Draw::Font::kConsole); + + h.x(currentMenu->x).text(it.text); + + h = h.x(BASEVIDWIDTH - 16); + h.align(Draw::Align::kRight).text(val); + + if (selected) + { + int ofs = skullAnimCounter / 5; + h.x(-val.width() - 10 - ofs).text("\x1C"); + h.x(2 + ofs).text("\x1D"); + } + } + + row = row.y(12); + } + + // Finally, draw the card ontop + if (optionsmenu.profile != NULL) + { + M_DrawProfileCard(optionsmenu.optx, optionsmenu.opty, false, optionsmenu.profile); + } +} + +}; // namespace + +menuitem_t OPTIONS_ProfileAccessibility[] = { + + {IT_STRING | IT_CVAR, "Rumble", "For gamepad users - should your device rumble?", + NULL, {.cvar = &cv_dummyprofilerumble}, 0, 0}, + + {IT_STRING | IT_CVAR, "Kickstart Accel", "Hold A to auto-accel. Tap it to cancel.", + NULL, {.cvar = &cv_dummyprofilekickstart}, 0, 0}, + + {IT_STRING | IT_CVAR, "Auto Roulette", "Item roulette auto-stops on a random result.", + NULL, {.cvar = &cv_dummyprofileautoroulette}, 0, 0}, + + {IT_STRING | IT_CVAR, "Lite Steer", "Hold DOWN on d-pad/keyboard for shallow turns.", + NULL, {.cvar = &cv_dummyprofilelitesteer}, 0, 0}, +}; + +menu_t OPTIONS_ProfileAccessibilityDef = { + sizeof (OPTIONS_ProfileAccessibility) / sizeof (menuitem_t), + &OPTIONS_EditProfileDef, + 0, + OPTIONS_ProfileAccessibility, + 145, 80, + SKINCOLOR_ULTRAMARINE, 0, + MBF_DRAWBGWHILEPLAYING, + "FILE", + 2, 5, + draw_routine, + M_DrawOptionsCogs, + M_OptionsTick, // animate cogs + NULL, + NULL, + NULL, +}; diff --git a/src/menus/options-profiles-edit-controls.c b/src/menus/options-profiles-edit-controls.c index 0036666fd..3a83dff63 100644 --- a/src/menus/options-profiles-edit-controls.c +++ b/src/menus/options-profiles-edit-controls.c @@ -82,21 +82,6 @@ menuitem_t OPTIONS_ProfileControls[] = { {IT_CONTROL, "LUA/C", "May be used by add-ons.", NULL, {.routine = M_ProfileSetControl}, gc_luac, 0}, - {IT_HEADER, "TOGGLES", "For per-player commands", - NULL, {NULL}, 0, 0}, - - {IT_CONTROL | IT_CVAR, "RUMBLE", "For gamepad users - should your device rumble?", - NULL, {.cvar = &cv_dummyprofilerumble}, 0, 0}, - - {IT_CONTROL | IT_CVAR, "KICKSTART ACCEL", "Hold A to auto-accel. Tap it to cancel.", - NULL, {.cvar = &cv_dummyprofilekickstart}, 0, 0}, - - {IT_CONTROL | IT_CVAR, "AUTO ROULETTE", "Item roulette auto-stops on a random result.", - NULL, {.cvar = &cv_dummyprofileautoroulette}, 0, 0}, - - {IT_CONTROL | IT_CVAR, "LITE STEER", "Hold DOWN on d-pad/keyboard for shallow turns.", - NULL, {.cvar = &cv_dummyprofilelitesteer}, 0, 0}, - {IT_HEADER, "EXTRA", "", NULL, {NULL}, 0, 0}, From 595d078a83f421588f1fe87f24f0e6b6c0578682 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 26 Dec 2023 18:53:13 -0800 Subject: [PATCH 2/3] Menu: move mindelay option to Profiles/Accessibility --- src/menus/options-gameplay-1.c | 6 ------ .../options-profiles-edit-accessibility.cpp | 18 +++++++++++++++--- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/menus/options-gameplay-1.c b/src/menus/options-gameplay-1.c index 74217467e..e8f3a8a5d 100644 --- a/src/menus/options-gameplay-1.c +++ b/src/menus/options-gameplay-1.c @@ -30,12 +30,6 @@ menuitem_t OPTIONS_Gameplay[] = {IT_STRING | IT_CVAR, "Starting Bumpers", "Change how many bumpers player start with in Battle.", NULL, {.cvar = &cv_kartbumpers}, 0, 0}, - {IT_SPACE | IT_NOTHING, NULL, NULL, - NULL, {NULL}, 0, 0}, - - {IT_STRING | IT_CVAR, "Minimum Input Delay", "Practice for online play! Higher = more delay, 0 = instant response.", - NULL, {.cvar = &cv_mindelay}, 0, 0}, - {IT_SPACE | IT_NOTHING, NULL, NULL, NULL, {NULL}, 0, 0}, diff --git a/src/menus/options-profiles-edit-accessibility.cpp b/src/menus/options-profiles-edit-accessibility.cpp index 686949302..9588de67e 100644 --- a/src/menus/options-profiles-edit-accessibility.cpp +++ b/src/menus/options-profiles-edit-accessibility.cpp @@ -3,8 +3,11 @@ #include "../v_draw.hpp" +#include "../command.h" #include "../k_menu.h" +extern "C" consvar_t cv_mindelay; + using srb2::Draw; namespace @@ -57,14 +60,23 @@ menuitem_t OPTIONS_ProfileAccessibility[] = { {IT_STRING | IT_CVAR, "Rumble", "For gamepad users - should your device rumble?", NULL, {.cvar = &cv_dummyprofilerumble}, 0, 0}, - {IT_STRING | IT_CVAR, "Kickstart Accel", "Hold A to auto-accel. Tap it to cancel.", - NULL, {.cvar = &cv_dummyprofilekickstart}, 0, 0}, + {IT_SPACE | IT_NOTHING, NULL, NULL, + NULL, {NULL}, 0, 0}, {IT_STRING | IT_CVAR, "Auto Roulette", "Item roulette auto-stops on a random result.", NULL, {.cvar = &cv_dummyprofileautoroulette}, 0, 0}, + {IT_STRING | IT_CVAR, "Kickstart Accel", "Hold A to auto-accel. Tap it to cancel.", + NULL, {.cvar = &cv_dummyprofilekickstart}, 0, 0}, + {IT_STRING | IT_CVAR, "Lite Steer", "Hold DOWN on d-pad/keyboard for shallow turns.", NULL, {.cvar = &cv_dummyprofilelitesteer}, 0, 0}, + + {IT_SPACE | IT_NOTHING, NULL, NULL, + NULL, {NULL}, 0, 0}, + + {IT_STRING | IT_CVAR, "Minimum Input Delay", "Practice for online play! 0 = instant response.", + NULL, {.cvar = &cv_mindelay}, 0, 0}, }; menu_t OPTIONS_ProfileAccessibilityDef = { @@ -72,7 +84,7 @@ menu_t OPTIONS_ProfileAccessibilityDef = { &OPTIONS_EditProfileDef, 0, OPTIONS_ProfileAccessibility, - 145, 80, + 145, 72, SKINCOLOR_ULTRAMARINE, 0, MBF_DRAWBGWHILEPLAYING, "FILE", From c65c45dcf93606e0671ab3d1d15d342be2b63a6f Mon Sep 17 00:00:00 2001 From: toaster Date: Fri, 29 Dec 2023 14:32:37 +0000 Subject: [PATCH 3/3] Minimum mergeable work to finish off branch - Seperate into "This Profile only" and "For all Profiles" - Move screen tilting and reducevfx from Video Options to Accessibility submenu, under "For all Profiles" - Adjust spacing on menu --- .../options-profiles-edit-accessibility.cpp | 62 +++++++++++++------ src/menus/options-video-1.c | 2 + 2 files changed, 46 insertions(+), 18 deletions(-) diff --git a/src/menus/options-profiles-edit-accessibility.cpp b/src/menus/options-profiles-edit-accessibility.cpp index 9588de67e..2d167fdd1 100644 --- a/src/menus/options-profiles-edit-accessibility.cpp +++ b/src/menus/options-profiles-edit-accessibility.cpp @@ -5,6 +5,7 @@ #include "../command.h" #include "../k_menu.h" +#include "../p_local.h" // cv_tilting extern "C" consvar_t cv_mindelay; @@ -23,27 +24,43 @@ void draw_routine() { const menuitem_t& it = currentMenu->menuitems[i]; - bool selected = i == itemOn; - Draw h = row.flags(selected ? highlightflags : 0); - - if ((it.status & IT_TYPE) == IT_CVAR) + if (it.status & IT_DISPLAY) { - auto val = Draw::TextElement(it.itemaction.cvar->string).font(Draw::Font::kConsole); + bool selected = i == itemOn; - h.x(currentMenu->x).text(it.text); + Draw h = row.x(currentMenu->x); - h = h.x(BASEVIDWIDTH - 16); - h.align(Draw::Align::kRight).text(val); - - if (selected) + if ((it.status & IT_HEADERTEXT) == IT_HEADERTEXT) { - int ofs = skullAnimCounter / 5; - h.x(-val.width() - 10 - ofs).text("\x1C"); - h.x(2 + ofs).text("\x1D"); + h + .x(-4) + .flags(V_GRAYMAP) + .text(it.text); + } + else + { + h + .flags(selected ? highlightflags : 0) + .text(it.text); + } + + if ((it.status & IT_TYPE) == IT_CVAR) + { + auto val = Draw::TextElement(it.itemaction.cvar->string).font(Draw::Font::kConsole); + + h = row.x(BASEVIDWIDTH - 16).flags(highlightflags); + h.align(Draw::Align::kRight).text(val); + + if (selected) + { + int ofs = skullAnimCounter / 5; + h.x(-val.width() - 10 - ofs).text("\x1C"); + h.x(2 + ofs).text("\x1D"); + } } } - row = row.y(12); + row = row.y(11); } // Finally, draw the card ontop @@ -57,12 +74,12 @@ void draw_routine() menuitem_t OPTIONS_ProfileAccessibility[] = { + {IT_HEADER, "This Profile only:", NULL, + NULL, {NULL}, 0, 0}, + {IT_STRING | IT_CVAR, "Rumble", "For gamepad users - should your device rumble?", NULL, {.cvar = &cv_dummyprofilerumble}, 0, 0}, - {IT_SPACE | IT_NOTHING, NULL, NULL, - NULL, {NULL}, 0, 0}, - {IT_STRING | IT_CVAR, "Auto Roulette", "Item roulette auto-stops on a random result.", NULL, {.cvar = &cv_dummyprofileautoroulette}, 0, 0}, @@ -75,8 +92,17 @@ menuitem_t OPTIONS_ProfileAccessibility[] = { {IT_SPACE | IT_NOTHING, NULL, NULL, NULL, {NULL}, 0, 0}, + {IT_HEADER, "For all Profiles:", NULL, + NULL, {NULL}, 0, 0}, + {IT_STRING | IT_CVAR, "Minimum Input Delay", "Practice for online play! 0 = instant response.", NULL, {.cvar = &cv_mindelay}, 0, 0}, + + {IT_STRING | IT_CVAR, "Screen Tilting", "View rotation on inclines.", + NULL, {.cvar = &cv_tilting}, 0, 0}, + + {IT_STRING | IT_CVAR, "Reduce Effects", "If overwhelmed, hide less-important particle cues.", + NULL, {.cvar = &cv_reducevfx}, 0, 0}, }; menu_t OPTIONS_ProfileAccessibilityDef = { @@ -84,7 +110,7 @@ menu_t OPTIONS_ProfileAccessibilityDef = { &OPTIONS_EditProfileDef, 0, OPTIONS_ProfileAccessibility, - 145, 72, + 145, 52, SKINCOLOR_ULTRAMARINE, 0, MBF_DRAWBGWHILEPLAYING, "FILE", diff --git a/src/menus/options-video-1.c b/src/menus/options-video-1.c index be534ddf2..3d2aaa503 100644 --- a/src/menus/options-video-1.c +++ b/src/menus/options-video-1.c @@ -27,11 +27,13 @@ menuitem_t OPTIONS_Video[] = {IT_NOTHING|IT_SPACE, NULL, NULL, NULL, {NULL}, 0, 0}, +#if 0 // See Profiles/Accessibility {IT_STRING | IT_CVAR, "Screen Tilting", "The view rotatation on inclines can be disabled to reduce motion sickness.", NULL, {.cvar = &cv_tilting}, 0, 0}, {IT_STRING | IT_CVAR, "Reduce Visual Effects", "If on, some less-important particle cues will be hidden.", NULL, {.cvar = &cv_reducevfx}, 0, 0}, +#endif {IT_STRING | IT_CVAR | IT_CV_SLIDER, "Gamma", "Adjusts the overall brightness of the game.", NULL, {.cvar = &cv_globalgamma}, 0, 0},