From 81b848977ac8cce9b4e2dffdf4f6ee954976af16 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Thu, 7 Dec 2000 00:06:45 +0000 Subject: [PATCH] showtime patches from Misty --- source/cl_main.c | 4 ++++ source/gl_screen.c | 42 +++++++++++++++++++++++++++++++++++++--- source/screen.c | 48 ++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 85 insertions(+), 9 deletions(-) diff --git a/source/cl_main.c b/source/cl_main.c index c84d4f2..3989706 100644 --- a/source/cl_main.c +++ b/source/cl_main.c @@ -66,6 +66,7 @@ cvar_t *m_forward; cvar_t *m_side; cvar_t *show_fps; +cvar_t *show_time; int fps_count; @@ -85,6 +86,9 @@ void CL_InitCvars(void) { show_fps = Cvar_Get("show_fps", "0", CVAR_NONE, "None"); + // Misty: I like to be able to see the time when I play + show_time = Cvar_Get("show_time", "0", CVAR_NONE, + "display the current time"); cl_warncmd = Cvar_Get("cl_warncmd", "0", CVAR_NONE, "None"); cl_name = Cvar_Get("_cl_name", "player", CVAR_ARCHIVE, "None"); cl_color = Cvar_Get("_cl_color", "0", CVAR_ARCHIVE, "None"); diff --git a/source/gl_screen.c b/source/gl_screen.c index 30b3466..91ea1e2 100644 --- a/source/gl_screen.c +++ b/source/gl_screen.c @@ -508,13 +508,48 @@ void SCR_DrawFPS (void) fps_count = 0; lastframetime = t; } - - snprintf(st, sizeof(st), "%3d FPS", lastfps); - x = vid.width - strlen(st) * 8 - 8; + snprintf(st, sizeof(st), "%-3d FPS", lastfps); + /* Misty: New trick! (for me) the ? makes this work like a if then else - IE: if + cl_hudswap->int_val is not null, do first case, else (else is a : here) do second case. + Deek taught me this trick */ + x = cl_hudswap->int_val ? vid.width - ((strlen (st) * 8) + 8) : 8; y = vid.height - sb_lines - 8; Draw_String8 (x, y, st); + } +/* Misty: I like to see the time */ +void SCR_DrawTime (void) +{ + extern cvar_t *show_time; + int x, y; + char st[80]; + char local_time[120]; + time_t systime; + + /* any cvar that can take multiple settings must be able to handle abuse. */ + if (show_time->int_val <= 0) + return; + + /* actually find the time and set systime to it*/ + time(&systime); + + if (show_time->int_val == 1) { + /* now set local_time to 24 hour time using hours:minutes format */ + strftime (local_time, sizeof (local_time), "%k:%M", + localtime (&systime)); + } else if (show_time->int_val >= 2) { + /* >= is another abuse protector */ + strftime (local_time, sizeof (local_time), "%l:%M %P", + localtime(&systime)); + } + + /* now actually print it to the screen directly above where show_fps is */ + snprintf (st, sizeof(st), "%s", local_time); + x = cl_hudswap->int_val ? vid.width - ((strlen (st) * 8) + 8) : 8; + y = vid.height - sb_lines - 16; + Draw_String8 (x, y, st); +} /* ============== @@ -980,6 +1015,7 @@ void SCR_UpdateScreen (void) SCR_DrawRam (); SCR_DrawFPS (); + SCR_DrawTime (); SCR_DrawTurtle (); SCR_DrawPause (); SCR_CheckDrawCenterString (); diff --git a/source/screen.c b/source/screen.c index e647330..fb444ec 100644 --- a/source/screen.c +++ b/source/screen.c @@ -30,6 +30,7 @@ # include "config.h" #endif +#include #include "r_local.h" #include "screen.h" #include "sbar.h" @@ -433,7 +434,7 @@ void SCR_DrawFPS (void) int x, y; char st[80]; - if (!show_fps->value) + if (!show_fps->int_val) return; t = Sys_DoubleTime(); @@ -442,13 +443,47 @@ void SCR_DrawFPS (void) fps_count = 0; lastframetime = t; } - - sprintf(st, "%3d FPS", lastfps); - x = vid.width - strlen(st) * 8 - 8; - y = vid.height - sb_lines - 8; - Draw_String8 (x, y, st); + snprintf (st, sizeof(st), "%-3d FPS", lastfps); + /* Misty: New trick! (for me) the ? makes this work like a if then else - IE: if + cl_hudswap->int_val is not null, do first case, else (else is a : here) do second case. + Deek taught me this trick */ + x = cl_hudswap->int_val ? vid.width - ((strlen (st) * 8) + 8) : 8; + y = vid.height - sb_lines - 8; + Draw_String8 (x, y, st); } +/* Misty: I like to see the time */ +void SCR_DrawTime (void) +{ + extern cvar_t *show_time; + int x, y; + char st[80]; + char local_time[120]; + time_t systime; + + /* any cvar that can take multiple settings must be able to handle abuse. */ + if (show_time->int_val <= 0) + return; + + /* actually find the time and set systime to it*/ + time(&systime); + + if (show_time->int_val == 1) { + /* now set local_time to 24 hour time using hours:minutes format */ + strftime (local_time, sizeof (local_time), "%k:%M", + localtime (&systime)); + } else if (show_time->int_val >= 2) { + /* >= is another cvar abuse protector */ + strftime (local_time, sizeof (local_time), "%l:%M %P", + localtime (&systime)); + } + + /* now actually print it to the screen directly above where show_fps is */ + snprintf (st, sizeof(st), "%s", local_time); + x = cl_hudswap->int_val ? vid.width - ((strlen (st) * 8) + 8) : 8; + y = vid.height - sb_lines - 16; + Draw_String8 (x, y, st); +} /* ============== @@ -984,6 +1019,7 @@ void SCR_UpdateScreen (void) SCR_DrawTurtle (); SCR_DrawPause (); SCR_DrawFPS (); + SCR_DrawTime (); SCR_CheckDrawCenterString (); Sbar_Draw (); SCR_DrawConsole ();