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;