From: terencehill Date: Sun, 13 Mar 2016 11:17:06 +0000 (+0100) Subject: Move 2 panel specific functions to their relative files X-Git-Tag: xonotic-v0.8.2~1015^2~2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=b58d502bc9feedd51eb1d29c6cad3f1b1f03d874;p=xonotic%2Fxonotic-data.pk3dir.git Move 2 panel specific functions to their relative files --- diff --git a/qcsrc/client/hud/hud.qc b/qcsrc/client/hud/hud.qc index b0f2b9ea6..619533bc3 100644 --- a/qcsrc/client/hud/hud.qc +++ b/qcsrc/client/hud/hud.qc @@ -112,85 +112,6 @@ vector HUD_GetTableSize_BestItemAR(int item_count, vector psize, float item_aspe return eX * best_columns + eY * best_rows; } -// return the string of the onscreen race timer -string MakeRaceString(int cp, float mytime, float theirtime, float lapdelta, string theirname) -{ - string col; - string timestr; - string cpname; - string lapstr; - lapstr = ""; - - if(theirtime == 0) // goal hit - { - if(mytime > 0) - { - timestr = strcat("+", ftos_decimals(+mytime, TIME_DECIMALS)); - col = "^1"; - } - else if(mytime == 0) - { - timestr = "+0.0"; - col = "^3"; - } - else - { - timestr = strcat("-", ftos_decimals(-mytime, TIME_DECIMALS)); - col = "^2"; - } - - if(lapdelta > 0) - { - lapstr = sprintf(_(" (-%dL)"), lapdelta); - col = "^2"; - } - else if(lapdelta < 0) - { - lapstr = sprintf(_(" (+%dL)"), -lapdelta); - col = "^1"; - } - } - else if(theirtime > 0) // anticipation - { - if(mytime >= theirtime) - timestr = strcat("+", ftos_decimals(mytime - theirtime, TIME_DECIMALS)); - else - timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(theirtime)); - col = "^3"; - } - else - { - col = "^7"; - timestr = ""; - } - - if(cp == 254) - cpname = _("Start line"); - else if(cp == 255) - cpname = _("Finish line"); - else if(cp) - cpname = sprintf(_("Intermediate %d"), cp); - else - cpname = _("Finish line"); - - if(theirtime < 0) - return strcat(col, cpname); - else if(theirname == "") - return strcat(col, sprintf("%s (%s)", cpname, timestr)); - else - return strcat(col, sprintf("%s (%s %s)", cpname, timestr, strcat(theirname, col, lapstr))); -} - -// Check if the given name already exist in race rankings? In that case, where? (otherwise return 0) -int race_CheckName(string net_name) -{ - int i; - for (i=RANKINGS_CNT-1;i>=0;--i) - if(grecordholder[i] == net_name) - return i+1; - return 0; -} - /* ================== HUD panels diff --git a/qcsrc/client/hud/panel/modicons.qc b/qcsrc/client/hud/panel/modicons.qc index dcc4a8b09..facb7cb94 100644 --- a/qcsrc/client/hud/panel/modicons.qc +++ b/qcsrc/client/hud/panel/modicons.qc @@ -485,6 +485,16 @@ float race_status_time; int race_status_prev; string race_status_name_prev; +// Check if the given name already exist in race rankings? In that case, where? (otherwise return 0) +int race_CheckName(string net_name) +{ + int i; + for (i=RANKINGS_CNT-1;i>=0;--i) + if(grecordholder[i] == net_name) + return i+1; + return 0; +} + void race_showTime(string text, vector pos, vector timeText_ofs, float theTime, vector textSize, float f) { drawstring_aspect(pos, text, textSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); diff --git a/qcsrc/client/hud/panel/racetimer.qc b/qcsrc/client/hud/panel/racetimer.qc index 1fa216b96..ca45f352f 100644 --- a/qcsrc/client/hud/panel/racetimer.qc +++ b/qcsrc/client/hud/panel/racetimer.qc @@ -1,4 +1,74 @@ /** Race timer (#8) */ + +// return the string of the onscreen race timer +string MakeRaceString(int cp, float mytime, float theirtime, float lapdelta, string theirname) +{ + string col; + string timestr; + string cpname; + string lapstr; + lapstr = ""; + + if(theirtime == 0) // goal hit + { + if(mytime > 0) + { + timestr = strcat("+", ftos_decimals(+mytime, TIME_DECIMALS)); + col = "^1"; + } + else if(mytime == 0) + { + timestr = "+0.0"; + col = "^3"; + } + else + { + timestr = strcat("-", ftos_decimals(-mytime, TIME_DECIMALS)); + col = "^2"; + } + + if(lapdelta > 0) + { + lapstr = sprintf(_(" (-%dL)"), lapdelta); + col = "^2"; + } + else if(lapdelta < 0) + { + lapstr = sprintf(_(" (+%dL)"), -lapdelta); + col = "^1"; + } + } + else if(theirtime > 0) // anticipation + { + if(mytime >= theirtime) + timestr = strcat("+", ftos_decimals(mytime - theirtime, TIME_DECIMALS)); + else + timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(theirtime)); + col = "^3"; + } + else + { + col = "^7"; + timestr = ""; + } + + if(cp == 254) + cpname = _("Start line"); + else if(cp == 255) + cpname = _("Finish line"); + else if(cp) + cpname = sprintf(_("Intermediate %d"), cp); + else + cpname = _("Finish line"); + + if(theirtime < 0) + return strcat(col, cpname); + else if(theirname == "") + return strcat(col, sprintf("%s (%s)", cpname, timestr)); + else + return strcat(col, sprintf("%s (%s %s)", cpname, timestr, strcat(theirname, col, lapstr))); +} + void HUD_RaceTimer () { if(!autocvar__hud_configure)