From ea3fc8f526415d0bb624af6dcad23635225318f9 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 21 Dec 2023 13:41:13 +0100 Subject: [PATCH] Kart v1.0/srb2 styled fps counter option this was so much pain for whatever reason lmao --- src/d_netcmd.c | 1 - src/m_menu.c | 2 +- src/screen.c | 76 +++++++++++++++++++++++++++++++++----------------- src/v_video.c | 2 +- 4 files changed, 52 insertions(+), 29 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index b15b15526..5cb77bf61 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -488,7 +488,6 @@ consvar_t cv_pingicon = {"pingicon", "On", CV_SAVE, CV_OnOff, 0, 0, NULL, NULL, static CV_PossibleValue_t cv_pingstyle_cons_t[] = {{0, "New"}, {1, "Old"}, {0, NULL}}; consvar_t cv_pingstyle = {"pingstyle", "New", CV_SAVE, cv_pingstyle_cons_t, 0, 0, NULL, NULL, 0, 0, NULL}; - consvar_t cv_luaimmersion = {"luaimmersion", "On", CV_SAVE, CV_OnOff, 0, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_minihead = {"smallminimapplayers", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; diff --git a/src/m_menu.c b/src/m_menu.c index 1e0c28352..3e366df68 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1392,7 +1392,7 @@ static const char* OP_VideoTooltips[] = "How far away weather is drawn.", "Toggle being able to see the sky.", "Player field of view.", - "Show current game framerate.", + "Show current game framerate and select the style.", "Sync game framerate to refresh rate of monitor.", "Set manual framerate cap.", "Size of drift spark pulse.", diff --git a/src/screen.c b/src/screen.c index bc787e4b2..06be64abf 100644 --- a/src/screen.c +++ b/src/screen.c @@ -429,41 +429,65 @@ void SCR_DisplayTicRate(void) INT32 x = 318; double fps = round(averageFPS); INT32 fpsflags = SCR_FPSflags(); + const char *fps_string; + + INT32 ticcntcolor2 = 0; if (gamestate == GS_NULL) return; - // draw "FPS" - if (cv_ticrate.value == 1) - V_DrawFixedPatch(306< (benchmark - 5)) - ticcntcolor = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_MINT, GTC_CACHE); - else if (fps < 20) - ticcntcolor = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_RASPBERRY, GTC_CACHE); - - if (cap != 0) + // new kart counter + if ((cv_ticrate.value == 1) || (cv_ticrate.value == 2)) { - UINT32 digits = 1; - UINT32 c2 = cap; + // draw "FPS" + if (cv_ticrate.value == 1) + V_DrawFixedPatch(306< (benchmark - 5)) + ticcntcolor = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_MINT, GTC_CACHE); + else if (fps < 20) + ticcntcolor = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_RASPBERRY, GTC_CACHE); - while (c2 > 0) + if (cap != 0) { - c2 = c2 / 10; - digits++; + UINT32 digits = 1; + UINT32 c2 = cap; + + while (c2 > 0) + { + c2 = c2 / 10; + digits++; + } + + // draw total frame: + V_DrawPingNum(x, 190, fpsflags, cap, ticcntcolor); + + x -= digits * 4; + + // draw "/" + V_DrawFixedPatch(x< (benchmark - 5)) + ticcntcolor2 = V_GREENMAP; + else if (fps < 20) + ticcntcolor2 = V_REDMAP; - // draw our actual framerate - V_DrawPingNum(x, 190, fpsflags, fps, ticcntcolor); + if (cap != 0) + fps_string = va("%d/%d\x82", (INT32)fps, cap); + else + fps_string = va("%d\x82", (INT32)fps); + + if (cv_ticrate.value == 3) + V_DrawRightAlignedString(319, 181, V_YELLOWMAP|fpsflags, "FPS"); + + V_DrawRightAlignedString(319, 190, ticcntcolor2|fpsflags, fps_string); + } } // SCR_DisplayLocalPing @@ -476,8 +500,8 @@ void SCR_DisplayLocalPing(void) if (cv_showping.value == 1 || (cv_showping.value == 2 && ping > servermaxping)) // only show 2 (warning) if our ping is at a bad level { - INT32 dispy = (cv_ticrate.value == 1) ? 165 : ((cv_ticrate.value == 2) ? 172 : 181); - + INT32 dispy = (cv_ticrate.value == 1) ? 165 : ((cv_ticrate.value == 2 || cv_ticrate.value == 4) ? 172 : ((cv_ticrate.value == 3) ? 163 : 181)); // absolute buttpain + HU_drawPing(308, dispy, ping, fpsflags); } } diff --git a/src/v_video.c b/src/v_video.c index 6058d8ede..d6c8831bf 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -42,7 +42,7 @@ UINT8 *screens[5]; static CV_PossibleValue_t gamma_cons_t[] = {{0, "MIN"}, {4, "MAX"}, {0, NULL}}; static void CV_usegamma_OnChange(void); -static CV_PossibleValue_t fps_cons_t[] = {{0, "No"}, {1, "Normal"}, {2, "Compact"}, {0, NULL}}; +static CV_PossibleValue_t fps_cons_t[] = {{0, "No"}, {1, "Normal"}, {2, "Compact"}, {3, "Old"}, {4, "Old Compact"}, {0, NULL}}; consvar_t cv_ticrate = {"showfps", "No", CV_SAVE, fps_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_usegamma = {"gamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_usegamma_OnChange, 0, NULL, NULL, 0, 0, NULL};