From 8e6fbd9d7bea401b0d6911d8b44f00ba5e5e8715 Mon Sep 17 00:00:00 2001 From: aurhat Date: Sat, 6 Dec 2014 17:53:29 +0100 Subject: [PATCH] Add the clock to scoreboard and change clockdisplay Commit shows time in format mm:ss in scoreboard, instead of "X minutes remaining" info. It also enables the clock default on the HUD and adds "clockcount" variable which let to choose between counting forward or backward in the clocks. DOCREF clockdisplay clockcount --- source/src/clientgame.cpp | 2 +- source/src/renderhud.cpp | 11 ++++++----- source/src/scoreboard.cpp | 11 +++++++++-- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index e0020e5b..0d7c8fd8 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -992,7 +992,7 @@ void timeupdate(int milliscur, int millismax) hudoutf("1 minute left!"); if(identexists("onLastMin")) execute("onLastMin"); } - else if(clockdisplay==0) conoutf(_("time remaining: %d minutes"), minutesremaining); + else if(!clockdisplay) 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 6eeb14fe..7b01b4f1 100644 --- a/source/src/renderhud.cpp +++ b/source/src/renderhud.cpp @@ -800,10 +800,12 @@ string enginestateinfo = ""; void CSgetEngineState() { result(enginestateinfo); } COMMANDN(getEngineState, CSgetEngineState, ""); -VARP(clockdisplay,0,0,2); +VARP(clockdisplay,0,1,1); +VARP(clockcount,0,0,1); VARP(dbgpos,0,0,1); VARP(showtargetname,0,1,1); VARP(showspeed, 0, 0, 1); +string gtime; void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwater) { @@ -970,13 +972,12 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat if(unsavededits) draw_text("U", VIRTW*2 - text_width("U") - FONTH, VIRTH*2 - 5*FONTH/2); } } - if(!intermission && clockdisplay!=0 && lastgametimeupdate!=0) + if(!intermission && lastgametimeupdate!=0) { - string gtime; int cssec = (gametimecurrent+(lastmillis-lastgametimeupdate))/1000; int gtsec = cssec%60; int gtmin = cssec/60; - if(clockdisplay==1) + if(!clockcount) { int gtmax = gametimemaximum/60000; gtmin = gtmax - gtmin; @@ -987,7 +988,7 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat } } formatstring(gtime)("%02d:%02d", gtmin, gtsec); - draw_text(gtime, (VIRTW-225-10)*2 - (text_width(gtime)/2 + FONTH/2), 20); + if(clockdisplay) 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 49fa9737..628f2c8f 100644 --- a/source/src/scoreboard.cpp +++ b/source/src/scoreboard.cpp @@ -355,7 +355,9 @@ void renderscores(void *menu, bool init) formatstring(modeline)("\"%s\" on map %s", modestr(gamemode, modeacronyms > 0), fldrprefix ? getclientmap()+strlen("maps/") : getclientmap()); } - extern int minutesremaining; + extern int minutesremaining, clockcount; + extern string gtime; + if((gamemode>1 || (gamemode==0 && (multiplayer(false) || watchingdemo))) && minutesremaining >= 0) { if(!minutesremaining) @@ -380,7 +382,12 @@ void renderscores(void *menu, bool init) else concatformatstring(modeline, ", \f1%s wins!", scores[0]->name); } } - else concatformatstring(modeline, ", %d %s remaining", minutesremaining, minutesremaining==1 ? "minute" : "minutes"); + else + { + concatformatstring(modeline, ", %s", gtime); + if(!clockcount) concatformatstring(modeline, " remaining"); + else concatformatstring(modeline, " / %d:00", gametimemaximum/60000); + } } if(multiplayer(false))