diff --git a/src/k_hud.cpp b/src/k_hud.cpp index 709e523a7..183afba6d 100644 --- a/src/k_hud.cpp +++ b/src/k_hud.cpp @@ -8296,16 +8296,17 @@ 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); } -// 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; - Draw::TextElement text = Draw::TextElement().as(player).parse(str).font((Draw::Font)font); + Draw draw = Draw(x, y).align((Draw::Align)alignment).flags(flags); + + Draw::TextElement text = Draw::TextElement().as(player).parse(str).font(draw.fontno_to_font(font)); INT32 width = text.width(); - Draw(x, y).align((srb2::Draw::Align)alignment).flags(flags).text(text); + draw.text(text); return width; } diff --git a/src/k_menudraw.c b/src/k_menudraw.c index 976a76556..94357b020 100644 --- a/src/k_menudraw.c +++ b/src/k_menudraw.c @@ -839,7 +839,7 @@ void M_DrawMenuMessage(void) workx -= K_DrawGameControl( workx+2, worky+2, 0, " ", - 2, 8, 0 + 2, MENU_FONT, 0 ); if (menumessage.confirmstr) @@ -863,7 +863,7 @@ void M_DrawMenuMessage(void) workx -= K_DrawGameControl( workx+2, worky+2, 0, " ", - 2, 8, 0 + 2, MENU_FONT, 0 ); } @@ -1257,7 +1257,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); - K_DrawGameControl(BASEVIDWIDTH + 4 + tx, y, 0, " Rejoin", 2, 0, V_ORANGEMAP); + K_DrawGameControl(BASEVIDWIDTH + 4 + tx, y, 0, " Rejoin", 2, TINY_FONT, V_ORANGEMAP); return shift; } @@ -2462,11 +2462,11 @@ void M_DrawCharacterSelect(void) if (!optionsmenu.profile) // Does nothing on this screen { - K_DrawGameControl(BASEVIDWIDTH/2, kTop, pid, " Info Default", 1, 0, 0); + K_DrawGameControl(BASEVIDWIDTH/2, kTop, pid, " Info Default", 1, TINY_FONT, 0); } else { - K_DrawGameControl(BASEVIDWIDTH/2+62, kTop, pid, " Accept Back Default", 1, 0, 0); + K_DrawGameControl(BASEVIDWIDTH/2+62, kTop, pid, " Accept Back Default", 1, TINY_FONT, 0); } } @@ -2745,11 +2745,11 @@ void M_DrawRaceDifficulty(void) switch (it->mvar2) { case MBT_Y: - K_DrawGameControl(cx + 24, cy + 22, 0, activated ? "" : "", 0, 8, 0); + K_DrawGameControl(cx + 24, cy + 22, 0, activated ? "" : "", 0, MENU_FONT, 0); break; case MBT_Z: - K_DrawGameControl(cx + 24, cy + 22, 0, activated ? "" : "", 0, 8, 0); + K_DrawGameControl(cx + 24, cy + 22, 0, activated ? "" : "", 0, MENU_FONT, 0); break; } break; @@ -3868,7 +3868,7 @@ void M_DrawTimeAttack(void) if (M_EncoreAttackTogglePermitted()) { - K_DrawGameControl(buttonx + 35, buttony - 3, 0, "", 0, 8, 0); + K_DrawGameControl(buttonx + 35, buttony - 3, 0, "", 0, MENU_FONT, 0); } if ((timeattackmenu.spbflicker == 0 || timeattackmenu.ticker % 2) == (cv_dummyspbattack.value == 1)) @@ -5559,7 +5559,7 @@ void M_DrawProfileControls(void) UINT16 oldsetting = cv_descriptiveinput->value; CV_StealthSetValue(cv_descriptiveinput, cv_dummyprofiledescriptiveinput.value); INT32 xpos = BASEVIDWIDTH - 12; - xpos = K_DrawGameControl(xpos, ypos, 0, " / Clear", 2, 0, 0); + xpos = K_DrawGameControl(xpos, ypos, 0, " / Clear", 2, TINY_FONT, 0); CV_StealthSetValue(cv_descriptiveinput, oldsetting); } @@ -6330,16 +6330,16 @@ void M_DrawPause(void) } else if (gametype == GT_TUTORIAL) { - 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/Rings", 0, 0, 0); + K_DrawGameControl(4, 184 - 60 + offset/2, 0, " Steering", 0, TINY_FONT, 0); + K_DrawGameControl(4, 184 - 45 + offset/2, 0, " Accelerate", 0, TINY_FONT, 0); + K_DrawGameControl(4, 184 - 30 + offset/2, 0, " Look Back", 0, TINY_FONT, 0); + K_DrawGameControl(4, 184 - 15 + offset/2, 0, " Spindash", 0, TINY_FONT, 0); + K_DrawGameControl(4, 184 - 0 + offset/2, 0, " Item/Rings", 0, TINY_FONT, 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); + K_DrawGameControl(90, 184 - 45 + offset/2, 0, " Brake", 0, TINY_FONT, 0); + K_DrawGameControl(90, 184 - 30 + offset/2, 0, " Respawn", 0, TINY_FONT, 0); + K_DrawGameControl(90, 184 - 15 + offset/2, 0, " Dialogue / Action", 0, TINY_FONT, 0); + K_DrawGameControl(90, 184 - 0 + offset/2, 0, " Drift", 0, TINY_FONT, 0); } else { @@ -6448,7 +6448,7 @@ void M_DrawKickHandler(void) (playerkickmenu.adminpowered) ? "You are using Admin Tools. Kick Ban" : K_GetMidVoteLabel(menucallvote), - 1, 0, 0 + 1, TINY_FONT, 0 ); } @@ -7523,7 +7523,7 @@ 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_DrawGameControl(x, y, 0, " Toggle", 0, 0, 0); + K_DrawGameControl(x, y, 0, " Toggle", 0, TINY_FONT, 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"); @@ -7590,9 +7590,9 @@ static void M_DrawChallengePreview(INT32 x, INT32 y) } if (!pushed) - K_DrawGameControl(x, y, 0, " E Side", 0, 0, 0); + K_DrawGameControl(x, y, 0, " E Side", 0, TINY_FONT, 0); else - K_DrawGameControl(x, y, 0, " E Side", 0, 0, 0); + K_DrawGameControl(x, y, 0, " E Side", 0, TINY_FONT, 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"); @@ -7615,9 +7615,9 @@ static void M_DrawChallengePreview(INT32 x, INT32 y) } if (!pushed) - K_DrawGameControl(x, y, 0, " Play CD", 0, 0, 0); + K_DrawGameControl(x, y, 0, " Play CD", 0, TINY_FONT, 0); else - K_DrawGameControl(x, y, 0, " Play CD", 0, 0, 0); + K_DrawGameControl(x, y, 0, " Play CD", 0, TINY_FONT, 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"); @@ -7700,7 +7700,7 @@ static void M_DrawChallengeKeys(INT32 tilex, INT32 tiley) K_DrawGameControl( 24, 16, 0, keybuttonpress ? "" : "", - 0, 0, 0 + 0, TINY_FONT, 0 ); // Metyr of rounds played that contribute to Chao Key generation @@ -9432,13 +9432,13 @@ void M_DrawDiscordRequests(void) /* K_DrawSticker(x, y + 26, stickerWidth, 0, true); - K_DrawGameControl(x, y+22, 0, "", 0, 0, V_SNAPTORIGHT); + K_DrawGameControl(x, y+22, 0, "", 0, TINY_FONT, V_SNAPTORIGHT); // K_drawButtonAnim(x, y + 22, V_SNAPTORIGHT, kp_button_a[1], discordrequestmenu.ticker); */ - UINT32 bigwidth = K_DrawGameControl(x, y+22, 0, " Accept Decline", 0, 0, V_SNAPTORIGHT); + UINT32 bigwidth = K_DrawGameControl(x, y+22, 0, " Accept Decline", 0, TINY_FONT, V_SNAPTORIGHT); K_DrawSticker(x, y + 26, bigwidth, 0, true); - K_DrawGameControl(x, y+22, 0, " Accept Decline", 0, 0, V_SNAPTORIGHT); + K_DrawGameControl(x, y+22, 0, " Accept Decline", 0, TINY_FONT, V_SNAPTORIGHT); /* V_DrawThinString((x + xoffs), y + 24, 0, acceptText); @@ -9447,7 +9447,7 @@ void M_DrawDiscordRequests(void) 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); + xoffs += K_DrawGameControl(x + xoffs, y+22, 0, "", 0, TINY_FONT, V_SNAPTORIGHT); K_drawButtonAnim((x + xoffs), y + 22, V_SNAPTORIGHT, kp_button_x[1], discordrequestmenu.ticker); xoffs += altDeclineButtonWidth; diff --git a/src/k_zvote.c b/src/k_zvote.c index be005c110..0eb9db702 100644 --- a/src/k_zvote.c +++ b/src/k_zvote.c @@ -1136,7 +1136,7 @@ void K_DrawMidVote(void) K_DrawGameControl( x/FRACUNIT - 4, y/FRACUNIT + exc->height - 8, id, pressed ? "" : "", - 0, 8, V_SNAPTOBOTTOM|V_SNAPTORIGHT|V_SPLITSCREEN + 0, MENU_FONT, V_SNAPTOBOTTOM|V_SNAPTORIGHT|V_SPLITSCREEN ); /* K_drawButton( @@ -1260,7 +1260,7 @@ void K_DrawMidVote(void) K_DrawGameControl( x/FRACUNIT-20, y/FRACUNIT + 2, id, pressed ? "" : "", - 0, 8, V_SNAPTOBOTTOM|V_SNAPTORIGHT|V_SPLITSCREEN + 0, MENU_FONT, V_SNAPTOBOTTOM|V_SNAPTORIGHT|V_SPLITSCREEN ); /* K_drawButton( diff --git a/src/menus/transient/pause-addonoptions.cpp b/src/menus/transient/pause-addonoptions.cpp index 2f3f69526..5b7c11896 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() + 8, draw.y()-6, 0, M_MenuButtonHeld(0, MBT_Y) ? " Switch Page" : " Switch Page", 0, 8, 0); + K_DrawGameControl(draw.x() + 8, draw.y()-6, 0, M_MenuButtonHeld(0, MBT_Y) ? " Switch Page" : " Switch Page", 0, MENU_FONT, 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 6f0e38886..5dc70fc39 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() + 8, draw.y()-6, 0, M_MenuButtonHeld(0, MBT_Y) ? " Switch Page" : " Switch Page", 0, 8, 0); + K_DrawGameControl(draw.x() + 8, draw.y()-6, 0, M_MenuButtonHeld(0, MBT_Y) ? " Switch Page" : " Switch Page", 0, MENU_FONT, 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/st_stuff.c b/src/st_stuff.c index c5054a602..5263c71d8 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -1501,7 +1501,7 @@ void ST_DrawSaveReplayHint(INT32 flags) 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 + 2, TINY_FONT, flags|V_YELLOWMAP ); } diff --git a/src/v_draw.cpp b/src/v_draw.cpp index a0ebf9050..44e971297 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -531,11 +531,58 @@ patch_t* Draw::cache_patch(const char* name) return static_cast(W_CachePatchName(name, PU_CACHE)); } +Draw::Font Draw::fontno_to_font(int font) +{ + switch (font) + { + case TINY_FONT: + default: + return Font::kThin; + + case GM_FONT: + return Font::kGamemode; + + case GENESIS_FONT: + return Font::kGenesis; + + case HU_FONT: + return Font::kConsole; + + case KART_FONT: + return Font::kFreeplay; + + case OPPRF_FONT: + return Font::kZVote; + + case PINGF_FONT: + return Font::kPing; + + case TIMER_FONT: + return Font::kTimer; + + case TINYTIMER_FONT: + return Font::kThinTimer; + + case MENU_FONT: + return Font::kMenu; + + case MED_FONT: + return Font::kMedium; + + case ROLNUM_FONT: + return Font::kRollingNum; + + case RO4NUM_FONT: + return Font::kRollingNum4P; + } +}; + int Draw::font_to_fontno(Font font) { switch (font) { case Font::kThin: + default: return TINY_FONT; case Font::kGamemode: @@ -574,8 +621,6 @@ int Draw::font_to_fontno(Font font) case Font::kRollingNum4P: return RO4NUM_FONT; } - - return TINY_FONT; }; INT32 Draw::default_font_flags(Font font) diff --git a/src/v_draw.hpp b/src/v_draw.hpp index 5801fe7a7..3e26f5e7d 100644 --- a/src/v_draw.hpp +++ b/src/v_draw.hpp @@ -206,6 +206,7 @@ public: kRollingNum, kRollingNum4P, }; + Font fontno_to_font(int font); enum class Align {