Skip to content

Commit 3f2d394

Browse files
committed
con_drawClock
Draws current time in console.
1 parent 085905e commit 3f2d394

File tree

3 files changed

+39
-8
lines changed

3 files changed

+39
-8
lines changed

code/client/cl_console.c

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ cvar_t *con_backColor;
7171

7272
cvar_t *con_scrollBar;
7373
cvar_t *con_scrollLines;
74+
cvar_t *con_drawClock;
7475

7576
int g_console_field_width = DEFAULT_CONSOLE_WIDTH;
7677

@@ -417,19 +418,21 @@ Con_Init
417418
================
418419
*/
419420
void Con_Init( void ) {
420-
con_notifyTime = Cvar_Get( "con_notifyTime", "3", 0, "0", "10", CV_FLOAT );
421+
con_notifyTime = Cvar_Get( "con_notifyTime", "3", CVAR_ARCHIVE_ND, "0", "10", CV_FLOAT );
421422
/**/Cvar_SetDescription( con_notifyTime, "Time notifications are displayed for (in seconds.)" );
422-
con_speed = Cvar_Get( "con_speed", "3", 0, "1", "10", CV_FLOAT );
423+
con_speed = Cvar_Get( "con_speed", "3", CVAR_ARCHIVE_ND, "1", "10", CV_FLOAT );
423424
/**/Cvar_SetDescription( con_speed, "Console opening/closing scroll speed." );
424425

425-
con_notifyXOffset = Cvar_Get( "con_notifyXOffset", "0", 0, "0", NULL, CV_INTEGER );
426+
con_notifyXOffset = Cvar_Get( "con_notifyXOffset", "0", CVAR_ARCHIVE_ND, "0", NULL, CV_INTEGER );
426427
/**/Cvar_SetDescription( con_notifyXOffset, "Notifications X-offset." );
427-
con_backColor = Cvar_Get( "con_backColor", "", 0, NULL, NULL, CV_NONE );
428+
con_backColor = Cvar_Get( "con_backColor", "", CVAR_ARCHIVE_ND, NULL, NULL, CV_NONE );
428429
/**/Cvar_SetDescription( con_backColor, "Console background color, set as R G B values from 0-255." );
429-
con_scrollBar = Cvar_Get( "con_scrollBar", "1", 0, "0", "1", CV_INTEGER );
430+
con_scrollBar = Cvar_Get( "con_scrollBar", "1", CVAR_ARCHIVE_ND, "0", "1", CV_INTEGER );
430431
/**/Cvar_SetDescription( con_scrollBar, "Draws the console scroll bar." );
431-
con_scrollLines = Cvar_Get( "con_scrollLines", "2", 0, "1", "8", CV_INTEGER );
432+
con_scrollLines = Cvar_Get( "con_scrollLines", "2", CVAR_ARCHIVE_ND, "1", "8", CV_INTEGER );
432433
/**/Cvar_SetDescription( con_scrollLines, "Console line scroll factor." );
434+
con_drawClock = Cvar_Get( "con_drawClock", "0", CVAR_ARCHIVE_ND, "0", "2", CV_INTEGER );
435+
/**/Cvar_SetDescription( con_drawClock, "Draws current time in console.\n 0: Hidden\n 1: 24 hour clock\n 2: AM/PM clock" );
433436

434437
Field_Clear( &g_consoleField );
435438
g_consoleField.widthInChars = g_console_field_width;
@@ -833,9 +836,27 @@ void Con_DrawSolidConsole( float frac, const int scrAdjust ) {
833836
//y = yf;
834837

835838
// draw the version number
836-
SCR_DrawSmallString( cls.glconfig.vidWidth - ( ARRAY_LEN( PRODUCT_VERSION ) ) * cls.smallchar_width,
839+
SCR_DrawSmallString( cls.glconfig.vidWidth - ( ARRAY_LEN( PRODUCT_VERSION ) + 1 ) * cls.smallchar_width,
837840
lines - cls.smallchar_height, PRODUCT_VERSION, ARRAY_LEN( PRODUCT_VERSION ) - 1, SA_NONE );
838841

842+
// draw time
843+
if ( con_drawClock->integer ) {
844+
qtime_t t;
845+
const char *ts;
846+
int tl;
847+
848+
Com_RealTime( &t );
849+
850+
if ( con_drawClock->integer > 1 ) {
851+
ts = va( "%d:%02d:%02d %s", t.tm_hour % 12, t.tm_min, t.tm_sec, ( t.tm_hour >= 12 ) ? "PM" : "AM" );
852+
} else {
853+
ts = va( "%d:%02d:%02d", t.tm_hour, t.tm_min, t.tm_sec );
854+
}
855+
tl = strlen( ts );
856+
SCR_DrawSmallString( cls.glconfig.vidWidth - (tl + 2) * cls.smallchar_width,
857+
lines - cls.smallchar_height * 2, ts, tl, SA_NONE );
858+
}
859+
839860
// draw the text
840861
con.visLines = lines;
841862
rows = lines / cls.smallchar_height - 1; // rows of text to draw

docs/darkmatter-changelog.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,13 @@ CHANGELOG:
5656
0: Console always assumes input as commands.
5757
1: Console assumes chat command when cvars or commands are not found.
5858
+ listDefShaders command lists all defaulted (missing/invalid) shaders
59+
+ con_drawClock [0|1|2] : Draws current time in console.
60+
0: Hidden
61+
1: 24 hour clock
62+
2: AM/PM clock
63+
+ verbose <bitmask>: Enable additional system console notifications for each category:
64+
& 1: Common
65+
& 2: Client
66+
& 4: Server
67+
& 8: Renderer
68+

docs/darkmatter-todo.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Based on Quake3e - 16 Jan 2021 release
66
FIXME:
77
------
88
- Jailbreak POW: Main menu text not drawing
9+
- Threewave menu aspect fixes, menu player model projection
910
- Console font scaling fix on video resolution changes
1011
- QUAKE LIVE: shader textures/ct_1997/rock_02b drawing overly bright white... see map Fuse
1112

@@ -27,7 +28,6 @@ TODO:
2728
- Asset base rules for QL: always check for map shaders from QL path first
2829
- Asset base flags for map loading, ie: map -q2 q2dm1 to search only QUAKE II path for the map
2930
- Asset base indicators for auto-complete map lists
30-
- Client and server verbose messages like renderer PRINT_V_RENDERER
3131

3232

3333
Low-priority/future TODO:

0 commit comments

Comments
 (0)