mirror of
https://git.code.sf.net/p/quake/newtree
synced 2025-01-22 16:01:25 +00:00
Rewrite of the clock code.
This commit is contained in:
parent
f9022537ee
commit
3783f9b562
1 changed files with 24 additions and 17 deletions
|
@ -75,10 +75,10 @@ xblited, but sync draw can just ignore it.
|
||||||
sync
|
sync
|
||||||
draw
|
draw
|
||||||
|
|
||||||
CenterPrint ()
|
CenterPrint ()
|
||||||
SlowPrint ()
|
SlowPrint ()
|
||||||
Screen_Update ();
|
Screen_Update ();
|
||||||
Con_Printf ();
|
Con_Printf ();
|
||||||
|
|
||||||
net
|
net
|
||||||
turn off messages option
|
turn off messages option
|
||||||
|
@ -94,7 +94,6 @@ console is:
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
// only the refresh window will be updated unless these variables are flagged
|
// only the refresh window will be updated unless these variables are flagged
|
||||||
int scr_copytop;
|
int scr_copytop;
|
||||||
int scr_copyeverything;
|
int scr_copyeverything;
|
||||||
|
@ -523,30 +522,38 @@ SCR_DrawFPS (void)
|
||||||
Draw_String8 (x, y, st);
|
Draw_String8 (x, y, st);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Misty: I like to see the time */
|
/*
|
||||||
|
SCR_DrawTime
|
||||||
|
|
||||||
|
Draw a clock on the screen
|
||||||
|
Written by Misty, rewritten by Deek
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
SCR_DrawTime (void)
|
SCR_DrawTime (void)
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
char st[80];
|
char st[80];
|
||||||
char local_time[120];
|
|
||||||
time_t systime;
|
time_t utc = 0;
|
||||||
|
struct tm *local = NULL;
|
||||||
|
char *timefmt = NULL;
|
||||||
|
|
||||||
// any cvar that can take multiple settings must be able to handle abuse.
|
// any cvar that can take multiple settings must be able to handle abuse.
|
||||||
if (show_time->int_val <= 0)
|
if (show_time->int_val <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* actually find the time and set systime to it */
|
// Get local time
|
||||||
time (&systime);
|
utc = time (NULL);
|
||||||
|
local = localtime (&utc);
|
||||||
|
|
||||||
if (show_time->int_val == 1) { // International format
|
if (show_time->int_val == 1) { // Use international format
|
||||||
strftime (local_time, sizeof (local_time), "%k:%M", localtime (&systime));
|
timefmt = "%k:%M";
|
||||||
} else if (show_time->int_val >= 2) { // AM/PM display
|
} else if (show_time->int_val >= 2) { // US AM/PM display
|
||||||
strftime (local_time, sizeof (local_time), "%l:%M %P", localtime (&systime));
|
timefmt = "%l:%M %P";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print it next to the fps meter
|
// Print it next to the fps meter
|
||||||
snprintf (st, sizeof (st), "%s", local_time);
|
strftime (st, sizeof (st), timefmt, local);
|
||||||
x = cl_hudswap->int_val ? (vid.width - ((strlen (st) * 8) + 8)) : 8;
|
x = cl_hudswap->int_val ? (vid.width - ((strlen (st) * 8) + 8)) : 8;
|
||||||
y = vid.height - (sb_lines + 8);
|
y = vid.height - (sb_lines + 8);
|
||||||
Draw_String8 (x, y, st);
|
Draw_String8 (x, y, st);
|
||||||
|
|
Loading…
Reference in a new issue