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 {