From 6085b1f652527a9d7e391f79bcbfbcb9c5923c2c Mon Sep 17 00:00:00 2001 From: terencehill Date: Sun, 13 Mar 2016 10:10:18 +0100 Subject: [PATCH] HUD_Mod_Race: cleanup --- qcsrc/client/hud/panel/modicons.qc | 39 ++++++++++++------------------ 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/qcsrc/client/hud/panel/modicons.qc b/qcsrc/client/hud/panel/modicons.qc index 74a34981b..dcc4a8b09 100644 --- a/qcsrc/client/hud/panel/modicons.qc +++ b/qcsrc/client/hud/panel/modicons.qc @@ -484,13 +484,23 @@ float srecordtime_change_time; // time when srecordtime last changed float race_status_time; int race_status_prev; string race_status_name_prev; + +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); + drawstring_aspect(pos + timeText_ofs, TIME_ENCODED_TOSTRING(theTime), textSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + if (f < 1) { + drawstring_aspect_expanding(pos, text, textSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f); + drawstring_aspect_expanding(pos + timeText_ofs, TIME_ENCODED_TOSTRING(theTime), textSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f); + } +} + void HUD_Mod_Race(vector pos, vector mySize) { mod_active = 1; // race should never hide the mod icons panel entity me; me = playerslots[player_localnum]; float score; - float f; // yet another function has this score = me.(scores[ps_primary]); if(!(scores_flags[ps_primary] & SFL_TIME) || teamplay) // race/cts record display on HUD @@ -508,7 +518,7 @@ void HUD_Mod_Race(vector pos, vector mySize) db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score)); if(autocvar_cl_autodemo_delete_keeprecords) { - f = autocvar_cl_autodemo_delete; + float f = autocvar_cl_autodemo_delete; f &= ~1; cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record! } @@ -532,18 +542,9 @@ void HUD_Mod_Race(vector pos, vector mySize) textPos = pos + eY * 0.5 * max(0, mySize.y/2 - squareSize) + eX * 0.5 * (mySize.x - squareSize); medalPos = pos + eY * 0.5 * max(0, mySize.y/2 - squareSize) + eY * 0.5 * mySize.y + eX * 0.5 * (mySize.x - squareSize); } + vector textSize = eX * squareSize + eY * 0.25 * squareSize; - f = time - crecordtime_change_time; - - if (f > 1) { - drawstring_aspect(textPos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); - drawstring_aspect(textPos + eY * 0.25 * squareSize, TIME_ENCODED_TOSTRING(t), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); - } else { - drawstring_aspect(textPos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); - drawstring_aspect(textPos + eY * 0.25 * squareSize, TIME_ENCODED_TOSTRING(t), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); - drawstring_aspect_expanding(textPos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f); - drawstring_aspect_expanding(textPos + eY * 0.25 * squareSize, TIME_ENCODED_TOSTRING(t), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f); - } + race_showTime(_("Personal best"), textPos, eY * 0.25 * squareSize, t, textSize, time - crecordtime_change_time); // server record t = race_server_record; @@ -551,17 +552,9 @@ void HUD_Mod_Race(vector pos, vector mySize) srecordtime_prev = t; srecordtime_change_time = time; } - f = time - srecordtime_change_time; - if (f > 1) { - drawstring_aspect(textPos + eY * 0.5 * squareSize, _("Server best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); - drawstring_aspect(textPos + eY * 0.75 * squareSize, TIME_ENCODED_TOSTRING(t), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); - } else { - drawstring_aspect(textPos + eY * 0.5 * squareSize, _("Server best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); - drawstring_aspect(textPos + eY * 0.75 * squareSize, TIME_ENCODED_TOSTRING(t), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); - drawstring_aspect_expanding(textPos + eY * 0.5 * squareSize, _("Server best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f); - drawstring_aspect_expanding(textPos + eY * 0.75 * squareSize, TIME_ENCODED_TOSTRING(t), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f); - } + textPos += eY * 0.5 * squareSize; + race_showTime(_("Server best"), textPos, eY * 0.25 * squareSize, t, textSize, time - srecordtime_change_time); if (race_status != race_status_prev || race_status_name != race_status_name_prev) { race_status_time = time + 5; -- 2.39.2