From 2ba24181765bb7181c31d2aae5ec1e3aaa5f2ec7 Mon Sep 17 00:00:00 2001
From: chromaticpipe2 <chromaticpipe@gmail.com>
Date: Fri, 21 Mar 2025 18:56:22 -0500
Subject: [PATCH] Add support for thin FPS/TPS display

---
 src/screen.c  | 71 +++++++++++++++++++++++++++++++++++++++------------
 src/v_video.c |  1 +
 src/v_video.h |  2 +-
 3 files changed, 57 insertions(+), 17 deletions(-)

diff --git a/src/screen.c b/src/screen.c
index b996c93a8a..915875e903 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -223,6 +223,7 @@ void SCR_Startup(void)
 
 	CV_RegisterVar(&cv_fpscounter);
 	CV_RegisterVar(&cv_tpscounter);
+	CV_RegisterVar(&cv_thinfps);
 	CV_RegisterVar(&cv_constextsize);
 
 	V_SetPalette(0);
@@ -578,9 +579,18 @@ void SCR_DisplayTicRate(void)
 
 	if (cv_fpscounter.value == 2) // compact counter
 	{
-		V_DrawRightAlignedString(vid.width, h,
-			fpscntcolor|V_NOSCALESTART|V_USERHUDTRANS, va("%04.2f", averageFPS)); // use averageFPS directly
-		hstep = 8*vid.dup;
+		if(cv_thinfps.value)
+		{
+			V_DrawRightAlignedThinString(vid.width, h,
+				fpscntcolor|V_NOSCALESTART|V_USERHUDTRANS, va("%04.2f", averageFPS)); // use averageFPS directly
+			hstep = 8*vid.dup;
+		}
+		else
+		{
+			V_DrawString(vid.width, h,
+				fpscntcolor|V_NOSCALESTART|V_USERHUDTRANS, va("%04.2f", averageFPS)); // use averageFPS directly
+			hstep = 8*vid.dup;
+		}
 	}
 	else if (cv_fpscounter.value == 1) // full counter
 	{
@@ -593,26 +603,55 @@ void SCR_DisplayTicRate(void)
 		else
 			drawnstr = va("%4.2f", averageFPS);
 
-		width = V_StringWidth(drawnstr, V_NOSCALESTART);
+		width = (cv_thinfps.value) ? V_ThinStringWidth(drawnstr, V_NOSCALESTART) : V_StringWidth(drawnstr, V_NOSCALESTART);
 
-		V_DrawString(vid.width - ((7 * 8 * vid.dup) + V_StringWidth("FPS: ", V_NOSCALESTART)), h,
-			V_YELLOWMAP|V_NOSCALESTART|V_USERHUDTRANS, "FPS: ");
-		V_DrawString(vid.width - width, h,
-			fpscntcolor|V_NOSCALESTART|V_USERHUDTRANS, drawnstr);
-		hstep = 8*vid.dup;
+		if(cv_thinfps.value)
+		{
+			V_DrawThinString(vid.width - ((7 * 8 * vid.dup) + V_StringWidth("FPS: ", V_NOSCALESTART)), h,
+				V_YELLOWMAP|V_NOSCALESTART|V_USERHUDTRANS, "FPS: ");
+			V_DrawThinString(vid.width - width, h,
+				fpscntcolor|V_NOSCALESTART|V_USERHUDTRANS, drawnstr);
+			hstep = 8*vid.dup;
+		}
+		else
+		{
+			V_DrawString(vid.width - ((7 * 8 * vid.dup) + V_StringWidth("FPS: ", V_NOSCALESTART)), h,
+				V_YELLOWMAP|V_NOSCALESTART|V_USERHUDTRANS, "FPS: ");
+			V_DrawString(vid.width - width, h,
+				fpscntcolor|V_NOSCALESTART|V_USERHUDTRANS, drawnstr);
+				hstep = 8*vid.dup;
+		}
 	}
 
 	if (cv_tpscounter.value == 2) // compact counter
 	{
-		V_DrawRightAlignedString(vid.width, h-hstep,
-			ticcntcolor|V_NOSCALESTART|V_USERHUDTRANS, va("%d", totaltics));
+		if(cv_thinfps.value)
+		{
+			V_DrawRightAlignedThinString(vid.width, h-hstep,
+				ticcntcolor|V_NOSCALESTART|V_USERHUDTRANS, va("%d", totaltics));
+		}
+		else
+		{
+			V_DrawThinString(vid.width, h-hstep,
+				ticcntcolor|V_NOSCALESTART|V_USERHUDTRANS, va("%d", totaltics));
+		}
 	}
 	else if (cv_tpscounter.value == 1) // full counter
-	{
-		V_DrawString(vid.width - ((7 * 8 * vid.dup) + V_StringWidth("TPS: ", V_NOSCALESTART)), h-hstep,
-			V_YELLOWMAP|V_NOSCALESTART|V_USERHUDTRANS, "TPS: ");
-		V_DrawRightAlignedString(vid.width, h-hstep,
-			ticcntcolor|V_NOSCALESTART|V_USERHUDTRANS, va("%d/%u", totaltics, TICRATE));
+	{	
+		if(cv_thinfps.value)
+		{
+			V_DrawThinString(vid.width - ((7 * 8 * vid.dup) + V_StringWidth("TPS: ", V_NOSCALESTART)), h-hstep,
+				V_YELLOWMAP|V_NOSCALESTART|V_USERHUDTRANS, "TPS: ");
+			V_DrawRightAlignedThinString(vid.width, h-hstep,
+				ticcntcolor|V_NOSCALESTART|V_USERHUDTRANS, va("%d/%u", totaltics, TICRATE));
+		}
+		else
+		{
+			V_DrawString(vid.width - ((7 * 8 * vid.dup) + V_StringWidth("TPS: ", V_NOSCALESTART)), h-hstep,
+				V_YELLOWMAP|V_NOSCALESTART|V_USERHUDTRANS, "TPS: ");
+			V_DrawRightAlignedString(vid.width, h-hstep,
+				ticcntcolor|V_NOSCALESTART|V_USERHUDTRANS, va("%d/%u", totaltics, TICRATE));
+		}
 	}
 	lasttic = ontic;
 }
diff --git a/src/v_video.c b/src/v_video.c
index 3e2a59a3a7..d01b176013 100644
--- a/src/v_video.c
+++ b/src/v_video.c
@@ -45,6 +45,7 @@ UINT8 *screens[5];
 static CV_PossibleValue_t fpscounter_cons_t[] = {{0, "No"}, {1, "Full"}, {2, "Compact"}, {0, NULL}};
 consvar_t cv_fpscounter = CVAR_INIT ("showfps", "No", "Displays the current framerate", CV_SAVE, fpscounter_cons_t, NULL);
 consvar_t cv_tpscounter = CVAR_INIT ("showtps", "No", "Displays the current ticrate", CV_SAVE, fpscounter_cons_t, NULL);
+consvar_t cv_thinfps = CVAR_INIT("thinfps", "No", "Renders FPS/TPS display in a thinner font", CV_SAVE, CV_YesNo, NULL);
 
 static void CV_palette_OnChange(void);
 
diff --git a/src/v_video.h b/src/v_video.h
index a8904beac9..6e2bae1645 100644
--- a/src/v_video.h
+++ b/src/v_video.h
@@ -28,7 +28,7 @@
 
 extern UINT8 *screens[5];
 
-extern consvar_t cv_fpscounter, cv_tpscounter, cv_constextsize,
+extern consvar_t cv_fpscounter, cv_tpscounter, cv_thinfps, cv_constextsize,
 cv_globalgamma, cv_globalsaturation,
 cv_rhue, cv_yhue, cv_ghue, cv_chue, cv_bhue, cv_mhue,
 cv_rgamma, cv_ygamma, cv_ggamma, cv_cgamma, cv_bgamma, cv_mgamma,
-- 
GitLab