added showtime/showtime_format and showdate/showdate_format cvars, and moved the...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 10 Mar 2004 05:51:53 +0000 (05:51 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 10 Mar 2004 05:51:53 +0000 (05:51 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@3994 d7cf8633-e32d-0410-b094-e92efae38249

menu.c
sbar.c
screen.h

diff --git a/menu.c b/menu.c
index a56f436..fd3bee9 100644 (file)
--- a/menu.c
+++ b/menu.c
@@ -1164,7 +1164,7 @@ void M_DrawCheckbox (int x, int y, int on)
 }
 
 
-#define OPTIONS_ITEMS 34
+#define OPTIONS_ITEMS 36
 
 int options_cursor;
 
@@ -1234,6 +1234,10 @@ void M_Menu_Options_AdjustSliders (int dir)
        else if (options_cursor == optnum++)
                Cvar_SetValueQuick (&showfps, !showfps.integer);
        else if (options_cursor == optnum++)
+               Cvar_SetValueQuick (&showtime, !showtime.integer);
+       else if (options_cursor == optnum++)
+               Cvar_SetValueQuick (&showdate, !showdate.integer);
+       else if (options_cursor == optnum++)
        {
                if (cl_forwardspeed.value > 200)
                {
@@ -1342,6 +1346,8 @@ void M_Options_Draw (void)
        M_Options_PrintSlider(  "    Crosshair Size", true, crosshair_size.value, 1, 5);
        M_Options_PrintCheckbox("  Static Crosshair", true, crosshair_static.integer);
        M_Options_PrintCheckbox("    Show Framerate", true, showfps.integer);
+       M_Options_PrintCheckbox("         Show Time", true, showtime.integer);
+       M_Options_PrintCheckbox("         Show Date", true, showdate.integer);
        M_Options_PrintCheckbox("        Always Run", true, cl_forwardspeed.value > 200);
        M_Options_PrintCheckbox("        Lookspring", true, lookspring.integer);
        M_Options_PrintCheckbox("        Lookstrafe", true, lookstrafe.integer);
diff --git a/sbar.c b/sbar.c
index 5171686..03a5de8 100644 (file)
--- a/sbar.c
+++ b/sbar.c
@@ -90,6 +90,10 @@ sbarpic_t *somsb_ammo[4];
 sbarpic_t *somsb_armor[3];
 
 cvar_t showfps = {CVAR_SAVE, "showfps", "0"};
+cvar_t showtime = {CVAR_SAVE, "showtime", "0"};
+cvar_t showtime_format = {CVAR_SAVE, "showtime_format", "%H:%M:%S"};
+cvar_t showdate = {CVAR_SAVE, "showdate", "0"};
+cvar_t showdate_format = {CVAR_SAVE, "showdate_format", "%Y-%m-%d"};
 cvar_t sbar_alpha = {CVAR_SAVE, "sbar_alpha", "1"};
 
 void Sbar_MiniDeathmatchOverlay (int x, int y);
@@ -309,6 +313,10 @@ void Sbar_Init (void)
        Cmd_AddCommand ("+showscores", Sbar_ShowScores);
        Cmd_AddCommand ("-showscores", Sbar_DontShowScores);
        Cvar_RegisterVariable (&showfps);
+       Cvar_RegisterVariable (&showtime);
+       Cvar_RegisterVariable (&showtime_format);
+       Cvar_RegisterVariable (&showdate);
+       Cvar_RegisterVariable (&showdate_format);
        Cvar_RegisterVariable (&sbar_alpha);
 
        R_RegisterModule("sbar", sbar_start, sbar_shutdown, sbar_newmap);
@@ -782,11 +790,16 @@ void Sbar_DrawFace (void)
 
 void Sbar_ShowFPS(void)
 {
+       float fps_x, fps_y, fps_scalex, fps_scaley, fps_height;
+       char fpsstring[32];
+       char timestring[32];
+       char datestring[32];
+       fpsstring[0] = 0;
+       timestring[0] = 0;
+       datestring[0] = 0;
        if (showfps.integer)
        {
                int calc;
-               char temp[32];
-               float fps_x, fps_y, fps_scalex, fps_scaley;
                if (showfps.integer > 1)
                {
                        static double currtime, frametimes[32];
@@ -828,15 +841,41 @@ void Sbar_ShowFPS(void)
                        }
                        calc = framerate;
                }
-               sprintf(temp, "%4i", calc);
+               snprintf(fpsstring, sizeof(fpsstring), "%4i fps", calc);
+       }
+       if (showtime.integer)
+               strlcpy(timestring, Sys_TimeString(showtime_format.string), sizeof(timestring));
+       if (showdate.integer)
+               strlcpy(datestring, Sys_TimeString(showdate_format.string), sizeof(datestring));
+       if (fpsstring[0] || timestring[0])
+       {
                fps_scalex = 12;
                fps_scaley = 12;
-               fps_x = vid.conwidth - (fps_scalex * strlen(temp));
-               fps_y = vid.conheight - sb_lines/* - 8*/; // yes this might draw over the sbar
-               if (fps_y > vid.conheight - fps_scaley)
-                       fps_y = vid.conheight - fps_scaley;
-               DrawQ_Fill(fps_x, fps_y, fps_scalex * strlen(temp), fps_scaley, 0, 0, 0, 0.5 * sbar_alpha.value, 0);
-               DrawQ_String(fps_x, fps_y, temp, 0, fps_scalex, fps_scaley, 1, 1, 1, 1 * sbar_alpha.value, 0);
+               fps_height = fps_scaley * ((fpsstring[0] != 0) + (timestring[0] != 0) + (datestring[0] != 0));
+               //fps_y = vid.conheight - sb_lines; // yes this may draw over the sbar
+               //fps_y = bound(0, fps_y, vid.conheight - fps_height);
+               fps_y = vid.conheight - fps_height;
+               if (fpsstring[0])
+               {
+                       fps_x = vid.conwidth - fps_scalex * strlen(fpsstring);
+                       DrawQ_Fill(fps_x, fps_y, fps_scalex * strlen(fpsstring), fps_scaley, 0, 0, 0, 0.5 * sbar_alpha.value, 0);
+                       DrawQ_String(fps_x, fps_y, fpsstring, 0, fps_scalex, fps_scaley, 1, 1, 1, 1 * sbar_alpha.value, 0);
+                       fps_y += fps_scaley;
+               }
+               if (timestring[0])
+               {
+                       fps_x = vid.conwidth - fps_scalex * strlen(timestring);
+                       DrawQ_Fill(fps_x, fps_y, fps_scalex * strlen(timestring), fps_scaley, 0, 0, 0, 0.5 * sbar_alpha.value, 0);
+                       DrawQ_String(fps_x, fps_y, timestring, 0, fps_scalex, fps_scaley, 1, 1, 1, 1 * sbar_alpha.value, 0);
+                       fps_y += fps_scaley;
+               }
+               if (datestring[0])
+               {
+                       fps_x = vid.conwidth - fps_scalex * strlen(datestring);
+                       DrawQ_Fill(fps_x, fps_y, fps_scalex * strlen(datestring), fps_scaley, 0, 0, 0, 0.5 * sbar_alpha.value, 0);
+                       DrawQ_String(fps_x, fps_y, datestring, 0, fps_scalex, fps_scaley, 1, 1, 1, 1 * sbar_alpha.value, 0);
+                       fps_y += fps_scaley;
+               }
        }
 }
 
index b970e0f..27b64bf 100644 (file)
--- a/screen.h
+++ b/screen.h
@@ -40,6 +40,8 @@ extern qboolean       scr_skipupdate;
 extern cvar_t scr_viewsize;
 extern cvar_t scr_fov;
 extern cvar_t showfps;
+extern cvar_t showtime;
+extern cvar_t showdate;
 
 extern cvar_t crosshair;
 extern cvar_t crosshair_size;