From 4bc2c576f0acb0dcde543cfac3afc82adf6e6ef5 Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Fri, 13 Sep 2024 19:05:00 -0700 Subject: [PATCH 01/56] WIP: Descriptive controls --- src/v_draw.cpp | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 12a05d63c..ec6ae45d3 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -21,6 +21,7 @@ #include "v_video.h" #include "w_wad.h" #include "z_zone.h" +#include "k_profiles.h" // controls using srb2::Draw; using Chain = Draw::Chain; @@ -77,6 +78,27 @@ Draw::TextElement& Draw::TextElement::parse(std::string_view raw) {"tan", 0x8F}, }; + static const std::unordered_map inputdefinition = { + {0x00, gc_up}, + {0x01, gc_down}, + {0x02, gc_right}, + {0x03, gc_left}, + + {0x04, gc_up}, + + {0x07, gc_r}, + {0x08, gc_l}, + {0x09, gc_start}, + + {0x0A, gc_a}, + {0x0B, gc_b}, + {0x0C, gc_c}, + + {0x0D, gc_x}, + {0x0E, gc_y}, + {0x0F, gc_z}, + }; + string_.clear(); string_.reserve(raw.size()); @@ -109,7 +131,17 @@ Draw::TextElement& Draw::TextElement::parse(std::string_view raw) if (auto it = translation.find(code); it != translation.end()) { - string_.push_back(it->second); // replace with character code + if (auto id = inputdefinition.find(it->second & (~0xF0)); it != translation.end()) + { + profile_t *ourProfile = PR_GetProfile(cv_lastprofile[0].value); + string_.append("\x88"); + string_.append(G_KeynumToString(ourProfile->controls[id->second][0])); + string_.append("\x80"); + } + else + { + string_.push_back(it->second); // replace with character code + } } else { From 8c51bc235dc99a554aa623eeb4a98acd47c0bac8 Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Fri, 13 Sep 2024 19:42:42 -0700 Subject: [PATCH 02/56] "Use Button Names" option --- src/cvars.cpp | 2 ++ src/menus/options-hud-1.c | 8 ++++++++ src/v_draw.cpp | 23 +++++++++++++++++------ src/v_draw.hpp | 2 ++ 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/cvars.cpp b/src/cvars.cpp index 130207d80..231919570 100644 --- a/src/cvars.cpp +++ b/src/cvars.cpp @@ -334,6 +334,8 @@ consvar_t cv_soundvolume = Player("soundvolume", "80").min_max(0, 100); consvar_t cv_discordstreamer = Player("discordstreamer", "Off").on_off(); #endif +consvar_t cv_descriptiveinput = Player("descriptiveinput", "Yes").yes_no(); // Display bound controls instead of Saturn buttons + consvar_t cv_drawdist = Player("drawdist", "Normal").values({ {3072, "Shortest"}, {4096, "Shorter"}, diff --git a/src/menus/options-hud-1.c b/src/menus/options-hud-1.c index 35eb45895..2d94830ec 100644 --- a/src/menus/options-hud-1.c +++ b/src/menus/options-hud-1.c @@ -13,6 +13,8 @@ #include "../r_main.h" // cv_showhud #include "../v_video.h" // cv_constextsize +extern consvar_t cv_descriptiveinput; + menuitem_t OPTIONS_HUD[] = { @@ -37,6 +39,12 @@ menuitem_t OPTIONS_HUD[] = {IT_SPACE | IT_NOTHING, NULL, NULL, NULL, {NULL}, 0, 0}, + {IT_STRING | IT_CVAR, "Use Button Names", "Show button/key names in help text? When off, show Saturn buttons.", + NULL, {.cvar = &cv_descriptiveinput}, 0, 0}, + + {IT_SPACE | IT_NOTHING, NULL, NULL, + NULL, {NULL}, 0, 0}, + {IT_STRING | IT_SUBMENU, "Online Chat Options...", "Visual options for the online chat box.", NULL, {.submenu = &OPTIONS_HUDOnlineDef}, 0, 0}, }; diff --git a/src/v_draw.cpp b/src/v_draw.cpp index ec6ae45d3..d903bf5b2 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -22,6 +22,7 @@ #include "w_wad.h" #include "z_zone.h" #include "k_profiles.h" // controls +#include "p_local.h" // stplyr using srb2::Draw; using Chain = Draw::Chain; @@ -131,14 +132,24 @@ Draw::TextElement& Draw::TextElement::parse(std::string_view raw) if (auto it = translation.find(code); it != translation.end()) { - if (auto id = inputdefinition.find(it->second & (~0xF0)); it != translation.end()) + if (cv_descriptiveinput.value) // Does this char represent a game control? { - profile_t *ourProfile = PR_GetProfile(cv_lastprofile[0].value); - string_.append("\x88"); - string_.append(G_KeynumToString(ourProfile->controls[id->second][0])); - string_.append("\x80"); + if (auto id = inputdefinition.find(it->second & (~0xF0)); it != translation.end()) // This is a game control, do descriptive input translation! + { + profile_t *ourProfile = PR_GetPlayerProfile(stplyr); // FIXME: Doesn't work, stplyr is always 0 here! + if (ourProfile == NULL) + ourProfile = PR_GetLocalPlayerProfile(0); + + string_.append("\x88"); + string_.append(G_KeynumToString(ourProfile->controls[id->second][0])); + string_.append("\x80"); + } + else // This is a color code or some other generic glyph, treat it as is. + { + string_.push_back(it->second); // replace with character code + } } - else + else // We don't care whether this is a generic glyph, because input translation isn't on. { string_.push_back(it->second); // replace with character code } diff --git a/src/v_draw.hpp b/src/v_draw.hpp index 82c60e845..ec8d22800 100644 --- a/src/v_draw.hpp +++ b/src/v_draw.hpp @@ -24,6 +24,8 @@ #include "typedef.h" #include "v_video.h" +extern consvar_t cv_descriptiveinput; + namespace srb2 { From 511255216c1283c9d19db1024f10a39a88d43a74 Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Fri, 13 Sep 2024 20:01:31 -0700 Subject: [PATCH 03/56] WIP --- src/g_input.c | 2 +- src/k_hud.cpp | 7 ++++++- src/k_hud.h | 2 +- src/v_draw.cpp | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/g_input.c b/src/g_input.c index e99f35499..8a209c12f 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -879,7 +879,7 @@ const char *G_KeynumToString(INT32 keynum) // return a string with the ascii char if displayable if (keynum > ' ' && keynum <= 'z' && keynum != KEY_CONSOLE) { - keynamestr[0] = (char)keynum; + keynamestr[0] = (char)(keynum - 32); // Uppercase looks better! keynamestr[1] = '\0'; return keynamestr; } diff --git a/src/k_hud.cpp b/src/k_hud.cpp index b6d47a30e..dcb5f0772 100644 --- a/src/k_hud.cpp +++ b/src/k_hud.cpp @@ -6303,7 +6303,7 @@ void K_ClearPersistentMessages() } // Return value can be used for "paired" splitscreen messages, true = was displayed -void K_AddMessageForPlayer(const player_t *player, const char *msg, boolean interrupt, boolean persist) +void K_AddMessageForPlayer(player_t *player, const char *msg, boolean interrupt, boolean persist) { if (!player) return; @@ -6319,7 +6319,12 @@ void K_AddMessageForPlayer(const player_t *player, const char *msg, boolean inte if (interrupt) state->clear(); + // FIXME: SUPER BAD HACK. + // Need a way to parse messages as a given player instead. + player_t *oldstplyr = stplyr; + stplyr = player; std::string parsedmsg = srb2::Draw::TextElement().parse(msg).string(); + stplyr = oldstplyr; if (persist) state->objective = parsedmsg; diff --git a/src/k_hud.h b/src/k_hud.h index 9112f00da..727115a35 100644 --- a/src/k_hud.h +++ b/src/k_hud.h @@ -109,7 +109,7 @@ extern patch_t *kp_facenum[MAXPLAYERS+1]; extern patch_t *kp_unknownminimap; void K_AddMessage(const char *msg, boolean interrupt, boolean persist); -void K_AddMessageForPlayer(const player_t *player, const char *msg, boolean interrupt, boolean persist); +void K_AddMessageForPlayer(player_t *player, const char *msg, boolean interrupt, boolean persist); void K_ClearPersistentMessages(void); void K_ClearPersistentMessageForPlayer(player_t *player); void K_TickMessages(void); diff --git a/src/v_draw.cpp b/src/v_draw.cpp index d903bf5b2..4b55f0ccb 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -141,7 +141,7 @@ Draw::TextElement& Draw::TextElement::parse(std::string_view raw) ourProfile = PR_GetLocalPlayerProfile(0); string_.append("\x88"); - string_.append(G_KeynumToString(ourProfile->controls[id->second][0])); + string_.append((G_KeynumToString(ourProfile->controls[id->second][0]))); string_.append("\x80"); } else // This is a color code or some other generic glyph, treat it as is. From 7bf63f521700b111db3927e11bbfd23a7def23f4 Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Fri, 13 Sep 2024 20:23:22 -0700 Subject: [PATCH 04/56] Descriptive controls: respond to player input method --- src/v_draw.cpp | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 4b55f0ccb..6de1bb2d5 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -132,16 +132,48 @@ Draw::TextElement& Draw::TextElement::parse(std::string_view raw) if (auto it = translation.find(code); it != translation.end()) { - if (cv_descriptiveinput.value) // Does this char represent a game control? + if (cv_descriptiveinput.value) // Should we do game control translation? { if (auto id = inputdefinition.find(it->second & (~0xF0)); it != translation.end()) // This is a game control, do descriptive input translation! { - profile_t *ourProfile = PR_GetPlayerProfile(stplyr); // FIXME: Doesn't work, stplyr is always 0 here! + // Grab our local controls + UINT8 localplayer = stplyr - players; + profile_t *ourProfile = PR_GetLocalPlayerProfile(localplayer); if (ourProfile == NULL) ourProfile = PR_GetLocalPlayerProfile(0); + INT32 device = G_GetDeviceForPlayer(localplayer); // TODO: Respond to what device player is CURRENTLY using + if (device == -1) // No registered device = you can't possibly be using a gamepad + device = KEYBOARD_MOUSE_DEVICE; + + INT32 bestbind = -1; // Bind that matches our input device + INT32 anybind = -1; // Bind that doesn't match, but is at least for this control + + for (INT32 control = 3; control >= 0; control--) // Prefer earlier binds + { + INT32 possiblecontrol = ourProfile->controls[id->second][control]; + + // if (device is gamepad) == (bound control is in gamepad range) - e.g. if bind matches device + if ((device != KEYBOARD_MOUSE_DEVICE) == (possiblecontrol >= KEY_JOY1 && possiblecontrol < JOYINPUTEND)) + { + bestbind = possiblecontrol; + anybind = possiblecontrol; + } + else + { + anybind = possiblecontrol; + } + } + + INT32 bind = (bestbind != -1) ? bestbind : anybind; // If we couldn't find a device-appropriate bind, try to at least use something + string_.append("\x88"); - string_.append((G_KeynumToString(ourProfile->controls[id->second][0]))); + + if (bind == -1) + string_.append("[NOT BOUND]"); + else + string_.append((G_KeynumToString(bind))); + string_.append("\x80"); } else // This is a color code or some other generic glyph, treat it as is. From 1c50c3510d8909a3f7bdd46fc25b02fd1fd9ff4d Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Fri, 13 Sep 2024 21:13:49 -0700 Subject: [PATCH 05/56] Descriptive input: keyboard/gamepad split, improve display of directions --- src/v_draw.cpp | 48 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 6de1bb2d5..5b5725d0e 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -79,14 +79,13 @@ Draw::TextElement& Draw::TextElement::parse(std::string_view raw) {"tan", 0x8F}, }; + // What glyphs should be rewritten as gamecontrols? static const std::unordered_map inputdefinition = { {0x00, gc_up}, {0x01, gc_down}, {0x02, gc_right}, {0x03, gc_left}, - {0x04, gc_up}, - {0x07, gc_r}, {0x08, gc_l}, {0x09, gc_start}, @@ -100,6 +99,22 @@ Draw::TextElement& Draw::TextElement::parse(std::string_view raw) {0x0F, gc_z}, }; + // What physical binds should always be rewritten as glyphs anyway? + static const std::unordered_map prettyinputs = { + {KEY_UPARROW, 0x00}, + {KEY_DOWNARROW, 0x01}, + {KEY_RIGHTARROW, 0x02}, + {KEY_LEFTARROW, 0x03}, + {KEY_JOY1+11, 0x00}, + {KEY_JOY1+12, 0x01}, + {KEY_JOY1+14, 0x02}, + {KEY_JOY1+13, 0x03}, + {KEY_AXIS1+0, 0x03}, // Left + {KEY_AXIS1+1, 0x02}, // Right + {KEY_AXIS1+2, 0x00}, // Up + {KEY_AXIS1+3, 0x01}, // Down + }; + string_.clear(); string_.reserve(raw.size()); @@ -134,7 +149,7 @@ Draw::TextElement& Draw::TextElement::parse(std::string_view raw) { if (cv_descriptiveinput.value) // Should we do game control translation? { - if (auto id = inputdefinition.find(it->second & (~0xF0)); it != translation.end()) // This is a game control, do descriptive input translation! + if (auto id = inputdefinition.find(it->second & (~0xF0)); id != inputdefinition.end()) // This is a game control, do descriptive input translation! { // Grab our local controls UINT8 localplayer = stplyr - players; @@ -149,9 +164,11 @@ Draw::TextElement& Draw::TextElement::parse(std::string_view raw) INT32 bestbind = -1; // Bind that matches our input device INT32 anybind = -1; // Bind that doesn't match, but is at least for this control - for (INT32 control = 3; control >= 0; control--) // Prefer earlier binds + INT32 control = 3; + + while (control >= 0) // Prefer earlier binds { - INT32 possiblecontrol = ourProfile->controls[id->second][control]; + INT32 possiblecontrol = ourProfile->controls[(INT32)id->second][control]; // if (device is gamepad) == (bound control is in gamepad range) - e.g. if bind matches device if ((device != KEYBOARD_MOUSE_DEVICE) == (possiblecontrol >= KEY_JOY1 && possiblecontrol < JOYINPUTEND)) @@ -163,18 +180,27 @@ Draw::TextElement& Draw::TextElement::parse(std::string_view raw) { anybind = possiblecontrol; } + + control--; } INT32 bind = (bestbind != -1) ? bestbind : anybind; // If we couldn't find a device-appropriate bind, try to at least use something - string_.append("\x88"); - - if (bind == -1) - string_.append("[NOT BOUND]"); + if (auto pretty = prettyinputs.find(bind); pretty != prettyinputs.end()) // Gamepad direction or keyboard arrow, use something nice-looking + { + string_.push_back(0xB0 | pretty->second); // take high bits from glyph invoked and low bits from control + } else - string_.append((G_KeynumToString(bind))); + { + string_.append("\x88"); - string_.append("\x80"); + if (bind == -1) + string_.append("[NOT BOUND]"); + else + string_.append((G_KeynumToString(bind))); + + string_.append("\x80"); + } } else // This is a color code or some other generic glyph, treat it as is. { From 0b9c5c7415eeccc17c58252fcdedb16d98e8f9d5 Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Fri, 13 Sep 2024 22:03:18 -0700 Subject: [PATCH 06/56] Move bind-search logic to g_input --- src/g_input.c | 36 ++++++++++++++++++++++++++++++++++++ src/g_input.h | 2 ++ src/v_draw.cpp | 32 +------------------------------- 3 files changed, 39 insertions(+), 31 deletions(-) diff --git a/src/g_input.c b/src/g_input.c index 8a209c12f..5a4b6ded5 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -1121,6 +1121,42 @@ INT32 G_CheckDoubleUsage(INT32 keynum, INT32 playernum, boolean modify) return result; } +INT32 G_FindPlayerBindForGameControl(INT32 player, gamecontrols_e control) +{ + profile_t *ourProfile = PR_GetLocalPlayerProfile(player); + if (ourProfile == NULL) + ourProfile = PR_GetLocalPlayerProfile(0); + + INT32 device = G_GetDeviceForPlayer(player); // TODO: Respond to what device player is CURRENTLY using + if (device == -1) // No registered device = you can't possibly be using a gamepad + device = KEYBOARD_MOUSE_DEVICE; + + INT32 bestbind = -1; // Bind that matches our input device + INT32 anybind = -1; // Bind that doesn't match, but is at least for this control + + INT32 bindindex = 3; + + while (bindindex >= 0) // Prefer earlier binds + { + INT32 possiblecontrol = ourProfile->controls[control][bindindex]; + + // if (device is gamepad) == (bound control is in gamepad range) - e.g. if bind matches device + if ((device != KEYBOARD_MOUSE_DEVICE) == (possiblecontrol >= KEY_JOY1 && possiblecontrol < JOYINPUTEND)) + { + bestbind = possiblecontrol; + anybind = possiblecontrol; + } + else + { + anybind = possiblecontrol; + } + + bindindex--; + } + + return (bestbind != -1) ? bestbind : anybind; // If we couldn't find a device-appropriate bind, try to at least use something +} + static void setcontrol(UINT8 player) { INT32 numctrl; diff --git a/src/g_input.h b/src/g_input.h index cc04f0047..485ba2618 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -205,6 +205,8 @@ void G_ApplyControlScheme(UINT8 splitplayer, INT32 (*fromcontrols)[MAXINPUTMAPPI void G_SaveKeySetting(FILE *f, INT32 (*fromcontrolsa)[MAXINPUTMAPPING], INT32 (*fromcontrolsb)[MAXINPUTMAPPING], INT32 (*fromcontrolsc)[MAXINPUTMAPPING], INT32 (*fromcontrolsd)[MAXINPUTMAPPING]); INT32 G_CheckDoubleUsage(INT32 keynum, INT32 playernum, boolean modify); +INT32 G_FindPlayerBindForGameControl(INT32 player, gamecontrols_e control); + #ifdef __cplusplus } // extern "C" #endif diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 5b5725d0e..a33b89f83 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -153,38 +153,8 @@ Draw::TextElement& Draw::TextElement::parse(std::string_view raw) { // Grab our local controls UINT8 localplayer = stplyr - players; - profile_t *ourProfile = PR_GetLocalPlayerProfile(localplayer); - if (ourProfile == NULL) - ourProfile = PR_GetLocalPlayerProfile(0); - INT32 device = G_GetDeviceForPlayer(localplayer); // TODO: Respond to what device player is CURRENTLY using - if (device == -1) // No registered device = you can't possibly be using a gamepad - device = KEYBOARD_MOUSE_DEVICE; - - INT32 bestbind = -1; // Bind that matches our input device - INT32 anybind = -1; // Bind that doesn't match, but is at least for this control - - INT32 control = 3; - - while (control >= 0) // Prefer earlier binds - { - INT32 possiblecontrol = ourProfile->controls[(INT32)id->second][control]; - - // if (device is gamepad) == (bound control is in gamepad range) - e.g. if bind matches device - if ((device != KEYBOARD_MOUSE_DEVICE) == (possiblecontrol >= KEY_JOY1 && possiblecontrol < JOYINPUTEND)) - { - bestbind = possiblecontrol; - anybind = possiblecontrol; - } - else - { - anybind = possiblecontrol; - } - - control--; - } - - INT32 bind = (bestbind != -1) ? bestbind : anybind; // If we couldn't find a device-appropriate bind, try to at least use something + INT32 bind = G_FindPlayerBindForGameControl(localplayer, id->second); if (auto pretty = prettyinputs.find(bind); pretty != prettyinputs.end()) // Gamepad direction or keyboard arrow, use something nice-looking { From dbd43859fe29dbf52b9b98cd937a2767ac0b4a7c Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Sat, 14 Sep 2024 05:23:17 -0700 Subject: [PATCH 07/56] Descriptive input: K_DrawGameControl rich text wrapper (WIP) --- src/g_input.c | 147 +++++++++++++++++++++++++++++++++++++++++++++++ src/g_input.h | 1 + src/k_hud.cpp | 18 ++++++ src/k_hud.h | 2 + src/k_menudraw.c | 23 ++------ src/v_draw.cpp | 4 +- 6 files changed, 176 insertions(+), 19 deletions(-) diff --git a/src/g_input.c b/src/g_input.c index 5a4b6ded5..c4bf27afe 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -759,6 +759,129 @@ static keyname_t keynames[] = {KEY_AXIS1+9, "R TRIGGER"}, }; +static keyname_t shortkeynames[] = +{ + {KEY_SPACE, "SPC"}, + {KEY_CAPSLOCK, "CAPS"}, + {KEY_ENTER, "ENTER"}, + {KEY_TAB, "TAB"}, + {KEY_ESCAPE, "ESC"}, + {KEY_BACKSPACE, "BSPC"}, + + {KEY_NUMLOCK, "NUMLOCK"}, + {KEY_SCROLLLOCK, "SCRLOCK"}, + + // bill gates keys + {KEY_LEFTWIN, "LWIN"}, + {KEY_RIGHTWIN, "RWIN"}, + {KEY_MENU, "MENU"}, + + {KEY_LSHIFT, "LSHIFT"}, + {KEY_RSHIFT, "RSHIFT"}, + {KEY_LSHIFT, "SHIFT"}, + {KEY_LCTRL, "LCTRL"}, + {KEY_RCTRL, "RCTRL"}, + {KEY_LCTRL, "CTRL"}, + {KEY_LALT, "LALT"}, + {KEY_RALT, "RALT"}, + {KEY_LALT, "ALT"}, + + // keypad keys + {KEY_KPADSLASH, "NUM/"}, + {KEY_KEYPAD7, "NUM7"}, + {KEY_KEYPAD8, "NUM8"}, + {KEY_KEYPAD9, "NUM9"}, + {KEY_MINUSPAD, "NUM-"}, + {KEY_KEYPAD4, "NUM4"}, + {KEY_KEYPAD5, "NUM5"}, + {KEY_KEYPAD6, "NUM6"}, + {KEY_PLUSPAD, "NUM+"}, + {KEY_KEYPAD1, "NUM1"}, + {KEY_KEYPAD2, "NUM2"}, + {KEY_KEYPAD3, "NUM3"}, + {KEY_KEYPAD0, "NUM0"}, + {KEY_KPADDEL, "NUM ."}, + + // extended keys (not keypad) + {KEY_HOME, "HOME"}, + {KEY_UPARROW, "UP"}, + {KEY_PGUP, "PGUP"}, + {KEY_LEFTARROW, "LEFT"}, + {KEY_RIGHTARROW, "RIGHT"}, + {KEY_END, "END"}, + {KEY_DOWNARROW, "DOWN"}, + {KEY_PGDN, "PGDN"}, + {KEY_INS, "INS"}, + {KEY_DEL, "DEL"}, + + // other keys + {KEY_F1, "F1"}, + {KEY_F2, "F2"}, + {KEY_F3, "F3"}, + {KEY_F4, "F4"}, + {KEY_F5, "F5"}, + {KEY_F6, "F6"}, + {KEY_F7, "F7"}, + {KEY_F8, "F8"}, + {KEY_F9, "F9"}, + {KEY_F10, "F10"}, + {KEY_F11, "F11"}, + {KEY_F12, "F12"}, + + // KEY_CONSOLE has an exception in the keyname code + {'`', "TILDE"}, + {KEY_PAUSE, "PAUSE/BREAK"}, + + // virtual keys for mouse buttons and joystick buttons + {KEY_MOUSE1+0,"M1"}, + {KEY_MOUSE1+1,"M2"}, + {KEY_MOUSE1+2,"M3"}, + {KEY_MOUSE1+3,"M4"}, + {KEY_MOUSE1+4,"M5"}, + {KEY_MOUSE1+5,"M6"}, + {KEY_MOUSE1+6,"M7"}, + {KEY_MOUSE1+7,"M8"}, + {KEY_MOUSEMOVE+0,"Mouse Up"}, + {KEY_MOUSEMOVE+1,"Mouse Down"}, + {KEY_MOUSEMOVE+2,"Mouse Left"}, + {KEY_MOUSEMOVE+3,"Mouse Right"}, + {KEY_MOUSEWHEELUP, "Wheel Up"}, + {KEY_MOUSEWHEELDOWN, "Wheel Down"}, + + {KEY_JOY1+0, "A"}, + {KEY_JOY1+1, "B"}, + {KEY_JOY1+2, "X"}, + {KEY_JOY1+3, "Y"}, + {KEY_JOY1+4, "BACK"}, + {KEY_JOY1+5, "GUIDE"}, + {KEY_JOY1+6, "START"}, + {KEY_JOY1+7, "LS"}, + {KEY_JOY1+8, "RS"}, + {KEY_JOY1+9, "LB"}, + {KEY_JOY1+10, "RB"}, + {KEY_JOY1+11, "D-UP"}, + {KEY_JOY1+12, "D-DOWN"}, + {KEY_JOY1+13, "D-LEFT"}, + {KEY_JOY1+14, "D-RIGHT"}, + {KEY_JOY1+15, "MISC."}, + {KEY_JOY1+16, "PADDLE1"}, + {KEY_JOY1+17, "PADDLE2"}, + {KEY_JOY1+18, "PADDLE3"}, + {KEY_JOY1+19, "PADDLE4"}, + {KEY_JOY1+20, "TOUCHPAD"}, + + {KEY_AXIS1+0, "LS LEFT"}, + {KEY_AXIS1+1, "LS RIGHT"}, + {KEY_AXIS1+2, "LS UP"}, + {KEY_AXIS1+3, "LS DOWN"}, + {KEY_AXIS1+4, "RS LEFT"}, + {KEY_AXIS1+5, "RS RIGHT"}, + {KEY_AXIS1+6, "RS UP"}, + {KEY_AXIS1+7, "RS DOWN"}, + {KEY_AXIS1+8, "LT"}, + {KEY_AXIS1+9, "RT"}, +}; + static const char *gamecontrolname[num_gamecontrols] = { "null", // a key/button mapped to gc_null has no effect @@ -894,6 +1017,30 @@ const char *G_KeynumToString(INT32 keynum) return keynamestr; } +const char *G_KeynumToShortString(INT32 keynum) +{ + static char keynamestr[8]; + + UINT32 j; + + // return a string with the ascii char if displayable + if (keynum > ' ' && keynum <= 'z' && keynum != KEY_CONSOLE) + { + keynamestr[0] = (char)(keynum - 32); // Uppercase looks better! + keynamestr[1] = '\0'; + return keynamestr; + } + + // find a description for special keys + for (j = 0; j < NUMKEYNAMES; j++) + if (shortkeynames[j].keynum == keynum) + return shortkeynames[j].name; + + // create a name for unknown keys + sprintf(keynamestr, "KEY%d", keynum); + return keynamestr; +} + INT32 G_KeyStringtoNum(const char *keystr) { UINT32 j; diff --git a/src/g_input.h b/src/g_input.h index 485ba2618..702a9c8f5 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -187,6 +187,7 @@ void G_MapEventsToControls(event_t *ev); // returns the name of a key const char *G_KeynumToString(INT32 keynum); +const char *G_KeynumToShortString(INT32 keynum); INT32 G_KeyStringtoNum(const char *keystr); boolean G_KeyBindIsNecessary(INT32 gc); diff --git a/src/k_hud.cpp b/src/k_hud.cpp index dcb5f0772..2d6b2df03 100644 --- a/src/k_hud.cpp +++ b/src/k_hud.cpp @@ -6854,3 +6854,21 @@ void K_DrawMarginSticker(INT32 x, INT32 y, INT32 width, INT32 flags, boolean isS if (!leftedge) V_DrawFixedPatch((x + width)*FRACUNIT, y*FRACUNIT, FRACUNIT, flags|V_FLIP, stickerEnd, NULL); } + +INT32 K_DrawGameControl(UINT16 x, UINT16 y, UINT8 player, const char *str, UINT8 alignment) +{ + using srb2::Draw; + + // FIXME: SUPER BAD HACK. + // Need a way to parse messages as a given player instead. + player_t *oldstplyr = stplyr; + stplyr = &players[player]; + Draw::TextElement text = Draw::TextElement().parse(str).font(Draw::Font::kMenu); + stplyr = oldstplyr; + + INT32 width = text.width(); + + Draw(x, y).align((srb2::Draw::Align)alignment).text(text); + + return width; +} \ No newline at end of file diff --git a/src/k_hud.h b/src/k_hud.h index 727115a35..2f8a6ddc8 100644 --- a/src/k_hud.h +++ b/src/k_hud.h @@ -133,6 +133,8 @@ INT32 K_GetMinimapTransFlags(const boolean usingProgressBar); INT32 K_GetMinimapSplitFlags(const boolean usingProgressBar); position_t K_GetKartObjectPosToMinimapPos(fixed_t objx, fixed_t objy); +INT32 K_DrawGameControl(UINT16 x, UINT16 y, UINT8 player, const char *str, UINT8 alignment); + #ifdef __cplusplus } // extern "C" #endif diff --git a/src/k_menudraw.c b/src/k_menudraw.c index dce2b8c7b..1ab891115 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -832,18 +832,9 @@ void M_DrawMenuMessage(void) 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 -= K_DrawGameControl( + workx, worky, + 0, " / ", 2 ); } else @@ -871,11 +862,9 @@ void M_DrawMenuMessage(void) if (standardbuttons) { - workx -= SHORT(kp_button_a[1][0]->width); - K_drawButton( - workx * FRACUNIT, worky * FRACUNIT, - 0, kp_button_a[1], - push + workx -= K_DrawGameControl( + workx, worky, + 0, "", 2 ); } else diff --git a/src/v_draw.cpp b/src/v_draw.cpp index a33b89f83..2075a04ce 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -162,12 +162,12 @@ Draw::TextElement& Draw::TextElement::parse(std::string_view raw) } else { - string_.append("\x88"); + string_.append("\x8D"); if (bind == -1) string_.append("[NOT BOUND]"); else - string_.append((G_KeynumToString(bind))); + string_.append((G_KeynumToShortString(bind))); string_.append("\x80"); } From 4921c42d4cb5b29e03144f519afd038878438ae1 Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Sat, 14 Sep 2024 05:40:39 -0700 Subject: [PATCH 08/56] Fix descriptive input rewriting color codes in Tutorial dialogue --- src/v_draw.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 2075a04ce..ba2c4dd86 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -147,7 +147,8 @@ Draw::TextElement& Draw::TextElement::parse(std::string_view raw) if (auto it = translation.find(code); it != translation.end()) { - if (cv_descriptiveinput.value) // Should we do game control translation? + // FIXME: This isn't how v_video.cpp checks for buttons and I don't know why. + if (cv_descriptiveinput.value && ((it->second & 0xF0) != 0x80)) // Should we do game control translation? { if (auto id = inputdefinition.find(it->second & (~0xF0)); id != inputdefinition.end()) // This is a game control, do descriptive input translation! { From 31eb1a8f5d9bcaaf83e62979c7a1f1459cda8655 Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Sat, 14 Sep 2024 19:09:02 -0700 Subject: [PATCH 09/56] Descriptive input: visually box control legends, better bind search --- src/g_input.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++-- src/k_hud.cpp | 26 ++++++++++++++++++ src/k_menudraw.c | 21 +++++++++------ src/v_draw.cpp | 7 +++-- src/v_video.cpp | 37 ++++++++++++++++++++++++++ 5 files changed, 148 insertions(+), 12 deletions(-) diff --git a/src/g_input.c b/src/g_input.c index c4bf27afe..db06e8ee8 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -1281,24 +1281,89 @@ INT32 G_FindPlayerBindForGameControl(INT32 player, gamecontrols_e control) INT32 bestbind = -1; // Bind that matches our input device INT32 anybind = -1; // Bind that doesn't match, but is at least for this control - INT32 bindindex = 3; + INT32 bindindex = MAXINPUTMAPPING-1; + + CONS_Printf("Searcrhing for gamecontrol %d on player %d device %d...\n", control, player, device); while (bindindex >= 0) // Prefer earlier binds { INT32 possiblecontrol = ourProfile->controls[control][bindindex]; + bindindex--; + + if (possiblecontrol == 0) + continue; + // if (device is gamepad) == (bound control is in gamepad range) - e.g. if bind matches device if ((device != KEYBOARD_MOUSE_DEVICE) == (possiblecontrol >= KEY_JOY1 && possiblecontrol < JOYINPUTEND)) { bestbind = possiblecontrol; anybind = possiblecontrol; + CONS_Printf("Matching control %s\n", G_KeynumToShortString(possiblecontrol)); } else { anybind = possiblecontrol; + CONS_Printf("Speculative control %s\n", G_KeynumToShortString(possiblecontrol)); } + } - bindindex--; + // Still no matching device bind? Try defaults... + if (bestbind == -1) + { + bindindex = MAXINPUTMAPPING-1; + + while (bindindex >= 0) // Prefer earlier binds + { + INT32 possiblecontrol = gamecontroldefault[control][bindindex]; + + bindindex--; + + if (possiblecontrol == 0) + continue; + + // if (device is gamepad) == (bound control is in gamepad range) - e.g. if bind matches device + if ((device != KEYBOARD_MOUSE_DEVICE) == (possiblecontrol >= KEY_JOY1 && possiblecontrol < JOYINPUTEND)) + { + bestbind = possiblecontrol; + anybind = possiblecontrol; + CONS_Printf("Matching default control %s\n", G_KeynumToShortString(possiblecontrol)); + } + else + { + anybind = possiblecontrol; + CONS_Printf("Speculative default control %s\n", G_KeynumToShortString(possiblecontrol)); + } + } + } + + // STILL no matching device bind? Try menu reserved! + if (bestbind == -1) + { + bindindex = MAXINPUTMAPPING-1; + + while (bindindex >= 0) // Prefer earlier binds + { + INT32 possiblecontrol = menucontrolreserved[control][bindindex]; + + bindindex--; + + if (possiblecontrol == 0) + continue; + + // if (device is gamepad) == (bound control is in gamepad range) - e.g. if bind matches device + if ((device != KEYBOARD_MOUSE_DEVICE) == (possiblecontrol >= KEY_JOY1 && possiblecontrol < JOYINPUTEND)) + { + bestbind = possiblecontrol; + anybind = possiblecontrol; + CONS_Printf("Matching reserved control %s\n", G_KeynumToShortString(possiblecontrol)); + } + else + { + anybind = possiblecontrol; + CONS_Printf("Speculative reserved control %s\n", G_KeynumToShortString(possiblecontrol)); + } + } } return (bestbind != -1) ? bestbind : anybind; // If we couldn't find a device-appropriate bind, try to at least use something diff --git a/src/k_hud.cpp b/src/k_hud.cpp index 2d6b2df03..bf94398ea 100644 --- a/src/k_hud.cpp +++ b/src/k_hud.cpp @@ -6444,6 +6444,32 @@ void K_drawKartHUD(void) K_drawEmeraldWin(false); } + // In case of font debugging break glass +#if 0 + using srb2::Draw; + + Draw::TextElement text = Draw::TextElement().parse("ABCxyz / 012 - Use + to Krungle!"); + + player_t *oldstplyr = stplyr; + stplyr = &players[0]; + Draw(5, 5).align((srb2::Draw::Align)0).font(Draw::Font::kMenu).text(text); + stplyr = &players[1]; + Draw(5, 15).align((srb2::Draw::Align)0).font(Draw::Font::kThin).text(text); + stplyr = &players[2]; + Draw(5, 25).align((srb2::Draw::Align)0).font(Draw::Font::kConsole).text(text); + stplyr = &players[3]; + Draw(5, 35).align((srb2::Draw::Align)0).font(Draw::Font::kMedium).text(text); + stplyr = &players[0]; + Draw(5, 45).align((srb2::Draw::Align)0).font(Draw::Font::kGamemode).text(text); + Draw(5, 75).align((srb2::Draw::Align)0).font(Draw::Font::kFreeplay).text(text); + Draw(5, 95).align((srb2::Draw::Align)0).font(Draw::Font::kPing).text(text); + Draw(5, 105).align((srb2::Draw::Align)0).font(Draw::Font::kThinTimer).text(text); + Draw(5, 115).align((srb2::Draw::Align)0).font(Draw::Font::kTimer).text(text); + Draw(5, 145).align((srb2::Draw::Align)0).font(Draw::Font::kZVote).text(text); + stplyr = oldstplyr; +#endif + + if (!demo.attract) { // Draw the CHECK indicator before the other items, so it's overlapped by everything else diff --git a/src/k_menudraw.c b/src/k_menudraw.c index 1ab891115..de3c3ebab 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -833,8 +833,8 @@ void M_DrawMenuMessage(void) if (standardbuttons) { workx -= K_DrawGameControl( - workx, worky, - 0, " / ", 2 + workx+2, worky, + 0, " ", 2 ); } else @@ -863,8 +863,8 @@ void M_DrawMenuMessage(void) if (standardbuttons) { workx -= K_DrawGameControl( - workx, worky, - 0, "", 2 + workx+2, worky, + 0, " ", 2 ); } else @@ -2458,12 +2458,17 @@ void M_DrawCharacterSelect(void) if (!optionsmenu.profile) // Does nothing on this screen { - K_drawButton((x += 22) * FRACUNIT, (kTop - 3) * FRACUNIT, 0, kp_button_r, M_MenuButtonPressed(pid, MBT_R)); - V_DrawThinString((x += kButtonWidth), kTop, 0, "Info"); + x += 22; + //K_drawButton((x += 22) * FRACUNIT, (kTop - 3) * FRACUNIT, 0, kp_button_r, M_MenuButtonPressed(pid, MBT_R)); + x += K_DrawGameControl(x, kTop, 0, "", 0); + V_DrawThinString((x), kTop, 0, "Info"); } - K_drawButton((x += 58) * FRACUNIT, (kTop - 1) * FRACUNIT, 0, kp_button_c[1], M_MenuButtonPressed(pid, MBT_C)); - V_DrawThinString((x += kButtonWidth), kTop, 0, "Default"); + x += 58; + + // K_drawButton((x += 58) * FRACUNIT, (kTop - 1) * FRACUNIT, 0, kp_button_c[1], M_MenuButtonPressed(pid, MBT_C)); + x += K_DrawGameControl(x, kTop, 0, "", 0); + V_DrawThinString((x), kTop, 0, "Default"); } // We have to loop twice -- first time to draw the drop shadows, a second time to draw the icons. diff --git a/src/v_draw.cpp b/src/v_draw.cpp index ba2c4dd86..b3559a41c 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -163,14 +163,17 @@ Draw::TextElement& Draw::TextElement::parse(std::string_view raw) } else { - string_.append("\x8D"); + // string_.append("\x8D"); + string_.push_back('\xEE'); if (bind == -1) string_.append("[NOT BOUND]"); else string_.append((G_KeynumToShortString(bind))); - string_.append("\x80"); + string_.push_back('\xEE'); + + // string_.append("\x80"); } } else // This is a color code or some other generic glyph, treat it as is. diff --git a/src/v_video.cpp b/src/v_video.cpp index 8439172f6..2fcc129a3 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -2272,6 +2272,7 @@ typedef struct fixed_t lfh; fixed_t (*dim_fn)(fixed_t,fixed_t,INT32,INT32,fixed_t *); UINT8 button_yofs; + UINT8 right_outline; } fontspec_t; static void V_GetFontSpecification(int fontno, INT32 flags, fontspec_t *result) @@ -2285,6 +2286,8 @@ static void V_GetFontSpecification(int fontno, INT32 flags, fontspec_t *result) result->chw = 0; result->button_yofs = 0; + result->right_outline = 1; + const INT32 spacing = ( flags & V_SPACINGMASK ); switch (fontno) @@ -2482,6 +2485,13 @@ static void V_GetFontSpecification(int fontno, INT32 flags, fontspec_t *result) result->button_yofs = 1; break; } + + switch (fontno) + { + case MENU_FONT: + result->right_outline = 2; + break; + } } static UINT8 V_GetButtonCodeWidth(UINT8 c) @@ -2540,6 +2550,9 @@ void V_DrawStringScaled( INT32 dupx; INT32 dupy; + const UINT8 outerbox = 26; + const UINT8 innerbox = 16; + fixed_t right; fixed_t bot; @@ -2547,6 +2560,7 @@ void V_DrawStringScaled( boolean uppercase; boolean notcolored; + boolean boxed; boolean dance; boolean nodanceoverride; @@ -2563,6 +2577,7 @@ void V_DrawStringScaled( uppercase = ((flags & V_FORCEUPPERCASE) == V_FORCEUPPERCASE); flags &= ~(V_FLIP);/* These two (V_FORCEUPPERCASE) share a bit. */ + boxed = false; dance = (flags & V_STRINGDANCE) != 0; nodanceoverride = !dance; @@ -2643,6 +2658,19 @@ void V_DrawStringScaled( return; cx = x; break; + case '\xEE': + boxed = !boxed; + if (boxed) // draw caps + { + V_DrawFill((cx)/FRACUNIT-2, (cy)/FRACUNIT-2, (fontspec.right_outline)+2, fontspec.lfh/FRACUNIT, flags|outerbox); + V_DrawFill((cx)/FRACUNIT-1, (cy)/FRACUNIT-1, (fontspec.right_outline)+1, fontspec.lfh/FRACUNIT-2, flags|innerbox); + } + else + { + //V_DrawFill((cx)/FRACUNIT+(fontspec.right_outline), (cy)/FRACUNIT-2, 2, fontspec.lfh/FRACUNIT, flags|outerbox); + //V_DrawFill((cx)/FRACUNIT+(fontspec.right_outline), (cy)/FRACUNIT-1, 1, fontspec.lfh/FRACUNIT-2, flags|innerbox); + } + break; default: if (( c & 0xF0 ) == 0x80) { @@ -2756,6 +2784,13 @@ void V_DrawStringScaled( fixed_t patchxofs = SHORT (font->font[c]->leftoffset) * dupx * scale; cw = SHORT (font->font[c]->width) * dupx; cxoff = (*fontspec.dim_fn)(scale, fontspec.chw, hchw, dupx, &cw); + + if (boxed) + { + V_DrawFill((cx)/FRACUNIT+(fontspec.right_outline), (cy)/FRACUNIT-2, (font->font[c]->width)-(fontspec.right_outline)+2, fontspec.lfh/FRACUNIT, flags|outerbox); + V_DrawFill((cx)/FRACUNIT+(fontspec.right_outline), (cy)/FRACUNIT-1, (font->font[c]->width)-(fontspec.right_outline)+1, fontspec.lfh/FRACUNIT-2, flags|innerbox); + } + V_DrawFixedPatch(cx + cxoff + patchxofs, cy + cyoff, scale, flags, font->font[c], colormap); cx += cw; @@ -2840,6 +2875,8 @@ fixed_t V_StringScaledWidth( case '\n': cx = 0; break; + case '\xEE': + break; default: if (( c & 0xF0 ) == 0x80 || c == V_STRINGDANCE) continue; From 7019c77b96959451bb61ae88b5ff48c3bf020b84 Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Mon, 16 Sep 2024 03:29:55 -0700 Subject: [PATCH 10/56] Generic input nightmare fuck --- src/g_input.c | 8 -- src/k_hud.cpp | 70 +++++++++++++++-- src/k_hud.h | 13 ++++ src/k_menudraw.c | 4 +- src/v_draw.cpp | 62 +++++++++++++++ src/v_draw.hpp | 22 ++++++ src/v_video.cpp | 197 +++++++++++++++++++++++++++++++++++++++++++++-- 7 files changed, 353 insertions(+), 23 deletions(-) diff --git a/src/g_input.c b/src/g_input.c index db06e8ee8..09a6204d2 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -1283,8 +1283,6 @@ INT32 G_FindPlayerBindForGameControl(INT32 player, gamecontrols_e control) INT32 bindindex = MAXINPUTMAPPING-1; - CONS_Printf("Searcrhing for gamecontrol %d on player %d device %d...\n", control, player, device); - while (bindindex >= 0) // Prefer earlier binds { INT32 possiblecontrol = ourProfile->controls[control][bindindex]; @@ -1299,12 +1297,10 @@ INT32 G_FindPlayerBindForGameControl(INT32 player, gamecontrols_e control) { bestbind = possiblecontrol; anybind = possiblecontrol; - CONS_Printf("Matching control %s\n", G_KeynumToShortString(possiblecontrol)); } else { anybind = possiblecontrol; - CONS_Printf("Speculative control %s\n", G_KeynumToShortString(possiblecontrol)); } } @@ -1327,12 +1323,10 @@ INT32 G_FindPlayerBindForGameControl(INT32 player, gamecontrols_e control) { bestbind = possiblecontrol; anybind = possiblecontrol; - CONS_Printf("Matching default control %s\n", G_KeynumToShortString(possiblecontrol)); } else { anybind = possiblecontrol; - CONS_Printf("Speculative default control %s\n", G_KeynumToShortString(possiblecontrol)); } } } @@ -1356,12 +1350,10 @@ INT32 G_FindPlayerBindForGameControl(INT32 player, gamecontrols_e control) { bestbind = possiblecontrol; anybind = possiblecontrol; - CONS_Printf("Matching reserved control %s\n", G_KeynumToShortString(possiblecontrol)); } else { anybind = possiblecontrol; - CONS_Printf("Speculative reserved control %s\n", G_KeynumToShortString(possiblecontrol)); } } } diff --git a/src/k_hud.cpp b/src/k_hud.cpp index bf94398ea..bf5c52e57 100644 --- a/src/k_hud.cpp +++ b/src/k_hud.cpp @@ -244,12 +244,31 @@ patch_t *kp_button_right[2]; patch_t *kp_button_left[2]; patch_t *kp_button_dpad[2]; +patch_t *gen_button_a[2][2]; +patch_t *gen_button_b[2][2]; +patch_t *gen_button_x[2][2]; +patch_t *gen_button_y[2][2]; +patch_t *gen_button_lb[2]; +patch_t *gen_button_rb[2]; +patch_t *gen_button_lt[2]; +patch_t *gen_button_rt[2]; +patch_t *gen_button_start[2]; +patch_t *gen_button_back[2]; +patch_t *gen_button_ls[2]; +patch_t *gen_button_rs[2]; + static void K_LoadButtonGraphics(patch_t *kp[2], int letter) { HU_UpdatePatch(&kp[0], "TLB_%c", letter); HU_UpdatePatch(&kp[1], "TLB_%cB", letter); } +static void K_LoadGenericButtonGraphics(patch_t *kp[2], int letter) +{ + HU_UpdatePatch(&kp[0], "TLG_%c", letter); + HU_UpdatePatch(&kp[1], "TLG_%cB", letter); +} + void K_LoadKartHUDGraphics(void) { INT32 i, j, k; @@ -962,6 +981,28 @@ void K_LoadKartHUDGraphics(void) K_LoadButtonGraphics(kp_button_right, 'L'); K_LoadButtonGraphics(kp_button_left, 'M'); K_LoadButtonGraphics(kp_button_dpad, 'T'); + + K_LoadGenericButtonGraphics(gen_button_a[0], 'A'); + K_LoadGenericButtonGraphics(gen_button_b[0], 'B'); + K_LoadGenericButtonGraphics(gen_button_x[0], 'D'); + K_LoadGenericButtonGraphics(gen_button_y[0], 'E'); + + K_LoadGenericButtonGraphics(gen_button_a[1], 'K'); + K_LoadGenericButtonGraphics(gen_button_b[1], 'M'); + K_LoadGenericButtonGraphics(gen_button_x[1], 'L'); + K_LoadGenericButtonGraphics(gen_button_y[1], 'J'); + + K_LoadGenericButtonGraphics(gen_button_lb, 'H'); + K_LoadGenericButtonGraphics(gen_button_rb, 'I'); + + K_LoadGenericButtonGraphics(gen_button_lt, 'C'); + K_LoadGenericButtonGraphics(gen_button_rt, 'F'); + + K_LoadGenericButtonGraphics(gen_button_start, 'G'); + K_LoadGenericButtonGraphics(gen_button_back, 'G'); // FIXME + + K_LoadGenericButtonGraphics(gen_button_ls, 'T'); + K_LoadGenericButtonGraphics(gen_button_rs, 'U'); } // For the item toggle menu @@ -6445,16 +6486,35 @@ void K_drawKartHUD(void) } // In case of font debugging break glass -#if 0 +#if 1 using srb2::Draw; - Draw::TextElement text = Draw::TextElement().parse("ABCxyz / 012 - Use + to Krungle!"); - + if (0) + { + Draw::TextElement text = Draw::TextElement().parse("A B C X Y Z \nST L R U D L R "); + player_t *oldstplyr = stplyr; stplyr = &players[0]; Draw(5, 5).align((srb2::Draw::Align)0).font(Draw::Font::kMenu).text(text); stplyr = &players[1]; - Draw(5, 15).align((srb2::Draw::Align)0).font(Draw::Font::kThin).text(text); + Draw(5, 35).align((srb2::Draw::Align)0).font(Draw::Font::kThin).text(text); + stplyr = oldstplyr; + } + + + if (1) + { + Draw::TextElement text = Draw::TextElement().parse("A \xEF\xA0 A\nB \xEF\xA1 B\nX \xEF\xA2 X\nY \xEF\xA3 Y\nLB \xEF\xA4 LB\nRB \xEF\xA5 RB\nLT \xEF\xA6 LT\nRT \xEF\xA7 RT\nST \xEF\xA8 ST\nBK \xEF\xA9 BK\nLS \xEF\xAA LS\nRS \xEF\xAB RS\n"); + + player_t *oldstplyr = stplyr; + stplyr = &players[0]; + Draw(160, 5).align((srb2::Draw::Align)0).font(Draw::Font::kMenu).text(text); + stplyr = &players[1]; + Draw(55, 5).align((srb2::Draw::Align)0).font(Draw::Font::kThin).text(text); + stplyr = oldstplyr; + } + + /* stplyr = &players[2]; Draw(5, 25).align((srb2::Draw::Align)0).font(Draw::Font::kConsole).text(text); stplyr = &players[3]; @@ -6466,7 +6526,7 @@ void K_drawKartHUD(void) Draw(5, 105).align((srb2::Draw::Align)0).font(Draw::Font::kThinTimer).text(text); Draw(5, 115).align((srb2::Draw::Align)0).font(Draw::Font::kTimer).text(text); Draw(5, 145).align((srb2::Draw::Align)0).font(Draw::Font::kZVote).text(text); - stplyr = oldstplyr; + */ #endif diff --git a/src/k_hud.h b/src/k_hud.h index 2f8a6ddc8..db2ff421b 100644 --- a/src/k_hud.h +++ b/src/k_hud.h @@ -103,6 +103,19 @@ extern patch_t *kp_button_right[2]; extern patch_t *kp_button_left[2]; extern patch_t *kp_button_dpad[2]; +extern patch_t *gen_button_a[2][2]; +extern patch_t *gen_button_b[2][2]; +extern patch_t *gen_button_x[2][2]; +extern patch_t *gen_button_y[2][2]; +extern patch_t *gen_button_lb[2]; +extern patch_t *gen_button_rb[2]; +extern patch_t *gen_button_lt[2]; +extern patch_t *gen_button_rt[2]; +extern patch_t *gen_button_start[2]; +extern patch_t *gen_button_back[2]; +extern patch_t *gen_button_ls[2]; +extern patch_t *gen_button_rs[2]; + extern patch_t *kp_eggnum[6]; extern patch_t *kp_facenum[MAXPLAYERS+1]; diff --git a/src/k_menudraw.c b/src/k_menudraw.c index de3c3ebab..72b4483c4 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -834,7 +834,7 @@ void M_DrawMenuMessage(void) { workx -= K_DrawGameControl( workx+2, worky, - 0, " ", 2 + 0, "", 2 ); } else @@ -864,7 +864,7 @@ void M_DrawMenuMessage(void) { workx -= K_DrawGameControl( workx+2, worky, - 0, " ", 2 + 0, "", 2 ); } else diff --git a/src/v_draw.cpp b/src/v_draw.cpp index b3559a41c..d2be8526f 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -100,6 +100,7 @@ Draw::TextElement& Draw::TextElement::parse(std::string_view raw) }; // What physical binds should always be rewritten as glyphs anyway? + static const std::unordered_map prettyinputs = { {KEY_UPARROW, 0x00}, {KEY_DOWNARROW, 0x01}, @@ -115,6 +116,21 @@ Draw::TextElement& Draw::TextElement::parse(std::string_view raw) {KEY_AXIS1+3, 0x01}, // Down }; + static const std::unordered_map genericinputs = { + {KEY_JOY1+0, 0x00}, + {KEY_JOY1+1, 0x01}, + {KEY_JOY1+2, 0x02}, + {KEY_JOY1+3, 0x03}, + {KEY_JOY1+9, 0x04}, + {KEY_JOY1+10, 0x05}, + {KEY_AXIS1+8, 0x06}, + {KEY_AXIS1+9, 0x07}, + {KEY_JOY1+6, 0x08}, + {KEY_JOY1+4, 0x09}, + {KEY_JOY1+7, 0x0A}, + {KEY_JOY1+8, 0x0B}, + }; + string_.clear(); string_.reserve(raw.size()); @@ -161,6 +177,11 @@ Draw::TextElement& Draw::TextElement::parse(std::string_view raw) { string_.push_back(0xB0 | pretty->second); // take high bits from glyph invoked and low bits from control } + else if (auto generic = genericinputs.find(bind); generic != genericinputs.end()) // Gamepad direction or keyboard arrow, use something nice-looking + { + string_.push_back(0xEF); + string_.push_back(0xB0 | generic->second); // take high bits from glyph invoked and low bits from control + } else { // string_.append("\x8D"); @@ -298,6 +319,47 @@ void Chain::button_(Button type, int ver, std::optional press) const } } +patch_t** get_button_patch(Draw::GenericButton type, int ver) +{ + switch (type) + { +#define X(x) \ + case Draw::GenericButton::x:\ + return gen_button_ ## x + + X(a)[ver]; + X(b)[ver]; + X(x)[ver]; + X(y)[ver]; + X(lb); + X(rb); + X(lt); + X(rt); + X(start); + X(back); + X(ls); + X(rs); + +#undef X + } + + return nullptr; +}; + +void Chain::generic_button_(GenericButton type, int ver, std::optional press) const +{ + const auto _ = Clipper(*this); + + if (press) + { + K_drawButton(FloatToFixed(x_), FloatToFixed(y_), flags_, get_button_patch(type, ver), *press); + } + else + { + K_drawButtonAnim(x_, y_, flags_, get_button_patch(type, ver), I_GetTime()); + } +} + void Chain::sticker(patch_t* end_graphic, UINT8 color) const { const auto _ = Clipper(*this); diff --git a/src/v_draw.hpp b/src/v_draw.hpp index ec8d22800..da3ccce2f 100644 --- a/src/v_draw.hpp +++ b/src/v_draw.hpp @@ -81,6 +81,22 @@ public: dpad, }; + enum class GenericButton + { + a, + b, + x, + y, + lb, + rb, + lt, + rt, + start, + back, + ls, + rs + }; + class TextElement { public: @@ -195,6 +211,9 @@ public: void button(Button type, std::optional press = {}) const { button_(type, 0, press); } void small_button(Button type, std::optional press = {}) const { button_(type, 1, press); } + void generic_button(Button type, std::optional press = {}) const { button_(type, 0, press); } + void generic_small_button(GenericButton type, std::optional press = {}) const { generic_button_(type, 1, press); } + void sticker(patch_t* end_graphic, UINT8 color) const; void sticker() const { sticker(Draw::cache_patch("K_STIKEN"), 24); } void small_sticker() const { sticker(Draw::cache_patch("K_STIKE2"), 24); } @@ -236,6 +255,7 @@ public: void string(const char* str, INT32 flags, Font font) const; void button_(Button type, int ver, std::optional press = {}) const; + void generic_button_(GenericButton type, int ver, std::optional press = {}) const; friend Draw; }; @@ -285,6 +305,8 @@ public: VOID_METHOD(fill); VOID_METHOD(button); VOID_METHOD(small_button); + VOID_METHOD(generic_button); + VOID_METHOD(generic_small_button); VOID_METHOD(sticker); VOID_METHOD(small_sticker); diff --git a/src/v_video.cpp b/src/v_video.cpp index 2fcc129a3..49f0e5233 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -2534,6 +2534,48 @@ static UINT8 V_GetButtonCodeWidth(UINT8 c) return x; } +static UINT8 V_GetGenericButtonCodeWidth(UINT8 c) +{ + UINT8 x = 0; + + switch (c & 0x0F) + { + case 0x00: + case 0x01: + case 0x02: + case 0x03: + // buttons + x = 14; + break; + + case 0x04: + case 0x05: + // bumpers + x = 14; + break; + + case 0x06: + case 0x07: + // triggers + x = 14; + break; + + case 0x08: + case 0x09: + // nav + x = 16; + break; + + case 0x0A: + case 0x0B: + // stick click + x = 18; + break; + } + + return x; +} + void V_DrawStringScaled( fixed_t x, fixed_t y, @@ -2561,6 +2603,7 @@ void V_DrawStringScaled( boolean uppercase; boolean notcolored; boolean boxed; + boolean descriptive = false; boolean dance; boolean nodanceoverride; @@ -2658,7 +2701,11 @@ void V_DrawStringScaled( return; cx = x; break; + case '\xEF': + descriptive = true; + break; case '\xEE': + cx += FRACUNIT*dupx; boxed = !boxed; if (boxed) // draw caps { @@ -2716,6 +2763,122 @@ void V_DrawStringScaled( if (( c & 0xB0 ) & 0x80) // button prompts { + if (!descriptive) + { + using srb2::Draw; + + struct BtConf + { + UINT8 x, y; + Draw::Button type; + }; + + auto bt_inst = [c]() -> std::optional + { + switch (c & 0x0F) + { + case 0x00: return {{0, 3, Draw::Button::up}}; + case 0x01: return {{0, 3, Draw::Button::down}}; + case 0x02: return {{0, 3, Draw::Button::right}}; + case 0x03: return {{0, 3, Draw::Button::left}}; + + case 0x04: return {{0, 4, Draw::Button::dpad}}; + + case 0x07: return {{0, 2, Draw::Button::r}}; + case 0x08: return {{0, 2, Draw::Button::l}}; + + case 0x09: return {{0, 1, Draw::Button::start}}; + + case 0x0A: return {{2, 1, Draw::Button::a}}; + case 0x0B: return {{2, 1, Draw::Button::b}}; + case 0x0C: return {{2, 1, Draw::Button::c}}; + + case 0x0D: return {{2, 1, Draw::Button::x}}; + case 0x0E: return {{2, 1, Draw::Button::y}}; + case 0x0F: return {{2, 1, Draw::Button::z}}; + + default: return {}; + } + }(); + + if (bt_inst) + { + auto bt_translate_press = [c]() -> std::optional + { + switch (c & 0xB0) + { + default: + case 0x90: return true; + case 0xA0: return {}; + case 0xB0: return false; + } + }; + + cw = V_GetButtonCodeWidth(c) * dupx; + cxoff = (*fontspec.dim_fn)(scale, fontspec.chw, hchw, dupx, &cw); + Draw( + FixedToFloat(cx + cxoff) - (bt_inst->x * dupx), + FixedToFloat(cy + cyoff) - ((bt_inst->y + fontspec.button_yofs) * dupy)) + .flags(flags) + .small_button(bt_inst->type, bt_translate_press()); + cx += cw; + } + break; + } + else + { + using srb2::Draw; + + struct BtConf + { + UINT8 x, y; + Draw::GenericButton type; + }; + + auto bt_inst = [c]() -> std::optional + { + switch (c & 0x0F) + { + case 0x00: return {{0, 2, Draw::GenericButton::a}}; + case 0x01: return {{0, 2, Draw::GenericButton::b}}; + case 0x02: return {{0, 2, Draw::GenericButton::x}}; + case 0x03: return {{0, 2, Draw::GenericButton::y}}; + case 0x04: return {{1, 3, Draw::GenericButton::lb}}; + case 0x05: return {{1, 3, Draw::GenericButton::rb}}; + case 0x06: return {{1, 4, Draw::GenericButton::lt}}; + case 0x07: return {{1, 4, Draw::GenericButton::rt}}; + case 0x08: return {{1, 6, Draw::GenericButton::start}}; + case 0x09: return {{1, 6, Draw::GenericButton::back}}; + case 0x0A: return {{0, 5, Draw::GenericButton::ls}}; + case 0x0B: return {{0, 5, Draw::GenericButton::rs}}; + default: return {}; + } + }(); + + if (bt_inst) + { + auto bt_translate_press = [c]() -> std::optional + { + switch (c & 0xB0) + { + default: + case 0x90: return true; + case 0xA0: return {}; + case 0xB0: return false; + } + }; + + cw = V_GetGenericButtonCodeWidth(c) * dupx; + cxoff = (*fontspec.dim_fn)(scale, fontspec.chw, hchw, dupx, &cw); + Draw( + FixedToFloat(cx + cxoff) - (bt_inst->x * dupx), + FixedToFloat(cy + cyoff) - ((bt_inst->y + fontspec.button_yofs) * dupy)) + .flags(flags) + .generic_small_button(bt_inst->type, bt_translate_press()); + cx += cw; + } + break; + } using srb2::Draw; struct BtConf @@ -2728,10 +2891,10 @@ void V_DrawStringScaled( { switch (c & 0x0F) { - case 0x00: return {{0, 3, Draw::Button::up}}; - case 0x01: return {{0, 3, Draw::Button::down}}; - case 0x02: return {{0, 3, Draw::Button::right}}; - case 0x03: return {{0, 3, Draw::Button::left}}; + case 0x00: return {{1, 3, Draw::Button::up}}; + case 0x01: return {{1, 3, Draw::Button::down}}; + case 0x02: return {{1, 3, Draw::Button::right}}; + case 0x03: return {{1, 3, Draw::Button::left}}; case 0x04: return {{0, 4, Draw::Button::dpad}}; @@ -2797,6 +2960,8 @@ void V_DrawStringScaled( } else cx += fontspec.spacew; + + descriptive = false; } } } @@ -2817,6 +2982,7 @@ fixed_t V_StringScaledWidth( font_t *font; boolean uppercase; + boolean descriptive = false;; fixed_t cx; fixed_t right; @@ -2875,7 +3041,11 @@ fixed_t V_StringScaledWidth( case '\n': cx = 0; break; + case '\xEF': + descriptive = true; + break; case '\xEE': + cx += FRACUNIT*dupx; break; default: if (( c & 0xF0 ) == 0x80 || c == V_STRINGDANCE) @@ -2883,10 +3053,20 @@ fixed_t V_StringScaledWidth( if (( c & 0xB0 ) & 0x80) { - cw = V_GetButtonCodeWidth(c) * dupx; - cx += cw * scale; - right = cx; - break; + if (descriptive) + { + cw = V_GetGenericButtonCodeWidth(c) * dupx; + cx += cw * scale; + right = cx; + break; + } + else + { + cw = V_GetButtonCodeWidth(c) * dupx; + cx += cw * scale; + right = cx; + break; + } } if (uppercase) @@ -2921,6 +3101,7 @@ fixed_t V_StringScaledWidth( } else cx += fontspec.spacew; + descriptive = false; } fullwidth = std::max(right, std::max(cx, fullwidth)); From af4dc813e2189db58d71c5cfac78bda7448ec2d4 Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Mon, 16 Sep 2024 04:02:39 -0700 Subject: [PATCH 11/56] The text spacing vortex consumes all --- src/k_hud.cpp | 2 +- src/k_menudraw.c | 4 ++-- src/v_video.cpp | 7 +++++-- src/w_wad.cpp | 2 ++ 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/k_hud.cpp b/src/k_hud.cpp index bf5c52e57..fd6ea180a 100644 --- a/src/k_hud.cpp +++ b/src/k_hud.cpp @@ -6504,7 +6504,7 @@ void K_drawKartHUD(void) if (1) { - Draw::TextElement text = Draw::TextElement().parse("A \xEF\xA0 A\nB \xEF\xA1 B\nX \xEF\xA2 X\nY \xEF\xA3 Y\nLB \xEF\xA4 LB\nRB \xEF\xA5 RB\nLT \xEF\xA6 LT\nRT \xEF\xA7 RT\nST \xEF\xA8 ST\nBK \xEF\xA9 BK\nLS \xEF\xAA LS\nRS \xEF\xAB RS\n"); + Draw::TextElement text = Draw::TextElement().parse("\xEELEFTSPACE\xEE\n\xEESPC\xEE \xEETAB\xEE\nA \xEF\xA0 A\nB \xEF\xA1 B\nX \xEF\xA2 X\nY \xEF\xA3 Y\nLB \xEF\xA4 LB\nRB \xEF\xA5 RB\nLT \xEF\xA6 LT\nRT \xEF\xA7 RT\nST \xEF\xA8 ST\nBK \xEF\xA9 BK\nLS \xEF\xAA LS\nRS \xEF\xAB RS\n"); player_t *oldstplyr = stplyr; stplyr = &players[0]; diff --git a/src/k_menudraw.c b/src/k_menudraw.c index 72b4483c4..e54170242 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -834,7 +834,7 @@ void M_DrawMenuMessage(void) { workx -= K_DrawGameControl( workx+2, worky, - 0, "", 2 + 0, " ", 2 ); } else @@ -864,7 +864,7 @@ void M_DrawMenuMessage(void) { workx -= K_DrawGameControl( workx+2, worky, - 0, "", 2 + 0, " ", 2 ); } else diff --git a/src/v_video.cpp b/src/v_video.cpp index 49f0e5233..0f278cf79 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -2705,7 +2705,6 @@ void V_DrawStringScaled( descriptive = true; break; case '\xEE': - cx += FRACUNIT*dupx; boxed = !boxed; if (boxed) // draw caps { @@ -2714,6 +2713,7 @@ void V_DrawStringScaled( } else { + cx += 3*scale; //V_DrawFill((cx)/FRACUNIT+(fontspec.right_outline), (cy)/FRACUNIT-2, 2, fontspec.lfh/FRACUNIT, flags|outerbox); //V_DrawFill((cx)/FRACUNIT+(fontspec.right_outline), (cy)/FRACUNIT-1, 1, fontspec.lfh/FRACUNIT-2, flags|innerbox); } @@ -2982,6 +2982,7 @@ fixed_t V_StringScaledWidth( font_t *font; boolean uppercase; + boolean boxed = false; boolean descriptive = false;; fixed_t cx; @@ -3045,7 +3046,9 @@ fixed_t V_StringScaledWidth( descriptive = true; break; case '\xEE': - cx += FRACUNIT*dupx; + if (boxed) + cx += 3*scale; + boxed = !boxed; break; default: if (( c & 0xF0 ) == 0x80 || c == V_STRINGDANCE) diff --git a/src/w_wad.cpp b/src/w_wad.cpp index 8d31c97a1..1c4dbde49 100644 --- a/src/w_wad.cpp +++ b/src/w_wad.cpp @@ -2406,6 +2406,8 @@ int W_VerifyNMUSlumps(const char *filename, boolean exit_on_error) {"K_", 2}, // Kart graphic changes {"MUSICDEF", 8}, // Kart song definitions + {"TLG_", 4}, // Generic button legends + #ifdef HWRENDER {"SHADERS", 7}, {"SH_", 3}, From 28221df0e99ff811ebe8f97e8f86941e8144d07f Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Mon, 16 Sep 2024 04:14:18 -0700 Subject: [PATCH 12/56] Actually use the animation bits, dummy! --- src/v_draw.cpp | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/v_draw.cpp b/src/v_draw.cpp index d2be8526f..ee2b940c8 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -99,8 +99,7 @@ Draw::TextElement& Draw::TextElement::parse(std::string_view raw) {0x0F, gc_z}, }; - // What physical binds should always be rewritten as glyphs anyway? - + // What physical binds should be rewritten as base Saturn icons? static const std::unordered_map prettyinputs = { {KEY_UPARROW, 0x00}, {KEY_DOWNARROW, 0x01}, @@ -116,18 +115,19 @@ Draw::TextElement& Draw::TextElement::parse(std::string_view raw) {KEY_AXIS1+3, 0x01}, // Down }; + // What physical binds should be rewritten as generic icons? static const std::unordered_map genericinputs = { - {KEY_JOY1+0, 0x00}, + {KEY_JOY1+0, 0x00}, // ABXY {KEY_JOY1+1, 0x01}, {KEY_JOY1+2, 0x02}, {KEY_JOY1+3, 0x03}, - {KEY_JOY1+9, 0x04}, + {KEY_JOY1+9, 0x04}, // LBRB {KEY_JOY1+10, 0x05}, - {KEY_AXIS1+8, 0x06}, + {KEY_AXIS1+8, 0x06}, // LTRT {KEY_AXIS1+9, 0x07}, - {KEY_JOY1+6, 0x08}, + {KEY_JOY1+6, 0x08}, // NAV {KEY_JOY1+4, 0x09}, - {KEY_JOY1+7, 0x0A}, + {KEY_JOY1+7, 0x0A}, // CLICK {KEY_JOY1+8, 0x0B}, }; @@ -175,16 +175,15 @@ Draw::TextElement& Draw::TextElement::parse(std::string_view raw) if (auto pretty = prettyinputs.find(bind); pretty != prettyinputs.end()) // Gamepad direction or keyboard arrow, use something nice-looking { - string_.push_back(0xB0 | pretty->second); // take high bits from glyph invoked and low bits from control + string_.push_back((it->second & 0xF0) | pretty->second); // original invocation has the animation bits, but the glyph bits come from the table } - else if (auto generic = genericinputs.find(bind); generic != genericinputs.end()) // Gamepad direction or keyboard arrow, use something nice-looking + else if (auto generic = genericinputs.find(bind); generic != genericinputs.end()) // Gamepad input, display it to the player as they are { string_.push_back(0xEF); - string_.push_back(0xB0 | generic->second); // take high bits from glyph invoked and low bits from control + string_.push_back((it->second & 0xF0) | generic->second); // original invocation has the animation bits, but the glyph bits come from the table } else { - // string_.append("\x8D"); string_.push_back('\xEE'); if (bind == -1) @@ -193,8 +192,6 @@ Draw::TextElement& Draw::TextElement::parse(std::string_view raw) string_.append((G_KeynumToShortString(bind))); string_.push_back('\xEE'); - - // string_.append("\x80"); } } else // This is a color code or some other generic glyph, treat it as is. From 1c87d358fb7725ad24dca157a5ccc7d1eb4b97ae Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Mon, 16 Sep 2024 04:30:15 -0700 Subject: [PATCH 13/56] Early review fixes --- src/g_input.c | 4 ++-- src/k_hud.cpp | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/g_input.c b/src/g_input.c index 09a6204d2..2eed40c88 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -1002,7 +1002,7 @@ const char *G_KeynumToString(INT32 keynum) // return a string with the ascii char if displayable if (keynum > ' ' && keynum <= 'z' && keynum != KEY_CONSOLE) { - keynamestr[0] = (char)(keynum - 32); // Uppercase looks better! + keynamestr[0] = toupper(keynum); // Uppercase looks better! keynamestr[1] = '\0'; return keynamestr; } @@ -1026,7 +1026,7 @@ const char *G_KeynumToShortString(INT32 keynum) // return a string with the ascii char if displayable if (keynum > ' ' && keynum <= 'z' && keynum != KEY_CONSOLE) { - keynamestr[0] = (char)(keynum - 32); // Uppercase looks better! + keynamestr[0] = toupper(keynum); // Uppercase looks better! keynamestr[1] = '\0'; return keynamestr; } diff --git a/src/k_hud.cpp b/src/k_hud.cpp index fd6ea180a..7fab59bdb 100644 --- a/src/k_hud.cpp +++ b/src/k_hud.cpp @@ -6425,7 +6425,7 @@ static void K_DrawMessageFeed(void) text.font(Draw::Font::kMenu); - UINT8 x = 160; + UINT8 x = BASEVIDWIDTH/2; UINT8 y = 10; SINT8 shift = 0; if (r_splitscreen >= 2) @@ -6449,6 +6449,7 @@ static void K_DrawMessageFeed(void) if (i >= 1) y += BASEVIDHEIGHT / 2; } + UINT16 sw = text.width(); K_DrawSticker(x - sw/2, y, sw, 0, true); @@ -6502,7 +6503,7 @@ void K_drawKartHUD(void) } - if (1) + if (0) { Draw::TextElement text = Draw::TextElement().parse("\xEELEFTSPACE\xEE\n\xEESPC\xEE \xEETAB\xEE\nA \xEF\xA0 A\nB \xEF\xA1 B\nX \xEF\xA2 X\nY \xEF\xA3 Y\nLB \xEF\xA4 LB\nRB \xEF\xA5 RB\nLT \xEF\xA6 LT\nRT \xEF\xA7 RT\nST \xEF\xA8 ST\nBK \xEF\xA9 BK\nLS \xEF\xAA LS\nRS \xEF\xAB RS\n"); @@ -6957,4 +6958,4 @@ INT32 K_DrawGameControl(UINT16 x, UINT16 y, UINT8 player, const char *str, UINT8 Draw(x, y).align((srb2::Draw::Align)alignment).text(text); return width; -} \ No newline at end of file +} From 2546fc8351243a8cebb8c6885adacc50de8ec06f Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Mon, 16 Sep 2024 05:17:01 -0700 Subject: [PATCH 14/56] No look lua support wheeeeeeeeeee --- src/lua_hudlib.c | 16 ++++++++++++++++ src/v_video.cpp | 7 +++++++ src/v_video.h | 3 +++ 3 files changed, 26 insertions(+) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index b59e12cf3..999232c35 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -964,6 +964,21 @@ static int libd_stringWidth(lua_State *L) return 1; } +static int libd_parseText(lua_State *L) +{ + HUDONLY + + const char *rawText = luaL_checkstring(L, 1); + + if (!rawText) + return luaL_error(L, "no string provided to v.parseText"); + + char *newText = V_ParseText(rawText); + lua_pushstring(gL, newText); + Z_Free(newText); + return 1; +} + static int libd_getColormap(lua_State *L) { INT32 skinnum = TC_DEFAULT; @@ -1162,6 +1177,7 @@ static luaL_Reg lib_draw[] = { // misc {"stringWidth", libd_stringWidth}, {"titleCardStringWidth", libd_titleCardStringWidth}, + {"parseText", libd_parseText}, // m_random {"RandomFixed",libd_RandomFixed}, {"RandomByte",libd_RandomByte}, diff --git a/src/v_video.cpp b/src/v_video.cpp index 0f278cf79..3772cb99a 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -3700,3 +3700,10 @@ void VID_DisplaySoftwareScreen() // Post-process blit to the 'default' framebuffer hw_state->blit_postimg_screens->draw(*rhi, ctx); } + +char *V_ParseText(const char *rawText) +{ + using srb2::Draw; + + return Z_StrDup(srb2::Draw::TextElement().parse(rawText).string().c_str()); +} diff --git a/src/v_video.h b/src/v_video.h index 018cd2c51..61467e641 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -442,6 +442,9 @@ void VID_BlitLinearScreen(const UINT8 *srcptr, UINT8 *destptr, INT32 width, INT3 */ void VID_DisplaySoftwareScreen(void); +char *V_ParseText(const char *rawText); // Launder srb2::draw::TextElement.parse() through C code! + + #ifdef __cplusplus } // extern "C" #endif From 512eb5ec6700958aa36263cfacbd7b7388e6c57b Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Mon, 16 Sep 2024 16:32:50 -0700 Subject: [PATCH 15/56] Allow overriding stplyr in Srb2::Draw::Parse --- src/g_input.c | 13 ++++++------- src/k_hud.cpp | 14 ++------------ src/v_draw.cpp | 12 +++++++----- src/v_draw.hpp | 7 +++++++ 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/src/g_input.c b/src/g_input.c index 2eed40c88..948eca026 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -1270,7 +1270,7 @@ INT32 G_CheckDoubleUsage(INT32 keynum, INT32 playernum, boolean modify) INT32 G_FindPlayerBindForGameControl(INT32 player, gamecontrols_e control) { - profile_t *ourProfile = PR_GetLocalPlayerProfile(player); + profile_t *ourProfile = PR_GetPlayerProfile(&players[player]); if (ourProfile == NULL) ourProfile = PR_GetLocalPlayerProfile(0); @@ -1283,6 +1283,7 @@ INT32 G_FindPlayerBindForGameControl(INT32 player, gamecontrols_e control) INT32 bindindex = MAXINPUTMAPPING-1; + // PASS 1: Binds that are directly in our profile control mapping. while (bindindex >= 0) // Prefer earlier binds { INT32 possiblecontrol = ourProfile->controls[control][bindindex]; @@ -1304,12 +1305,12 @@ INT32 G_FindPlayerBindForGameControl(INT32 player, gamecontrols_e control) } } - // Still no matching device bind? Try defaults... + // PASS 2: Binds that are in the default controls. if (bestbind == -1) { bindindex = MAXINPUTMAPPING-1; - while (bindindex >= 0) // Prefer earlier binds + while (bindindex >= 0) { INT32 possiblecontrol = gamecontroldefault[control][bindindex]; @@ -1318,7 +1319,6 @@ INT32 G_FindPlayerBindForGameControl(INT32 player, gamecontrols_e control) if (possiblecontrol == 0) continue; - // if (device is gamepad) == (bound control is in gamepad range) - e.g. if bind matches device if ((device != KEYBOARD_MOUSE_DEVICE) == (possiblecontrol >= KEY_JOY1 && possiblecontrol < JOYINPUTEND)) { bestbind = possiblecontrol; @@ -1331,12 +1331,12 @@ INT32 G_FindPlayerBindForGameControl(INT32 player, gamecontrols_e control) } } - // STILL no matching device bind? Try menu reserved! + // PASS 3: "Safety" binds that are reserved by the menu system. if (bestbind == -1) { bindindex = MAXINPUTMAPPING-1; - while (bindindex >= 0) // Prefer earlier binds + while (bindindex >= 0) { INT32 possiblecontrol = menucontrolreserved[control][bindindex]; @@ -1345,7 +1345,6 @@ INT32 G_FindPlayerBindForGameControl(INT32 player, gamecontrols_e control) if (possiblecontrol == 0) continue; - // if (device is gamepad) == (bound control is in gamepad range) - e.g. if bind matches device if ((device != KEYBOARD_MOUSE_DEVICE) == (possiblecontrol >= KEY_JOY1 && possiblecontrol < JOYINPUTEND)) { bestbind = possiblecontrol; diff --git a/src/k_hud.cpp b/src/k_hud.cpp index 7fab59bdb..6cb5e2b2c 100644 --- a/src/k_hud.cpp +++ b/src/k_hud.cpp @@ -6360,12 +6360,7 @@ void K_AddMessageForPlayer(player_t *player, const char *msg, boolean interrupt, if (interrupt) state->clear(); - // FIXME: SUPER BAD HACK. - // Need a way to parse messages as a given player instead. - player_t *oldstplyr = stplyr; - stplyr = player; - std::string parsedmsg = srb2::Draw::TextElement().parse(msg).string(); - stplyr = oldstplyr; + std::string parsedmsg = srb2::Draw::TextElement().as(player - players).parse(msg).string(); if (persist) state->objective = parsedmsg; @@ -6946,12 +6941,7 @@ INT32 K_DrawGameControl(UINT16 x, UINT16 y, UINT8 player, const char *str, UINT8 { using srb2::Draw; - // FIXME: SUPER BAD HACK. - // Need a way to parse messages as a given player instead. - player_t *oldstplyr = stplyr; - stplyr = &players[player]; - Draw::TextElement text = Draw::TextElement().parse(str).font(Draw::Font::kMenu); - stplyr = oldstplyr; + Draw::TextElement text = Draw::TextElement().as(player).parse(str).font(Draw::Font::kMenu); INT32 width = text.width(); diff --git a/src/v_draw.cpp b/src/v_draw.cpp index ee2b940c8..46b3cf1b2 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -169,22 +169,24 @@ Draw::TextElement& Draw::TextElement::parse(std::string_view raw) if (auto id = inputdefinition.find(it->second & (~0xF0)); id != inputdefinition.end()) // This is a game control, do descriptive input translation! { // Grab our local controls - UINT8 localplayer = stplyr - players; + UINT8 targetplayer = as_.value_or(stplyr - players); // If not set in the call to parse(), use stplyr's controls + if (targetplayer >= MAXPLAYERS) + targetplayer = 0; - INT32 bind = G_FindPlayerBindForGameControl(localplayer, id->second); + INT32 bind = G_FindPlayerBindForGameControl(targetplayer, id->second); if (auto pretty = prettyinputs.find(bind); pretty != prettyinputs.end()) // Gamepad direction or keyboard arrow, use something nice-looking { string_.push_back((it->second & 0xF0) | pretty->second); // original invocation has the animation bits, but the glyph bits come from the table } - else if (auto generic = genericinputs.find(bind); generic != genericinputs.end()) // Gamepad input, display it to the player as they are + else if (auto generic = genericinputs.find(bind); generic != genericinputs.end()) // Non-directional gamepad input, display it to the player as they are { - string_.push_back(0xEF); + string_.push_back(0xEF); // Control code: "switch to descriptive input mode" - Saturn buttons will draw as generic gamepad buttons string_.push_back((it->second & 0xF0) | generic->second); // original invocation has the animation bits, but the glyph bits come from the table } else { - string_.push_back('\xEE'); + string_.push_back('\xEE'); // Control code: "toggle boxed drawing" if (bind == -1) string_.append("[NOT BOUND]"); diff --git a/src/v_draw.hpp b/src/v_draw.hpp index da3ccce2f..6035e2317 100644 --- a/src/v_draw.hpp +++ b/src/v_draw.hpp @@ -113,6 +113,7 @@ public: const std::string& string() const { return string_; } std::optional font() const { return font_; } std::optional flags() const { return flags_; } + std::optional as() const { return as_; } int width() const; @@ -142,10 +143,16 @@ public: return *this; } + TextElement& as(UINT8 as) + { + as_ = as; + return *this; + } private: std::string string_; std::optional font_; std::optional flags_; + std::optional as_; }; class Chain From 5c5ab934b30ca53c3d5586de6cd6cae0178b9458 Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Mon, 16 Sep 2024 18:00:45 -0700 Subject: [PATCH 16/56] Touch up keyboard prompt spacing --- src/v_video.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/v_video.cpp b/src/v_video.cpp index 3772cb99a..1925d404a 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -2713,7 +2713,7 @@ void V_DrawStringScaled( } else { - cx += 3*scale; + cx += 2*scale; //V_DrawFill((cx)/FRACUNIT+(fontspec.right_outline), (cy)/FRACUNIT-2, 2, fontspec.lfh/FRACUNIT, flags|outerbox); //V_DrawFill((cx)/FRACUNIT+(fontspec.right_outline), (cy)/FRACUNIT-1, 1, fontspec.lfh/FRACUNIT-2, flags|innerbox); } @@ -3047,7 +3047,7 @@ fixed_t V_StringScaledWidth( break; case '\xEE': if (boxed) - cx += 3*scale; + cx += 2*scale; boxed = !boxed; break; default: From 9edeaaf0ba610fb0f2372e25a669ebcdeff34c3a Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Thu, 19 Sep 2024 02:53:50 -0700 Subject: [PATCH 17/56] Keyboard label fuckapalooza --- src/g_game.c | 5 +++++ src/g_input.c | 7 +++++++ src/g_input.h | 1 + src/k_hud.cpp | 27 +++++++++++++++++++------- src/k_hud.h | 6 +++++- src/k_menudraw.c | 30 ++++++++++++++++++++--------- src/v_video.cpp | 50 ++++++++++++++++++++++++++++++++---------------- 7 files changed, 92 insertions(+), 34 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 0158f6e6b..487fb71f8 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -879,6 +879,7 @@ INT32 G_PlayerInputAnalog(UINT8 p, INT32 gc, UINT8 menuPlayers) // This is only intended for P1. if (main_player == true) { + showgamepadprompts[p] = false; return value; } else @@ -898,6 +899,7 @@ INT32 G_PlayerInputAnalog(UINT8 p, INT32 gc, UINT8 menuPlayers) value = G_GetValueFromControlTable(deviceID, deadzone, &(gamecontrol[p][gc][0])); if (value > 0) { + showgamepadprompts[p] = (deviceID != KEYBOARD_MOUSE_DEVICE); return value; } if (value != NO_BINDS_REACHABLE) @@ -911,6 +913,7 @@ INT32 G_PlayerInputAnalog(UINT8 p, INT32 gc, UINT8 menuPlayers) value = G_GetValueFromControlTable(KEYBOARD_MOUSE_DEVICE, deadzone, &(gamecontrol[p][gc][0])); if (value > 0) { + showgamepadprompts[p] = true; return value; } if (value != NO_BINDS_REACHABLE) @@ -951,6 +954,7 @@ INT32 G_PlayerInputAnalog(UINT8 p, INT32 gc, UINT8 menuPlayers) value = G_GetValueFromControlTable(tryDevice, deadzone, &(gamecontrol[p][gc][0])); if (value > 0) { + showgamepadprompts[p] = (tryDevice != KEYBOARD_MOUSE_DEVICE); return value; } if (value != NO_BINDS_REACHABLE) @@ -967,6 +971,7 @@ INT32 G_PlayerInputAnalog(UINT8 p, INT32 gc, UINT8 menuPlayers) value = G_GetValueFromControlTable(deviceID, deadzone, &(gamecontroldefault[gc][0])); if (value > 0) { + showgamepadprompts[p] = (deviceID != KEYBOARD_MOUSE_DEVICE); return value; } } diff --git a/src/g_input.c b/src/g_input.c index 948eca026..3695656b9 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -33,6 +33,7 @@ INT32 gamekeydown[MAXDEVICES][NUMINPUTS]; // two key codes (or virtual key) per game control INT32 gamecontrol[MAXSPLITSCREENPLAYERS][num_gamecontrols][MAXINPUTMAPPING]; UINT8 gamecontrolflags[MAXSPLITSCREENPLAYERS]; +UINT8 showgamepadprompts[MAXSPLITSCREENPLAYERS]; INT32 gamecontroldefault[num_gamecontrols][MAXINPUTMAPPING]; // default control storage INT32 menucontrolreserved[num_gamecontrols][MAXINPUTMAPPING]; @@ -1274,9 +1275,12 @@ INT32 G_FindPlayerBindForGameControl(INT32 player, gamecontrols_e control) if (ourProfile == NULL) ourProfile = PR_GetLocalPlayerProfile(0); +#if 0 INT32 device = G_GetDeviceForPlayer(player); // TODO: Respond to what device player is CURRENTLY using if (device == -1) // No registered device = you can't possibly be using a gamepad device = KEYBOARD_MOUSE_DEVICE; +#endif + INT32 device = showgamepadprompts[player] ? 1 : KEYBOARD_MOUSE_DEVICE; INT32 bestbind = -1; // Bind that matches our input device INT32 anybind = -1; // Bind that doesn't match, but is at least for this control @@ -1305,6 +1309,8 @@ INT32 G_FindPlayerBindForGameControl(INT32 player, gamecontrols_e control) } } +// DUMBASS. Default controls aren't necessarily in use! +#if 0 // PASS 2: Binds that are in the default controls. if (bestbind == -1) { @@ -1330,6 +1336,7 @@ INT32 G_FindPlayerBindForGameControl(INT32 player, gamecontrols_e control) } } } +#endif // PASS 3: "Safety" binds that are reserved by the menu system. if (bestbind == -1) diff --git a/src/g_input.h b/src/g_input.h index 702a9c8f5..7e1e65a99 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -120,6 +120,7 @@ extern INT32 gamekeydown[MAXDEVICES][NUMINPUTS]; // several key codes (or virtual key) per game control extern INT32 gamecontrol[MAXSPLITSCREENPLAYERS][num_gamecontrols][MAXINPUTMAPPING]; extern UINT8 gamecontrolflags[MAXSPLITSCREENPLAYERS]; +extern UINT8 showgamepadprompts[MAXSPLITSCREENPLAYERS]; extern INT32 gamecontroldefault[num_gamecontrols][MAXINPUTMAPPING]; // default control storage extern INT32 menucontrolreserved[num_gamecontrols][MAXINPUTMAPPING]; diff --git a/src/k_hud.cpp b/src/k_hud.cpp index 6cb5e2b2c..90b5b28fd 100644 --- a/src/k_hud.cpp +++ b/src/k_hud.cpp @@ -257,6 +257,10 @@ patch_t *gen_button_back[2]; patch_t *gen_button_ls[2]; patch_t *gen_button_rs[2]; +patch_t *gen_button_keyleft[2]; +patch_t *gen_button_keyright[2]; +patch_t *gen_button_keycenter[2]; + static void K_LoadButtonGraphics(patch_t *kp[2], int letter) { HU_UpdatePatch(&kp[0], "TLB_%c", letter); @@ -999,10 +1003,17 @@ void K_LoadKartHUDGraphics(void) K_LoadGenericButtonGraphics(gen_button_rt, 'F'); K_LoadGenericButtonGraphics(gen_button_start, 'G'); - K_LoadGenericButtonGraphics(gen_button_back, 'G'); // FIXME + K_LoadGenericButtonGraphics(gen_button_back, 'V'); // FIXME K_LoadGenericButtonGraphics(gen_button_ls, 'T'); K_LoadGenericButtonGraphics(gen_button_rs, 'U'); + + HU_UpdatePatch(&gen_button_keyleft[0], "TLK_L"); + HU_UpdatePatch(&gen_button_keyleft[1], "TLK_R"); + HU_UpdatePatch(&gen_button_keyright[0], "TLK_R"); + HU_UpdatePatch(&gen_button_keyright[1], "TLK_RB"); + HU_UpdatePatch(&gen_button_keycenter[0], "TLK_M"); + HU_UpdatePatch(&gen_button_keycenter[1], "TLK_MB"); } // For the item toggle menu @@ -6498,15 +6509,17 @@ void K_drawKartHUD(void) } - if (0) + if (1) { Draw::TextElement text = Draw::TextElement().parse("\xEELEFTSPACE\xEE\n\xEESPC\xEE \xEETAB\xEE\nA \xEF\xA0 A\nB \xEF\xA1 B\nX \xEF\xA2 X\nY \xEF\xA3 Y\nLB \xEF\xA4 LB\nRB \xEF\xA5 RB\nLT \xEF\xA6 LT\nRT \xEF\xA7 RT\nST \xEF\xA8 ST\nBK \xEF\xA9 BK\nLS \xEF\xAA LS\nRS \xEF\xAB RS\n"); + UINT8 offset = 0; + player_t *oldstplyr = stplyr; stplyr = &players[0]; - Draw(160, 5).align((srb2::Draw::Align)0).font(Draw::Font::kMenu).text(text); + Draw(160+offset, 5).align((srb2::Draw::Align)1).font(Draw::Font::kThin).text(text); stplyr = &players[1]; - Draw(55, 5).align((srb2::Draw::Align)0).font(Draw::Font::kThin).text(text); + Draw(55+offset, 5).align((srb2::Draw::Align)1).font(Draw::Font::kMenu).text(text); stplyr = oldstplyr; } @@ -6937,15 +6950,15 @@ void K_DrawMarginSticker(INT32 x, INT32 y, INT32 width, INT32 flags, boolean isS V_DrawFixedPatch((x + width)*FRACUNIT, y*FRACUNIT, FRACUNIT, flags|V_FLIP, stickerEnd, NULL); } -INT32 K_DrawGameControl(UINT16 x, UINT16 y, UINT8 player, const char *str, UINT8 alignment) +INT32 K_DrawGameControl(UINT16 x, UINT16 y, UINT8 player, const char *str, UINT8 alignment, UINT8 font) { using srb2::Draw; - Draw::TextElement text = Draw::TextElement().as(player).parse(str).font(Draw::Font::kMenu); + Draw::TextElement text = Draw::TextElement().as(player).parse(str).font((Draw::Font)font); INT32 width = text.width(); Draw(x, y).align((srb2::Draw::Align)alignment).text(text); return width; -} +} \ No newline at end of file diff --git a/src/k_hud.h b/src/k_hud.h index db2ff421b..d48b14cf4 100644 --- a/src/k_hud.h +++ b/src/k_hud.h @@ -116,6 +116,10 @@ extern patch_t *gen_button_back[2]; extern patch_t *gen_button_ls[2]; extern patch_t *gen_button_rs[2]; +extern patch_t *gen_button_keyleft[2]; +extern patch_t *gen_button_keyright[2]; +extern patch_t *gen_button_keycenter[2]; + extern patch_t *kp_eggnum[6]; extern patch_t *kp_facenum[MAXPLAYERS+1]; @@ -146,7 +150,7 @@ INT32 K_GetMinimapTransFlags(const boolean usingProgressBar); INT32 K_GetMinimapSplitFlags(const boolean usingProgressBar); position_t K_GetKartObjectPosToMinimapPos(fixed_t objx, fixed_t objy); -INT32 K_DrawGameControl(UINT16 x, UINT16 y, UINT8 player, const char *str, UINT8 alignment); +INT32 K_DrawGameControl(UINT16 x, UINT16 y, UINT8 player, const char *str, UINT8 alignment, UINT8 font); #ifdef __cplusplus } // extern "C" diff --git a/src/k_menudraw.c b/src/k_menudraw.c index e54170242..ff042ce20 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -833,8 +833,9 @@ void M_DrawMenuMessage(void) if (standardbuttons) { workx -= K_DrawGameControl( - workx+2, worky, - 0, " ", 2 + workx+2, worky+2, + 0, " ", + 2, 8 ); } else @@ -863,8 +864,9 @@ void M_DrawMenuMessage(void) if (standardbuttons) { workx -= K_DrawGameControl( - workx+2, worky, - 0, " ", 2 + workx+2, worky+2, + 0, " ", + 2, 8 ); } else @@ -2458,17 +2460,22 @@ void M_DrawCharacterSelect(void) if (!optionsmenu.profile) // Does nothing on this screen { - x += 22; + // x += 22; //K_drawButton((x += 22) * FRACUNIT, (kTop - 3) * FRACUNIT, 0, kp_button_r, M_MenuButtonPressed(pid, MBT_R)); - x += K_DrawGameControl(x, kTop, 0, "", 0); - V_DrawThinString((x), kTop, 0, "Info"); + // x += K_DrawGameControl(x, kTop, 0, "", 0); + // V_DrawThinString((x), kTop, 0, "Info"); + K_DrawGameControl(BASEVIDWIDTH/2, kTop, 0, " Info Default", 1, 0); + } + else + { + K_DrawGameControl(BASEVIDWIDTH/2, kTop, 0, " Accept Back Default", 1, 0); } x += 58; // K_drawButton((x += 58) * FRACUNIT, (kTop - 1) * FRACUNIT, 0, kp_button_c[1], M_MenuButtonPressed(pid, MBT_C)); - x += K_DrawGameControl(x, kTop, 0, "", 0); - V_DrawThinString((x), kTop, 0, "Default"); + // x += K_DrawGameControl(x, kTop, 0, "", 0); + // V_DrawThinString((x), kTop, 0, "Default"); } // We have to loop twice -- first time to draw the drop shadows, a second time to draw the icons. @@ -2578,6 +2585,11 @@ void M_DrawCharacterSelect(void) // Draw the priority player over the other ones M_DrawCharSelectCursor(priority); } + + if (setup_numplayers > 1) + { + V_DrawCenteredThinString(BASEVIDWIDTH/2, BASEVIDHEIGHT-12, V_30TRANS, "\x85""Double-input problems?\x80 Close Steam, DS4Windows, and other controller wrappers!"); + } } // DIFFICULTY SELECT diff --git a/src/v_video.cpp b/src/v_video.cpp index 1925d404a..be9c8a202 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -2592,9 +2592,6 @@ void V_DrawStringScaled( INT32 dupx; INT32 dupy; - const UINT8 outerbox = 26; - const UINT8 innerbox = 16; - fixed_t right; fixed_t bot; @@ -2602,7 +2599,7 @@ void V_DrawStringScaled( boolean uppercase; boolean notcolored; - boolean boxed; + int boxed = 0; boolean descriptive = false; boolean dance; @@ -2610,6 +2607,9 @@ void V_DrawStringScaled( INT32 dancecounter; fixed_t cx, cy; + fixed_t cxsave; + + const char *ssave; fixed_t cxoff, cyoff; fixed_t cw; @@ -2696,6 +2696,8 @@ void V_DrawStringScaled( switch (c) { case '\n': + if (boxed) + continue; cy += fontspec.lfh; if (cy >= bot) return; @@ -2705,18 +2707,34 @@ void V_DrawStringScaled( descriptive = true; break; case '\xEE': - boxed = !boxed; - if (boxed) // draw caps + if (boxed == 0) // Save our position and start no-op drawing { - V_DrawFill((cx)/FRACUNIT-2, (cy)/FRACUNIT-2, (fontspec.right_outline)+2, fontspec.lfh/FRACUNIT, flags|outerbox); - V_DrawFill((cx)/FRACUNIT-1, (cy)/FRACUNIT-1, (fontspec.right_outline)+1, fontspec.lfh/FRACUNIT-2, flags|innerbox); + // TODO animate + Draw(FixedToFloat(cx), FixedToFloat(cy)-3).patch(gen_button_keyleft[0]); + cx += 3*FRACUNIT; + ssave = s; + cxsave = cx; + boxed = 1; } - else + else if (boxed == 1) // Draw box from saved pos to current pos and roll back { - cx += 2*scale; - //V_DrawFill((cx)/FRACUNIT+(fontspec.right_outline), (cy)/FRACUNIT-2, 2, fontspec.lfh/FRACUNIT, flags|outerbox); - //V_DrawFill((cx)/FRACUNIT+(fontspec.right_outline), (cy)/FRACUNIT-1, 1, fontspec.lfh/FRACUNIT-2, flags|innerbox); + cx += (fontspec.right_outline)*FRACUNIT; + fixed_t working = cxsave - 1*FRACUNIT; + // TODO animate + Draw(FixedToFloat(working), FixedToFloat(cy)-3) + .width(FixedToFloat(cx - working)) + .stretch(Draw::Stretch::kWidth).patch(gen_button_keycenter[0]); + Draw(FixedToFloat(cx), FixedToFloat(cy)-3).patch(gen_button_keyright[0]); + s = ssave; + cx = cxsave; + boxed = 2; } + else // Meeting the ending tag the second time, noop + { + boxed = 0; + cx += (4)*FRACUNIT; + } + break; default: if (( c & 0xF0 ) == 0x80) @@ -2948,14 +2966,12 @@ void V_DrawStringScaled( cw = SHORT (font->font[c]->width) * dupx; cxoff = (*fontspec.dim_fn)(scale, fontspec.chw, hchw, dupx, &cw); - if (boxed) + if (boxed != 1) { - V_DrawFill((cx)/FRACUNIT+(fontspec.right_outline), (cy)/FRACUNIT-2, (font->font[c]->width)-(fontspec.right_outline)+2, fontspec.lfh/FRACUNIT, flags|outerbox); - V_DrawFill((cx)/FRACUNIT+(fontspec.right_outline), (cy)/FRACUNIT-1, (font->font[c]->width)-(fontspec.right_outline)+1, fontspec.lfh/FRACUNIT-2, flags|innerbox); + V_DrawFixedPatch(cx + cxoff + patchxofs, cy + cyoff, scale, + flags | ((boxed == 2) ? V_20TRANS : 0), font->font[c], colormap); } - V_DrawFixedPatch(cx + cxoff + patchxofs, cy + cyoff, scale, - flags, font->font[c], colormap); cx += cw; } else From 9c622c283bcce6dcd3c19fe71c5db656bf507f94 Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Thu, 19 Sep 2024 06:17:11 -0700 Subject: [PATCH 18/56] Some keycap alignment stuff --- src/k_hud.cpp | 2 +- src/v_video.cpp | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/k_hud.cpp b/src/k_hud.cpp index 90b5b28fd..79842bf29 100644 --- a/src/k_hud.cpp +++ b/src/k_hud.cpp @@ -6509,7 +6509,7 @@ void K_drawKartHUD(void) } - if (1) + if (0) { Draw::TextElement text = Draw::TextElement().parse("\xEELEFTSPACE\xEE\n\xEESPC\xEE \xEETAB\xEE\nA \xEF\xA0 A\nB \xEF\xA1 B\nX \xEF\xA2 X\nY \xEF\xA3 Y\nLB \xEF\xA4 LB\nRB \xEF\xA5 RB\nLT \xEF\xA6 LT\nRT \xEF\xA7 RT\nST \xEF\xA8 ST\nBK \xEF\xA9 BK\nLS \xEF\xAA LS\nRS \xEF\xAB RS\n"); diff --git a/src/v_video.cpp b/src/v_video.cpp index be9c8a202..90b5ee48e 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -2710,6 +2710,7 @@ void V_DrawStringScaled( if (boxed == 0) // Save our position and start no-op drawing { // TODO animate + cy -= 2*FRACUNIT; Draw(FixedToFloat(cx), FixedToFloat(cy)-3).patch(gen_button_keyleft[0]); cx += 3*FRACUNIT; ssave = s; @@ -2729,10 +2730,11 @@ void V_DrawStringScaled( cx = cxsave; boxed = 2; } - else // Meeting the ending tag the second time, noop + else // Meeting the ending tag the second time, space away and resume standard parsing { boxed = 0; - cx += (4)*FRACUNIT; + cx += (3)*FRACUNIT; + cy += 2*FRACUNIT; } break; @@ -2969,7 +2971,7 @@ void V_DrawStringScaled( if (boxed != 1) { V_DrawFixedPatch(cx + cxoff + patchxofs, cy + cyoff, scale, - flags | ((boxed == 2) ? V_20TRANS : 0), font->font[c], colormap); + flags | ((boxed == 2) ? V_40TRANS : 0), font->font[c], colormap); } cx += cw; @@ -3063,7 +3065,9 @@ fixed_t V_StringScaledWidth( break; case '\xEE': if (boxed) - cx += 2*scale; + cx += 3*FRACUNIT; + else + cx += 3*FRACUNIT; boxed = !boxed; break; default: From 7a9e36cfb4b964df625ccd03decf62e4d3fd2b72 Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Thu, 19 Sep 2024 06:25:59 -0700 Subject: [PATCH 19/56] Read out of binds in use directly! --- src/g_input.c | 52 ++++++++++++--------------------------------------- 1 file changed, 12 insertions(+), 40 deletions(-) diff --git a/src/g_input.c b/src/g_input.c index 3695656b9..068008dbc 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -1271,26 +1271,27 @@ INT32 G_CheckDoubleUsage(INT32 keynum, INT32 playernum, boolean modify) INT32 G_FindPlayerBindForGameControl(INT32 player, gamecontrols_e control) { - profile_t *ourProfile = PR_GetPlayerProfile(&players[player]); - if (ourProfile == NULL) - ourProfile = PR_GetLocalPlayerProfile(0); + UINT8 targetplayer = MAXSPLITSCREENPLAYERS; + for (UINT8 i = 0; i < MAXSPLITSCREENPLAYERS; i++) + { + if (g_localplayers[i] == player) + targetplayer = i; + } -#if 0 - INT32 device = G_GetDeviceForPlayer(player); // TODO: Respond to what device player is CURRENTLY using - if (device == -1) // No registered device = you can't possibly be using a gamepad - device = KEYBOARD_MOUSE_DEVICE; -#endif - INT32 device = showgamepadprompts[player] ? 1 : KEYBOARD_MOUSE_DEVICE; + if (targetplayer == MAXSPLITSCREENPLAYERS) + targetplayer = 0; + + INT32 device = showgamepadprompts[targetplayer] ? 1 : KEYBOARD_MOUSE_DEVICE; INT32 bestbind = -1; // Bind that matches our input device INT32 anybind = -1; // Bind that doesn't match, but is at least for this control INT32 bindindex = MAXINPUTMAPPING-1; - // PASS 1: Binds that are directly in our profile control mapping. + // PASS 1: Binds that are directly in our active control mapping. while (bindindex >= 0) // Prefer earlier binds { - INT32 possiblecontrol = ourProfile->controls[control][bindindex]; + INT32 possiblecontrol = gamecontrol[targetplayer][control][bindindex]; bindindex--; @@ -1309,35 +1310,6 @@ INT32 G_FindPlayerBindForGameControl(INT32 player, gamecontrols_e control) } } -// DUMBASS. Default controls aren't necessarily in use! -#if 0 - // PASS 2: Binds that are in the default controls. - if (bestbind == -1) - { - bindindex = MAXINPUTMAPPING-1; - - while (bindindex >= 0) - { - INT32 possiblecontrol = gamecontroldefault[control][bindindex]; - - bindindex--; - - if (possiblecontrol == 0) - continue; - - if ((device != KEYBOARD_MOUSE_DEVICE) == (possiblecontrol >= KEY_JOY1 && possiblecontrol < JOYINPUTEND)) - { - bestbind = possiblecontrol; - anybind = possiblecontrol; - } - else - { - anybind = possiblecontrol; - } - } - } -#endif - // PASS 3: "Safety" binds that are reserved by the menu system. if (bestbind == -1) { From 735a7923801a088b61c43da2bceb10595fb009d0 Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Thu, 19 Sep 2024 07:12:58 -0700 Subject: [PATCH 20/56] ABSTRACTION HELL --- src/g_game.c | 19 ++++++++++++++----- src/g_input.c | 20 ++++++++------------ src/v_draw.cpp | 17 ++++++++++++----- 3 files changed, 34 insertions(+), 22 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 487fb71f8..5e9f7634e 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -848,6 +848,15 @@ static INT32 G_GetValueFromControlTable(INT32 deviceID, INT32 deadzone, INT32 *c return failret; } +static void G_SetGamepadPrompts(UINT8 p, boolean prompts) +{ + if (showgamepadprompts[p] != prompts) + { + // CONS_Printf("Setting player %d to gamepadprompts %d\n", p, prompts); + showgamepadprompts[p] = prompts; + } +} + INT32 G_PlayerInputAnalog(UINT8 p, INT32 gc, UINT8 menuPlayers) { const INT32 deadzone = (JOYAXISRANGE * cv_deadzone[p].value) / FRACUNIT; @@ -879,7 +888,7 @@ INT32 G_PlayerInputAnalog(UINT8 p, INT32 gc, UINT8 menuPlayers) // This is only intended for P1. if (main_player == true) { - showgamepadprompts[p] = false; + G_SetGamepadPrompts(p, false); return value; } else @@ -899,7 +908,7 @@ INT32 G_PlayerInputAnalog(UINT8 p, INT32 gc, UINT8 menuPlayers) value = G_GetValueFromControlTable(deviceID, deadzone, &(gamecontrol[p][gc][0])); if (value > 0) { - showgamepadprompts[p] = (deviceID != KEYBOARD_MOUSE_DEVICE); + G_SetGamepadPrompts(p, (deviceID != KEYBOARD_MOUSE_DEVICE)); return value; } if (value != NO_BINDS_REACHABLE) @@ -913,7 +922,7 @@ INT32 G_PlayerInputAnalog(UINT8 p, INT32 gc, UINT8 menuPlayers) value = G_GetValueFromControlTable(KEYBOARD_MOUSE_DEVICE, deadzone, &(gamecontrol[p][gc][0])); if (value > 0) { - showgamepadprompts[p] = true; + G_SetGamepadPrompts(p, false); return value; } if (value != NO_BINDS_REACHABLE) @@ -954,7 +963,7 @@ INT32 G_PlayerInputAnalog(UINT8 p, INT32 gc, UINT8 menuPlayers) value = G_GetValueFromControlTable(tryDevice, deadzone, &(gamecontrol[p][gc][0])); if (value > 0) { - showgamepadprompts[p] = (tryDevice != KEYBOARD_MOUSE_DEVICE); + G_SetGamepadPrompts(p, (tryDevice != KEYBOARD_MOUSE_DEVICE)); return value; } if (value != NO_BINDS_REACHABLE) @@ -971,7 +980,7 @@ INT32 G_PlayerInputAnalog(UINT8 p, INT32 gc, UINT8 menuPlayers) value = G_GetValueFromControlTable(deviceID, deadzone, &(gamecontroldefault[gc][0])); if (value > 0) { - showgamepadprompts[p] = (deviceID != KEYBOARD_MOUSE_DEVICE); + G_SetGamepadPrompts(p, (deviceID != KEYBOARD_MOUSE_DEVICE)); return value; } } diff --git a/src/g_input.c b/src/g_input.c index 068008dbc..2859ff500 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -1271,27 +1271,19 @@ INT32 G_CheckDoubleUsage(INT32 keynum, INT32 playernum, boolean modify) INT32 G_FindPlayerBindForGameControl(INT32 player, gamecontrols_e control) { - UINT8 targetplayer = MAXSPLITSCREENPLAYERS; - for (UINT8 i = 0; i < MAXSPLITSCREENPLAYERS; i++) - { - if (g_localplayers[i] == player) - targetplayer = i; - } - - if (targetplayer == MAXSPLITSCREENPLAYERS) - targetplayer = 0; - - INT32 device = showgamepadprompts[targetplayer] ? 1 : KEYBOARD_MOUSE_DEVICE; + INT32 device = showgamepadprompts[player] ? 1 : KEYBOARD_MOUSE_DEVICE; INT32 bestbind = -1; // Bind that matches our input device INT32 anybind = -1; // Bind that doesn't match, but is at least for this control INT32 bindindex = MAXINPUTMAPPING-1; + // CONS_Printf("Check bind %d for player %d device %d\n", control, player, device); + // PASS 1: Binds that are directly in our active control mapping. while (bindindex >= 0) // Prefer earlier binds { - INT32 possiblecontrol = gamecontrol[targetplayer][control][bindindex]; + INT32 possiblecontrol = gamecontrol[player][control][bindindex]; bindindex--; @@ -1301,11 +1293,13 @@ INT32 G_FindPlayerBindForGameControl(INT32 player, gamecontrols_e control) // if (device is gamepad) == (bound control is in gamepad range) - e.g. if bind matches device if ((device != KEYBOARD_MOUSE_DEVICE) == (possiblecontrol >= KEY_JOY1 && possiblecontrol < JOYINPUTEND)) { + // CONS_Printf("PASS1 found %s\n", G_KeynumToShortString(possiblecontrol)); bestbind = possiblecontrol; anybind = possiblecontrol; } else { + // CONS_Printf("PASS1 considering %s\n", G_KeynumToShortString(possiblecontrol)); anybind = possiblecontrol; } } @@ -1326,11 +1320,13 @@ INT32 G_FindPlayerBindForGameControl(INT32 player, gamecontrols_e control) if ((device != KEYBOARD_MOUSE_DEVICE) == (possiblecontrol >= KEY_JOY1 && possiblecontrol < JOYINPUTEND)) { + // CONS_Printf("PASS2 found %s\n", G_KeynumToShortString(possiblecontrol)); bestbind = possiblecontrol; anybind = possiblecontrol; } else { + // CONS_Printf("PASS2 considering %s\n", G_KeynumToShortString(possiblecontrol)); anybind = possiblecontrol; } } diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 46b3cf1b2..b387a2fa8 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -168,12 +168,19 @@ Draw::TextElement& Draw::TextElement::parse(std::string_view raw) { if (auto id = inputdefinition.find(it->second & (~0xF0)); id != inputdefinition.end()) // This is a game control, do descriptive input translation! { - // Grab our local controls - UINT8 targetplayer = as_.value_or(stplyr - players); // If not set in the call to parse(), use stplyr's controls - if (targetplayer >= MAXPLAYERS) - targetplayer = 0; + // Grab our local controls - if pid set in the call to parse(), use stplyr's controls + UINT8 localplayer = 0; + UINT8 indexedplayer = as_.value_or(stplyr - players); + for (UINT8 i = 0; i < MAXSPLITSCREENPLAYERS; i++) + { + if (g_localplayers[i] == indexedplayer) + { + localplayer = i; + break; + } + } - INT32 bind = G_FindPlayerBindForGameControl(targetplayer, id->second); + INT32 bind = G_FindPlayerBindForGameControl(localplayer, id->second); if (auto pretty = prettyinputs.find(bind); pretty != prettyinputs.end()) // Gamepad direction or keyboard arrow, use something nice-looking { From 43960d7a23c8e6c83e40090be9418e6a6fc0489b Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Thu, 19 Sep 2024 20:53:27 -0700 Subject: [PATCH 21/56] Animated keyboard, prelim large buttons --- src/k_hud.cpp | 21 +++---- src/k_menudraw.c | 4 +- src/v_draw.cpp | 16 ++++- src/v_draw.hpp | 2 +- src/v_video.cpp | 148 ++++++++++++++++++++++------------------------- 5 files changed, 92 insertions(+), 99 deletions(-) diff --git a/src/k_hud.cpp b/src/k_hud.cpp index 79842bf29..ab8bfb577 100644 --- a/src/k_hud.cpp +++ b/src/k_hud.cpp @@ -1009,7 +1009,7 @@ void K_LoadKartHUDGraphics(void) K_LoadGenericButtonGraphics(gen_button_rs, 'U'); HU_UpdatePatch(&gen_button_keyleft[0], "TLK_L"); - HU_UpdatePatch(&gen_button_keyleft[1], "TLK_R"); + HU_UpdatePatch(&gen_button_keyleft[1], "TLK_LB"); HU_UpdatePatch(&gen_button_keyright[0], "TLK_R"); HU_UpdatePatch(&gen_button_keyright[1], "TLK_RB"); HU_UpdatePatch(&gen_button_keycenter[0], "TLK_M"); @@ -6496,16 +6496,14 @@ void K_drawKartHUD(void) #if 1 using srb2::Draw; - if (0) + if (1) { - Draw::TextElement text = Draw::TextElement().parse("A B C X Y Z \nST L R U D L R "); + // Draw::TextElement text = Draw::TextElement().parse("A B C X Y Z \nST L R U D L R "); + Draw::TextElement text = Draw::TextElement().parse("Unpressed Pressed Animated "); - player_t *oldstplyr = stplyr; - stplyr = &players[0]; - Draw(5, 5).align((srb2::Draw::Align)0).font(Draw::Font::kMenu).text(text); - stplyr = &players[1]; - Draw(5, 35).align((srb2::Draw::Align)0).font(Draw::Font::kThin).text(text); - stplyr = oldstplyr; + UINT8 fakeoff = (stplyr - players)*40; + Draw(5, 5+fakeoff).align((srb2::Draw::Align)0).font(Draw::Font::kMenu).text(text); + Draw(5, 20+fakeoff).align((srb2::Draw::Align)0).font(Draw::Font::kThin).text(text); } @@ -6514,13 +6512,8 @@ void K_drawKartHUD(void) Draw::TextElement text = Draw::TextElement().parse("\xEELEFTSPACE\xEE\n\xEESPC\xEE \xEETAB\xEE\nA \xEF\xA0 A\nB \xEF\xA1 B\nX \xEF\xA2 X\nY \xEF\xA3 Y\nLB \xEF\xA4 LB\nRB \xEF\xA5 RB\nLT \xEF\xA6 LT\nRT \xEF\xA7 RT\nST \xEF\xA8 ST\nBK \xEF\xA9 BK\nLS \xEF\xAA LS\nRS \xEF\xAB RS\n"); UINT8 offset = 0; - - player_t *oldstplyr = stplyr; - stplyr = &players[0]; Draw(160+offset, 5).align((srb2::Draw::Align)1).font(Draw::Font::kThin).text(text); - stplyr = &players[1]; Draw(55+offset, 5).align((srb2::Draw::Align)1).font(Draw::Font::kMenu).text(text); - stplyr = oldstplyr; } /* diff --git a/src/k_menudraw.c b/src/k_menudraw.c index ff042ce20..459148362 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -2464,11 +2464,11 @@ void M_DrawCharacterSelect(void) //K_drawButton((x += 22) * FRACUNIT, (kTop - 3) * FRACUNIT, 0, kp_button_r, M_MenuButtonPressed(pid, MBT_R)); // x += K_DrawGameControl(x, kTop, 0, "", 0); // V_DrawThinString((x), kTop, 0, "Info"); - K_DrawGameControl(BASEVIDWIDTH/2, kTop, 0, " Info Default", 1, 0); + K_DrawGameControl(BASEVIDWIDTH/2, kTop, 0, " Info Default", 1, 0); } else { - K_DrawGameControl(BASEVIDWIDTH/2, kTop, 0, " Accept Back Default", 1, 0); + K_DrawGameControl(BASEVIDWIDTH/2, kTop, 0, " Accept Back Default", 1, 0); } x += 58; diff --git a/src/v_draw.cpp b/src/v_draw.cpp index b387a2fa8..73f78f147 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -61,6 +61,8 @@ Draw::TextElement& Draw::TextElement::parse(std::string_view raw) #undef BUTTON + {"large", 0xEB}, + {"white", 0x80}, {"purple", 0x81}, {"yellow", 0x82}, @@ -166,7 +168,7 @@ Draw::TextElement& Draw::TextElement::parse(std::string_view raw) // FIXME: This isn't how v_video.cpp checks for buttons and I don't know why. if (cv_descriptiveinput.value && ((it->second & 0xF0) != 0x80)) // Should we do game control translation? { - if (auto id = inputdefinition.find(it->second & (~0xF0)); id != inputdefinition.end()) // This is a game control, do descriptive input translation! + if (auto id = inputdefinition.find(it->second & (~0xB0)); id != inputdefinition.end()) // This is a game control, do descriptive input translation! { // Grab our local controls - if pid set in the call to parse(), use stplyr's controls UINT8 localplayer = 0; @@ -193,14 +195,22 @@ Draw::TextElement& Draw::TextElement::parse(std::string_view raw) } else { - string_.push_back('\xEE'); // Control code: "toggle boxed drawing" + UINT8 fragment = (it->second & 0xB0); + UINT8 code = '\xEE'; // Control code: "toggle boxed drawing" + + if (fragment == 0xA0) + code = '\xED'; // ... but animated + else if (fragment == 0x90) + code = '\xEC'; // ... but pressed + + string_.push_back(code); if (bind == -1) string_.append("[NOT BOUND]"); else string_.append((G_KeynumToShortString(bind))); - string_.push_back('\xEE'); + string_.push_back(code); } } else // This is a color code or some other generic glyph, treat it as is. diff --git a/src/v_draw.hpp b/src/v_draw.hpp index 6035e2317..a1c2a86c0 100644 --- a/src/v_draw.hpp +++ b/src/v_draw.hpp @@ -218,7 +218,7 @@ public: void button(Button type, std::optional press = {}) const { button_(type, 0, press); } void small_button(Button type, std::optional press = {}) const { button_(type, 1, press); } - void generic_button(Button type, std::optional press = {}) const { button_(type, 0, press); } + void generic_button(GenericButton type, std::optional press = {}) const { generic_button_(type, 0, press); } void generic_small_button(GenericButton type, std::optional press = {}) const { generic_button_(type, 1, press); } void sticker(patch_t* end_graphic, UINT8 color) const; diff --git a/src/v_video.cpp b/src/v_video.cpp index 90b5ee48e..1ba86ecae 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -2606,6 +2606,8 @@ void V_DrawStringScaled( boolean nodanceoverride; INT32 dancecounter; + boolean largebutton = false; + fixed_t cx, cy; fixed_t cxsave; @@ -2703,41 +2705,66 @@ void V_DrawStringScaled( return; cx = x; break; + case '\xEB': + largebutton = true; + break; case '\xEF': descriptive = true; break; case '\xEE': + case '\xED': + case '\xEC': + { + UINT8 anim_duration = 16; + boolean anim = ((I_GetTime() % (anim_duration * 2)) < anim_duration); + if (c == '\xEE') + anim = false; + else if (c == '\xEC') + anim = true; + + // For bullshit text outlining reasons, we cannot draw this background character-by-character. + // Thinking about doing string manipulation and calling out to V_StringWidth made me drink water. + // So instead, we just draw this section of the string twice—invisibly the first time, to measure the width. + if (boxed == 0) // Save our position and start no-op drawing { - // TODO animate cy -= 2*FRACUNIT; - Draw(FixedToFloat(cx), FixedToFloat(cy)-3).patch(gen_button_keyleft[0]); + + Draw(FixedToFloat(cx), FixedToFloat(cy)-3).patch(gen_button_keyleft[anim]); + cx += 3*FRACUNIT; ssave = s; cxsave = cx; + boxed = 1; } else if (boxed == 1) // Draw box from saved pos to current pos and roll back { cx += (fontspec.right_outline)*FRACUNIT; fixed_t working = cxsave - 1*FRACUNIT; - // TODO animate - Draw(FixedToFloat(working), FixedToFloat(cy)-3) - .width(FixedToFloat(cx - working)) - .stretch(Draw::Stretch::kWidth).patch(gen_button_keycenter[0]); - Draw(FixedToFloat(cx), FixedToFloat(cy)-3).patch(gen_button_keyright[0]); + + Draw(FixedToFloat(working)+1, FixedToFloat(cy)-3) + .width(FixedToFloat(cx - working)-1) + .stretch(Draw::Stretch::kWidth).patch(gen_button_keycenter[anim]); + Draw(FixedToFloat(cx), FixedToFloat(cy)-3).patch(gen_button_keyright[anim]); + s = ssave; cx = cxsave; - boxed = 2; + + // This is a little gross, but this is our way of smuggling text offset to + // the standard character drawing case. boxed=3 means we're drawing a pressed button. + boxed = 2 + anim; } else // Meeting the ending tag the second time, space away and resume standard parsing { boxed = 0; + cx += (3)*FRACUNIT; cy += 2*FRACUNIT; } break; + } default: if (( c & 0xF0 ) == 0x80) { @@ -2836,13 +2863,21 @@ void V_DrawStringScaled( cw = V_GetButtonCodeWidth(c) * dupx; cxoff = (*fontspec.dim_fn)(scale, fontspec.chw, hchw, dupx, &cw); - Draw( + + Draw bt = Draw( FixedToFloat(cx + cxoff) - (bt_inst->x * dupx), FixedToFloat(cy + cyoff) - ((bt_inst->y + fontspec.button_yofs) * dupy)) - .flags(flags) - .small_button(bt_inst->type, bt_translate_press()); + .flags(flags); + + if (largebutton) + bt.button(bt_inst->type, bt_translate_press()); + else + bt.small_button(bt_inst->type, bt_translate_press()); + cx += cw; } + descriptive = false; + largebutton = false; break; } else @@ -2890,73 +2925,23 @@ void V_DrawStringScaled( cw = V_GetGenericButtonCodeWidth(c) * dupx; cxoff = (*fontspec.dim_fn)(scale, fontspec.chw, hchw, dupx, &cw); - Draw( + + Draw bt = Draw( FixedToFloat(cx + cxoff) - (bt_inst->x * dupx), FixedToFloat(cy + cyoff) - ((bt_inst->y + fontspec.button_yofs) * dupy)) - .flags(flags) - .generic_small_button(bt_inst->type, bt_translate_press()); + .flags(flags); + + if (largebutton) + bt.generic_button(bt_inst->type, bt_translate_press()); + else + bt.generic_small_button(bt_inst->type, bt_translate_press()); + cx += cw; } + descriptive = false; + largebutton = false; break; } - using srb2::Draw; - - struct BtConf - { - UINT8 x, y; - Draw::Button type; - }; - - auto bt_inst = [c]() -> std::optional - { - switch (c & 0x0F) - { - case 0x00: return {{1, 3, Draw::Button::up}}; - case 0x01: return {{1, 3, Draw::Button::down}}; - case 0x02: return {{1, 3, Draw::Button::right}}; - case 0x03: return {{1, 3, Draw::Button::left}}; - - case 0x04: return {{0, 4, Draw::Button::dpad}}; - - case 0x07: return {{0, 2, Draw::Button::r}}; - case 0x08: return {{0, 2, Draw::Button::l}}; - - case 0x09: return {{0, 1, Draw::Button::start}}; - - case 0x0A: return {{2, 1, Draw::Button::a}}; - case 0x0B: return {{2, 1, Draw::Button::b}}; - case 0x0C: return {{2, 1, Draw::Button::c}}; - - case 0x0D: return {{2, 1, Draw::Button::x}}; - case 0x0E: return {{2, 1, Draw::Button::y}}; - case 0x0F: return {{2, 1, Draw::Button::z}}; - - default: return {}; - } - }(); - - if (bt_inst) - { - auto bt_translate_press = [c]() -> std::optional - { - switch (c & 0xB0) - { - default: - case 0x90: return true; - case 0xA0: return {}; - case 0xB0: return false; - } - }; - - cw = V_GetButtonCodeWidth(c) * dupx; - cxoff = (*fontspec.dim_fn)(scale, fontspec.chw, hchw, dupx, &cw); - Draw( - FixedToFloat(cx + cxoff) - (bt_inst->x * dupx), - FixedToFloat(cy + cyoff) - ((bt_inst->y + fontspec.button_yofs) * dupy)) - .flags(flags) - .small_button(bt_inst->type, bt_translate_press()); - cx += cw; - } break; } @@ -2970,16 +2955,14 @@ void V_DrawStringScaled( if (boxed != 1) { - V_DrawFixedPatch(cx + cxoff + patchxofs, cy + cyoff, scale, - flags | ((boxed == 2) ? V_40TRANS : 0), font->font[c], colormap); + V_DrawFixedPatch(cx + cxoff + patchxofs, cy + cyoff + (boxed == 3 ? 2*FRACUNIT : 0), scale, + flags | ((!!boxed) ? V_40TRANS : 0), font->font[c], colormap); } cx += cw; } else cx += fontspec.spacew; - - descriptive = false; } } } @@ -3001,7 +2984,8 @@ fixed_t V_StringScaledWidth( boolean uppercase; boolean boxed = false; - boolean descriptive = false;; + boolean descriptive = false; + boolean largebutton = false; fixed_t cx; fixed_t right; @@ -3060,10 +3044,14 @@ fixed_t V_StringScaledWidth( case '\n': cx = 0; break; + case '\xEB': + largebutton = true; case '\xEF': descriptive = true; break; case '\xEE': + case '\xED': + case '\xEC': if (boxed) cx += 3*FRACUNIT; else @@ -3081,15 +3069,17 @@ fixed_t V_StringScaledWidth( cw = V_GetGenericButtonCodeWidth(c) * dupx; cx += cw * scale; right = cx; - break; } else { cw = V_GetButtonCodeWidth(c) * dupx; cx += cw * scale; right = cx; - break; } + + largebutton = false; + descriptive = false; + break; } if (uppercase) From 9a669ff8643f0ecf3a7b4a12a56117fd9f89a90a Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Thu, 19 Sep 2024 21:51:32 -0700 Subject: [PATCH 22/56] scratchass big buttons --- src/k_dialogue.cpp | 22 +++++++++++++--------- src/k_hud.cpp | 2 +- src/v_video.cpp | 14 ++++++++++++-- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/k_dialogue.cpp b/src/k_dialogue.cpp index 74abfa72e..c7c5beaa8 100644 --- a/src/k_dialogue.cpp +++ b/src/k_dialogue.cpp @@ -486,18 +486,22 @@ void Dialogue::Draw(void) .patch(patchCache["TUTDIAG2"]); } - auto bt_translate_press = [this]() -> std::optional - { - if (Held()) - return true; - if (TextDone()) - return {}; - return false; - }; + std::string ctrl = ""; + + if (Held()) + ctrl += ""; + else if (TextDone()) + ctrl += ""; + else + ctrl += ""; + + // FIXME: Old animation behavior (bt_translate_press above) + std::string parsedctrl = srb2::Draw::TextElement().parse(ctrl).string(); drawer .xy(17-14 - BASEVIDWIDTH, -39-16) - .button(srb2::Draw::Button::z, bt_translate_press()); + .font(Draw::Font::kMenu) + .text(parsedctrl); } } diff --git a/src/k_hud.cpp b/src/k_hud.cpp index ab8bfb577..8f8eae434 100644 --- a/src/k_hud.cpp +++ b/src/k_hud.cpp @@ -6496,7 +6496,7 @@ void K_drawKartHUD(void) #if 1 using srb2::Draw; - if (1) + if (0) { // Draw::TextElement text = Draw::TextElement().parse("A B C X Y Z \nST L R U D L R "); Draw::TextElement text = Draw::TextElement().parse("Unpressed Pressed Animated "); diff --git a/src/v_video.cpp b/src/v_video.cpp index 1ba86ecae..63005c92b 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -2862,11 +2862,16 @@ void V_DrawStringScaled( }; cw = V_GetButtonCodeWidth(c) * dupx; + + // FIXME do real widths + if (largebutton) + cw += 3*dupx; + cxoff = (*fontspec.dim_fn)(scale, fontspec.chw, hchw, dupx, &cw); Draw bt = Draw( FixedToFloat(cx + cxoff) - (bt_inst->x * dupx), - FixedToFloat(cy + cyoff) - ((bt_inst->y + fontspec.button_yofs) * dupy)) + FixedToFloat(cy + cyoff) - ((bt_inst->y + fontspec.button_yofs) * dupy) - (largebutton ? 2*dupy : 0)) .flags(flags); if (largebutton) @@ -2924,11 +2929,16 @@ void V_DrawStringScaled( }; cw = V_GetGenericButtonCodeWidth(c) * dupx; + + // FIXME do real widths + if (largebutton) + cw += 3*dupx; + cxoff = (*fontspec.dim_fn)(scale, fontspec.chw, hchw, dupx, &cw); Draw bt = Draw( FixedToFloat(cx + cxoff) - (bt_inst->x * dupx), - FixedToFloat(cy + cyoff) - ((bt_inst->y + fontspec.button_yofs) * dupy)) + FixedToFloat(cy + cyoff) - ((bt_inst->y + fontspec.button_yofs) * dupy) - (largebutton ? 2*dupy : 0)) .flags(flags); if (largebutton) From 1d7aa0ee18016ab0c0eef78b3d4859a21cac61c5 Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Thu, 19 Sep 2024 22:25:22 -0700 Subject: [PATCH 23/56] Inline dialogue advance prompt --- src/k_dialogue.cpp | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/k_dialogue.cpp b/src/k_dialogue.cpp index c7c5beaa8..fc163498f 100644 --- a/src/k_dialogue.cpp +++ b/src/k_dialogue.cpp @@ -472,11 +472,35 @@ void Dialogue::Draw(void) .flags(V_VFLIP|V_FLIP) .patch(patchCache["TUTDIAGE"]); + std::string intertext = ""; + + if (Dismissable() && typewriter.text.length() > 0) + { + if (TextDone()) + { + drawer + .xy(-14, -7-5) + .patch(patchCache["TUTDIAG2"]); + } + + intertext += " "; + + if (Held()) + intertext += ""; + else if (TextDone()) + intertext += ""; + else + intertext += ""; + } + + std::string fulltext = typewriter.text + srb2::Draw::TextElement().parse(intertext).string(); + drawer .xy(10 - BASEVIDWIDTH, -3-32) .font(srb2::Draw::Font::kConsole) - .text( typewriter.text.c_str() ); + .text( fulltext.c_str() ); + /* if (Dismissable()) { if (TextDone()) @@ -495,7 +519,6 @@ void Dialogue::Draw(void) else ctrl += ""; - // FIXME: Old animation behavior (bt_translate_press above) std::string parsedctrl = srb2::Draw::TextElement().parse(ctrl).string(); drawer @@ -503,6 +526,7 @@ void Dialogue::Draw(void) .font(Draw::Font::kMenu) .text(parsedctrl); } + */ } void Dialogue::Dismiss(void) From dfdd46d69f3b789acfc78050a4e49915848a87ad Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Thu, 19 Sep 2024 22:50:25 -0700 Subject: [PATCH 24/56] Something something large buttons --- src/v_draw.cpp | 1 + src/v_video.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 73f78f147..4120a8dc1 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -191,6 +191,7 @@ Draw::TextElement& Draw::TextElement::parse(std::string_view raw) else if (auto generic = genericinputs.find(bind); generic != genericinputs.end()) // Non-directional gamepad input, display it to the player as they are { string_.push_back(0xEF); // Control code: "switch to descriptive input mode" - Saturn buttons will draw as generic gamepad buttons + string_.push_back(0xEB); // Control code: "large button" string_.push_back((it->second & 0xF0) | generic->second); // original invocation has the animation bits, but the glyph bits come from the table } else diff --git a/src/v_video.cpp b/src/v_video.cpp index 63005c92b..10bdb41f0 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -2706,7 +2706,8 @@ void V_DrawStringScaled( cx = x; break; case '\xEB': - largebutton = true; + if (fontno != TINY_FONT) + largebutton = true; break; case '\xEF': descriptive = true; @@ -3055,7 +3056,8 @@ fixed_t V_StringScaledWidth( cx = 0; break; case '\xEB': - largebutton = true; + if (fontno != TINY_FONT) + largebutton = true; case '\xEF': descriptive = true; break; From 7573c7dac90b4ed07e17e6768e9c55dd4d650445 Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Sat, 21 Sep 2024 19:30:59 -0700 Subject: [PATCH 25/56] idk --- src/k_dialogue.cpp | 39 ++++++++++++----------------- src/k_hud.cpp | 10 ++++++++ src/k_menudraw.c | 13 ++++++++++ src/v_draw.cpp | 4 +++ src/v_video.cpp | 61 +++++++++++++++++++++++++++++----------------- 5 files changed, 82 insertions(+), 45 deletions(-) diff --git a/src/k_dialogue.cpp b/src/k_dialogue.cpp index fc163498f..4f965c25a 100644 --- a/src/k_dialogue.cpp +++ b/src/k_dialogue.cpp @@ -241,7 +241,7 @@ void Dialogue::NewText(std::string_view rawText) Init(); char* newText = V_ScaledWordWrap( - 290 << FRACBITS, + 275 << FRACBITS, FRACUNIT, FRACUNIT, FRACUNIT, 0, HU_FONT, srb2::Draw::TextElement().parse(rawText).string().c_str() // parse special characters @@ -474,31 +474,24 @@ void Dialogue::Draw(void) std::string intertext = ""; - if (Dismissable() && typewriter.text.length() > 0) - { - if (TextDone()) - { - drawer - .xy(-14, -7-5) - .patch(patchCache["TUTDIAG2"]); - } - - intertext += " "; - - if (Held()) - intertext += ""; - else if (TextDone()) - intertext += ""; - else - intertext += ""; - } - - std::string fulltext = typewriter.text + srb2::Draw::TextElement().parse(intertext).string(); - drawer .xy(10 - BASEVIDWIDTH, -3-32) .font(srb2::Draw::Font::kConsole) - .text( fulltext.c_str() ); + .text( typewriter.text.c_str() ); + + if (TextDone()) + { + drawer + .xy(-18 - 5, -7-5) + .patch(patchCache["TUTDIAG2"]); + + if (Held()) + intertext += ""; + else + intertext += ""; + + drawer.xy(-18 + 4 - 5, -7-8 - 14).align(Draw::Align::kCenter).font(Draw::Font::kMenu).text(srb2::Draw::TextElement().parse(intertext).string()); + } /* if (Dismissable()) diff --git a/src/k_hud.cpp b/src/k_hud.cpp index 8f8eae434..7c098fb07 100644 --- a/src/k_hud.cpp +++ b/src/k_hud.cpp @@ -6516,6 +6516,16 @@ void K_drawKartHUD(void) Draw(55+offset, 5).align((srb2::Draw::Align)1).font(Draw::Font::kMenu).text(text); } + if (0) + { + Draw::TextElement text = Draw::TextElement().parse("\xEELEFTSPACE\xEE\n\xEESPC\xEE \xEETAB\xEE\nA \xEB\xEF\xA0 A\nB \xEB\xEF\xA1 B\nX \xEB\xEF\xA2 X\nY \xEB\xEF\xA3 Y\nLB \xEB\xEF\xA4 LB\nRB \xEB\xEF\xA5 RB\nLT \xEB\xEF\xA6 LT\nRT \xEB\xEF\xA7 RT\nST \xEB\xEF\xA8 ST\nBK \xEB\xEF\xA9 BK\nLS \xEB\xEF\xAA LS\nRS \xEB\xEF\xAB RS\n"); + + UINT8 offset = 0; + Draw(160+offset, 5).align((srb2::Draw::Align)1).font(Draw::Font::kThin).text(text); + Draw(55+offset, 5).align((srb2::Draw::Align)1).font(Draw::Font::kMenu).text(text); + } + + /* stplyr = &players[2]; Draw(5, 25).align((srb2::Draw::Align)0).font(Draw::Font::kConsole).text(text); diff --git a/src/k_menudraw.c b/src/k_menudraw.c index 459148362..c63f94242 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -6099,6 +6099,19 @@ void M_DrawPause(void) Y_RoundQueueDrawer(&standings, offset/2, false, false); } + else if (gametype == GT_TUTORIAL) + { + K_DrawGameControl(4, 184 - 60 + offset/2, 0, " Steering", 0, 0); + K_DrawGameControl(4, 184 - 45 + offset/2, 0, " Accelerate", 0, 0); + K_DrawGameControl(4, 184 - 30 + offset/2, 0, " Look Back", 0, 0); + K_DrawGameControl(4, 184 - 15 + offset/2, 0, " Spindash", 0, 0); + K_DrawGameControl(4, 184 - 0 + offset/2, 0, " Item", 0, 0); + + K_DrawGameControl(90, 184 - 45 + offset/2, 0, " Brake", 0, 0); + K_DrawGameControl(90, 184 - 30 + offset/2, 0, " Respawn", 0, 0); + K_DrawGameControl(90, 184 - 15 + offset/2, 0, " Dialogue / Action", 0, 0); + K_DrawGameControl(90, 184 - 0 + offset/2, 0, " Drift", 0, 0); + } else { V_DrawMenuString(4, 188 + offset/2, V_YELLOWMAP, M_GetGameplayMode()); diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 4120a8dc1..d9c6ea44d 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -63,6 +63,10 @@ Draw::TextElement& Draw::TextElement::parse(std::string_view raw) {"large", 0xEB}, + {"box", 0xEC}, + {"box_pressed", 0xED}, + {"box_animated", 0xEE}, + {"white", 0x80}, {"purple", 0x81}, {"yellow", 0x82}, diff --git a/src/v_video.cpp b/src/v_video.cpp index 10bdb41f0..1adaaa851 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -2494,7 +2494,7 @@ static void V_GetFontSpecification(int fontno, INT32 flags, fontspec_t *result) } } -static UINT8 V_GetButtonCodeWidth(UINT8 c) +static UINT8 V_GetButtonCodeWidth(UINT8 c, boolean largebutton) { UINT8 x = 0; @@ -2527,14 +2527,14 @@ static UINT8 V_GetButtonCodeWidth(UINT8 c) case 0x0E: case 0x0F: // faces - x = 10; + x = largebutton ? 13 : 10; break; } return x; } -static UINT8 V_GetGenericButtonCodeWidth(UINT8 c) +static UINT8 V_GetGenericButtonCodeWidth(UINT8 c, boolean largebutton) { UINT8 x = 0; @@ -2545,7 +2545,7 @@ static UINT8 V_GetGenericButtonCodeWidth(UINT8 c) case 0x02: case 0x03: // buttons - x = 14; + x = largebutton ? 17 : 14; break; case 0x04: @@ -2563,7 +2563,7 @@ static UINT8 V_GetGenericButtonCodeWidth(UINT8 c) case 0x08: case 0x09: // nav - x = 16; + x = 14; break; case 0x0A: @@ -2706,7 +2706,7 @@ void V_DrawStringScaled( cx = x; break; case '\xEB': - if (fontno != TINY_FONT) + if (fontno != TINY_FONT && fontno != HU_FONT) largebutton = true; break; case '\xEF': @@ -2862,17 +2862,13 @@ void V_DrawStringScaled( } }; - cw = V_GetButtonCodeWidth(c) * dupx; - - // FIXME do real widths - if (largebutton) - cw += 3*dupx; + cw = V_GetButtonCodeWidth(c, largebutton) * dupx; cxoff = (*fontspec.dim_fn)(scale, fontspec.chw, hchw, dupx, &cw); Draw bt = Draw( FixedToFloat(cx + cxoff) - (bt_inst->x * dupx), - FixedToFloat(cy + cyoff) - ((bt_inst->y + fontspec.button_yofs) * dupy) - (largebutton ? 2*dupy : 0)) + FixedToFloat(cy + cyoff) - ((bt_inst->y + fontspec.button_yofs) * dupy) - (largebutton ? 0*dupy : 0)) .flags(flags); if (largebutton) @@ -2929,17 +2925,13 @@ void V_DrawStringScaled( } }; - cw = V_GetGenericButtonCodeWidth(c) * dupx; - - // FIXME do real widths - if (largebutton) - cw += 3*dupx; + cw = V_GetGenericButtonCodeWidth(c, largebutton) * dupx; cxoff = (*fontspec.dim_fn)(scale, fontspec.chw, hchw, dupx, &cw); Draw bt = Draw( FixedToFloat(cx + cxoff) - (bt_inst->x * dupx), - FixedToFloat(cy + cyoff) - ((bt_inst->y + fontspec.button_yofs) * dupy) - (largebutton ? 2*dupy : 0)) + FixedToFloat(cy + cyoff) - ((bt_inst->y + fontspec.button_yofs) * dupy) - (largebutton ? 0*dupy : 0)) .flags(flags); if (largebutton) @@ -3056,7 +3048,7 @@ fixed_t V_StringScaledWidth( cx = 0; break; case '\xEB': - if (fontno != TINY_FONT) + if (fontno != TINY_FONT && fontno != HU_FONT) largebutton = true; case '\xEF': descriptive = true; @@ -3078,13 +3070,13 @@ fixed_t V_StringScaledWidth( { if (descriptive) { - cw = V_GetGenericButtonCodeWidth(c) * dupx; + cw = V_GetGenericButtonCodeWidth(c, largebutton) * dupx; cx += cw * scale; right = cx; } else { - cw = V_GetButtonCodeWidth(c) * dupx; + cw = V_GetButtonCodeWidth(c, largebutton) * dupx; cx += cw * scale; right = cx; } @@ -3152,6 +3144,9 @@ char * V_ScaledWordWrap( font_t *font; boolean uppercase; + boolean largebutton = false; + boolean descriptive = false; + boolean boxed = false; fixed_t cx; fixed_t right; @@ -3223,14 +3218,36 @@ char * V_ScaledWordWrap( cxatstart = 0; startwriter = 0; break; + case '\xEB': + if (fontno != TINY_FONT && fontno != HU_FONT) + largebutton = true; + case '\xEF': + descriptive = true; + break; + case '\xEE': + case '\xED': + case '\xEC': + if (boxed) + cx += 3*FRACUNIT; + else + cx += 3*FRACUNIT; + boxed = !boxed; + break; default: if (( c & 0xF0 ) == 0x80 || c == V_STRINGDANCE) ; else if (( c & 0xB0 ) & 0x80) // button prompts { - cw = V_GetButtonCodeWidth(c) * dupx; + if (descriptive) + cw = V_GetGenericButtonCodeWidth(c, largebutton) * dupx; + else + cw = V_GetButtonCodeWidth(c, largebutton) * dupx; + cx += cw * scale; right = cx; + + descriptive = false; + boxed = false; } else { From 81d6ac9f6ebc6d66dbd4fe19c44c09e7ec24c6a6 Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Sat, 21 Sep 2024 20:37:25 -0700 Subject: [PATCH 26/56] FUCK A DRAWBUTTON --- src/k_hud.cpp | 5 +- src/k_hud.h | 2 +- src/k_menudraw.c | 96 +++++++++++----------- src/k_zvote.c | 14 ++++ src/menus/transient/pause-addonoptions.cpp | 3 +- src/menus/transient/pause-cheats.cpp | 3 +- src/y_inter.cpp | 10 +++ 7 files changed, 81 insertions(+), 52 deletions(-) diff --git a/src/k_hud.cpp b/src/k_hud.cpp index 7c098fb07..8a3288684 100644 --- a/src/k_hud.cpp +++ b/src/k_hud.cpp @@ -6953,7 +6953,8 @@ void K_DrawMarginSticker(INT32 x, INT32 y, INT32 width, INT32 flags, boolean isS V_DrawFixedPatch((x + width)*FRACUNIT, y*FRACUNIT, FRACUNIT, flags|V_FLIP, stickerEnd, NULL); } -INT32 K_DrawGameControl(UINT16 x, UINT16 y, UINT8 player, const char *str, UINT8 alignment, UINT8 font) +// common fonts: 0 = thin, 8 = menu. sorry we have to launder a C++ enum in here +INT32 K_DrawGameControl(UINT16 x, UINT16 y, UINT8 player, const char *str, UINT8 alignment, UINT8 font, UINT32 flags) { using srb2::Draw; @@ -6961,7 +6962,7 @@ INT32 K_DrawGameControl(UINT16 x, UINT16 y, UINT8 player, const char *str, UINT8 INT32 width = text.width(); - Draw(x, y).align((srb2::Draw::Align)alignment).text(text); + Draw(x, y).align((srb2::Draw::Align)alignment).flags(flags).text(text); return width; } \ No newline at end of file diff --git a/src/k_hud.h b/src/k_hud.h index d48b14cf4..dcc272553 100644 --- a/src/k_hud.h +++ b/src/k_hud.h @@ -150,7 +150,7 @@ INT32 K_GetMinimapTransFlags(const boolean usingProgressBar); INT32 K_GetMinimapSplitFlags(const boolean usingProgressBar); position_t K_GetKartObjectPosToMinimapPos(fixed_t objx, fixed_t objy); -INT32 K_DrawGameControl(UINT16 x, UINT16 y, UINT8 player, const char *str, UINT8 alignment, UINT8 font); +INT32 K_DrawGameControl(UINT16 x, UINT16 y, UINT8 player, const char *str, UINT8 alignment, UINT8 font, UINT32 flags); #ifdef __cplusplus } // extern "C" diff --git a/src/k_menudraw.c b/src/k_menudraw.c index c63f94242..3b42e2c77 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -835,7 +835,7 @@ void M_DrawMenuMessage(void) workx -= K_DrawGameControl( workx+2, worky+2, 0, " ", - 2, 8 + 2, 8, 0 ); } else @@ -866,7 +866,7 @@ void M_DrawMenuMessage(void) workx -= K_DrawGameControl( workx+2, worky+2, 0, " ", - 2, 8 + 2, 8, 0 ); } else @@ -2455,7 +2455,6 @@ void M_DrawCharacterSelect(void) { const int kLeft = 76; const int kTop = 6; - const int kButtonWidth = 16; INT32 x = basex + kLeft; if (!optionsmenu.profile) // Does nothing on this screen @@ -2464,11 +2463,11 @@ void M_DrawCharacterSelect(void) //K_drawButton((x += 22) * FRACUNIT, (kTop - 3) * FRACUNIT, 0, kp_button_r, M_MenuButtonPressed(pid, MBT_R)); // x += K_DrawGameControl(x, kTop, 0, "", 0); // V_DrawThinString((x), kTop, 0, "Info"); - K_DrawGameControl(BASEVIDWIDTH/2, kTop, 0, " Info Default", 1, 0); + K_DrawGameControl(BASEVIDWIDTH/2, kTop, pid, " Info Default", 1, 0, 0); } else { - K_DrawGameControl(BASEVIDWIDTH/2, kTop, 0, " Accept Back Default", 1, 0); + K_DrawGameControl(BASEVIDWIDTH/2, kTop, pid, " Accept Back Default", 1, 0, 0); } x += 58; @@ -2750,21 +2749,16 @@ void M_DrawRaceDifficulty(void) V_DrawMappedPatch(cx, cy, 0, W_CachePatchName("OFF_TOGG", PU_CACHE), NULL); } - patch_t **bt = NULL; switch (it->mvar2) { case MBT_Y: - bt = kp_button_y[1]; + K_DrawGameControl(cx + 24, cy + 22, 0, activated ? "" : "", 0, 8, 0); break; case MBT_Z: - bt = kp_button_z[1]; + K_DrawGameControl(cx + 24, cy + 22, 0, activated ? "" : "", 0, 8, 0); break; } - if (bt) - { - K_drawButton((cx + 24) * FRACUNIT, (cy + 22) * FRACUNIT, 0, bt, activated); - } break; } } @@ -3668,7 +3662,7 @@ void M_DrawTimeAttack(void) if (M_EncoreAttackTogglePermitted()) { - K_drawButtonAnim(buttonx + 35, buttony - 3, 0, kp_button_r, timeattackmenu.ticker); + K_DrawGameControl(buttonx + 35, buttony - 3, 0, "", 0, 8, 0); } if ((timeattackmenu.spbflicker == 0 || timeattackmenu.ticker % 2) == (cv_dummyspbattack.value == 1)) @@ -6101,16 +6095,16 @@ void M_DrawPause(void) } else if (gametype == GT_TUTORIAL) { - K_DrawGameControl(4, 184 - 60 + offset/2, 0, " Steering", 0, 0); - K_DrawGameControl(4, 184 - 45 + offset/2, 0, " Accelerate", 0, 0); - K_DrawGameControl(4, 184 - 30 + offset/2, 0, " Look Back", 0, 0); - K_DrawGameControl(4, 184 - 15 + offset/2, 0, " Spindash", 0, 0); - K_DrawGameControl(4, 184 - 0 + offset/2, 0, " Item", 0, 0); + K_DrawGameControl(4, 184 - 60 + offset/2, 0, " Steering", 0, 0, 0); + K_DrawGameControl(4, 184 - 45 + offset/2, 0, " Accelerate", 0, 0, 0); + K_DrawGameControl(4, 184 - 30 + offset/2, 0, " Look Back", 0, 0, 0); + K_DrawGameControl(4, 184 - 15 + offset/2, 0, " Spindash", 0, 0, 0); + K_DrawGameControl(4, 184 - 0 + offset/2, 0, " Item", 0, 0, 0); - K_DrawGameControl(90, 184 - 45 + offset/2, 0, " Brake", 0, 0); - K_DrawGameControl(90, 184 - 30 + offset/2, 0, " Respawn", 0, 0); - K_DrawGameControl(90, 184 - 15 + offset/2, 0, " Dialogue / Action", 0, 0); - K_DrawGameControl(90, 184 - 0 + offset/2, 0, " Drift", 0, 0); + K_DrawGameControl(90, 184 - 45 + offset/2, 0, " Brake", 0, 0, 0); + K_DrawGameControl(90, 184 - 30 + offset/2, 0, " Respawn", 0, 0, 0); + K_DrawGameControl(90, 184 - 15 + offset/2, 0, " Dialogue / Action", 0, 0, 0); + K_DrawGameControl(90, 184 - 0 + offset/2, 0, " Drift", 0, 0, 0); } else { @@ -7281,9 +7275,10 @@ static void M_DrawChallengePreview(INT32 x, INT32 y) y = BASEVIDHEIGHT-16; V_DrawGamemodeString(x, y - 33, 0, R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_PLAGUE, GTC_MENUCACHE), M_UseAlternateTitleScreen() ? "On" : "Off"); - K_drawButtonAnim(x, y, 0, kp_button_a[1], challengesmenu.ticker); - x += SHORT(kp_button_a[1][0]->width); - V_DrawThinString(x, y + 1, highlightflags, "Toggle"); + K_DrawGameControl(x, y, 0, " Toggle", 0, 0, 0); + // K_drawButtonAnim(x, y, 0, kp_button_a[1], challengesmenu.ticker); + // x += SHORT(kp_button_a[1][0]->width); + // V_DrawThinString(x, y + 1, highlightflags, "Toggle"); break; @@ -7346,9 +7341,13 @@ static void M_DrawChallengePreview(INT32 x, INT32 y) pushed = strcmp(song, mapheaderinfo[map]->encoremusname[musicid]) == 0; } - K_drawButton(x&FRACUNIT, y*FRACUNIT, 0, kp_button_l, pushed); - x += SHORT(kp_button_l[0]->width); - V_DrawThinString(x, y + 1, (pushed ? V_GRAYMAP : highlightflags), "E Side"); + if (!pushed) + K_DrawGameControl(x, y, 0, " E Side", 0, 0, 0); + else + K_DrawGameControl(x, y, 0, " E Side", 0, 0, 0); + // K_drawButton(x&FRACUNIT, y*FRACUNIT, 0, kp_button_l, pushed); + // x += SHORT(kp_button_l[0]->width); + // V_DrawThinString(x, y + 1, (pushed ? V_GRAYMAP : highlightflags), "E Side"); x = 8; y -= 10; @@ -7367,9 +7366,13 @@ static void M_DrawChallengePreview(INT32 x, INT32 y) pushed = strcmp(song, mapheaderinfo[map]->musname[musicid]) == 0; } - K_drawButton(x*FRACUNIT, y*FRACUNIT, 0, kp_button_a[1], pushed); - x += SHORT(kp_button_a[1][0]->width); - V_DrawThinString(x, y + 1, (pushed ? V_GRAYMAP : highlightflags), "Play CD"); + if (!pushed) + K_DrawGameControl(x, y, 0, " Play CD", 0, 0, 0); + else + K_DrawGameControl(x, y, 0, " Play CD", 0, 0, 0); + // K_drawButton(x*FRACUNIT, y*FRACUNIT, 0, kp_button_a[1], pushed); + // x += SHORT(kp_button_a[1][0]->width); + // V_DrawThinString(x, y + 1, (pushed ? V_GRAYMAP : highlightflags), "Play CD"); } } default: @@ -7446,11 +7449,10 @@ static void M_DrawChallengeKeys(INT32 tilex, INT32 tiley) const boolean keybuttonpress = (menumessage.active == false && M_MenuExtraHeld(pid) == true); // Button prompt - K_drawButton( - 24 << FRACBITS, - 16 << FRACBITS, - 0, kp_button_c[1], - keybuttonpress + K_DrawGameControl( + 24, 16, + 0, keybuttonpress ? "" : "", + 0, 0, 0 ); // Metyr of rounds played that contribute to Chao Key generation @@ -9111,8 +9113,6 @@ void M_DrawDiscordRequests(void) patch_t *hand = NULL; const char *wantText = "...would like to join!"; - const char *acceptText = "Accept" ; - const char *declineText = "Decline"; INT32 x = 100; INT32 y = 133; @@ -9154,29 +9154,31 @@ void M_DrawDiscordRequests(void) K_DrawSticker(x, y + 12, V_ThinStringWidth(wantText, 0), 0, true); V_DrawThinString(x, y + 10, 0, wantText); - INT32 confirmButtonWidth = SHORT(kp_button_a[1][0]->width); - INT32 declineButtonWidth = SHORT(kp_button_b[1][0]->width); - INT32 altDeclineButtonWidth = SHORT(kp_button_x[1][0]->width); - INT32 acceptTextWidth = V_ThinStringWidth(acceptText, 0); - INT32 declineTextWidth = V_ThinStringWidth(declineText, 0); - INT32 stickerWidth = (confirmButtonWidth + declineButtonWidth + altDeclineButtonWidth + acceptTextWidth + declineTextWidth); - + /* K_DrawSticker(x, y + 26, stickerWidth, 0, true); - K_drawButtonAnim(x, y + 22, V_SNAPTORIGHT, kp_button_a[1], discordrequestmenu.ticker); + K_DrawGameControl(x, y+22, 0, "", 0, 0, V_SNAPTORIGHT); + // K_drawButtonAnim(x, y + 22, V_SNAPTORIGHT, kp_button_a[1], discordrequestmenu.ticker); + */ - INT32 xoffs = confirmButtonWidth; + UINT32 bigwidth = K_DrawGameControl(x, y+22, 0, " Accept Decline", 0, 0, V_SNAPTORIGHT); + K_DrawSticker(x, y + 26, bigwidth, 0, true); + K_DrawGameControl(x, y+22, 0, " Accept Decline", 0, 0, V_SNAPTORIGHT); + /* V_DrawThinString((x + xoffs), y + 24, 0, acceptText); xoffs += acceptTextWidth; K_drawButtonAnim((x + xoffs), y + 22, V_SNAPTORIGHT, kp_button_b[1], discordrequestmenu.ticker); xoffs += declineButtonWidth; + xoffs += K_DrawGameControl(x + xoffs, y+22, 0, "", 0, 0, V_SNAPTORIGHT); K_drawButtonAnim((x + xoffs), y + 22, V_SNAPTORIGHT, kp_button_x[1], discordrequestmenu.ticker); xoffs += altDeclineButtonWidth; V_DrawThinString((x + xoffs), y + 24, 0, declineText); + */ + y -= 18; while (curRequest->next != NULL) diff --git a/src/k_zvote.c b/src/k_zvote.c index cfd2dbc40..68ede592c 100644 --- a/src/k_zvote.c +++ b/src/k_zvote.c @@ -1103,12 +1103,19 @@ void K_DrawMidVote(void) V_SNAPTOBOTTOM|V_SNAPTORIGHT|V_SPLITSCREEN, exc, NULL ); + K_DrawGameControl( + x - 4, y + exc->height - 12, + id, pressed ? "" : "", + 0, 8, V_SNAPTOBOTTOM|V_SNAPTORIGHT + ); + /* K_drawButton( x - (4 * FRACUNIT), y + ((exc->height - kp_button_z[1][0]->height) * FRACUNIT), V_SNAPTOBOTTOM|V_SNAPTORIGHT|V_SPLITSCREEN, kp_button_z[1], pressed ); + */ } else { @@ -1219,12 +1226,19 @@ void K_DrawMidVote(void) if (drawButton == true) { + K_DrawGameControl( + x-20, y-2, id, + pressed ? "" : "", + 0, 8, V_SNAPTOBOTTOM|V_SNAPTORIGHT|V_SPLITSCREEN + ); + /* K_drawButton( x - (20 * FRACUNIT), y - (2 * FRACUNIT), V_SNAPTOBOTTOM|V_SNAPTORIGHT|V_SPLITSCREEN, kp_button_z[0], pressed ); + */ } // Vote count diff --git a/src/menus/transient/pause-addonoptions.cpp b/src/menus/transient/pause-addonoptions.cpp index 42e238234..0a0a0c207 100644 --- a/src/menus/transient/pause-addonoptions.cpp +++ b/src/menus/transient/pause-addonoptions.cpp @@ -264,7 +264,8 @@ void draw_menu() draw.x(BASEVIDWIDTH/2).font(Draw::Font::kGamemode).text(mode_strings[menu_mode()]); if (server || IsPlayerAdmin(consoleplayer)) - K_drawButton((draw.x() + 8) * FRACUNIT, (draw.y() + 8) * FRACUNIT, 0, kp_button_y[0], M_MenuButtonHeld(0, MBT_Y)); + K_DrawGameControl(draw.x(), draw.y(), 0, M_MenuButtonHeld(0, MBT_Y) ? "" : "", 0, 8, 0); + // K_drawButton((draw.x() + 8) * FRACUNIT, (draw.y() + 8) * FRACUNIT, 0, kp_button_y[0], M_MenuButtonHeld(0, MBT_Y)); draw = draw.y(32 + kMargin); currentMenu->y = std::min(static_cast(draw.y()), (BASEVIDHEIGHT/2) - g_menu_offsets[itemOn]); diff --git a/src/menus/transient/pause-cheats.cpp b/src/menus/transient/pause-cheats.cpp index bbd9a4d8b..d00bc1ed9 100644 --- a/src/menus/transient/pause-cheats.cpp +++ b/src/menus/transient/pause-cheats.cpp @@ -208,7 +208,8 @@ void draw_menu() draw = draw.y(27 + kMargin); draw.x(BASEVIDWIDTH/2).font(Draw::Font::kGamemode).text(mode_strings[menu_mode()]); - K_drawButton((draw.x() + 8) * FRACUNIT, (draw.y() + 8) * FRACUNIT, 0, kp_button_y[0], M_MenuButtonHeld(0, MBT_Y)); + K_DrawGameControl(draw.x(), draw.y(), 0, M_MenuButtonHeld(0, MBT_Y) ? "" : "", 0, 8, 0); + // K_drawButton((draw.x() + 8) * FRACUNIT, (draw.y() + 8) * FRACUNIT, 0, kp_button_y[0], M_MenuButtonHeld(0, MBT_Y)); draw = draw.y(32 + kMargin); currentMenu->y = std::min(static_cast(draw.y()), (BASEVIDHEIGHT/2) - g_menu_offsets[itemOn]); diff --git a/src/y_inter.cpp b/src/y_inter.cpp index 935303fbf..b48828395 100644 --- a/src/y_inter.cpp +++ b/src/y_inter.cpp @@ -56,6 +56,8 @@ #include "m_easing.h" #include "music.h" +#include "v_draw.hpp" + #ifdef HWRENDER #include "hardware/hw_main.h" #endif @@ -1474,6 +1476,13 @@ void Y_DrawIntermissionButton(INT32 startslide, INT32 through, boolean widescree ); } + using srb2::Draw; + + Draw::TextElement text = Draw::TextElement().parse(pressed ? "" : ""); + Draw draw = Draw(FixedToFloat(2*FRACUNIT - offset), FixedToFloat((BASEVIDHEIGHT - 16)*FRACUNIT)).flags(widescreen ? (V_SNAPTOLEFT|V_SNAPTOBOTTOM) : 0); + draw.text(text.string()); + + /* K_drawButton( 2*FRACUNIT - offset, (BASEVIDHEIGHT - 16)*FRACUNIT, @@ -1484,6 +1493,7 @@ void Y_DrawIntermissionButton(INT32 startslide, INT32 through, boolean widescree kp_button_a[1], pressed ); + */ } } From 397db81a739bc719bb6b99d563ed33908bfafbd1 Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Sat, 21 Sep 2024 21:31:54 -0700 Subject: [PATCH 27/56] TA fix --- src/k_hud.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/k_hud.cpp b/src/k_hud.cpp index 8a3288684..0bdfacf7b 100644 --- a/src/k_hud.cpp +++ b/src/k_hud.cpp @@ -6605,10 +6605,11 @@ void K_drawKartHUD(void) if (ta) { using srb2::Draw; + Draw::TextElement text = Draw::TextElement().parse(" Restart"); Draw(BASEVIDWIDTH - 19, 2) .flags(flags | V_YELLOWMAP) .align(Draw::Align::kRight) - .text("\xBE Restart"); + .text(text.string()); } else { From 5563a0682731c17a583d4bea03aa5072e32299d6 Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Sat, 21 Sep 2024 22:30:34 -0700 Subject: [PATCH 28/56] Lua ABC -> Lua 123, move dpad to generic to make room for lua gamecontrol translation --- src/d_ticcmd.h | 3 ++ src/deh_tables.c | 3 ++ src/g_build_ticcmd.cpp | 6 ++-- src/g_input.h | 6 ++-- src/k_hud.cpp | 22 ++++++++++---- src/k_hud.h | 6 +++- src/menus/options-profiles-edit-controls.c | 12 ++++---- src/v_draw.cpp | 34 ++++++++++++++++++---- src/v_draw.hpp | 7 +++-- src/v_video.cpp | 16 ++++++++-- 10 files changed, 87 insertions(+), 28 deletions(-) diff --git a/src/d_ticcmd.h b/src/d_ticcmd.h index 046488a98..7787058b3 100644 --- a/src/d_ticcmd.h +++ b/src/d_ticcmd.h @@ -42,8 +42,11 @@ typedef enum // Lua garbage, replace with freeslottable buttons some day BT_LUAA = 1<<13, + BT_LUA1 = 1<<13, BT_LUAB = 1<<14, + BT_LUA2 = 1<<14, BT_LUAC = 1<<15, + BT_LUA3 = 1<<15, } buttoncode_t; // The data sampled per tick (single player) diff --git a/src/deh_tables.c b/src/deh_tables.c index ab4b0907b..e6d331f5a 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -5003,6 +5003,9 @@ struct int_const_s const INT_CONST[] = { {"BT_LUAA",BT_LUAA}, // Lua customizable {"BT_LUAB",BT_LUAB}, // Lua customizable {"BT_LUAC",BT_LUAC}, // Lua customizable + {"BT_LUA1",BT_LUA1}, // Lua customizable + {"BT_LUA2",BT_LUA2}, // Lua customizable + {"BT_LUA3",BT_LUA3}, // Lua customizable // Lua command registration flags {"COM_ADMIN",COM_ADMIN}, diff --git a/src/g_build_ticcmd.cpp b/src/g_build_ticcmd.cpp index b74f48d2d..75c475eac 100644 --- a/src/g_build_ticcmd.cpp +++ b/src/g_build_ticcmd.cpp @@ -408,9 +408,9 @@ class TiccmdBuilder map(gc_vote, BT_VOTE); // mp general function button // lua buttons a thru c - map(gc_luaa, BT_LUAA); - map(gc_luab, BT_LUAB); - map(gc_luac, BT_LUAC); + map(gc_lua1, BT_LUA1); + map(gc_lua2, BT_LUA2); + map(gc_lua3, BT_LUA3); } public: diff --git a/src/g_input.h b/src/g_input.h index 7e1e65a99..58edccdd1 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -77,9 +77,9 @@ typedef enum // special keys gc_abc, - gc_luaa, - gc_luab, - gc_luac, + gc_lua1, + gc_lua2, + gc_lua3, gc_console, gc_talk, gc_teamtalk, diff --git a/src/k_hud.cpp b/src/k_hud.cpp index 0bdfacf7b..56f9d078e 100644 --- a/src/k_hud.cpp +++ b/src/k_hud.cpp @@ -242,7 +242,9 @@ patch_t *kp_button_up[2]; patch_t *kp_button_down[2]; patch_t *kp_button_right[2]; patch_t *kp_button_left[2]; -patch_t *kp_button_dpad[2]; +patch_t *kp_button_lua1[2]; +patch_t *kp_button_lua2[2]; +patch_t *kp_button_lua3[2]; patch_t *gen_button_a[2][2]; patch_t *gen_button_b[2][2]; @@ -256,6 +258,7 @@ patch_t *gen_button_start[2]; patch_t *gen_button_back[2]; patch_t *gen_button_ls[2]; patch_t *gen_button_rs[2]; +patch_t *gen_button_dpad[2]; patch_t *gen_button_keyleft[2]; patch_t *gen_button_keyright[2]; @@ -984,7 +987,14 @@ void K_LoadKartHUDGraphics(void) K_LoadButtonGraphics(kp_button_down, 'K'); K_LoadButtonGraphics(kp_button_right, 'L'); K_LoadButtonGraphics(kp_button_left, 'M'); - K_LoadButtonGraphics(kp_button_dpad, 'T'); + // K_LoadButtonGraphics(kp_button_dpad, 'T'); + + HU_UpdatePatch(&kp_button_lua1[0], "TLG_L1"); + HU_UpdatePatch(&kp_button_lua1[1], "TLG_L1B"); + HU_UpdatePatch(&kp_button_lua2[0], "TLG_L2"); + HU_UpdatePatch(&kp_button_lua2[1], "TLG_L2B"); + HU_UpdatePatch(&kp_button_lua3[0], "TLG_L3"); + HU_UpdatePatch(&kp_button_lua3[1], "TLG_L3B"); K_LoadGenericButtonGraphics(gen_button_a[0], 'A'); K_LoadGenericButtonGraphics(gen_button_b[0], 'B'); @@ -1008,6 +1018,9 @@ void K_LoadKartHUDGraphics(void) K_LoadGenericButtonGraphics(gen_button_ls, 'T'); K_LoadGenericButtonGraphics(gen_button_rs, 'U'); + HU_UpdatePatch(&gen_button_dpad[0], "TLB_T"); + HU_UpdatePatch(&gen_button_dpad[1], "TLB_TB"); + HU_UpdatePatch(&gen_button_keyleft[0], "TLK_L"); HU_UpdatePatch(&gen_button_keyleft[1], "TLK_LB"); HU_UpdatePatch(&gen_button_keyright[0], "TLK_R"); @@ -6496,17 +6509,16 @@ void K_drawKartHUD(void) #if 1 using srb2::Draw; - if (0) + if (1) { // Draw::TextElement text = Draw::TextElement().parse("A B C X Y Z \nST L R U D L R "); - Draw::TextElement text = Draw::TextElement().parse("Unpressed Pressed Animated "); + Draw::TextElement text = Draw::TextElement().parse("Unpressed Pressed Animated "); UINT8 fakeoff = (stplyr - players)*40; Draw(5, 5+fakeoff).align((srb2::Draw::Align)0).font(Draw::Font::kMenu).text(text); Draw(5, 20+fakeoff).align((srb2::Draw::Align)0).font(Draw::Font::kThin).text(text); } - if (0) { Draw::TextElement text = Draw::TextElement().parse("\xEELEFTSPACE\xEE\n\xEESPC\xEE \xEETAB\xEE\nA \xEF\xA0 A\nB \xEF\xA1 B\nX \xEF\xA2 X\nY \xEF\xA3 Y\nLB \xEF\xA4 LB\nRB \xEF\xA5 RB\nLT \xEF\xA6 LT\nRT \xEF\xA7 RT\nST \xEF\xA8 ST\nBK \xEF\xA9 BK\nLS \xEF\xAA LS\nRS \xEF\xAB RS\n"); diff --git a/src/k_hud.h b/src/k_hud.h index dcc272553..5323a2f9d 100644 --- a/src/k_hud.h +++ b/src/k_hud.h @@ -101,7 +101,10 @@ extern patch_t *kp_button_up[2]; extern patch_t *kp_button_down[2]; extern patch_t *kp_button_right[2]; extern patch_t *kp_button_left[2]; -extern patch_t *kp_button_dpad[2]; +// extern patch_t *kp_button_dpad[2]; +extern patch_t *kp_button_lua1[2]; +extern patch_t *kp_button_lua2[2]; +extern patch_t *kp_button_lua3[2]; extern patch_t *gen_button_a[2][2]; extern patch_t *gen_button_b[2][2]; @@ -115,6 +118,7 @@ extern patch_t *gen_button_start[2]; extern patch_t *gen_button_back[2]; extern patch_t *gen_button_ls[2]; extern patch_t *gen_button_rs[2]; +extern patch_t *gen_button_dpad[2]; extern patch_t *gen_button_keyleft[2]; extern patch_t *gen_button_keyright[2]; diff --git a/src/menus/options-profiles-edit-controls.c b/src/menus/options-profiles-edit-controls.c index 2c5dcec9e..69deb89df 100644 --- a/src/menus/options-profiles-edit-controls.c +++ b/src/menus/options-profiles-edit-controls.c @@ -81,14 +81,14 @@ menuitem_t OPTIONS_ProfileControls[] = { {IT_CONTROL, "OPEN TEAM CHAT", "Opens team-only full chat for online games.", NULL, {.routine = M_ProfileSetControl}, gc_teamtalk, 0}, - {IT_CONTROL, "LUA/A", "May be used by add-ons.", - NULL, {.routine = M_ProfileSetControl}, gc_luaa, 0}, + {IT_CONTROL, "LUA/1", "May be used by add-ons.", + NULL, {.routine = M_ProfileSetControl}, gc_lua1, 0}, - {IT_CONTROL, "LUA/B", "May be used by add-ons.", - NULL, {.routine = M_ProfileSetControl}, gc_luab, 0}, + {IT_CONTROL, "LUA/2", "May be used by add-ons.", + NULL, {.routine = M_ProfileSetControl}, gc_lua2, 0}, - {IT_CONTROL, "LUA/C", "May be used by add-ons.", - NULL, {.routine = M_ProfileSetControl}, gc_luac, 0}, + {IT_CONTROL, "LUA/3", "May be used by add-ons.", + NULL, {.routine = M_ProfileSetControl}, gc_lua3, 0}, {IT_CONTROL, "OPEN CONSOLE", "Opens the developer options console.", NULL, {.routine = M_ProfileSetControl}, gc_console, 0}, diff --git a/src/v_draw.cpp b/src/v_draw.cpp index d9c6ea44d..31d348419 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -45,7 +45,9 @@ Draw::TextElement& Draw::TextElement::parse(std::string_view raw) BUTTON("right", 0x02), BUTTON("left", 0x03), - BUTTON("dpad", 0x04), + BUTTON("lua1", 0x04), + BUTTON("lua2", 0x05), + BUTTON("lua3", 0x06), BUTTON("r", 0x07), BUTTON("l", 0x08), @@ -92,6 +94,10 @@ Draw::TextElement& Draw::TextElement::parse(std::string_view raw) {0x02, gc_right}, {0x03, gc_left}, + {0x04, gc_lua1}, + {0x05, gc_lua2}, + {0x06, gc_lua3}, + {0x07, gc_r}, {0x08, gc_l}, {0x09, gc_start}, @@ -167,9 +173,24 @@ Draw::TextElement& Draw::TextElement::parse(std::string_view raw) string_view code = raw.substr(1, p - 1); - if (auto it = translation.find(code); it != translation.end()) + if (code == "dpad" || code == "dpad_pressed" || code == "dpad_animated") { - // FIXME: This isn't how v_video.cpp checks for buttons and I don't know why. + // SPECIAL: Generic button that we invoke explicitly, not via gamecontrol reference. + // If we ever add anything else to this category, I promise I will create a real abstraction, + // but for now, just hardcode the character replacements and pray for forgiveness. + + string_.push_back(0xEF); // Control code: "switch to descriptive input mode" + string_.push_back(0xEB); // Control code: "large button" + if (code == "dpad") + string_.push_back(0xBC); + else if (code == "dpad_pressed") + string_.push_back(0x9C); + else + string_.push_back(0xAC); + } + else if (auto it = translation.find(code); it != translation.end()) // This represents a gamecontrol, turn into Saturn button or generic button. + { + // This isn't how v_video.cpp checks for buttons and I don't know why. if (cv_descriptiveinput.value && ((it->second & 0xF0) != 0x80)) // Should we do game control translation? { if (auto id = inputdefinition.find(it->second & (~0xB0)); id != inputdefinition.end()) // This is a game control, do descriptive input translation! @@ -211,7 +232,7 @@ Draw::TextElement& Draw::TextElement::parse(std::string_view raw) string_.push_back(code); if (bind == -1) - string_.append("[NOT BOUND]"); + string_.append("N/A"); else string_.append((G_KeynumToShortString(bind))); @@ -316,7 +337,9 @@ patch_t** get_button_patch(Draw::Button type, int ver) X(down); X(right); X(left); - X(dpad); + X(lua1); + X(lua2); + X(lua3); #undef X } @@ -360,6 +383,7 @@ patch_t** get_button_patch(Draw::GenericButton type, int ver) X(back); X(ls); X(rs); + X(dpad); #undef X } diff --git a/src/v_draw.hpp b/src/v_draw.hpp index a1c2a86c0..e10faf733 100644 --- a/src/v_draw.hpp +++ b/src/v_draw.hpp @@ -78,7 +78,9 @@ public: down, right, left, - dpad, + lua1, + lua2, + lua3, }; enum class GenericButton @@ -94,7 +96,8 @@ public: start, back, ls, - rs + rs, + dpad }; class TextElement diff --git a/src/v_video.cpp b/src/v_video.cpp index 1adaaa851..667f1d0c3 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -2516,8 +2516,10 @@ static UINT8 V_GetButtonCodeWidth(UINT8 c, boolean largebutton) break; case 0x04: - // dpad - x = 14; + case 0x05: + case 0x06: + // lua + x = 16; break; case 0x0A: @@ -2571,6 +2573,11 @@ static UINT8 V_GetGenericButtonCodeWidth(UINT8 c, boolean largebutton) // stick click x = 18; break; + + case 0x0C: + // dpad + x = 14; + break; } return x; @@ -2830,7 +2837,9 @@ void V_DrawStringScaled( case 0x02: return {{0, 3, Draw::Button::right}}; case 0x03: return {{0, 3, Draw::Button::left}}; - case 0x04: return {{0, 4, Draw::Button::dpad}}; + case 0x04: return {{0, 4, Draw::Button::lua1}}; + case 0x05: return {{0, 4, Draw::Button::lua2}}; + case 0x06: return {{0, 4, Draw::Button::lua3}}; case 0x07: return {{0, 2, Draw::Button::r}}; case 0x08: return {{0, 2, Draw::Button::l}}; @@ -2908,6 +2917,7 @@ void V_DrawStringScaled( case 0x09: return {{1, 6, Draw::GenericButton::back}}; case 0x0A: return {{0, 5, Draw::GenericButton::ls}}; case 0x0B: return {{0, 5, Draw::GenericButton::rs}}; + case 0x0C: return {{0, 4, Draw::GenericButton::dpad}}; default: return {}; } }(); From d531fd744c3e9a75e1178116d2bb4e94f070fa5a Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Sat, 21 Sep 2024 22:31:11 -0700 Subject: [PATCH 29/56] Remove goofy largebutton y offset testing --- src/v_video.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/v_video.cpp b/src/v_video.cpp index 667f1d0c3..520935a78 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -2877,7 +2877,7 @@ void V_DrawStringScaled( Draw bt = Draw( FixedToFloat(cx + cxoff) - (bt_inst->x * dupx), - FixedToFloat(cy + cyoff) - ((bt_inst->y + fontspec.button_yofs) * dupy) - (largebutton ? 0*dupy : 0)) + FixedToFloat(cy + cyoff) - ((bt_inst->y + fontspec.button_yofs) * dupy)) .flags(flags); if (largebutton) @@ -2941,7 +2941,7 @@ void V_DrawStringScaled( Draw bt = Draw( FixedToFloat(cx + cxoff) - (bt_inst->x * dupx), - FixedToFloat(cy + cyoff) - ((bt_inst->y + fontspec.button_yofs) * dupy) - (largebutton ? 0*dupy : 0)) + FixedToFloat(cy + cyoff) - ((bt_inst->y + fontspec.button_yofs) * dupy)) .flags(flags); if (largebutton) From 246bab76183aba4d646873b8d315675704113214 Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Sat, 21 Sep 2024 22:37:20 -0700 Subject: [PATCH 30/56] Debug cleanup --- src/k_hud.cpp | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/src/k_hud.cpp b/src/k_hud.cpp index 56f9d078e..7453d3864 100644 --- a/src/k_hud.cpp +++ b/src/k_hud.cpp @@ -6506,10 +6506,10 @@ void K_drawKartHUD(void) } // In case of font debugging break glass -#if 1 +#if 0 using srb2::Draw; - if (1) + if (0) { // Draw::TextElement text = Draw::TextElement().parse("A B C X Y Z \nST L R U D L R "); Draw::TextElement text = Draw::TextElement().parse("Unpressed Pressed Animated "); @@ -6536,21 +6536,6 @@ void K_drawKartHUD(void) Draw(160+offset, 5).align((srb2::Draw::Align)1).font(Draw::Font::kThin).text(text); Draw(55+offset, 5).align((srb2::Draw::Align)1).font(Draw::Font::kMenu).text(text); } - - - /* - stplyr = &players[2]; - Draw(5, 25).align((srb2::Draw::Align)0).font(Draw::Font::kConsole).text(text); - stplyr = &players[3]; - Draw(5, 35).align((srb2::Draw::Align)0).font(Draw::Font::kMedium).text(text); - stplyr = &players[0]; - Draw(5, 45).align((srb2::Draw::Align)0).font(Draw::Font::kGamemode).text(text); - Draw(5, 75).align((srb2::Draw::Align)0).font(Draw::Font::kFreeplay).text(text); - Draw(5, 95).align((srb2::Draw::Align)0).font(Draw::Font::kPing).text(text); - Draw(5, 105).align((srb2::Draw::Align)0).font(Draw::Font::kThinTimer).text(text); - Draw(5, 115).align((srb2::Draw::Align)0).font(Draw::Font::kTimer).text(text); - Draw(5, 145).align((srb2::Draw::Align)0).font(Draw::Font::kZVote).text(text); - */ #endif From 9eaf53b11fdec64874d708dee35508847d758f39 Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Sat, 21 Sep 2024 22:59:36 -0700 Subject: [PATCH 31/56] Misc menu fixups --- src/k_zvote.c | 2 +- src/menus/transient/pause-addonoptions.cpp | 2 +- src/menus/transient/pause-cheats.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/k_zvote.c b/src/k_zvote.c index 68ede592c..cc3462b71 100644 --- a/src/k_zvote.c +++ b/src/k_zvote.c @@ -1227,7 +1227,7 @@ void K_DrawMidVote(void) if (drawButton == true) { K_DrawGameControl( - x-20, y-2, id, + x/FRACUNIT-20, y/FRACUNIT-2, id, pressed ? "" : "", 0, 8, V_SNAPTOBOTTOM|V_SNAPTORIGHT|V_SPLITSCREEN ); diff --git a/src/menus/transient/pause-addonoptions.cpp b/src/menus/transient/pause-addonoptions.cpp index 0a0a0c207..9d733cc4f 100644 --- a/src/menus/transient/pause-addonoptions.cpp +++ b/src/menus/transient/pause-addonoptions.cpp @@ -264,7 +264,7 @@ void draw_menu() draw.x(BASEVIDWIDTH/2).font(Draw::Font::kGamemode).text(mode_strings[menu_mode()]); if (server || IsPlayerAdmin(consoleplayer)) - K_DrawGameControl(draw.x(), draw.y(), 0, M_MenuButtonHeld(0, MBT_Y) ? "" : "", 0, 8, 0); + K_DrawGameControl(draw.x() + 8, draw.y()-6, 0, M_MenuButtonHeld(0, MBT_Y) ? " Switch Page" : " Switch Page", 0, 8, 0); // K_drawButton((draw.x() + 8) * FRACUNIT, (draw.y() + 8) * FRACUNIT, 0, kp_button_y[0], M_MenuButtonHeld(0, MBT_Y)); draw = draw.y(32 + kMargin); diff --git a/src/menus/transient/pause-cheats.cpp b/src/menus/transient/pause-cheats.cpp index d00bc1ed9..b6e5160e1 100644 --- a/src/menus/transient/pause-cheats.cpp +++ b/src/menus/transient/pause-cheats.cpp @@ -208,7 +208,7 @@ void draw_menu() draw = draw.y(27 + kMargin); draw.x(BASEVIDWIDTH/2).font(Draw::Font::kGamemode).text(mode_strings[menu_mode()]); - K_DrawGameControl(draw.x(), draw.y(), 0, M_MenuButtonHeld(0, MBT_Y) ? "" : "", 0, 8, 0); + K_DrawGameControl(draw.x() + 8, draw.y()-6, 0, M_MenuButtonHeld(0, MBT_Y) ? " Switch Page" : " Switch Page", 0, 8, 0); // K_drawButton((draw.x() + 8) * FRACUNIT, (draw.y() + 8) * FRACUNIT, 0, kp_button_y[0], M_MenuButtonHeld(0, MBT_Y)); draw = draw.y(32 + kMargin); From 88bd460cde859b60c198e967cf946d552840f490 Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Sun, 22 Sep 2024 00:02:48 -0700 Subject: [PATCH 32/56] Fix midvote wrong coords (resolves mystery keyboard patch in tutorial) --- src/k_dialogue.cpp | 28 ---------------------------- src/k_zvote.c | 2 +- 2 files changed, 1 insertion(+), 29 deletions(-) diff --git a/src/k_dialogue.cpp b/src/k_dialogue.cpp index 4f965c25a..36c90a079 100644 --- a/src/k_dialogue.cpp +++ b/src/k_dialogue.cpp @@ -492,34 +492,6 @@ void Dialogue::Draw(void) drawer.xy(-18 + 4 - 5, -7-8 - 14).align(Draw::Align::kCenter).font(Draw::Font::kMenu).text(srb2::Draw::TextElement().parse(intertext).string()); } - - /* - if (Dismissable()) - { - if (TextDone()) - { - drawer - .xy(-14, -7-5) - .patch(patchCache["TUTDIAG2"]); - } - - std::string ctrl = ""; - - if (Held()) - ctrl += ""; - else if (TextDone()) - ctrl += ""; - else - ctrl += ""; - - std::string parsedctrl = srb2::Draw::TextElement().parse(ctrl).string(); - - drawer - .xy(17-14 - BASEVIDWIDTH, -39-16) - .font(Draw::Font::kMenu) - .text(parsedctrl); - } - */ } void Dialogue::Dismiss(void) diff --git a/src/k_zvote.c b/src/k_zvote.c index cc3462b71..0a5ea2421 100644 --- a/src/k_zvote.c +++ b/src/k_zvote.c @@ -1104,7 +1104,7 @@ void K_DrawMidVote(void) exc, NULL ); K_DrawGameControl( - x - 4, y + exc->height - 12, + x/FRACUNIT - 4, y/FRACUNIT + exc->height/FRACUNIT - 12, id, pressed ? "" : "", 0, 8, V_SNAPTOBOTTOM|V_SNAPTORIGHT ); From 16727f8df83e76254b2f6797ce0c0dead971358f Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Sun, 22 Sep 2024 00:09:49 -0700 Subject: [PATCH 33/56] Fix spacing on profile charsel control help --- src/k_menudraw.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/k_menudraw.c b/src/k_menudraw.c index 3b42e2c77..750ea395b 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -2453,28 +2453,16 @@ void M_DrawCharacterSelect(void) } { - const int kLeft = 76; const int kTop = 6; - INT32 x = basex + kLeft; if (!optionsmenu.profile) // Does nothing on this screen { - // x += 22; - //K_drawButton((x += 22) * FRACUNIT, (kTop - 3) * FRACUNIT, 0, kp_button_r, M_MenuButtonPressed(pid, MBT_R)); - // x += K_DrawGameControl(x, kTop, 0, "", 0); - // V_DrawThinString((x), kTop, 0, "Info"); K_DrawGameControl(BASEVIDWIDTH/2, kTop, pid, " Info Default", 1, 0, 0); } else { - K_DrawGameControl(BASEVIDWIDTH/2, kTop, pid, " Accept Back Default", 1, 0, 0); + K_DrawGameControl(BASEVIDWIDTH/2+62, kTop, pid, " Accept Back Default", 1, 0, 0); } - - x += 58; - - // K_drawButton((x += 58) * FRACUNIT, (kTop - 1) * FRACUNIT, 0, kp_button_c[1], M_MenuButtonPressed(pid, MBT_C)); - // x += K_DrawGameControl(x, kTop, 0, "", 0); - // V_DrawThinString((x), kTop, 0, "Default"); } // We have to loop twice -- first time to draw the drop shadows, a second time to draw the icons. From bd1b4ac9c3c96abb0821f87d9d7c76a585a68046 Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Sun, 22 Sep 2024 00:44:27 -0700 Subject: [PATCH 34/56] Fix general flag handling in boxed drawing mode (transparency, slidein) --- src/k_hud.cpp | 2 +- src/v_video.cpp | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/k_hud.cpp b/src/k_hud.cpp index 7453d3864..54f0ff13d 100644 --- a/src/k_hud.cpp +++ b/src/k_hud.cpp @@ -6512,7 +6512,7 @@ void K_drawKartHUD(void) if (0) { // Draw::TextElement text = Draw::TextElement().parse("A B C X Y Z \nST L R U D L R "); - Draw::TextElement text = Draw::TextElement().parse("Unpressed Pressed Animated "); + Draw::TextElement text = Draw::TextElement().parse("Unpressed Pressed Animated "); UINT8 fakeoff = (stplyr - players)*40; Draw(5, 5+fakeoff).align((srb2::Draw::Align)0).font(Draw::Font::kMenu).text(text); diff --git a/src/v_video.cpp b/src/v_video.cpp index 520935a78..3c6c80bb3 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -2613,6 +2613,8 @@ void V_DrawStringScaled( boolean nodanceoverride; INT32 dancecounter; + INT32 boxedflags = ((flags) & (~V_HUDTRANS)) | (V_40TRANS); + boolean largebutton = false; fixed_t cx, cy; @@ -2738,7 +2740,7 @@ void V_DrawStringScaled( { cy -= 2*FRACUNIT; - Draw(FixedToFloat(cx), FixedToFloat(cy)-3).patch(gen_button_keyleft[anim]); + Draw(FixedToFloat(cx), FixedToFloat(cy)-3).flags(flags).patch(gen_button_keyleft[anim]); cx += 3*FRACUNIT; ssave = s; @@ -2753,8 +2755,9 @@ void V_DrawStringScaled( Draw(FixedToFloat(working)+1, FixedToFloat(cy)-3) .width(FixedToFloat(cx - working)-1) + .flags(flags) .stretch(Draw::Stretch::kWidth).patch(gen_button_keycenter[anim]); - Draw(FixedToFloat(cx), FixedToFloat(cy)-3).patch(gen_button_keyright[anim]); + Draw(FixedToFloat(cx), FixedToFloat(cy)-3).flags(flags).patch(gen_button_keyright[anim]); s = ssave; cx = cxsave; @@ -2969,7 +2972,7 @@ void V_DrawStringScaled( if (boxed != 1) { V_DrawFixedPatch(cx + cxoff + patchxofs, cy + cyoff + (boxed == 3 ? 2*FRACUNIT : 0), scale, - flags | ((!!boxed) ? V_40TRANS : 0), font->font[c], colormap); + boxed ? boxedflags : flags, font->font[c], boxed ? 0 : colormap); } cx += cw; From d1798c80fe1c5d413ce6b09445efb5508ede6df2 Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Sun, 22 Sep 2024 16:10:25 -0700 Subject: [PATCH 35/56] Descriptive input: expanded 6bt support --- src/cvars.cpp | 10 ++++++++- src/v_draw.cpp | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 1 deletion(-) diff --git a/src/cvars.cpp b/src/cvars.cpp index 231919570..7537ba2ca 100644 --- a/src/cvars.cpp +++ b/src/cvars.cpp @@ -334,7 +334,15 @@ consvar_t cv_soundvolume = Player("soundvolume", "80").min_max(0, 100); consvar_t cv_discordstreamer = Player("discordstreamer", "Off").on_off(); #endif -consvar_t cv_descriptiveinput = Player("descriptiveinput", "Yes").yes_no(); // Display bound controls instead of Saturn buttons +consvar_t cv_descriptiveinput = Player("descriptiveinput", "Modern") + .values({ + {0, "Emulator"}, + {1, "Modern"}, + {2, "6Bt. (LB LT)"}, + {3, "6Bt. (LT RT)"}, + {4, "6bt. (LB RB)"}, + } +); // Display bound controls instead of Saturn buttons consvar_t cv_drawdist = Player("drawdist", "Normal").values({ {3072, "Shortest"}, diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 31d348419..d822617e8 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -143,6 +143,45 @@ Draw::TextElement& Draw::TextElement::parse(std::string_view raw) {KEY_JOY1+8, 0x0B}, }; + // Saturn Type 1 - Retrobit Wired Dinput, RB RT LB LT + static const std::unordered_map saturntype1 = { + {KEY_JOY1+0, 0x0A}, // ABXY + {KEY_JOY1+1, 0x0B}, + {KEY_JOY1+2, 0x0D}, + {KEY_JOY1+3, 0x0E}, + {KEY_JOY1+9, 0x08}, // LBRB + {KEY_JOY1+10, 0x0C}, + {KEY_AXIS1+8, 0x07}, // LTRT + {KEY_AXIS1+9, 0x0F}, + {KEY_JOY1+6, 0x09}, // NAV + }; + + // Saturn Type 2 - Retrobit Wireless Dinput, LB RB LT RT + static const std::unordered_map saturntype2 = { + {KEY_JOY1+0, 0x0A}, // ABXY + {KEY_JOY1+1, 0x0B}, + {KEY_JOY1+2, 0x0D}, + {KEY_JOY1+3, 0x0E}, + {KEY_JOY1+9, 0x0C}, // LBRB + {KEY_JOY1+10, 0x0F}, + {KEY_AXIS1+8, 0x08}, // LTRT + {KEY_AXIS1+9, 0x07}, + {KEY_JOY1+6, 0x09}, // NAV + }; + + // Saturn Type 3 - Retrobit Wireless Xinput, RT LT LB RB + static const std::unordered_map saturntype3 = { + {KEY_JOY1+0, 0x0A}, // ABXY + {KEY_JOY1+1, 0x0B}, + {KEY_JOY1+2, 0x0D}, + {KEY_JOY1+3, 0x0E}, + {KEY_JOY1+9, 0x08}, // LBRB + {KEY_JOY1+10, 0x07}, + {KEY_AXIS1+8, 0x0F}, // LTRT + {KEY_AXIS1+9, 0x0C}, + {KEY_JOY1+6, 0x09}, // NAV + }; + string_.clear(); string_.reserve(raw.size()); @@ -209,10 +248,30 @@ Draw::TextElement& Draw::TextElement::parse(std::string_view raw) INT32 bind = G_FindPlayerBindForGameControl(localplayer, id->second); + // EXTRA: descriptiveinput values above 1 translate binds back to Saturn buttons, + // with various modes for various fucked up 6bt pads + std::unordered_map saturnconfig = {}; + switch (cv_descriptiveinput.value) + { + case 2: + saturnconfig = saturntype1; + break; + case 3: + saturnconfig = saturntype2; + break; + case 4: + saturnconfig = saturntype3; + break; + } + if (auto pretty = prettyinputs.find(bind); pretty != prettyinputs.end()) // Gamepad direction or keyboard arrow, use something nice-looking { string_.push_back((it->second & 0xF0) | pretty->second); // original invocation has the animation bits, but the glyph bits come from the table } + else if (auto st = saturnconfig.find(bind); st != saturnconfig.end()) + { + string_.push_back((it->second & 0xF0) | st->second); // original invocation has the animation bits, but the glyph bits come from the table + } else if (auto generic = genericinputs.find(bind); generic != genericinputs.end()) // Non-directional gamepad input, display it to the player as they are { string_.push_back(0xEF); // Control code: "switch to descriptive input mode" - Saturn buttons will draw as generic gamepad buttons From 598a91039b146711c4796d28b5c7a2c3f7bdf70e Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Sun, 22 Sep 2024 16:12:44 -0700 Subject: [PATCH 36/56] Change help text for descriptiveinput --- src/menus/options-hud-1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/menus/options-hud-1.c b/src/menus/options-hud-1.c index 2d94830ec..a977881d5 100644 --- a/src/menus/options-hud-1.c +++ b/src/menus/options-hud-1.c @@ -39,7 +39,7 @@ menuitem_t OPTIONS_HUD[] = {IT_SPACE | IT_NOTHING, NULL, NULL, NULL, {NULL}, 0, 0}, - {IT_STRING | IT_CVAR, "Use Button Names", "Show button/key names in help text? When off, show Saturn buttons.", + {IT_STRING | IT_CVAR, "Use Button Names", "Choose which controller prompts to show. \"Emulator\" = ignore your mapped controls.", NULL, {.cvar = &cv_descriptiveinput}, 0, 0}, {IT_SPACE | IT_NOTHING, NULL, NULL, From 80912b173cde71e29ad9e9e6e811f180d5efcb7b Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Sun, 22 Sep 2024 18:16:06 -0700 Subject: [PATCH 37/56] Descriptiveinput in profiles, various 6bt. modes --- src/command.c | 8 +++ src/command.h | 2 +- src/cvars.cpp | 19 ++++--- src/g_game.h | 2 + src/k_menu.h | 1 + src/k_menudraw.c | 2 +- src/k_profiles.cpp | 10 ++++ src/k_profiles.h | 3 ++ src/menus/options-hud-1.c | 8 --- src/menus/options-profiles-1.c | 2 + src/menus/options-profiles-edit-1.c | 1 + src/menus/options-profiles-edit-controls.c | 3 ++ src/v_draw.cpp | 58 ++++++++++++++++------ src/v_draw.hpp | 2 - 14 files changed, 84 insertions(+), 37 deletions(-) diff --git a/src/command.c b/src/command.c index b42b73a5c..eda7c0e67 100644 --- a/src/command.c +++ b/src/command.c @@ -102,6 +102,14 @@ CV_PossibleValue_t gpdifficulty_cons_t[] = { {KARTGP_MASTER, "Master"}, {0, NULL} }; +CV_PossibleValue_t descriptiveinput_cons_t[] = { + {0, "Emulator"}, + {1, "Modern"}, + {2, "6Bt. (Match)"}, + {3, "6Bt. (LB LT)"}, + {4, "6Bt. (LT RT)"}, + {5, "6bt. (LB RB)"}, +}; // Filter consvars by EXECVERSION // First implementation is 2 (1.0.2), so earlier configs default at 1 (1.0.0) diff --git a/src/command.h b/src/command.h index eabbc1b1b..98c9f4830 100644 --- a/src/command.h +++ b/src/command.h @@ -233,7 +233,7 @@ extern CV_PossibleValue_t CV_TrueFalse[]; // SRB2kart // the KARTSPEED and KARTGP were previously defined here, but moved to doomstat to avoid circular dependencies -extern CV_PossibleValue_t kartspeed_cons_t[], dummykartspeed_cons_t[], gpdifficulty_cons_t[]; +extern CV_PossibleValue_t kartspeed_cons_t[], dummykartspeed_cons_t[], gpdifficulty_cons_t[], descriptiveinput_cons_t[]; extern consvar_t cv_cheats; extern consvar_t cv_execversion; diff --git a/src/cvars.cpp b/src/cvars.cpp index 7537ba2ca..f292b6f1f 100644 --- a/src/cvars.cpp +++ b/src/cvars.cpp @@ -334,16 +334,6 @@ consvar_t cv_soundvolume = Player("soundvolume", "80").min_max(0, 100); consvar_t cv_discordstreamer = Player("discordstreamer", "Off").on_off(); #endif -consvar_t cv_descriptiveinput = Player("descriptiveinput", "Modern") - .values({ - {0, "Emulator"}, - {1, "Modern"}, - {2, "6Bt. (LB LT)"}, - {3, "6Bt. (LT RT)"}, - {4, "6bt. (LB RB)"}, - } -); // Display bound controls instead of Saturn buttons - consvar_t cv_drawdist = Player("drawdist", "Normal").values({ {3072, "Shortest"}, {4096, "Shorter"}, @@ -989,6 +979,7 @@ consvar_t cv_dummymenuplayer = MenuDummy("dummymenuplayer", "P1").onchange(Dummy consvar_t cv_dummyprofileautoroulette = MenuDummy("dummyprofileautoroulette", "Off").on_off(); consvar_t cv_dummyprofilefov = MenuDummy("dummyprofilefov", "100").min_max(70, 110); consvar_t cv_dummyprofilelitesteer = MenuDummy("dummyprofilelitesteer", "Off").on_off(); +consvar_t cv_dummyprofiledescriptiveinput = Player("dummyprofiledescriptiveinput", "Modern").values(descriptiveinput_cons_t); consvar_t cv_dummyprofileautoring = MenuDummy("dummyprofileautoring", "Off").on_off(); consvar_t cv_dummyprofilekickstart = MenuDummy("dummyprofilekickstart", "Off").on_off(); consvar_t cv_dummyprofilename = MenuDummy("dummyprofilename", ""); @@ -1123,6 +1114,14 @@ consvar_t cv_cam_height[MAXSPLITSCREENPLAYERS] = { Player("cam4_height", "95").floating_point(), }; +consvar_t cv_descriptiveinput[MAXSPLITSCREENPLAYERS] = { + Player("descriptiveinput", "Modern").values(descriptiveinput_cons_t), + Player("descriptiveinput2", "Modern").values(descriptiveinput_cons_t), + Player("descriptiveinput3", "Modern").values(descriptiveinput_cons_t), + Player("descriptiveinput4", "Modern").values(descriptiveinput_cons_t), +}; + + void CV_CamRotate_OnChange(void); void CV_CamRotate2_OnChange(void); void CV_CamRotate3_OnChange(void); diff --git a/src/g_game.h b/src/g_game.h index 5d33303c8..221643c04 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -105,6 +105,8 @@ extern consvar_t cv_shrinkme[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_deadzone[MAXSPLITSCREENPLAYERS]; +extern consvar_t cv_descriptiveinput[MAXSPLITSCREENPLAYERS]; + extern consvar_t cv_ghost_besttime, cv_ghost_bestlap, cv_ghost_last, cv_ghost_guest, cv_ghost_staff; // mouseaiming (looking up/down with the mouse or keyboard) diff --git a/src/k_menu.h b/src/k_menu.h index 116caa793..7f49fa60f 100644 --- a/src/k_menu.h +++ b/src/k_menu.h @@ -1124,6 +1124,7 @@ extern consvar_t cv_dummyprofileplayername; extern consvar_t cv_dummyprofilekickstart; extern consvar_t cv_dummyprofileautoroulette; extern consvar_t cv_dummyprofilelitesteer; +extern consvar_t cv_dummyprofiledescriptiveinput; extern consvar_t cv_dummyprofileautoring; extern consvar_t cv_dummyprofilerumble; extern consvar_t cv_dummyprofilefov; diff --git a/src/k_menudraw.c b/src/k_menudraw.c index 750ea395b..7fec31182 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -5094,7 +5094,7 @@ void M_DrawProfileControls(void) V_DrawMenuString(x, y+2, (i == itemOn ? highlightflags : 0), currentMenu->menuitems[i].text); if (currentMenu->menuitems[i].status & IT_CVAR) // not the proper way to check but this menu only has normal onoff cvars. - { + { // (bitch you thought - Tyron 2024-09-22) INT32 w; consvar_t *cv = currentMenu->menuitems[i].itemaction.cvar; diff --git a/src/k_profiles.cpp b/src/k_profiles.cpp index f054e84d3..0098a0a86 100644 --- a/src/k_profiles.cpp +++ b/src/k_profiles.cpp @@ -82,6 +82,7 @@ profile_t* PR_MakeProfile( newprofile->kickstartaccel = false; newprofile->autoroulette = false; newprofile->litesteer = false; + newprofile->descriptiveinput = 1; newprofile->autoring = false; newprofile->rumble = true; newprofile->fov = atoi(cv_dummyprofilefov.defaultvalue); @@ -104,6 +105,7 @@ profile_t* PR_MakeProfileFromPlayer(const char *prname, const char *pname, const newprofile->kickstartaccel = cv_kickstartaccel[pnum].value; newprofile->autoroulette = cv_autoroulette[pnum].value; newprofile->litesteer = cv_litesteer[pnum].value; + newprofile->descriptiveinput = cv_descriptiveinput[pnum].value; newprofile->autoring = cv_autoring[pnum].value; newprofile->rumble = cv_rumble[pnum].value; newprofile->fov = cv_fov[pnum].value / FRACUNIT; @@ -301,6 +303,7 @@ void PR_SaveProfiles(void) jsonprof.preferences.kickstartaccel = cprof->kickstartaccel; jsonprof.preferences.autoroulette = cprof->autoroulette; jsonprof.preferences.litesteer = cprof->litesteer; + jsonprof.preferences.descriptiveinput = cprof->descriptiveinput; jsonprof.preferences.autoring = cprof->autoring; jsonprof.preferences.rumble = cprof->rumble; jsonprof.preferences.fov = cprof->fov; @@ -486,6 +489,7 @@ void PR_LoadProfiles(void) newprof->kickstartaccel = jsprof.preferences.kickstartaccel; newprof->autoroulette = jsprof.preferences.autoroulette; newprof->litesteer = jsprof.preferences.litesteer; + newprof->descriptiveinput = jsprof.preferences.descriptiveinput; newprof->autoring = jsprof.preferences.autoring; newprof->rumble = jsprof.preferences.rumble; newprof->fov = jsprof.preferences.fov; @@ -568,6 +572,7 @@ static void PR_ApplyProfile_Settings(profile_t *p, UINT8 playernum) CV_StealthSetValue(&cv_kickstartaccel[playernum], p->kickstartaccel); CV_StealthSetValue(&cv_autoroulette[playernum], p->autoroulette); CV_StealthSetValue(&cv_litesteer[playernum], p->litesteer); + CV_StealthSetValue(&cv_descriptiveinput[playernum], p->descriptiveinput); CV_StealthSetValue(&cv_autoring[playernum], p->autoring); CV_StealthSetValue(&cv_rumble[playernum], p->rumble); CV_StealthSetValue(&cv_fov[playernum], p->fov); @@ -581,11 +586,16 @@ static void PR_ApplyProfile_Memory(UINT8 profilenum, UINT8 playernum) // set memory cvar CV_StealthSetValue(&cv_lastprofile[playernum], profilenum); + CONS_Printf("Applying profile memory %d to player %d", profilenum, playernum); + // If we're doing this on P1, also change current profile. if (playernum == 0) { CV_StealthSetValue(&cv_currprofile, profilenum); + CONS_Printf(" and swapping currprofile"); } + + CONS_Printf("\n"); } void PR_ApplyProfile(UINT8 profilenum, UINT8 playernum) diff --git a/src/k_profiles.h b/src/k_profiles.h index 988101f98..fea61ebf8 100644 --- a/src/k_profiles.h +++ b/src/k_profiles.h @@ -46,6 +46,7 @@ struct ProfilePreferencesJson bool kickstartaccel; bool autoroulette; bool litesteer; + uint8_t descriptiveinput; bool autoring; bool rumble; uint8_t fov; @@ -56,6 +57,7 @@ struct ProfilePreferencesJson kickstartaccel, autoroulette, litesteer, + descriptiveinput, autoring, rumble, fov @@ -162,6 +164,7 @@ struct profile_t boolean kickstartaccel; // cv_kickstartaccel boolean autoroulette; // cv_autoroulette boolean litesteer; // cv_litesteer + UINT8 descriptiveinput; // cv_descriptiveinput boolean autoring; // cv_autoring boolean rumble; // cv_rumble UINT8 fov; // cv_fov diff --git a/src/menus/options-hud-1.c b/src/menus/options-hud-1.c index a977881d5..35eb45895 100644 --- a/src/menus/options-hud-1.c +++ b/src/menus/options-hud-1.c @@ -13,8 +13,6 @@ #include "../r_main.h" // cv_showhud #include "../v_video.h" // cv_constextsize -extern consvar_t cv_descriptiveinput; - menuitem_t OPTIONS_HUD[] = { @@ -39,12 +37,6 @@ menuitem_t OPTIONS_HUD[] = {IT_SPACE | IT_NOTHING, NULL, NULL, NULL, {NULL}, 0, 0}, - {IT_STRING | IT_CVAR, "Use Button Names", "Choose which controller prompts to show. \"Emulator\" = ignore your mapped controls.", - NULL, {.cvar = &cv_descriptiveinput}, 0, 0}, - - {IT_SPACE | IT_NOTHING, NULL, NULL, - NULL, {NULL}, 0, 0}, - {IT_STRING | IT_SUBMENU, "Online Chat Options...", "Visual options for the online chat box.", NULL, {.submenu = &OPTIONS_HUDOnlineDef}, 0, 0}, }; diff --git a/src/menus/options-profiles-1.c b/src/menus/options-profiles-1.c index e7c31449c..047ad6148 100644 --- a/src/menus/options-profiles-1.c +++ b/src/menus/options-profiles-1.c @@ -102,6 +102,7 @@ void M_StartEditProfile(INT32 c) CV_StealthSetValue(&cv_dummyprofilekickstart, optionsmenu.profile->kickstartaccel); CV_StealthSetValue(&cv_dummyprofileautoroulette, optionsmenu.profile->autoroulette); CV_StealthSetValue(&cv_dummyprofilelitesteer, optionsmenu.profile->litesteer); + CV_StealthSetValue(&cv_dummyprofiledescriptiveinput, optionsmenu.profile->descriptiveinput); CV_StealthSetValue(&cv_dummyprofileautoring, optionsmenu.profile->autoring); CV_StealthSetValue(&cv_dummyprofilerumble, optionsmenu.profile->rumble); CV_StealthSetValue(&cv_dummyprofilefov, optionsmenu.profile->fov); @@ -113,6 +114,7 @@ void M_StartEditProfile(INT32 c) CV_StealthSetValue(&cv_dummyprofilekickstart, 0); // off CV_StealthSetValue(&cv_dummyprofileautoroulette, 0); // off CV_StealthSetValue(&cv_dummyprofilelitesteer, 1); // on + CV_StealthSetValue(&cv_dummyprofiledescriptiveinput, 1); // Modern CV_StealthSetValue(&cv_dummyprofileautoring, 0); // on CV_StealthSetValue(&cv_dummyprofilerumble, 1); // on CV_StealthSetValue(&cv_dummyprofilefov, 90); diff --git a/src/menus/options-profiles-edit-1.c b/src/menus/options-profiles-edit-1.c index 8bdd552c2..97b2b2c16 100644 --- a/src/menus/options-profiles-edit-1.c +++ b/src/menus/options-profiles-edit-1.c @@ -98,6 +98,7 @@ static void M_ProfileEditApply(void) optionsmenu.profile->kickstartaccel = cv_dummyprofilekickstart.value; optionsmenu.profile->autoroulette = cv_dummyprofileautoroulette.value; optionsmenu.profile->litesteer = cv_dummyprofilelitesteer.value; + optionsmenu.profile->descriptiveinput = cv_dummyprofiledescriptiveinput.value; optionsmenu.profile->autoring = cv_dummyprofileautoring.value; optionsmenu.profile->rumble = cv_dummyprofilerumble.value; optionsmenu.profile->fov = cv_dummyprofilefov.value; diff --git a/src/menus/options-profiles-edit-controls.c b/src/menus/options-profiles-edit-controls.c index 69deb89df..7f5e6e18f 100644 --- a/src/menus/options-profiles-edit-controls.c +++ b/src/menus/options-profiles-edit-controls.c @@ -99,6 +99,9 @@ menuitem_t OPTIONS_ProfileControls[] = { {IT_STRING | IT_CALL, "TRY MAPPINGS", "Test your controls.", NULL, {.routine = M_ProfileTryController}, 0, 0}, + {IT_STRING2 | IT_CVAR, "Show Button Names", "Change how help text displays your controls.", + NULL, {.cvar = &cv_dummyprofiledescriptiveinput}, 0, 0}, + {IT_STRING | IT_CALL, "RESET TO DEFAULT", "Reset all controls back to default.", NULL, {.routine = M_ProfileDefaultControls}, 0, 0}, diff --git a/src/v_draw.cpp b/src/v_draw.cpp index d822617e8..191aaa737 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -229,37 +229,65 @@ Draw::TextElement& Draw::TextElement::parse(std::string_view raw) } else if (auto it = translation.find(code); it != translation.end()) // This represents a gamecontrol, turn into Saturn button or generic button. { + + UINT8 localplayer = 0; + UINT8 indexedplayer = as_.value_or(stplyr - players); + for (UINT8 i = 0; i < MAXSPLITSCREENPLAYERS; i++) + { + if (g_localplayers[i] == indexedplayer) + { + localplayer = i; + break; + } + } + // This isn't how v_video.cpp checks for buttons and I don't know why. - if (cv_descriptiveinput.value && ((it->second & 0xF0) != 0x80)) // Should we do game control translation? + if (cv_descriptiveinput[localplayer].value && ((it->second & 0xF0) != 0x80)) // Should we do game control translation? { if (auto id = inputdefinition.find(it->second & (~0xB0)); id != inputdefinition.end()) // This is a game control, do descriptive input translation! { // Grab our local controls - if pid set in the call to parse(), use stplyr's controls - UINT8 localplayer = 0; - UINT8 indexedplayer = as_.value_or(stplyr - players); - for (UINT8 i = 0; i < MAXSPLITSCREENPLAYERS; i++) - { - if (g_localplayers[i] == indexedplayer) - { - localplayer = i; - break; - } - } - INT32 bind = G_FindPlayerBindForGameControl(localplayer, id->second); // EXTRA: descriptiveinput values above 1 translate binds back to Saturn buttons, // with various modes for various fucked up 6bt pads std::unordered_map saturnconfig = {}; - switch (cv_descriptiveinput.value) + switch (cv_descriptiveinput[localplayer].value) { case 2: + { + INT32 leftbumper = G_FindPlayerBindForGameControl(localplayer, gc_l); + INT32 rightbumper = G_FindPlayerBindForGameControl(localplayer, gc_r); + + if (leftbumper == KEY_JOY1+9 && rightbumper == KEY_AXIS1+8) + { + saturnconfig = saturntype1; // LB LT + // CONS_Printf("Saturn type 1\n"); + } + else if (leftbumper == KEY_AXIS1+8 && rightbumper == KEY_AXIS1+9) + { + saturnconfig = saturntype2; // LT RT + // CONS_Printf("Saturn type 2\n"); + } + else if (leftbumper == KEY_JOY1+9 && rightbumper == KEY_JOY1+10) + { + saturnconfig = saturntype3; // LB RB + // CONS_Printf("Saturn type 3\n"); + } + else + { + saturnconfig = saturntype1; // :( ??? + // CONS_Printf("Unknown, falling back to type 1\n"); + } + break; + } + case 3: saturnconfig = saturntype1; break; - case 3: + case 4: saturnconfig = saturntype2; break; - case 4: + case 5: saturnconfig = saturntype3; break; } diff --git a/src/v_draw.hpp b/src/v_draw.hpp index e10faf733..e99e80fee 100644 --- a/src/v_draw.hpp +++ b/src/v_draw.hpp @@ -24,8 +24,6 @@ #include "typedef.h" #include "v_video.h" -extern consvar_t cv_descriptiveinput; - namespace srb2 { From cad7273ff41069ccbaf4fe4162169660929be4a4 Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Sun, 22 Sep 2024 21:56:11 -0700 Subject: [PATCH 38/56] Controller type refactor --- src/command.c | 14 +- src/g_input.h | 27 +++ src/k_menudraw.c | 42 ++++- src/k_profiles.cpp | 5 - src/menus/options-profiles-edit-controls.c | 9 +- src/v_draw.cpp | 193 +++++++++------------ src/v_draw.hpp | 159 +++++++++++++++++ src/v_video.cpp | 60 +++---- 8 files changed, 354 insertions(+), 155 deletions(-) diff --git a/src/command.c b/src/command.c index eda7c0e67..0b728f06c 100644 --- a/src/command.c +++ b/src/command.c @@ -103,12 +103,16 @@ CV_PossibleValue_t gpdifficulty_cons_t[] = { {0, NULL} }; CV_PossibleValue_t descriptiveinput_cons_t[] = { - {0, "Emulator"}, + {0, "\"Emulator\""}, {1, "Modern"}, - {2, "6Bt. (Match)"}, - {3, "6Bt. (LB LT)"}, - {4, "6Bt. (LT RT)"}, - {5, "6bt. (LB RB)"}, + {2, "Modern Flip"}, + {3, "6Bt. (Auto)"}, + {4, "6Bt. (A)"}, + {5, "6Bt. (B)"}, + {6, "6Bt. (C)"}, + {7, "6Bt. (D)"}, + {8, "6Bt. (E)"}, + {0, NULL} }; // Filter consvars by EXECVERSION diff --git a/src/g_input.h b/src/g_input.h index 58edccdd1..ccca4cbe9 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -56,6 +56,33 @@ typedef enum NUMINPUTS = MOUSEINPUTEND, } key_input_e; +// Helper to keep descriptive input setup slightly more readable +typedef enum +{ + nc_a = KEY_JOY1, + nc_b, + nc_x, + nc_y, + nc_back, + nc_guide, + nc_start, + nc_ls, + nc_rs, + nc_lb, + nc_rb, + nc_hatup, + nc_hatdown, + nc_hatleft, + nc_hatright, + nc_touch = KEY_JOY1+20, + nc_lsleft = KEY_AXIS1+0, + nc_lsright, + nc_lsup, + nc_lsdown, + nc_lt = KEY_AXIS1+8, + nc_rt, +} named_controls_e; + typedef enum { gc_null = 0, // a key/button mapped to gc_null has no effect diff --git a/src/k_menudraw.c b/src/k_menudraw.c index 7fec31182..ad0734bb0 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -5099,7 +5099,7 @@ void M_DrawProfileControls(void) consvar_t *cv = currentMenu->menuitems[i].itemaction.cvar; w = V_MenuStringWidth(cv->string, 0); - V_DrawMenuString(x + 12, y + 13, ((cv->flags & CV_CHEAT) && !CV_IsSetToDefault(cv) ? warningflags : highlightflags), cv->string); + V_DrawMenuString(x + 12, y + 13, (!CV_IsSetToDefault(cv) ? warningflags : highlightflags), cv->string); if (i == itemOn) { V_DrawMenuString(x - (skullAnimCounter/5), y+12, highlightflags, "\x1C"); // left arrow @@ -5288,7 +5288,45 @@ void M_DrawProfileControls(void) if (currentMenu->menuitems[itemOn].tooltip != NULL) { INT32 ypos = BASEVIDHEIGHT + hintofs - 9 - 12; - V_DrawThinString(12, ypos, V_YELLOWMAP, currentMenu->menuitems[itemOn].tooltip); + + if (!strcmp(currentMenu->menuitems[itemOn].tooltip, "DESCRIPTIVEINPUT-SENTINEL")) + { + char* help = va("Modern: Standard console controller prompts."); + switch (cv_dummyprofiledescriptiveinput.value) + { + case 0: + help = va("\"Emulator\": Display the default (Saturn) controls."); + break; + case 2: + help = va("Modern Flip: Swap A+X/B+Y. Use if Modern is wrong."); + break; + case 3: + help = va("6Bt. (Auto): Tries to guess your 6-button pad's layout."); + break; + case 4: + help = va("6Bt. (A): Saturn buttons, Retro-Bit Wired DInput layout."); + break; + case 5: + help = va("6Bt. (B): Saturn buttons, Retro-Bit Wireless DInput layout."); + break; + case 6: + help = va("6Bt. (C): Saturn buttons, Retro-Bit XInput layout."); + break; + case 7: + help = va("6Bt. (D): Saturn buttons, arcade/8BitDo layout. (C/Z = RT/RB)"); + break; + case 8: + help = va("6Bt. (E): Saturn buttons, Hori/M30X layout. (LB/LT = LS/RS)"); + break; + } + + V_DrawThinString(12, ypos, V_YELLOWMAP, help); + } + else + { + V_DrawThinString(12, ypos, V_YELLOWMAP, currentMenu->menuitems[itemOn].tooltip); + } + boolean standardbuttons = gamedata->gonerlevel > GDGONER_PROFILE; INT32 xpos = BASEVIDWIDTH - 12; diff --git a/src/k_profiles.cpp b/src/k_profiles.cpp index 0098a0a86..7e07f3c9e 100644 --- a/src/k_profiles.cpp +++ b/src/k_profiles.cpp @@ -586,16 +586,11 @@ static void PR_ApplyProfile_Memory(UINT8 profilenum, UINT8 playernum) // set memory cvar CV_StealthSetValue(&cv_lastprofile[playernum], profilenum); - CONS_Printf("Applying profile memory %d to player %d", profilenum, playernum); - // If we're doing this on P1, also change current profile. if (playernum == 0) { CV_StealthSetValue(&cv_currprofile, profilenum); - CONS_Printf(" and swapping currprofile"); } - - CONS_Printf("\n"); } void PR_ApplyProfile(UINT8 profilenum, UINT8 playernum) diff --git a/src/menus/options-profiles-edit-controls.c b/src/menus/options-profiles-edit-controls.c index 7f5e6e18f..ffbccfb8e 100644 --- a/src/menus/options-profiles-edit-controls.c +++ b/src/menus/options-profiles-edit-controls.c @@ -18,6 +18,12 @@ menuitem_t OPTIONS_ProfileControls[] = { + {IT_HEADER, "DEVICE SETTINGS", "", + NULL, {NULL}, 0, 0}, + + {IT_STRING2 | IT_CVAR, "Button Display", "DESCRIPTIVEINPUT-SENTINEL", + NULL, {.cvar = &cv_dummyprofiledescriptiveinput}, 0, 0}, + {IT_HEADER, "MAIN CONTROLS", "That's the stuff on the controller!!", NULL, {NULL}, 0, 0}, @@ -99,9 +105,6 @@ menuitem_t OPTIONS_ProfileControls[] = { {IT_STRING | IT_CALL, "TRY MAPPINGS", "Test your controls.", NULL, {.routine = M_ProfileTryController}, 0, 0}, - {IT_STRING2 | IT_CVAR, "Show Button Names", "Change how help text displays your controls.", - NULL, {.cvar = &cv_dummyprofiledescriptiveinput}, 0, 0}, - {IT_STRING | IT_CALL, "RESET TO DEFAULT", "Reset all controls back to default.", NULL, {.routine = M_ProfileDefaultControls}, 0, 0}, diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 191aaa737..b0b26716d 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -40,26 +40,26 @@ Draw::TextElement& Draw::TextElement::parse(std::string_view raw) {str "_animated", 0xA0 | lower_bits},\ {str "_pressed", 0x90 | lower_bits} - BUTTON("up", 0x00), - BUTTON("down", 0x01), - BUTTON("right", 0x02), - BUTTON("left", 0x03), + BUTTON("up", sb_up), + BUTTON("down", sb_down), + BUTTON("right", sb_right), + BUTTON("left", sb_left), - BUTTON("lua1", 0x04), - BUTTON("lua2", 0x05), - BUTTON("lua3", 0x06), + BUTTON("lua1", sb_lua1), + BUTTON("lua2", sb_lua2), + BUTTON("lua3", sb_lua3), - BUTTON("r", 0x07), - BUTTON("l", 0x08), - BUTTON("start", 0x09), + BUTTON("r", sb_r), + BUTTON("l", sb_l), + BUTTON("start", sb_start), - BUTTON("a", 0x0A), - BUTTON("b", 0x0B), - BUTTON("c", 0x0C), + BUTTON("a", sb_a), + BUTTON("b", sb_b), + BUTTON("c", sb_c), - BUTTON("x", 0x0D), - BUTTON("y", 0x0E), - BUTTON("z", 0x0F), + BUTTON("x", sb_x), + BUTTON("y", sb_y), + BUTTON("z", sb_z), #undef BUTTON @@ -87,7 +87,7 @@ Draw::TextElement& Draw::TextElement::parse(std::string_view raw) {"tan", 0x8F}, }; - // What glyphs should be rewritten as gamecontrols? + // When we encounter a Saturn button, what gamecontrol does it represent? static const std::unordered_map inputdefinition = { {0x00, gc_up}, {0x01, gc_down}, @@ -111,75 +111,22 @@ Draw::TextElement& Draw::TextElement::parse(std::string_view raw) {0x0F, gc_z}, }; - // What physical binds should be rewritten as base Saturn icons? + // What physical binds should appear as Saturn icons anyway? + // (We don't have generic binds for stick/dpad directions, so + // using the existing arrow graphics is the best thing here.) static const std::unordered_map prettyinputs = { - {KEY_UPARROW, 0x00}, - {KEY_DOWNARROW, 0x01}, - {KEY_RIGHTARROW, 0x02}, - {KEY_LEFTARROW, 0x03}, - {KEY_JOY1+11, 0x00}, - {KEY_JOY1+12, 0x01}, - {KEY_JOY1+14, 0x02}, - {KEY_JOY1+13, 0x03}, - {KEY_AXIS1+0, 0x03}, // Left - {KEY_AXIS1+1, 0x02}, // Right - {KEY_AXIS1+2, 0x00}, // Up - {KEY_AXIS1+3, 0x01}, // Down - }; - - // What physical binds should be rewritten as generic icons? - static const std::unordered_map genericinputs = { - {KEY_JOY1+0, 0x00}, // ABXY - {KEY_JOY1+1, 0x01}, - {KEY_JOY1+2, 0x02}, - {KEY_JOY1+3, 0x03}, - {KEY_JOY1+9, 0x04}, // LBRB - {KEY_JOY1+10, 0x05}, - {KEY_AXIS1+8, 0x06}, // LTRT - {KEY_AXIS1+9, 0x07}, - {KEY_JOY1+6, 0x08}, // NAV - {KEY_JOY1+4, 0x09}, - {KEY_JOY1+7, 0x0A}, // CLICK - {KEY_JOY1+8, 0x0B}, - }; - - // Saturn Type 1 - Retrobit Wired Dinput, RB RT LB LT - static const std::unordered_map saturntype1 = { - {KEY_JOY1+0, 0x0A}, // ABXY - {KEY_JOY1+1, 0x0B}, - {KEY_JOY1+2, 0x0D}, - {KEY_JOY1+3, 0x0E}, - {KEY_JOY1+9, 0x08}, // LBRB - {KEY_JOY1+10, 0x0C}, - {KEY_AXIS1+8, 0x07}, // LTRT - {KEY_AXIS1+9, 0x0F}, - {KEY_JOY1+6, 0x09}, // NAV - }; - - // Saturn Type 2 - Retrobit Wireless Dinput, LB RB LT RT - static const std::unordered_map saturntype2 = { - {KEY_JOY1+0, 0x0A}, // ABXY - {KEY_JOY1+1, 0x0B}, - {KEY_JOY1+2, 0x0D}, - {KEY_JOY1+3, 0x0E}, - {KEY_JOY1+9, 0x0C}, // LBRB - {KEY_JOY1+10, 0x0F}, - {KEY_AXIS1+8, 0x08}, // LTRT - {KEY_AXIS1+9, 0x07}, - {KEY_JOY1+6, 0x09}, // NAV - }; - - // Saturn Type 3 - Retrobit Wireless Xinput, RT LT LB RB - static const std::unordered_map saturntype3 = { - {KEY_JOY1+0, 0x0A}, // ABXY - {KEY_JOY1+1, 0x0B}, - {KEY_JOY1+2, 0x0D}, - {KEY_JOY1+3, 0x0E}, - {KEY_JOY1+9, 0x08}, // LBRB - {KEY_JOY1+10, 0x07}, - {KEY_AXIS1+8, 0x0F}, // LTRT - {KEY_AXIS1+9, 0x0C}, - {KEY_JOY1+6, 0x09}, // NAV + {KEY_UPARROW, sb_up}, + {KEY_DOWNARROW, sb_down}, + {KEY_LEFTARROW, sb_left}, + {KEY_RIGHTARROW, sb_right}, + {nc_hatup, sb_up}, + {nc_hatdown, sb_down}, + {nc_hatleft, sb_left}, + {nc_hatright, sb_right}, + {nc_lsup, sb_up}, + {nc_lsdown, sb_down}, + {nc_lsleft, sb_left}, + {nc_lsright, sb_right}, }; string_.clear(); @@ -251,44 +198,65 @@ Draw::TextElement& Draw::TextElement::parse(std::string_view raw) // EXTRA: descriptiveinput values above 1 translate binds back to Saturn buttons, // with various modes for various fucked up 6bt pads - std::unordered_map saturnconfig = {}; + std::unordered_map padconfig = {}; switch (cv_descriptiveinput[localplayer].value) { + case 1: + padconfig = standardpad; + break; case 2: + padconfig = flippedpad; + break; + case 3: { + // Most players will map gc_L to their physical L button, + // and gc_R to their physical R button. Assuming this is + // true, try to guess their physical layout based on what + // they've chosen. + INT32 leftbumper = G_FindPlayerBindForGameControl(localplayer, gc_l); INT32 rightbumper = G_FindPlayerBindForGameControl(localplayer, gc_r); - if (leftbumper == KEY_JOY1+9 && rightbumper == KEY_AXIS1+8) + if (leftbumper == nc_lb && rightbumper == nc_lt) { - saturnconfig = saturntype1; // LB LT - // CONS_Printf("Saturn type 1\n"); + padconfig = saturntypeA; } - else if (leftbumper == KEY_AXIS1+8 && rightbumper == KEY_AXIS1+9) + else if (leftbumper == nc_lt && rightbumper == nc_rt) { - saturnconfig = saturntype2; // LT RT - // CONS_Printf("Saturn type 2\n"); + padconfig = saturntypeB; } - else if (leftbumper == KEY_JOY1+9 && rightbumper == KEY_JOY1+10) + else if (leftbumper == nc_lb && rightbumper == nc_rb) { - saturnconfig = saturntype3; // LB RB - // CONS_Printf("Saturn type 3\n"); + padconfig = saturntypeC; + } + else if (leftbumper == nc_ls && rightbumper == nc_lb) + { + padconfig = saturntypeE; + } + else if (leftbumper == nc_rs && rightbumper == nc_lt) + { + padconfig = saturntypeE; // Not a typo! Users might bind a Hori layout pad to either bumpers or triggers } else { - saturnconfig = saturntype1; // :( ??? - // CONS_Printf("Unknown, falling back to type 1\n"); + padconfig = saturntypeA; // :( ??? } break; } - case 3: - saturnconfig = saturntype1; - break; case 4: - saturnconfig = saturntype2; + padconfig = saturntypeA; break; case 5: - saturnconfig = saturntype3; + padconfig = saturntypeB; + break; + case 6: + padconfig = saturntypeC; + break; + case 7: + padconfig = saturntypeD; + break; + case 8: + padconfig = saturntypeE; break; } @@ -296,15 +264,20 @@ Draw::TextElement& Draw::TextElement::parse(std::string_view raw) { string_.push_back((it->second & 0xF0) | pretty->second); // original invocation has the animation bits, but the glyph bits come from the table } - else if (auto st = saturnconfig.find(bind); st != saturnconfig.end()) + else if (auto pad = padconfig.find(bind); pad != padconfig.end()) { - string_.push_back((it->second & 0xF0) | st->second); // original invocation has the animation bits, but the glyph bits come from the table - } - else if (auto generic = genericinputs.find(bind); generic != genericinputs.end()) // Non-directional gamepad input, display it to the player as they are - { - string_.push_back(0xEF); // Control code: "switch to descriptive input mode" - Saturn buttons will draw as generic gamepad buttons - string_.push_back(0xEB); // Control code: "large button" - string_.push_back((it->second & 0xF0) | generic->second); // original invocation has the animation bits, but the glyph bits come from the table + // If high bits are set, this is meant to be a generic button. + if (pad->second & 0xF0) + { + string_.push_back(0xEF); // Control code: "switch to descriptive input mode" - buttons will draw as generics + string_.push_back(0xEB); // Control code: "large button" + } + + // Clear high bits so we can add animation bits back cleanly. + pad->second = pad->second & (0x0F); + + // original invocation has the animation bits, but the glyph bits come from the table + string_.push_back((it->second & 0xF0) | pad->second); } else { diff --git a/src/v_draw.hpp b/src/v_draw.hpp index e99e80fee..8e6ad5c24 100644 --- a/src/v_draw.hpp +++ b/src/v_draw.hpp @@ -23,6 +23,165 @@ #include "screen.h" // BASEVIDWIDTH #include "typedef.h" #include "v_video.h" +#include "g_input.h" + +// Helpers for setting up pad napping nonsense +typedef enum +{ + gb_mask = 0xF0, + gb_a = 0xF0, + gb_b, + gb_x, + gb_y, + gb_lb, + gb_rb, + gb_lt, + gb_rt, + gb_start, + gb_back, + gb_ls, + gb_rs, + gb_dpad +} generic_buttons_e; + +typedef enum +{ + sb_up = 0x00, + sb_down, + sb_right, + sb_left, + sb_lua1, + sb_lua2, + sb_lua3, + sb_r, + sb_l, + sb_start, + sb_a, + sb_b, + sb_c, + sb_x, + sb_y, + sb_z +} saturn_buttons_e; + +// Garden-variety standard gamepad +static const std::unordered_map standardpad = { + {nc_a, gb_a}, + {nc_b, gb_b}, + {nc_x, gb_x}, + {nc_y, gb_y}, + {nc_lb, gb_lb}, + {nc_rb, gb_rb}, + {nc_lt, gb_lt}, + {nc_rt, gb_rt}, + {nc_start, gb_start}, + {nc_back, gb_back}, + {nc_ls, gb_ls}, + {nc_rs, gb_rs}, +}; + +// Standard gamepad, but evil Nintendo layout flip was applied by your +// controller firmware or Steam Input—swap B/A and X/Y +static const std::unordered_map flippedpad = { + {nc_a, gb_b}, + {nc_b, gb_a}, + {nc_x, gb_y}, + {nc_y, gb_x}, + {nc_lb, gb_lb}, + {nc_rb, gb_rb}, + {nc_lt, gb_lt}, + {nc_rt, gb_rt}, + {nc_start, gb_start}, + {nc_back, gb_back}, + {nc_ls, gb_ls}, + {nc_rs, gb_rs}, +}; + +// Saturn Type A - Retrobit Wired Dinput, RB RT LB LT (CZLR) +static const std::unordered_map saturntypeA = { + {nc_a, sb_a}, + {nc_b, sb_b}, + {nc_x, sb_x}, + {nc_y, sb_y}, + {nc_rb, sb_c}, + {nc_rt, sb_z}, + {nc_lb, sb_l}, + {nc_lt, sb_r}, + {nc_start, gb_start}, + {nc_back, gb_back}, + {nc_ls, gb_ls}, + {nc_rs, gb_rs}, +}; + +// Saturn Type B - Retrobit Wireless Dinput, LB RB LT RT (CZLR) +static const std::unordered_map saturntypeB = { + {nc_a, sb_a}, + {nc_b, sb_b}, + {nc_x, sb_x}, + {nc_y, sb_y}, + {nc_lb, sb_c}, + {nc_rb, sb_z}, + {nc_lt, sb_l}, + {nc_rt, sb_r}, + {nc_start, gb_start}, + {nc_back, gb_back}, + {nc_ls, gb_ls}, + {nc_rs, gb_rs}, +}; + +// Saturn Type C - Retrobit Xinput, RT LT LB RB (CZLR) +static const std::unordered_map saturntypeC = { + {nc_a, sb_a}, + {nc_b, sb_b}, + {nc_x, sb_x}, + {nc_y, sb_y}, + {nc_rt, sb_c}, + {nc_lb, sb_z}, + {nc_lb, sb_l}, + {nc_rb, sb_r}, + {nc_start, gb_start}, + {nc_back, gb_back}, + {nc_ls, gb_ls}, + {nc_rs, gb_rs}, +}; + +// Saturn Type D - 8BitDo M30 / arcade, RT RB LB LT (CZLR) +// This cannot be disambiguated (shares L/R with type 1) +// but is more spatially correct w/r/t SDL expectations +// and standard arcade mapping (Z on top, C on bottom) +static const std::unordered_map saturntypeD = { + {nc_a, sb_a}, + {nc_b, sb_b}, + {nc_x, sb_x}, + {nc_y, sb_y}, + {nc_rt, sb_c}, + {nc_rb, sb_z}, + {nc_lb, sb_l}, + {nc_lt, sb_r}, + {nc_start, gb_start}, + {nc_back, gb_back}, + {nc_ls, gb_ls}, + {nc_rs, gb_rs}, +}; + +// Saturn Type E - Hori, RT RB (CZ) with some fucked up bumpers/triggers +// The Hori layout is, to my knowledge, the only 6bt one that has fully +// unique buttons in every slot while having both bumpers and triggers, +// so there's no way to accurately portray it without using generics. +static const std::unordered_map saturntypeE = { + {nc_a, sb_a}, + {nc_b, sb_b}, + {nc_x, sb_x}, + {nc_y, sb_y}, + {nc_rt, sb_c}, + {nc_rb, sb_z}, + {nc_lb, gb_rb}, + {nc_lt, gb_rt}, + {nc_ls, gb_lb}, + {nc_rs, gb_lt}, + {nc_start, gb_start}, + {nc_back, gb_back}, +}; namespace srb2 { diff --git a/src/v_video.cpp b/src/v_video.cpp index 3c6c80bb3..d4edf89e8 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -2835,27 +2835,27 @@ void V_DrawStringScaled( { switch (c & 0x0F) { - case 0x00: return {{0, 3, Draw::Button::up}}; - case 0x01: return {{0, 3, Draw::Button::down}}; - case 0x02: return {{0, 3, Draw::Button::right}}; - case 0x03: return {{0, 3, Draw::Button::left}}; + case sb_up: return {{0, 3, Draw::Button::up}}; + case sb_down: return {{0, 3, Draw::Button::down}}; + case sb_right: return {{0, 3, Draw::Button::right}}; + case sb_left: return {{0, 3, Draw::Button::left}}; - case 0x04: return {{0, 4, Draw::Button::lua1}}; - case 0x05: return {{0, 4, Draw::Button::lua2}}; - case 0x06: return {{0, 4, Draw::Button::lua3}}; + case sb_lua1: return {{0, 4, Draw::Button::lua1}}; + case sb_lua2: return {{0, 4, Draw::Button::lua2}}; + case sb_lua3: return {{0, 4, Draw::Button::lua3}}; - case 0x07: return {{0, 2, Draw::Button::r}}; - case 0x08: return {{0, 2, Draw::Button::l}}; + case sb_r: return {{0, 2, Draw::Button::r}}; + case sb_l: return {{0, 2, Draw::Button::l}}; - case 0x09: return {{0, 1, Draw::Button::start}}; + case sb_start: return {{0, 1, Draw::Button::start}}; - case 0x0A: return {{2, 1, Draw::Button::a}}; - case 0x0B: return {{2, 1, Draw::Button::b}}; - case 0x0C: return {{2, 1, Draw::Button::c}}; + case sb_a: return {{2, 1, Draw::Button::a}}; + case sb_b: return {{2, 1, Draw::Button::b}}; + case sb_c: return {{2, 1, Draw::Button::c}}; - case 0x0D: return {{2, 1, Draw::Button::x}}; - case 0x0E: return {{2, 1, Draw::Button::y}}; - case 0x0F: return {{2, 1, Draw::Button::z}}; + case sb_x: return {{2, 1, Draw::Button::x}}; + case sb_y: return {{2, 1, Draw::Button::y}}; + case sb_z: return {{2, 1, Draw::Button::z}}; default: return {}; } @@ -2906,21 +2906,21 @@ void V_DrawStringScaled( auto bt_inst = [c]() -> std::optional { - switch (c & 0x0F) + switch ((c & 0x0F) | gb_mask) { - case 0x00: return {{0, 2, Draw::GenericButton::a}}; - case 0x01: return {{0, 2, Draw::GenericButton::b}}; - case 0x02: return {{0, 2, Draw::GenericButton::x}}; - case 0x03: return {{0, 2, Draw::GenericButton::y}}; - case 0x04: return {{1, 3, Draw::GenericButton::lb}}; - case 0x05: return {{1, 3, Draw::GenericButton::rb}}; - case 0x06: return {{1, 4, Draw::GenericButton::lt}}; - case 0x07: return {{1, 4, Draw::GenericButton::rt}}; - case 0x08: return {{1, 6, Draw::GenericButton::start}}; - case 0x09: return {{1, 6, Draw::GenericButton::back}}; - case 0x0A: return {{0, 5, Draw::GenericButton::ls}}; - case 0x0B: return {{0, 5, Draw::GenericButton::rs}}; - case 0x0C: return {{0, 4, Draw::GenericButton::dpad}}; + case gb_a: return {{0, 2, Draw::GenericButton::a}}; + case gb_b: return {{0, 2, Draw::GenericButton::b}}; + case gb_x: return {{0, 2, Draw::GenericButton::x}}; + case gb_y: return {{0, 2, Draw::GenericButton::y}}; + case gb_lb: return {{1, 3, Draw::GenericButton::lb}}; + case gb_rb: return {{1, 3, Draw::GenericButton::rb}}; + case gb_lt: return {{1, 4, Draw::GenericButton::lt}}; + case gb_rt: return {{1, 4, Draw::GenericButton::rt}}; + case gb_start: return {{1, 6, Draw::GenericButton::start}}; + case gb_back: return {{1, 6, Draw::GenericButton::back}}; + case gb_ls: return {{0, 5, Draw::GenericButton::ls}}; + case gb_rs: return {{0, 5, Draw::GenericButton::rs}}; + case gb_dpad: return {{0, 4, Draw::GenericButton::dpad}}; default: return {}; } }(); From c96b96eb5fe11af511cdf18aeb81b5c3609ba7a7 Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Sun, 22 Sep 2024 22:02:18 -0700 Subject: [PATCH 39/56] Fix saturn type C --- src/v_draw.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/v_draw.hpp b/src/v_draw.hpp index 8e6ad5c24..6d910f167 100644 --- a/src/v_draw.hpp +++ b/src/v_draw.hpp @@ -136,7 +136,7 @@ static const std::unordered_map saturntypeC = { {nc_x, sb_x}, {nc_y, sb_y}, {nc_rt, sb_c}, - {nc_lb, sb_z}, + {nc_lt, sb_z}, {nc_lb, sb_l}, {nc_rb, sb_r}, {nc_start, gb_start}, From c6d3f78246f77fc07073ce83797d57b9602474b1 Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Mon, 23 Sep 2024 01:09:34 -0700 Subject: [PATCH 40/56] bring that enum in --- src/v_draw.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/v_draw.cpp b/src/v_draw.cpp index b0b26716d..ef8b2fe4b 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -89,26 +89,26 @@ Draw::TextElement& Draw::TextElement::parse(std::string_view raw) // When we encounter a Saturn button, what gamecontrol does it represent? static const std::unordered_map inputdefinition = { - {0x00, gc_up}, - {0x01, gc_down}, - {0x02, gc_right}, - {0x03, gc_left}, + {sb_up, gc_up}, + {sb_down, gc_down}, + {sb_right, gc_right}, + {sb_left, gc_left}, - {0x04, gc_lua1}, - {0x05, gc_lua2}, - {0x06, gc_lua3}, + {sb_lua1, gc_lua1}, + {sb_lua2, gc_lua2}, + {sb_lua3, gc_lua3}, - {0x07, gc_r}, - {0x08, gc_l}, - {0x09, gc_start}, + {sb_r, gc_r}, + {sb_l, gc_l}, + {sb_start, gc_start}, - {0x0A, gc_a}, - {0x0B, gc_b}, - {0x0C, gc_c}, + {sb_a, gc_a}, + {sb_b, gc_b}, + {sb_c, gc_c}, - {0x0D, gc_x}, - {0x0E, gc_y}, - {0x0F, gc_z}, + {sb_x, gc_x}, + {sb_y, gc_y}, + {sb_z, gc_z}, }; // What physical binds should appear as Saturn icons anyway? From 8e47e37af1d55c91effae06756de5d91a6b23ea2 Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Tue, 24 Sep 2024 22:51:22 -0700 Subject: [PATCH 41/56] Responsive button display setting, no more standardbuttons --- src/g_input.c | 2 +- src/k_menudraw.c | 49 +++++++++++++++--------------------------------- 2 files changed, 16 insertions(+), 35 deletions(-) diff --git a/src/g_input.c b/src/g_input.c index 2859ff500..a20d99a9c 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -767,7 +767,7 @@ static keyname_t shortkeynames[] = {KEY_ENTER, "ENTER"}, {KEY_TAB, "TAB"}, {KEY_ESCAPE, "ESC"}, - {KEY_BACKSPACE, "BSPC"}, + {KEY_BACKSPACE, "BKSP"}, {KEY_NUMLOCK, "NUMLOCK"}, {KEY_SCROLLLOCK, "SCRLOCK"}, diff --git a/src/k_menudraw.c b/src/k_menudraw.c index ad0734bb0..e8a2d7d2c 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -806,10 +806,6 @@ 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) @@ -830,18 +826,11 @@ void M_DrawMenuMessage(void) workx -= 2; - if (standardbuttons) - { - workx -= K_DrawGameControl( - workx+2, worky+2, - 0, " ", - 2, 8, 0 - ); - } - else - { - M_DrawMediocreKeyboardKey("ESC", &workx, worky, push, true); - } + workx -= K_DrawGameControl( + workx+2, worky+2, + 0, " ", + 2, 8, 0 + ); if (menumessage.confirmstr) { @@ -861,18 +850,11 @@ void M_DrawMenuMessage(void) workx -= 2; } - if (standardbuttons) - { - workx -= K_DrawGameControl( - workx+2, worky+2, - 0, " ", - 2, 8, 0 - ); - } - else - { - M_DrawMediocreKeyboardKey("ENTER", &workx, worky, push, true); - } + workx -= K_DrawGameControl( + workx+2, worky+2, + 0, " ", + 2, 8, 0 + ); } x -= 4; @@ -5291,7 +5273,7 @@ void M_DrawProfileControls(void) if (!strcmp(currentMenu->menuitems[itemOn].tooltip, "DESCRIPTIVEINPUT-SENTINEL")) { - char* help = va("Modern: Standard console controller prompts."); + char* help = va("Modern: Standard console controller/keyboard prompts."); switch (cv_dummyprofiledescriptiveinput.value) { case 0: @@ -5327,12 +5309,11 @@ void M_DrawProfileControls(void) V_DrawThinString(12, ypos, V_YELLOWMAP, currentMenu->menuitems[itemOn].tooltip); } - - boolean standardbuttons = gamedata->gonerlevel > GDGONER_PROFILE; + UINT16 oldsetting = cv_descriptiveinput->value; + CV_StealthSetValue(cv_descriptiveinput, cv_dummyprofiledescriptiveinput.value); INT32 xpos = BASEVIDWIDTH - 12; - xpos = standardbuttons ? - M_DrawProfileLegend(xpos, ypos, "\xB2 / \xBC Clear", NULL) : - M_DrawProfileLegend(xpos, ypos, "Clear", "BKSP"); + xpos = K_DrawGameControl(xpos, ypos, 0, " / Clear", 2, 0, 0); + CV_StealthSetValue(cv_descriptiveinput, oldsetting); } // Overlay for control binding From 89036e07eb5d7d59afc0e937cca1935c95fe521f Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Thu, 26 Sep 2024 20:36:21 -0700 Subject: [PATCH 42/56] big ol fucking fuck --- src/cvars.cpp | 1 + src/hu_stuff.c | 2 + src/k_dialogue.cpp | 4 +- src/k_hud.cpp | 143 ++++++++++++--------------- src/k_hud.h | 43 ++++---- src/k_menudraw.c | 2 +- src/r_main.h | 1 + src/v_draw.cpp | 38 ++++---- src/v_video.cpp | 238 ++++++++++++++++++++++++++++++--------------- 9 files changed, 269 insertions(+), 203 deletions(-) diff --git a/src/cvars.cpp b/src/cvars.cpp index f292b6f1f..1a8f7904e 100644 --- a/src/cvars.cpp +++ b/src/cvars.cpp @@ -914,6 +914,7 @@ consvar_t cv_debugvirtualkeyboard = PlayerCheat("debugvirtualkeyboard", "Off").o consvar_t cv_devmode_screen = PlayerCheat("devmode_screen", "1").min_max(1, 4).description("Choose which splitscreen player devmode applies to"); consvar_t cv_drawpickups = PlayerCheat("drawpickups", "Yes").yes_no().description("Hide rings, spheres, item capsules, prison capsules (visual only)"); consvar_t cv_drawtimer = PlayerCheat("drawtimer", "No").yes_no().description("Always draw the timer (race checkpoint timing, etc)"); +consvar_t cv_debugfonts = PlayerCheat("debugfonts", "No").yes_no().description("Draw font bounding boxes (integer precision, beware centered text!)"); void lua_profile_OnChange(void); consvar_t cv_lua_profile = PlayerCheat("lua_profile", "0").values(CV_Unsigned).onchange(lua_profile_OnChange).description("Show hook timings over an average of N tics"); diff --git a/src/hu_stuff.c b/src/hu_stuff.c index c866184b4..a01bf99d6 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -385,6 +385,8 @@ patch_t *HU_UpdateOrBlankPatch(patch_t **user, boolean required, const char *for vsnprintf(buffer, sizeof buffer, format, ap); va_end (ap); + CONS_Printf("%s\n", buffer); + if (user && partadd_earliestfile != UINT16_MAX) { UINT16 fileref = numwadfiles; diff --git a/src/k_dialogue.cpp b/src/k_dialogue.cpp index 36c90a079..ea52a746b 100644 --- a/src/k_dialogue.cpp +++ b/src/k_dialogue.cpp @@ -482,7 +482,7 @@ void Dialogue::Draw(void) if (TextDone()) { drawer - .xy(-18 - 5, -7-5) + .xy(-18 - 3, -7-5) .patch(patchCache["TUTDIAG2"]); if (Held()) @@ -490,7 +490,7 @@ void Dialogue::Draw(void) else intertext += ""; - drawer.xy(-18 + 4 - 5, -7-8 - 14).align(Draw::Align::kCenter).font(Draw::Font::kMenu).text(srb2::Draw::TextElement().parse(intertext).string()); + drawer.xy(-18, -7-8 - 14).align(Draw::Align::kCenter).font(Draw::Font::kMenu).text(srb2::Draw::TextElement().parse(intertext).string()); } } diff --git a/src/k_hud.cpp b/src/k_hud.cpp index 54f0ff13d..fc4948357 100644 --- a/src/k_hud.cpp +++ b/src/k_hud.cpp @@ -235,45 +235,49 @@ patch_t *kp_button_c[2][2]; patch_t *kp_button_x[2][2]; patch_t *kp_button_y[2][2]; patch_t *kp_button_z[2][2]; -patch_t *kp_button_start[2]; -patch_t *kp_button_l[2]; -patch_t *kp_button_r[2]; -patch_t *kp_button_up[2]; -patch_t *kp_button_down[2]; -patch_t *kp_button_right[2]; -patch_t *kp_button_left[2]; -patch_t *kp_button_lua1[2]; -patch_t *kp_button_lua2[2]; -patch_t *kp_button_lua3[2]; +patch_t *kp_button_start[2][2]; +patch_t *kp_button_l[2][2]; +patch_t *kp_button_r[2][2]; +patch_t *kp_button_up[2][2]; +patch_t *kp_button_down[2][2]; +patch_t *kp_button_right[2][2]; +patch_t *kp_button_left[2][2]; +patch_t *kp_button_lua1[2][2]; +patch_t *kp_button_lua2[2][2]; +patch_t *kp_button_lua3[2][2]; patch_t *gen_button_a[2][2]; patch_t *gen_button_b[2][2]; patch_t *gen_button_x[2][2]; patch_t *gen_button_y[2][2]; -patch_t *gen_button_lb[2]; -patch_t *gen_button_rb[2]; -patch_t *gen_button_lt[2]; -patch_t *gen_button_rt[2]; -patch_t *gen_button_start[2]; -patch_t *gen_button_back[2]; -patch_t *gen_button_ls[2]; -patch_t *gen_button_rs[2]; -patch_t *gen_button_dpad[2]; +patch_t *gen_button_lb[2][2]; +patch_t *gen_button_rb[2][2]; +patch_t *gen_button_lt[2][2]; +patch_t *gen_button_rt[2][2]; +patch_t *gen_button_start[2][2]; +patch_t *gen_button_back[2][2]; +patch_t *gen_button_ls[2][2]; +patch_t *gen_button_rs[2][2]; +patch_t *gen_button_dpad[2][2]; patch_t *gen_button_keyleft[2]; patch_t *gen_button_keyright[2]; patch_t *gen_button_keycenter[2]; -static void K_LoadButtonGraphics(patch_t *kp[2], int letter) +static void K_LoadButtonGraphics(patch_t *kp[2][2], const char* code) { - HU_UpdatePatch(&kp[0], "TLB_%c", letter); - HU_UpdatePatch(&kp[1], "TLB_%cB", letter); + HU_UpdatePatch(&kp[0][0], "TLB_%s", code); + HU_UpdatePatch(&kp[0][1], "TLB_%sB", code); + HU_UpdatePatch(&kp[1][0], "TLBS%s", code); + HU_UpdatePatch(&kp[1][1], "TLBS%sB", code); } -static void K_LoadGenericButtonGraphics(patch_t *kp[2], int letter) +static void K_LoadGenericButtonGraphics(patch_t *kp[2][2], const char* code) { - HU_UpdatePatch(&kp[0], "TLG_%c", letter); - HU_UpdatePatch(&kp[1], "TLG_%cB", letter); + HU_UpdatePatch(&kp[0][0], "TLG_%s", code); + HU_UpdatePatch(&kp[0][1], "TLG_%sB", code); + HU_UpdatePatch(&kp[1][0], "TLGS%s", code); + HU_UpdatePatch(&kp[1][1], "TLGS%sB", code); } void K_LoadKartHUDGraphics(void) @@ -968,58 +972,23 @@ void K_LoadKartHUDGraphics(void) HU_UpdatePatch(&kp_spraycantarget_near[1][i], "%s", buffer); } - K_LoadButtonGraphics(kp_button_a[0], 'A'); - K_LoadButtonGraphics(kp_button_a[1], 'N'); - K_LoadButtonGraphics(kp_button_b[0], 'B'); - K_LoadButtonGraphics(kp_button_b[1], 'O'); - K_LoadButtonGraphics(kp_button_c[0], 'C'); - K_LoadButtonGraphics(kp_button_c[1], 'P'); - K_LoadButtonGraphics(kp_button_x[0], 'D'); - K_LoadButtonGraphics(kp_button_x[1], 'Q'); - K_LoadButtonGraphics(kp_button_y[0], 'E'); - K_LoadButtonGraphics(kp_button_y[1], 'R'); - K_LoadButtonGraphics(kp_button_z[0], 'F'); - K_LoadButtonGraphics(kp_button_z[1], 'S'); - K_LoadButtonGraphics(kp_button_start, 'G'); - K_LoadButtonGraphics(kp_button_l, 'H'); - K_LoadButtonGraphics(kp_button_r, 'I'); - K_LoadButtonGraphics(kp_button_up, 'J'); - K_LoadButtonGraphics(kp_button_down, 'K'); - K_LoadButtonGraphics(kp_button_right, 'L'); - K_LoadButtonGraphics(kp_button_left, 'M'); - // K_LoadButtonGraphics(kp_button_dpad, 'T'); + K_LoadButtonGraphics(kp_button_a, "A"); + K_LoadButtonGraphics(kp_button_b, "B"); + K_LoadButtonGraphics(kp_button_c, "C"); + K_LoadButtonGraphics(kp_button_x, "X"); + K_LoadButtonGraphics(kp_button_y, "Y"); + K_LoadButtonGraphics(kp_button_z, "Z"); + K_LoadButtonGraphics(kp_button_l, "L1"); + K_LoadButtonGraphics(kp_button_r, "R1"); + K_LoadButtonGraphics(kp_button_up, "ARU"); + K_LoadButtonGraphics(kp_button_down, "ARD"); + K_LoadButtonGraphics(kp_button_right, "ARR"); + K_LoadButtonGraphics(kp_button_left, "ARL"); + K_LoadButtonGraphics(kp_button_start, "S"); - HU_UpdatePatch(&kp_button_lua1[0], "TLG_L1"); - HU_UpdatePatch(&kp_button_lua1[1], "TLG_L1B"); - HU_UpdatePatch(&kp_button_lua2[0], "TLG_L2"); - HU_UpdatePatch(&kp_button_lua2[1], "TLG_L2B"); - HU_UpdatePatch(&kp_button_lua3[0], "TLG_L3"); - HU_UpdatePatch(&kp_button_lua3[1], "TLG_L3B"); - - K_LoadGenericButtonGraphics(gen_button_a[0], 'A'); - K_LoadGenericButtonGraphics(gen_button_b[0], 'B'); - K_LoadGenericButtonGraphics(gen_button_x[0], 'D'); - K_LoadGenericButtonGraphics(gen_button_y[0], 'E'); - - K_LoadGenericButtonGraphics(gen_button_a[1], 'K'); - K_LoadGenericButtonGraphics(gen_button_b[1], 'M'); - K_LoadGenericButtonGraphics(gen_button_x[1], 'L'); - K_LoadGenericButtonGraphics(gen_button_y[1], 'J'); - - K_LoadGenericButtonGraphics(gen_button_lb, 'H'); - K_LoadGenericButtonGraphics(gen_button_rb, 'I'); - - K_LoadGenericButtonGraphics(gen_button_lt, 'C'); - K_LoadGenericButtonGraphics(gen_button_rt, 'F'); - - K_LoadGenericButtonGraphics(gen_button_start, 'G'); - K_LoadGenericButtonGraphics(gen_button_back, 'V'); // FIXME - - K_LoadGenericButtonGraphics(gen_button_ls, 'T'); - K_LoadGenericButtonGraphics(gen_button_rs, 'U'); - - HU_UpdatePatch(&gen_button_dpad[0], "TLB_T"); - HU_UpdatePatch(&gen_button_dpad[1], "TLB_TB"); + K_LoadGenericButtonGraphics(kp_button_lua1, "LU1"); + K_LoadGenericButtonGraphics(kp_button_lua2, "LU2"); + K_LoadGenericButtonGraphics(kp_button_lua3, "LU3"); HU_UpdatePatch(&gen_button_keyleft[0], "TLK_L"); HU_UpdatePatch(&gen_button_keyleft[1], "TLK_LB"); @@ -1027,6 +996,20 @@ void K_LoadKartHUDGraphics(void) HU_UpdatePatch(&gen_button_keyright[1], "TLK_RB"); HU_UpdatePatch(&gen_button_keycenter[0], "TLK_M"); HU_UpdatePatch(&gen_button_keycenter[1], "TLK_MB"); + + K_LoadGenericButtonGraphics(gen_button_dpad, "DP"); + K_LoadGenericButtonGraphics(gen_button_a, "A"); + K_LoadGenericButtonGraphics(gen_button_b, "B"); + K_LoadGenericButtonGraphics(gen_button_x, "X"); + K_LoadGenericButtonGraphics(gen_button_y, "Y"); + K_LoadGenericButtonGraphics(gen_button_lb, "L1"); + K_LoadGenericButtonGraphics(gen_button_rb, "R1"); + K_LoadGenericButtonGraphics(gen_button_lt, "L2"); + K_LoadGenericButtonGraphics(gen_button_rt, "R2"); + K_LoadGenericButtonGraphics(gen_button_ls, "L3"); + K_LoadGenericButtonGraphics(gen_button_rs, "R3"); + K_LoadGenericButtonGraphics(gen_button_start, "S"); + K_LoadGenericButtonGraphics(gen_button_back, "I"); } // For the item toggle menu @@ -6509,14 +6492,14 @@ void K_drawKartHUD(void) #if 0 using srb2::Draw; - if (0) + if (1) { - // Draw::TextElement text = Draw::TextElement().parse("A B C X Y Z \nST L R U D L R "); - Draw::TextElement text = Draw::TextElement().parse("Unpressed Pressed Animated "); + CV_StealthSetValue(cv_descriptiveinput, 0); + Draw::TextElement text = Draw::TextElement().parse("Hamburger Hamburger\n\nHamburger Hamburger\n\nHamburger \xEB\xEF\xA0\xEB\xEF\xA1\xEB\xEF\xA2\xEB\xEF\xA3\xEB\xEF\xA4\xEB\xEF\xA5\xEB\xEF\xA6\xEB\xEF\xA7\xEB\xEF\xA8\xEB\xEF\xA9\xEB\xEF\xAA\xEB\xEF\xAB\xEB\xEF\xAC Hamburger"); UINT8 fakeoff = (stplyr - players)*40; Draw(5, 5+fakeoff).align((srb2::Draw::Align)0).font(Draw::Font::kMenu).text(text); - Draw(5, 20+fakeoff).align((srb2::Draw::Align)0).font(Draw::Font::kThin).text(text); + Draw(40, 80+fakeoff).align((srb2::Draw::Align)0).font(Draw::Font::kThin).text(text); } if (0) diff --git a/src/k_hud.h b/src/k_hud.h index 5323a2f9d..acdfc916b 100644 --- a/src/k_hud.h +++ b/src/k_hud.h @@ -94,31 +94,34 @@ extern patch_t *kp_button_c[2][2]; extern patch_t *kp_button_x[2][2]; extern patch_t *kp_button_y[2][2]; extern patch_t *kp_button_z[2][2]; -extern patch_t *kp_button_start[2]; -extern patch_t *kp_button_l[2]; -extern patch_t *kp_button_r[2]; -extern patch_t *kp_button_up[2]; -extern patch_t *kp_button_down[2]; -extern patch_t *kp_button_right[2]; -extern patch_t *kp_button_left[2]; -// extern patch_t *kp_button_dpad[2]; -extern patch_t *kp_button_lua1[2]; -extern patch_t *kp_button_lua2[2]; -extern patch_t *kp_button_lua3[2]; +extern patch_t *kp_button_start[2][2]; +extern patch_t *kp_button_l[2][2]; +extern patch_t *kp_button_r[2][2]; +extern patch_t *kp_button_up[2][2]; +extern patch_t *kp_button_down[2][2]; +extern patch_t *kp_button_right[2][2]; +extern patch_t *kp_button_left[2][2]; +extern patch_t *kp_button_lua1[2][2]; +extern patch_t *kp_button_lua2[2][2]; +extern patch_t *kp_button_lua3[2][2]; extern patch_t *gen_button_a[2][2]; extern patch_t *gen_button_b[2][2]; extern patch_t *gen_button_x[2][2]; extern patch_t *gen_button_y[2][2]; -extern patch_t *gen_button_lb[2]; -extern patch_t *gen_button_rb[2]; -extern patch_t *gen_button_lt[2]; -extern patch_t *gen_button_rt[2]; -extern patch_t *gen_button_start[2]; -extern patch_t *gen_button_back[2]; -extern patch_t *gen_button_ls[2]; -extern patch_t *gen_button_rs[2]; -extern patch_t *gen_button_dpad[2]; +extern patch_t *gen_button_lb[2][2]; +extern patch_t *gen_button_rb[2][2]; +extern patch_t *gen_button_lt[2][2]; +extern patch_t *gen_button_rt[2][2]; +extern patch_t *gen_button_start[2][2]; +extern patch_t *gen_button_back[2][2]; +extern patch_t *gen_button_ls[2][2]; +extern patch_t *gen_button_rs[2][2]; +extern patch_t *gen_button_dpad[2][2]; + +extern patch_t *gen_button_keyleft[2]; +extern patch_t *gen_button_keyright[2]; +extern patch_t *gen_button_keycenter[2]; extern patch_t *gen_button_keyleft[2]; extern patch_t *gen_button_keyright[2]; diff --git a/src/k_menudraw.c b/src/k_menudraw.c index e8a2d7d2c..276303595 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -6106,7 +6106,7 @@ void M_DrawPause(void) K_DrawGameControl(4, 184 - 45 + offset/2, 0, " Accelerate", 0, 0, 0); K_DrawGameControl(4, 184 - 30 + offset/2, 0, " Look Back", 0, 0, 0); K_DrawGameControl(4, 184 - 15 + offset/2, 0, " Spindash", 0, 0, 0); - K_DrawGameControl(4, 184 - 0 + offset/2, 0, " Item", 0, 0, 0); + K_DrawGameControl(4, 184 - 0 + offset/2, 0, " Item/Rings", 0, 0, 0); K_DrawGameControl(90, 184 - 45 + offset/2, 0, " Brake", 0, 0, 0); K_DrawGameControl(90, 184 - 30 + offset/2, 0, " Respawn", 0, 0, 0); diff --git a/src/r_main.h b/src/r_main.h index 31448b308..ccb534213 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -138,6 +138,7 @@ extern consvar_t cv_drawpickups; extern consvar_t cv_debugfinishline; extern consvar_t cv_drawinput; extern consvar_t cv_drawtimer; +extern consvar_t cv_debugfonts; // debugging diff --git a/src/v_draw.cpp b/src/v_draw.cpp index ef8b2fe4b..ae813d3f9 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -390,16 +390,16 @@ patch_t** get_button_patch(Draw::Button type, int ver) X(x)[ver]; X(y)[ver]; X(z)[ver]; - X(start); - X(l); - X(r); - X(up); - X(down); - X(right); - X(left); - X(lua1); - X(lua2); - X(lua3); + X(start)[ver]; + X(l)[ver]; + X(r)[ver]; + X(up)[ver]; + X(down)[ver]; + X(right)[ver]; + X(left)[ver]; + X(lua1)[ver]; + X(lua2)[ver]; + X(lua3)[ver]; #undef X } @@ -435,15 +435,15 @@ patch_t** get_button_patch(Draw::GenericButton type, int ver) X(b)[ver]; X(x)[ver]; X(y)[ver]; - X(lb); - X(rb); - X(lt); - X(rt); - X(start); - X(back); - X(ls); - X(rs); - X(dpad); + X(lb)[ver]; + X(rb)[ver]; + X(lt)[ver]; + X(rt)[ver]; + X(start)[ver]; + X(back)[ver]; + X(ls)[ver]; + X(rs)[ver]; + X(dpad)[ver]; #undef X } diff --git a/src/v_video.cpp b/src/v_video.cpp index d4edf89e8..793fbe71e 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -2496,40 +2496,39 @@ static void V_GetFontSpecification(int fontno, INT32 flags, fontspec_t *result) static UINT8 V_GetButtonCodeWidth(UINT8 c, boolean largebutton) { - UINT8 x = 0; + UINT8 x = 14; switch (c & 0x0F) { - case 0x00: - case 0x01: - case 0x02: - case 0x03: - // arrows - x = 12; + case sb_up: + case sb_down: + case sb_left: + case sb_right: + x -= largebutton ? 2 : 4; break; - case 0x07: - case 0x08: - case 0x09: - // shoulders, start - x = 14; + case sb_l: + case sb_r: + x -= largebutton ? 1 : 4; break; - case 0x04: - case 0x05: - case 0x06: - // lua - x = 16; + case sb_start: + x -= largebutton ? 0 : 4; break; - case 0x0A: - case 0x0B: - case 0x0C: - case 0x0D: - case 0x0E: - case 0x0F: - // faces - x = largebutton ? 13 : 10; + case sb_lua1: + case sb_lua2: + case sb_lua3: + x -= largebutton ? 0 : 4; + break; + + case sb_a: + case sb_b: + case sb_c: + case sb_x: + case sb_y: + case sb_z: + x -= largebutton ? 0 : 4; break; } @@ -2538,45 +2537,42 @@ static UINT8 V_GetButtonCodeWidth(UINT8 c, boolean largebutton) static UINT8 V_GetGenericButtonCodeWidth(UINT8 c, boolean largebutton) { - UINT8 x = 0; + UINT8 x = 16; - switch (c & 0x0F) + switch ((c & 0x0F) | gb_mask) { - case 0x00: - case 0x01: - case 0x02: - case 0x03: - // buttons - x = largebutton ? 17 : 14; + case gb_a: + case gb_b: + case gb_x: + case gb_y: + x -= largebutton ? 0 : 2; break; - case 0x04: - case 0x05: - // bumpers - x = 14; + case gb_lb: + case gb_rb: + x -= largebutton ? 2 : 6; break; - case 0x06: - case 0x07: - // triggers - x = 14; + case gb_lt: + case gb_rt: + x -= largebutton ? 2 : 6; break; - case 0x08: - case 0x09: - // nav - x = 14; + case gb_start: + x -= largebutton ? 2 : 6; break; - case 0x0A: - case 0x0B: - // stick click - x = 18; + case gb_back: + x -= largebutton ? 2 : 6; break; - case 0x0C: - // dpad - x = 14; + case gb_ls: + case gb_rs: + x -= largebutton ? 1 : 4; + break; + + case gb_dpad: + x -= largebutton ? 2 : 5; break; } @@ -2609,6 +2605,10 @@ void V_DrawStringScaled( int boxed = 0; boolean descriptive = false; + boolean debugalternation = false; + UINT8 debugcolor1 = 181; + UINT8 debugcolor2 = 96; + boolean dance; boolean nodanceoverride; INT32 dancecounter; @@ -2835,32 +2835,65 @@ void V_DrawStringScaled( { switch (c & 0x0F) { - case sb_up: return {{0, 3, Draw::Button::up}}; - case sb_down: return {{0, 3, Draw::Button::down}}; - case sb_right: return {{0, 3, Draw::Button::right}}; - case sb_left: return {{0, 3, Draw::Button::left}}; + case sb_up: return {{2, 2, Draw::Button::up}}; + case sb_down: return {{2, 2, Draw::Button::down}}; + case sb_right: return {{2, 2, Draw::Button::right}}; + case sb_left: return {{2, 2, Draw::Button::left}}; - case sb_lua1: return {{0, 4, Draw::Button::lua1}}; - case sb_lua2: return {{0, 4, Draw::Button::lua2}}; - case sb_lua3: return {{0, 4, Draw::Button::lua3}}; + case sb_lua1: return {{2, 2, Draw::Button::lua1}}; + case sb_lua2: return {{2, 2, Draw::Button::lua2}}; + case sb_lua3: return {{2, 2, Draw::Button::lua3}}; - case sb_r: return {{0, 2, Draw::Button::r}}; - case sb_l: return {{0, 2, Draw::Button::l}}; + case sb_r: return {{2, 2, Draw::Button::r}}; + case sb_l: return {{2, 2, Draw::Button::l}}; - case sb_start: return {{0, 1, Draw::Button::start}}; + case sb_start: return {{2, 2, Draw::Button::start}}; - case sb_a: return {{2, 1, Draw::Button::a}}; - case sb_b: return {{2, 1, Draw::Button::b}}; - case sb_c: return {{2, 1, Draw::Button::c}}; + case sb_a: return {{2, 2, Draw::Button::a}}; + case sb_b: return {{2, 2, Draw::Button::b}}; + case sb_c: return {{2, 2, Draw::Button::c}}; - case sb_x: return {{2, 1, Draw::Button::x}}; - case sb_y: return {{2, 1, Draw::Button::y}}; - case sb_z: return {{2, 1, Draw::Button::z}}; + case sb_x: return {{2, 2, Draw::Button::x}}; + case sb_y: return {{2, 2, Draw::Button::y}}; + case sb_z: return {{2, 2, Draw::Button::z}}; default: return {}; } }(); + if (largebutton) + { + bt_inst = [c]() -> std::optional + { + switch (c & 0x0F) + { + case sb_up: return {{2, 4, Draw::Button::up}}; + case sb_down: return {{2, 4, Draw::Button::down}}; + case sb_right: return {{2, 4, Draw::Button::right}}; + case sb_left: return {{2, 4, Draw::Button::left}}; + + case sb_lua1: return {{1, 4, Draw::Button::lua1}}; + case sb_lua2: return {{1, 4, Draw::Button::lua2}}; + case sb_lua3: return {{1, 4, Draw::Button::lua3}}; + + case sb_r: return {{1, 4, Draw::Button::r}}; + case sb_l: return {{1, 4, Draw::Button::l}}; + + case sb_start: return {{1, 4, Draw::Button::start}}; + + case sb_a: return {{1, 4, Draw::Button::a}}; + case sb_b: return {{1, 4, Draw::Button::b}}; + case sb_c: return {{1, 4, Draw::Button::c}}; + + case sb_x: return {{1, 4, Draw::Button::x}}; + case sb_y: return {{1, 4, Draw::Button::y}}; + case sb_z: return {{1, 4, Draw::Button::z}}; + + default: return {}; + } + }(); + } + if (bt_inst) { auto bt_translate_press = [c]() -> std::optional @@ -2878,6 +2911,12 @@ void V_DrawStringScaled( cxoff = (*fontspec.dim_fn)(scale, fontspec.chw, hchw, dupx, &cw); + if (cv_debugfonts.value) + { + V_DrawFill(cx/FRACUNIT, cy/FRACUNIT, cw/FRACUNIT, fontspec.lfh/FRACUNIT, debugalternation ? debugcolor1 : debugcolor2); + debugalternation = !debugalternation; + } + Draw bt = Draw( FixedToFloat(cx + cxoff) - (bt_inst->x * dupx), FixedToFloat(cy + cyoff) - ((bt_inst->y + fontspec.button_yofs) * dupy)) @@ -2908,23 +2947,47 @@ void V_DrawStringScaled( { switch ((c & 0x0F) | gb_mask) { - case gb_a: return {{0, 2, Draw::GenericButton::a}}; - case gb_b: return {{0, 2, Draw::GenericButton::b}}; - case gb_x: return {{0, 2, Draw::GenericButton::x}}; - case gb_y: return {{0, 2, Draw::GenericButton::y}}; - case gb_lb: return {{1, 3, Draw::GenericButton::lb}}; - case gb_rb: return {{1, 3, Draw::GenericButton::rb}}; - case gb_lt: return {{1, 4, Draw::GenericButton::lt}}; - case gb_rt: return {{1, 4, Draw::GenericButton::rt}}; - case gb_start: return {{1, 6, Draw::GenericButton::start}}; - case gb_back: return {{1, 6, Draw::GenericButton::back}}; - case gb_ls: return {{0, 5, Draw::GenericButton::ls}}; - case gb_rs: return {{0, 5, Draw::GenericButton::rs}}; - case gb_dpad: return {{0, 4, Draw::GenericButton::dpad}}; + case gb_a: return {{0, 1, Draw::GenericButton::a}}; + case gb_b: return {{0, 1, Draw::GenericButton::b}}; + case gb_x: return {{0, 1, Draw::GenericButton::x}}; + case gb_y: return {{0, 1, Draw::GenericButton::y}}; + case gb_lb: return {{2, 2, Draw::GenericButton::lb}}; + case gb_rb: return {{2, 2, Draw::GenericButton::rb}}; + case gb_lt: return {{2, 2, Draw::GenericButton::lt}}; + case gb_rt: return {{2, 2, Draw::GenericButton::rt}}; + case gb_start: return {{2, 2, Draw::GenericButton::start}}; + case gb_back: return {{2, 2, Draw::GenericButton::back}}; + case gb_ls: return {{1, 2, Draw::GenericButton::ls}}; + case gb_rs: return {{1, 2, Draw::GenericButton::rs}}; + case gb_dpad: return {{2, 2, Draw::GenericButton::dpad}}; default: return {}; } }(); + if (largebutton) + { + bt_inst = [c]() -> std::optional + { + switch ((c & 0x0F) | gb_mask) + { + case gb_a: return {{0, 3, Draw::GenericButton::a}}; + case gb_b: return {{0, 3, Draw::GenericButton::b}}; + case gb_x: return {{0, 3, Draw::GenericButton::x}}; + case gb_y: return {{0, 3, Draw::GenericButton::y}}; + case gb_lb: return {{1, 3, Draw::GenericButton::lb}}; + case gb_rb: return {{1, 3, Draw::GenericButton::rb}}; + case gb_lt: return {{1, 4, Draw::GenericButton::lt}}; + case gb_rt: return {{1, 4, Draw::GenericButton::rt}}; + case gb_start: return {{1, 6, Draw::GenericButton::start}}; + case gb_back: return {{1, 6, Draw::GenericButton::back}}; + case gb_ls: return {{1, 5, Draw::GenericButton::ls}}; + case gb_rs: return {{1, 5, Draw::GenericButton::rs}}; + case gb_dpad: return {{1, 4, Draw::GenericButton::dpad}}; + default: return {}; + } + }(); + } + if (bt_inst) { auto bt_translate_press = [c]() -> std::optional @@ -2942,6 +3005,12 @@ void V_DrawStringScaled( cxoff = (*fontspec.dim_fn)(scale, fontspec.chw, hchw, dupx, &cw); + if (cv_debugfonts.value) + { + V_DrawFill(cx/FRACUNIT, cy/FRACUNIT, cw/FRACUNIT, fontspec.lfh/FRACUNIT, debugalternation ? debugcolor1 : debugcolor2); + debugalternation = !debugalternation; + } + Draw bt = Draw( FixedToFloat(cx + cxoff) - (bt_inst->x * dupx), FixedToFloat(cy + cyoff) - ((bt_inst->y + fontspec.button_yofs) * dupy)) @@ -2969,6 +3038,12 @@ void V_DrawStringScaled( cw = SHORT (font->font[c]->width) * dupx; cxoff = (*fontspec.dim_fn)(scale, fontspec.chw, hchw, dupx, &cw); + if (cv_debugfonts.value) + { + V_DrawFill(cx/FRACUNIT, cy/FRACUNIT, cw/FRACUNIT, fontspec.lfh/FRACUNIT, debugalternation ? debugcolor1 : debugcolor2); + debugalternation = !debugalternation; + } + if (boxed != 1) { V_DrawFixedPatch(cx + cxoff + patchxofs, cy + cyoff + (boxed == 3 ? 2*FRACUNIT : 0), scale, @@ -3063,6 +3138,7 @@ fixed_t V_StringScaledWidth( case '\xEB': if (fontno != TINY_FONT && fontno != HU_FONT) largebutton = true; + break; case '\xEF': descriptive = true; break; From 7a9793f20257543efff54dd9bd439eff46e6fa8d Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Fri, 27 Sep 2024 03:19:45 -0700 Subject: [PATCH 43/56] Fix profile control menu youfuckedups --- src/menus/options-profiles-edit-controls.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/menus/options-profiles-edit-controls.c b/src/menus/options-profiles-edit-controls.c index ffbccfb8e..1cfa086cf 100644 --- a/src/menus/options-profiles-edit-controls.c +++ b/src/menus/options-profiles-edit-controls.c @@ -37,34 +37,34 @@ menuitem_t OPTIONS_ProfileControls[] = { "TLB_C", {.routine = M_ProfileSetControl}, gc_c, 0}, {IT_CONTROL, "Brake / Go back", "Brake / Go back", - "TLB_D", {.routine = M_ProfileSetControl}, gc_x, 0}, + "TLB_X", {.routine = M_ProfileSetControl}, gc_x, 0}, {IT_CONTROL, "Respawn", "Respawn", - "TLB_E", {.routine = M_ProfileSetControl}, gc_y, 0}, + "TLB_Y", {.routine = M_ProfileSetControl}, gc_y, 0}, {IT_CONTROL, "Action", "Multiplayer quick-chat / quick-vote", - "TLB_F", {.routine = M_ProfileSetControl}, gc_z, 0}, + "TLB_Z", {.routine = M_ProfileSetControl}, gc_z, 0}, {IT_CONTROL, "Use Item", "Use item", - "TLB_H", {.routine = M_ProfileSetControl}, gc_l, 0}, + "TLB_L1", {.routine = M_ProfileSetControl}, gc_l, 0}, {IT_CONTROL, "Drift", "Drift", - "TLB_I", {.routine = M_ProfileSetControl}, gc_r, 0}, + "TLB_R1", {.routine = M_ProfileSetControl}, gc_r, 0}, {IT_CONTROL, "Turn Left", "Turn left", - "TLB_M", {.routine = M_ProfileSetControl}, gc_left, 0}, + "TLB_ARL", {.routine = M_ProfileSetControl}, gc_left, 0}, {IT_CONTROL, "Turn Right", "Turn right", - "TLB_L", {.routine = M_ProfileSetControl}, gc_right, 0}, + "TLB_ARR", {.routine = M_ProfileSetControl}, gc_right, 0}, {IT_CONTROL, "Aim Forward", "Aim forwards", - "TLB_J", {.routine = M_ProfileSetControl}, gc_up, 0}, + "TLB_ARU", {.routine = M_ProfileSetControl}, gc_up, 0}, {IT_CONTROL, "Aim Backwards", "Aim backwards", - "TLB_K", {.routine = M_ProfileSetControl}, gc_down, 0}, + "TLB_ARD", {.routine = M_ProfileSetControl}, gc_down, 0}, {IT_CONTROL, "Open pause menu", "Open pause menu", - "TLB_G", {.routine = M_ProfileSetControl}, gc_start, 0}, + "TLB_S", {.routine = M_ProfileSetControl}, gc_start, 0}, {IT_HEADER, "OPTIONAL CONTROLS", "Take a screenshot, chat...", NULL, {NULL}, 0, 0}, From 92c2f5d5a5270c95c566edbcd48322abdcc5eb77 Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Fri, 27 Sep 2024 03:22:20 -0700 Subject: [PATCH 44/56] Unused warning --- src/k_menudraw.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/k_menudraw.c b/src/k_menudraw.c index 276303595..794858355 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -4978,6 +4978,8 @@ static void M_DrawBindMediumString(INT32 y, INT32 flags, const char *string) ); } +// largely replaced by K_DrawGameControl +/* static INT32 M_DrawProfileLegend(INT32 x, INT32 y, const char *legend, const char *mediocre_key) { INT32 w = V_ThinStringWidth(legend, 0); @@ -4987,6 +4989,7 @@ static INT32 M_DrawProfileLegend(INT32 x, INT32 y, const char *legend, const cha M_DrawMediocreKeyboardKey(mediocre_key, &x, y, false, true); return x; } +*/ // the control stuff. // Dear god. From a51ec952375e859665ec834213e653f5729d22ad Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Fri, 27 Sep 2024 03:28:12 -0700 Subject: [PATCH 45/56] Fix extra debug print in patch allocation --- src/hu_stuff.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index a01bf99d6..c866184b4 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -385,8 +385,6 @@ patch_t *HU_UpdateOrBlankPatch(patch_t **user, boolean required, const char *for vsnprintf(buffer, sizeof buffer, format, ap); va_end (ap); - CONS_Printf("%s\n", buffer); - if (user && partadd_earliestfile != UINT16_MAX) { UINT16 fileref = numwadfiles; From f12f69559bc345613a19f437fd23ab4f4e15647d Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Fri, 27 Sep 2024 03:30:52 -0700 Subject: [PATCH 46/56] Unused warning TWO --- src/k_menudraw.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/k_menudraw.c b/src/k_menudraw.c index 794858355..acfc86168 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -755,6 +755,8 @@ static void M_DrawMenuTyping(void) } +// Largely replaced by boxed drawing mode in K_DrawGameControl and rich text +/* static void M_DrawMediocreKeyboardKey(const char *text, INT32 *workx, INT32 worky, boolean push, boolean rightaligned) { INT32 buttonwidth = V_StringWidth(text, 0) + 2; @@ -779,6 +781,7 @@ static void M_DrawMediocreKeyboardKey(const char *text, INT32 *workx, INT32 work 0, text ); } +*/ // Draw the message popup submenu void M_DrawMenuMessage(void) From 00e97a4387d5daf0e46e2239f343623c99fc6c3e Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Fri, 27 Sep 2024 04:19:34 -0700 Subject: [PATCH 47/56] fix Top, FPZ help text --- src/k_hud_track.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/k_hud_track.cpp b/src/k_hud_track.cpp index f4bacdd09..5e4be21cd 100644 --- a/src/k_hud_track.cpp +++ b/src/k_hud_track.cpp @@ -433,13 +433,18 @@ std::optional object_tooltip(const mobj_t* mobj) case MT_GARDENTOP: return conditional( mobj->tracer == stplyr->mo && Obj_GardenTopPlayerNeedsHelp(mobj), - [&] { return TextElement("Try \xA7!").font(splitfont); } + [&] { return TextElement().parse("Try !").font(splitfont); } ); case MT_PLAYER: return conditional( mobj->player == stplyr && stplyr->icecube.frozen, - [&] { return Tooltip(TextElement("\xA7")).offset3d(0, 0, 64 * mobj->scale * P_MobjFlip(mobj)); } + [&] { return Tooltip(TextElement( + (leveltime/(TICRATE/2)%2) ? + TextElement().parse("").font(Draw::Font::kMenu) : + TextElement().parse("").font(Draw::Font::kMenu) + )).offset3d(0, 0, 64 * mobj->scale * P_MobjFlip(mobj)); } + // I will be trying to figure out why the return value didn't accept a straightforward call to parse() for the rest of my life (apprx. 15 seconds) ); default: From d7eebe10168744da6f7bdafbef096338172e927c Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Fri, 27 Sep 2024 04:20:44 -0700 Subject: [PATCH 48/56] Use splitfont for FPZ help text --- src/k_hud_track.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/k_hud_track.cpp b/src/k_hud_track.cpp index 5e4be21cd..06cc0ad5b 100644 --- a/src/k_hud_track.cpp +++ b/src/k_hud_track.cpp @@ -441,8 +441,8 @@ std::optional object_tooltip(const mobj_t* mobj) mobj->player == stplyr && stplyr->icecube.frozen, [&] { return Tooltip(TextElement( (leveltime/(TICRATE/2)%2) ? - TextElement().parse("").font(Draw::Font::kMenu) : - TextElement().parse("").font(Draw::Font::kMenu) + TextElement().parse("").font(splitfont) : + TextElement().parse("").font(splitfont) )).offset3d(0, 0, 64 * mobj->scale * P_MobjFlip(mobj)); } // I will be trying to figure out why the return value didn't accept a straightforward call to parse() for the rest of my life (apprx. 15 seconds) ); From 555e4eaa4c3a877b46611562a7ff4bd27b4f0fe5 Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Fri, 27 Sep 2024 04:44:59 -0700 Subject: [PATCH 49/56] Final raw button literal fixups?! --- src/d_clisrv.c | 11 ++++++----- src/k_kart.c | 2 +- src/k_menudraw.c | 2 +- src/menus/transient/pause-addonoptions.cpp | 2 +- src/st_stuff.c | 8 ++++---- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index b03224472..870b2cc1a 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -75,6 +75,7 @@ // cl loading screen #include "v_video.h" #include "f_finale.h" +#include "k_hud.h" #ifdef HAVE_DISCORDRPC #include "discord.h" @@ -685,7 +686,7 @@ static inline void CL_DrawConnectionStatus(void) // Draw bottom box M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-24-8, 32, 1); - V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-24, V_YELLOWMAP, "Press \xAB or \xAD to abort"); + K_DrawGameControl(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-24, 0, "Press or to abort", 1, 2, V_YELLOWMAP); for (i = 0; i < 16; ++i) V_DrawFill((BASEVIDWIDTH/2-128) + (i * 16), BASEVIDHEIGHT-24, 16, 8, palstart + ((animtime - i) & 15)); @@ -758,7 +759,7 @@ static inline void CL_DrawConnectionStatus(void) INT32 checkednum = 0; INT32 i; - V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-24, V_YELLOWMAP, "Press \xAB or \xAD to abort"); + K_DrawGameControl(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-24, 0, "Press or to abort", 1, 2, V_YELLOWMAP); //ima just count files here for (i = 0; i < fileneedednum; i++) @@ -780,7 +781,7 @@ static inline void CL_DrawConnectionStatus(void) INT32 loadcompletednum = 0; INT32 i; - V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-24, V_YELLOWMAP, "Press \xAB or \xAD to abort"); + K_DrawGameControl(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-24, 0, "Press or to abort", 1, 2, V_YELLOWMAP); //ima just count files here for (i = 0; i < fileneedednum; i++) @@ -807,7 +808,7 @@ static inline void CL_DrawConnectionStatus(void) // Draw the bottom box. M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-58-8, 32, 1); - V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-58-14, V_YELLOWMAP, "Press \xAB or \xAD to abort"); + K_DrawGameControl(BASEVIDWIDTH/2, BASEVIDHEIGHT-58-14, 0, "Press or to abort", 1, 2, V_YELLOWMAP); Net_GetNetStat(); dldlength = (INT32)((file->currentsize/(double)file->totalsize) * 256); @@ -873,7 +874,7 @@ static inline void CL_DrawConnectionStatus(void) //Draw bottom box M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-24-8, 32, 1); - V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-24, V_YELLOWMAP, "Press \xAB or \xAD to abort"); + K_DrawGameControl(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-24, 0, "Press or to abort", 1, 2, V_YELLOWMAP); for (i = 0; i < 16; ++i) V_DrawFill((BASEVIDWIDTH/2-128) + (i * 16), BASEVIDHEIGHT-24, 16, 8, palstart + ((animtime - i) & 15)); diff --git a/src/k_kart.c b/src/k_kart.c index f0dc9d530..8de6f538e 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -9502,7 +9502,7 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) if (!player->bigwaypointgap) K_DoIngameRespawn(player); else if (player->bigwaypointgap == AUTORESPAWN_THRESHOLD) - K_AddMessageForPlayer(player, "Press \xAE to respawn", true, false); + K_AddMessageForPlayer(player, "Press to respawn", true, false); } if (player->tripwireUnstuck && !player->mo->hitlag) diff --git a/src/k_menudraw.c b/src/k_menudraw.c index acfc86168..82710d282 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -1240,7 +1240,7 @@ static INT32 M_DrawRejoinIP(INT32 x, INT32 y, INT32 tx) V_DrawMenuString(x - 10 - (skullAnimCounter/5), y, f, "\x1C"); // left arrow V_DrawMenuString(x + w + 2+ (skullAnimCounter/5), y, f, "\x1D"); // right arrow V_DrawThinString(x, y, f, text); - V_DrawRightAlignedThinString(BASEVIDWIDTH + 4 + tx, y, V_ORANGEMAP, "\xAC Rejoin"); + K_DrawGameControl(BASEVIDWIDTH + 4 + tx, y, 0, " Rejoin", 2, 0, V_ORANGEMAP); return shift; } diff --git a/src/menus/transient/pause-addonoptions.cpp b/src/menus/transient/pause-addonoptions.cpp index 9d733cc4f..a7db2ccfe 100644 --- a/src/menus/transient/pause-addonoptions.cpp +++ b/src/menus/transient/pause-addonoptions.cpp @@ -146,7 +146,7 @@ void list_commands() if (flags & COM_NOSHOWHELP) continue; - g_menu.push_back(menuitem_t {IT_STRING | IT_CALL, cmd->name, "Press \xAA to execute this command", nullptr, {.routine = call}, 0, 8}); + g_menu.push_back(menuitem_t {IT_STRING | IT_CALL, cmd->name, "No information available for commands. Press to execute.", nullptr, {.routine = call}, 0, 8}); } } diff --git a/src/st_stuff.c b/src/st_stuff.c index aac564183..5531316cd 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -1498,10 +1498,10 @@ void ST_DrawServerSplash(boolean timelimited) void ST_DrawSaveReplayHint(INT32 flags) { - V_DrawRightAlignedThinString( - BASEVIDWIDTH - 2, 2, - flags|V_YELLOWMAP, - (demo.willsave && demo.titlename[0]) ? "Replay will be saved. \xAB Change title" : "\xAB or \xAD Save replay" + K_DrawGameControl( + BASEVIDWIDTH - 2, 2, 0, + (demo.willsave && demo.titlename[0]) ? "Replay will be saved. Change title" : " or Save replay", + 2, 0, flags|V_YELLOWMAP ); } From b1bd711d5e85cd58e8b7af4a1c4699e7cdb99731 Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Fri, 27 Sep 2024 05:29:47 -0700 Subject: [PATCH 50/56] Really definitely final button literal unfuck --- src/menus/options-sound.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/menus/options-sound.cpp b/src/menus/options-sound.cpp index fd7b1b701..9efc666e4 100644 --- a/src/menus/options-sound.cpp +++ b/src/menus/options-sound.cpp @@ -70,7 +70,8 @@ struct Slider if (!basic_options()) { - h.xy(kWidth + 9, -3).small_button(Draw::Button::z, false); + Draw::TextElement tx = Draw::TextElement().parse(""); + h.xy(kWidth + 9, -2).text(tx.string()); } } From dfd15ca8a2b9ef5276e990001f0dcca470164496 Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Fri, 27 Sep 2024 05:29:57 -0700 Subject: [PATCH 51/56] Real definitely final button unfuck TWO --- src/menus/options-sound.cpp | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/menus/options-sound.cpp b/src/menus/options-sound.cpp index 9efc666e4..e2ad9341b 100644 --- a/src/menus/options-sound.cpp +++ b/src/menus/options-sound.cpp @@ -29,12 +29,6 @@ using srb2::Draw; namespace { -bool basic_options() -{ - // M_GameTrulyStarted - return gamedata && gamestartchallenge < MAXUNLOCKABLES && !netgame && gamedata->gonerlevel <= GDGONER_PROFILE; -} - int flip_delay = 0; struct Slider @@ -68,11 +62,8 @@ struct Slider arrows.x(-10 - ofs).text("\x1C"); arrows.x(kWidth + 2 + ofs).text("\x1D"); - if (!basic_options()) - { - Draw::TextElement tx = Draw::TextElement().parse(""); - h.xy(kWidth + 9, -2).text(tx.string()); - } + Draw::TextElement tx = Draw::TextElement().parse(""); + h.xy(kWidth + 9, -2).text(tx.string()); } h = h.y(1); @@ -252,7 +243,7 @@ boolean input_routine(INT32) const menuitem_t& it = currentMenu->menuitems[itemOn]; - if (M_MenuButtonPressed(pid, MBT_Z) && (it.status & IT_TYPE) == IT_ARROWS && !basic_options()) + if (M_MenuButtonPressed(pid, MBT_Z) && (it.status & IT_TYPE) == IT_ARROWS) { sliders.at(it.mvar2).toggle_(true); return true; From 7161de29fd859b6678fa3854dccf905c6be95aa3 Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Fri, 27 Sep 2024 06:44:00 -0700 Subject: [PATCH 52/56] Migrate old profiles, set descriptiveinput Modern --- src/k_profiles.cpp | 6 ++++++ src/k_profiles.h | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/k_profiles.cpp b/src/k_profiles.cpp index 7e07f3c9e..e0f35b159 100644 --- a/src/k_profiles.cpp +++ b/src/k_profiles.cpp @@ -545,6 +545,12 @@ void PR_LoadProfiles(void) converted = true; } + if (jsprof.version < 4) + { + newprof->descriptiveinput = 1; + converted = true; + } + if (converted) { CONS_Printf("Profile '%s' was converted from version %d to version %d\n", diff --git a/src/k_profiles.h b/src/k_profiles.h index fea61ebf8..0a2874dd4 100644 --- a/src/k_profiles.h +++ b/src/k_profiles.h @@ -118,7 +118,8 @@ extern "C" { // 2 - litesteer is off by default, old profiles litesteer // 3 - auto roulette is switched off again // option is reset to default -#define PROFILEVER 3 +// 4 - Descriptive Input - set everyone to Modern! +#define PROFILEVER 4 #define MAXPROFILES 16 #define PROFILESFILE "ringprofiles.prf" #define PROFILE_GUEST 0 From c2f56050c36398a930c934a1ec7b50f071ce49de Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Fri, 27 Sep 2024 15:24:54 -0700 Subject: [PATCH 53/56] Descriptive spectator controls --- src/hud/spectator.cpp | 46 +++++++++++-------------------------------- 1 file changed, 11 insertions(+), 35 deletions(-) diff --git a/src/hud/spectator.cpp b/src/hud/spectator.cpp index 194f41785..1f7568a5c 100644 --- a/src/hud/spectator.cpp +++ b/src/hud/spectator.cpp @@ -39,10 +39,9 @@ struct List { struct Field { - Field(const char* label, Draw::Button button, std::optional pressed = {}) : + Field(const char* label, const char* button = {}) : label_(Draw::TextElement(label).font(Draw::Font::kThin)), - button_(button), - pressed_(pressed) + btlabel_(Draw::TextElement().parse(button).font(Draw::Font::kThin)) { } @@ -55,29 +54,7 @@ struct List col.text(label_); col = col.x(left ? -(kButtonWidth + kButtonMargin) : width() - (kButtonWidth + kFieldSpacing)); - //if (r_splitscreen) - { - auto small_button_offset = [&] - { - switch (button_) - { - case Draw::Button::l: - case Draw::Button::r: - return -4; - - default: - return -2; - } - }; - - col.y(small_button_offset()).small_button(button_, pressed_); - } -#if 0 - else - { - col.y(-4).button(button_, pressed_); - } -#endif + col.text(btlabel_); } private: @@ -86,8 +63,7 @@ struct List static constexpr int kFieldSpacing = 8; Draw::TextElement label_; - Draw::Button button_; - std::optional pressed_; + Draw::TextElement btlabel_; }; List(int x, int y) : row_(split_draw(x, y, left_)) {} @@ -209,7 +185,7 @@ void K_drawSpectatorHUD(boolean director) label += fmt::format(" [{}/{}]", numingame, cv_maxplayers.value); } - list.insert({{label.c_str(), Draw::Button::l}}); + list.insert({{label.c_str(), ""}}); } if (director || camera[viewnum].freecam) @@ -217,14 +193,14 @@ void K_drawSpectatorHUD(boolean director) // Not locked into freecam -- can toggle it. if (director) { - list.insert({{"Freecam", Draw::Button::c}}); + list.insert({{"Freecam", ""}}); } else { bool press = D_LocalTiccmd(viewnum)->buttons & BT_RESPAWN; const char* label = (press && I_GetTime() % 16 < 8) ? "> <" : ">< "; - list.insert({{label, Draw::Button::y, press}, {"Exit", Draw::Button::c}}); + list.insert({{label, press ? "" : ""}, {"Exit", ""}}); } } @@ -232,19 +208,19 @@ void K_drawSpectatorHUD(boolean director) { if (numingame > 1) { - list.insert({{"+", Draw::Button::a}, {"-", Draw::Button::x}}); + list.insert({{"+", ""}, {"-", ""}}); } if (player) { - list.insert({{K_DirectorIsEnabled(viewnum) ? "\x82" "Director" : "Director", Draw::Button::r}}); + list.insert({{K_DirectorIsEnabled(viewnum) ? "\x82" "Director" : "Director", ""}}); } } else { auto bt = D_LocalTiccmd(viewnum)->buttons; - list.insert({{"", Draw::Button::r, bt & BT_DRIFT}, {"Pivot", Draw::Button::b, bt & BT_LOOKBACK}}); - list.insert({{"+", Draw::Button::a, bt & BT_ACCELERATE}, {"-", Draw::Button::x, bt & BT_BRAKE}}); + list.insert({{"", bt & BT_DRIFT ? "" : ""}, {"Pivot", bt & BT_LOOKBACK ? "" : ""}}); + list.insert({{"+", bt & BT_ACCELERATE ? "" : ""}, {"-", bt & BT_BRAKE ? "" : ""}}); } } From bac60e3af8fb1cb2342d9b0c2de8fc6581847829 Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Fri, 27 Sep 2024 15:43:19 -0700 Subject: [PATCH 54/56] Improve descriptive zvote offsetting --- src/k_zvote.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/k_zvote.c b/src/k_zvote.c index 0a5ea2421..0ba40a708 100644 --- a/src/k_zvote.c +++ b/src/k_zvote.c @@ -1104,9 +1104,9 @@ void K_DrawMidVote(void) exc, NULL ); K_DrawGameControl( - x/FRACUNIT - 4, y/FRACUNIT + exc->height/FRACUNIT - 12, + x/FRACUNIT - 4, y/FRACUNIT + exc->height - 8, id, pressed ? "" : "", - 0, 8, V_SNAPTOBOTTOM|V_SNAPTORIGHT + 0, 8, V_SNAPTOBOTTOM|V_SNAPTORIGHT|V_SPLITSCREEN ); /* K_drawButton( @@ -1227,7 +1227,7 @@ void K_DrawMidVote(void) if (drawButton == true) { K_DrawGameControl( - x/FRACUNIT-20, y/FRACUNIT-2, id, + x/FRACUNIT-20, y/FRACUNIT + 2, id, pressed ? "" : "", 0, 8, V_SNAPTOBOTTOM|V_SNAPTORIGHT|V_SPLITSCREEN ); From f721eca7be0e931d582a8871c5e4f13ff281f4be Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Sat, 28 Sep 2024 02:52:31 -0700 Subject: [PATCH 55/56] Shorter key names --- src/g_input.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/g_input.c b/src/g_input.c index a20d99a9c..313c81722 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -769,17 +769,17 @@ static keyname_t shortkeynames[] = {KEY_ESCAPE, "ESC"}, {KEY_BACKSPACE, "BKSP"}, - {KEY_NUMLOCK, "NUMLOCK"}, - {KEY_SCROLLLOCK, "SCRLOCK"}, + {KEY_NUMLOCK, "NLOK"}, + {KEY_SCROLLLOCK, "SLOK"}, // bill gates keys {KEY_LEFTWIN, "LWIN"}, {KEY_RIGHTWIN, "RWIN"}, {KEY_MENU, "MENU"}, - {KEY_LSHIFT, "LSHIFT"}, - {KEY_RSHIFT, "RSHIFT"}, - {KEY_LSHIFT, "SHIFT"}, + {KEY_LSHIFT, "LSFT"}, + {KEY_RSHIFT, "RSFT"}, + {KEY_LSHIFT, "SFT"}, {KEY_LCTRL, "LCTRL"}, {KEY_RCTRL, "RCTRL"}, {KEY_LCTRL, "CTRL"}, @@ -788,20 +788,20 @@ static keyname_t shortkeynames[] = {KEY_LALT, "ALT"}, // keypad keys - {KEY_KPADSLASH, "NUM/"}, - {KEY_KEYPAD7, "NUM7"}, - {KEY_KEYPAD8, "NUM8"}, - {KEY_KEYPAD9, "NUM9"}, - {KEY_MINUSPAD, "NUM-"}, - {KEY_KEYPAD4, "NUM4"}, - {KEY_KEYPAD5, "NUM5"}, - {KEY_KEYPAD6, "NUM6"}, - {KEY_PLUSPAD, "NUM+"}, - {KEY_KEYPAD1, "NUM1"}, - {KEY_KEYPAD2, "NUM2"}, - {KEY_KEYPAD3, "NUM3"}, - {KEY_KEYPAD0, "NUM0"}, - {KEY_KPADDEL, "NUM ."}, + {KEY_KPADSLASH, "/"}, + {KEY_KEYPAD7, "7"}, + {KEY_KEYPAD8, "8"}, + {KEY_KEYPAD9, "9"}, + {KEY_MINUSPAD, "-"}, + {KEY_KEYPAD4, "4"}, + {KEY_KEYPAD5, "5"}, + {KEY_KEYPAD6, "6"}, + {KEY_PLUSPAD, "+"}, + {KEY_KEYPAD1, "1"}, + {KEY_KEYPAD2, "2"}, + {KEY_KEYPAD3, "3"}, + {KEY_KEYPAD0, "0"}, + {KEY_KPADDEL, "."}, // extended keys (not keypad) {KEY_HOME, "HOME"}, @@ -831,7 +831,7 @@ static keyname_t shortkeynames[] = // KEY_CONSOLE has an exception in the keyname code {'`', "TILDE"}, - {KEY_PAUSE, "PAUSE/BREAK"}, + {KEY_PAUSE, "PAUSE"}, // virtual keys for mouse buttons and joystick buttons {KEY_MOUSE1+0,"M1"}, From 94db0ebc0e21f8bbdee61f694d8282e8991a7e8d Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Sat, 28 Sep 2024 03:03:40 -0700 Subject: [PATCH 56/56] Admin Tools descriptige input --- src/k_menudraw.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/k_menudraw.c b/src/k_menudraw.c index 82710d282..8e54b48a4 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -6216,12 +6216,12 @@ void M_DrawKickHandler(void) //V_DrawFill(32 + (playerkickmenu.player & 8), 32 + (playerkickmenu.player & 7)*8, 8, 8, playeringame[playerkickmenu.player] ? 0 : 16); V_DrawFixedPatch(0, 0, FRACUNIT, 0, W_CachePatchName("MENUHINT", PU_CACHE), NULL); - V_DrawCenteredThinString( - BASEVIDWIDTH/2, 12, - 0, + K_DrawGameControl( + BASEVIDWIDTH/2, 12, 0, (playerkickmenu.adminpowered) - ? "You are using ""\x85""Admin Tools""\x80"", ""\x83""(A)""\x80"" to kick and ""\x84""(C)""\x80"" to ban" - : K_GetMidVoteLabel(menucallvote) + ? "You are using Admin Tools. Kick Ban" + : K_GetMidVoteLabel(menucallvote), + 1, 0, 0 ); }