From f10342fa809ce22030f84d36f8394eed2c39a1b5 Mon Sep 17 00:00:00 2001 From: aurhat Date: Sun, 6 Sep 2015 22:09:00 +0200 Subject: [PATCH] Improve game time and wall clock display 1. Counting backward for gametimedisplay = 1 and forward for 2. The setting added to HUD menu. 2. Changed name from clockdisplay to gimetimedisplay, in order to distinguish clocks with system time and game time. 3. Added to wall clock options with UTC/GMT time and 12h format. DOCREF clockcount clockdisplay gametimedisplay --- config/menus_settings.cfg | 4 +++- source/src/clientgame.cpp | 4 ++-- source/src/renderhud.cpp | 10 +++++----- source/src/scoreboard.cpp | 6 +++--- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/config/menus_settings.cfg b/config/menus_settings.cfg index 154ebb8f..a51b4eba 100644 --- a/config/menus_settings.cfg +++ b/config/menus_settings.cfg @@ -502,6 +502,7 @@ menuitem [Reset to default scoreboard...] [ loop rsl (listlen $DEFAULT_SCOREBOAR menuitem [Close] [ closecurmenu ] alias wallclockformat "" // strftime formatting +alias wallclockformatlist ["" %H:%M %H:%M:%S %I:%M%P %I:%M:%S%P U%H:%M U%H:%M:%S] //"U" at beginning means UTC/GMT time newmenu HUD @@ -521,7 +522,8 @@ menuitemcheckbox [ Radar ] "(= $hideradar 0)" [ menuitemslider [ Radar zoom: ] 5 500 [ $radarheight ] 5 [][ radarheight $arg1 ] menuitemslider [ Votes: ] 0 2 "$hidevote" 1 ["Always show" "Show until you vote" "Never show"] [ hidevote $arg1 ] menuitemslider [ Graphics statistics: ] 0 2 "$showstats" 1 [None "FPS Only" All] [ showstats $arg1 ] -menuitemslider [ Wall clock: ] 0 2 [findlist ["" %H:%M %H:%M:%S] $wallclockformat] 1 [None HH:MM HH:MM:SS] [ persistidents 1; alias wallclockformat (at ["" %H:%M %H:%M:%S] $arg1); persistidents 0 ] +menuitemslider [ Game time: ] 0 2 "$gametimedisplay" 1 [None "Count backward" "Count forward"] [ gametimedisplay $arg1 ] +menuitemslider [ Wall clock: ] 0 6 [findlist $wallclockformatlist $wallclockformat] 1 [None "HH:MM (local, 24h)" "HH:MM:SS (local, 24h)" "HH:MM (local, 12h)" "HH:MM:SS (local, 12h)" "HH:MM (UTC/GMT)" "HH:MM:SS (UTC/GMT)"] [ persistidents 1; alias wallclockformat (at $wallclockformatlist $arg1); persistidents 0 ] menuitemslider [ Extra messages: ] 0 3 "$hudextras" 1 ["No extra messages" "Show extra messages in console" "Pop up extra messages!" "SPAM EXTRA MESSAGES!"] [ hudextras $arg1 ] menuitemslider [ Hand alignment: ] 0 1 "$righthanded" 1 [Left-handed Right-handed] [ righthanded $arg1 ] menuitemslider [ Max-roll: ] 0 20 "$maxroll" 1 [] [ maxroll $arg1 ] diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index 6c21e0aa..1962740b 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -975,7 +975,7 @@ void timeupdate(int milliscur, int millismax) } else { - extern int clockdisplay; // only output to console if no hud-clock is being shown + extern int gametimedisplay; // only output to console if no hud-clock with game time is being shown int sec = 60 - ( (gametimecurrent + ( lastmillis - lastgametimeupdate ) ) / 1000) % 60; if(minutesremaining==1) { @@ -983,7 +983,7 @@ void timeupdate(int milliscur, int millismax) hudoutf("%s1 minute left!", sec==60 ? "" : "less than "); exechook(HOOK_SP_MP, "onLastMin", ""); } - else if(!clockdisplay) conoutf("time remaining: %d minutes", minutesremaining); + else if(!gametimedisplay) conoutf("time remaining: %d minutes", minutesremaining); else clientlogf("time remaining: %d minutes", minutesremaining); } } diff --git a/source/src/renderhud.cpp b/source/src/renderhud.cpp index 345b93ce..c3cdbb25 100644 --- a/source/src/renderhud.cpp +++ b/source/src/renderhud.cpp @@ -738,8 +738,7 @@ string enginestateinfo = ""; void CSgetEngineState() { result(enginestateinfo); } COMMANDN(getEngineState, CSgetEngineState, ""); -VARP(clockdisplay,0,1,1); -VARP(clockcount,0,0,1); +VARP(gametimedisplay,0,1,2); VARP(dbgpos,0,0,1); VARP(showtargetname,0,1,1); VARP(showspeed, 0, 0, 1); @@ -841,7 +840,8 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat string ltime; const char *ltimeformat = getalias("wallclockformat"); bool wallclock = ltimeformat && *ltimeformat; - if(wallclock) formatstring(ltime)("%s", timestring(true, ltimeformat)); + //wallclockformat beginning with "U" shows UTC/GMT time + if(wallclock) formatstring(ltime)("%s", timestring(*ltimeformat != 'U', ltimeformat + int(*ltimeformat == 'U'))); if(showstats) { @@ -928,7 +928,7 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat int cssec = (gametimecurrent+(lastmillis-lastgametimeupdate))/1000; int gtsec = cssec%60; int gtmin = cssec/60; - if(!clockcount) + if(gametimedisplay == 1) { int gtmax = gametimemaximum/60000; gtmin = gtmax - gtmin; @@ -939,7 +939,7 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat } } formatstring(gtime)("%02d:%02d", gtmin, gtsec); - if(clockdisplay) draw_text(gtime, (VIRTW-225-10)*2 - (text_width(gtime)/2 + FONTH/2), 20); + if(gametimedisplay) draw_text(gtime, (VIRTW-225-10)*2 - (text_width(gtime)/2 + FONTH/2), 20); } if(hidevote < 2 && multiplayer(false)) diff --git a/source/src/scoreboard.cpp b/source/src/scoreboard.cpp index 37e96e0c..e55992ce 100644 --- a/source/src/scoreboard.cpp +++ b/source/src/scoreboard.cpp @@ -363,7 +363,7 @@ void renderscores(void *menu, bool init) formatstring(modeline)("\"%s\" on map %s", modestr(gamemode, modeacronyms > 0), fldrprefix ? getclientmap()+strlen("maps/") : getclientmap()); } - extern int minutesremaining, clockcount; + extern int minutesremaining, gametimedisplay; extern string gtime; if((gamemode>1 || (gamemode==0 && (multiplayer(false) || watchingdemo))) && minutesremaining >= 0) @@ -393,8 +393,8 @@ void renderscores(void *menu, bool init) else { concatformatstring(modeline, ", %s", gtime); - if(!clockcount) concatformatstring(modeline, " remaining"); - else concatformatstring(modeline, " / %d:00", gametimemaximum/60000); + if(gametimedisplay == 2) concatformatstring(modeline, " / %d:00", gametimemaximum/60000); + else concatformatstring(modeline, " remaining"); } }