From 55e3abf58d3c1497fbb36c407c841b79d3dcf348 Mon Sep 17 00:00:00 2001 From: toaster Date: Mon, 18 Dec 2023 14:30:58 +0000 Subject: [PATCH] Teach players how to interact with Goner Setup just before input is first required - Checks for whether a Gamepad is connected - If yes, says you can use "your Gamepad" - If no, says you can use "Enter, ESC, and the Arrow Keys" - Show ENTER and ESC on any Message prompt (instead of A/B/X) if no Gamepad is connected - Add M_DrawMediocreKeyboardKey, a genericisation of the previous entry in the series' Time Attack HUD --- src/k_menudraw.c | 79 +++++++++++++++++++++++++++++++--------- src/menus/main-goner.cpp | 30 +++++++++++++++ 2 files changed, 91 insertions(+), 18 deletions(-) diff --git a/src/k_menudraw.c b/src/k_menudraw.c index 01259d02d..c8e67e29a 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -632,6 +632,31 @@ static void M_DrawMenuTyping(void) } +static void M_DrawMediocreKeyboardKey(const char *text, INT32 *workx, INT32 worky, boolean push, boolean rightaligned) +{ + INT32 buttonwidth = V_StringWidth(text, 0) + 2; + + if (rightaligned) + { + (*workx) -= buttonwidth; + } + + if (push) + { + worky += 2; + } + else + { + V_DrawFill((*workx)-1, worky+10, buttonwidth, 2, 24); + } + + V_DrawFill((*workx)-1, worky, buttonwidth, 10, 16); + V_DrawString( + (*workx), worky + 1, + 0, text + ); +} + // Draw the message popup submenu void M_DrawMenuMessage(void) { @@ -658,6 +683,10 @@ void M_DrawMenuMessage(void) INT32 workx = x + menumessage.x; INT32 worky = y + menumessage.y; + boolean standardbuttons = ( + cv_currprofile.value != -1 || G_GetNumAvailableGamepads() + ); + boolean push; if (menumessage.closing) @@ -678,19 +707,26 @@ void M_DrawMenuMessage(void) workx -= 2; - workx -= SHORT(kp_button_x[1][0]->width); - K_drawButton( - workx * FRACUNIT, worky * FRACUNIT, - 0, kp_button_x[1], - push - ); + if (standardbuttons) + { + workx -= SHORT(kp_button_x[1][0]->width); + K_drawButton( + workx * FRACUNIT, worky * FRACUNIT, + 0, kp_button_x[1], + push + ); - workx -= SHORT(kp_button_b[1][0]->width); - K_drawButton( - workx * FRACUNIT, worky * FRACUNIT, - 0, kp_button_b[1], - push - ); + workx -= SHORT(kp_button_b[1][0]->width); + K_drawButton( + workx * FRACUNIT, worky * FRACUNIT, + 0, kp_button_b[1], + push + ); + } + else + { + M_DrawMediocreKeyboardKey("ESC", &workx, worky, push, true); + } if (menumessage.confirmstr) { @@ -710,12 +746,19 @@ void M_DrawMenuMessage(void) workx -= 2; } - workx -= SHORT(kp_button_a[1][0]->width); - K_drawButton( - workx * FRACUNIT, worky * FRACUNIT, - 0, kp_button_a[1], - push - ); + if (standardbuttons) + { + workx -= SHORT(kp_button_a[1][0]->width); + K_drawButton( + workx * FRACUNIT, worky * FRACUNIT, + 0, kp_button_a[1], + push + ); + } + else + { + M_DrawMediocreKeyboardKey("ENTER", &workx, worky, push, true); + } } x -= 4; diff --git a/src/menus/main-goner.cpp b/src/menus/main-goner.cpp index c8c8a745c..cb7efb5bf 100644 --- a/src/menus/main-goner.cpp +++ b/src/menus/main-goner.cpp @@ -14,6 +14,7 @@ #include "../m_random.h" #include "../r_main.h" #include "../m_easing.h" +#include "../g_input.h" #include @@ -399,6 +400,32 @@ void M_GonerResetText(void) goner_scrollend = -1; } +static void Initial_Control_Info(void) +{ + if (cv_currprofile.value != -1) + return; + + auto line = GonerChatLine(GONERSPEAKER_TAILS, 0, + va("You should be able to use ""\x86""%s""\x80"" to operate this menu.", + (!G_GetNumAvailableGamepads() + ? "Enter, ESC, and the Arrow Keys" + : "your Gamepad" + ) + ) + ); + + if (LinesToDigest.empty()) + { + LinesToDigest.emplace_front(line); + return; + } + + LinesToDigest.emplace_after( + LinesToDigest.begin(), + line + ); +} + void M_AddGonerLines(void) { SRB2_ASSERT(LinesToDigest.empty()); @@ -472,6 +499,9 @@ void M_AddGonerLines(void) "Alright, Metal! I don't remember your specifications offhand. "\ "First things first, go ahead and set up your "\ "\x87""Video Options""\x80"" yourself."); + + LinesToDigest.emplace_front(0, Initial_Control_Info); + break; } case GDGONER_SOUND: