X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fclient%2Fhud%2Fpanel%2Fmodicons.qc;h=2d6774e2efce12d7a94b2f14ba160f7a5c2cc712;hb=4f133bdb70d13143f2ce4b9de097744371c1f92a;hp=8fab80ed6170b0dc93e19877d994f64be9be6f56;hpb=2bb4c42f723576432bb2c80e0afe0a09ec7350f3;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/client/hud/panel/modicons.qc b/qcsrc/client/hud/panel/modicons.qc index 8fab80ed6..2d6774e2e 100644 --- a/qcsrc/client/hud/panel/modicons.qc +++ b/qcsrc/client/hud/panel/modicons.qc @@ -1,9 +1,16 @@ +#include "modicons.qh" + +#include +#include +#include // TODO: remove + // Mod icons panel (#10) bool mod_active; // is there any active mod icon? void DrawCAItem(vector myPos, vector mySize, float aspect_ratio, int layout, int i) { + TC(int, layout); TC(int, i); int stat = -1; string pic = ""; vector color = '0 0 0'; @@ -101,6 +108,7 @@ void HUD_Mod_CTF_Reset() redflag_statuschange_time = blueflag_statuschange_time = yellowflag_statuschange_time = pinkflag_statuschange_time = neutralflag_statuschange_time = 0; } +int autocvar__teams_available; void HUD_Mod_CTF(vector pos, vector mySize) { vector redflag_pos, blueflag_pos, yellowflag_pos, pinkflag_pos, neutralflag_pos; @@ -108,12 +116,15 @@ void HUD_Mod_CTF(vector pos, vector mySize) float f; // every function should have that int redflag, blueflag, yellowflag, pinkflag, neutralflag; // current status - float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime, yellowflag_statuschange_elapsedtime, pinkflag_statuschange_elapsedtime, neutralflag_statuschange_elapsedtime; // time since the status changed + float redflag_statuschange_elapsedtime = 0, blueflag_statuschange_elapsedtime = 0, yellowflag_statuschange_elapsedtime = 0, pinkflag_statuschange_elapsedtime = 0, neutralflag_statuschange_elapsedtime = 0; // time since the status changed bool ctf_oneflag; // one-flag CTF mode enabled/disabled + bool ctf_stalemate; // currently in stalemate int stat_items = STAT(CTF_FLAGSTATUS); float fs, fs2, fs3, size1, size2; vector e1, e2; + int nteams = autocvar__teams_available; + redflag = (stat_items/CTF_RED_FLAG_TAKEN) & 3; blueflag = (stat_items/CTF_BLUE_FLAG_TAKEN) & 3; yellowflag = (stat_items/CTF_YELLOW_FLAG_TAKEN) & 3; @@ -122,27 +133,29 @@ void HUD_Mod_CTF(vector pos, vector mySize) ctf_oneflag = (stat_items & CTF_FLAG_NEUTRAL); - mod_active = (redflag || blueflag || yellowflag || pinkflag || neutralflag); + ctf_stalemate = (stat_items & CTF_STALEMATE); + + mod_active = (redflag || blueflag || yellowflag || pinkflag || neutralflag || (stat_items & CTF_SHIELDED)); if (autocvar__hud_configure) { redflag = 1; blueflag = 2; - if (team_count >= 3) + if (nteams & BIT(2)) yellowflag = 2; - if (team_count >= 4) + if (nteams & BIT(3)) pinkflag = 3; ctf_oneflag = neutralflag = 0; // disable neutral flag in hud editor? } // when status CHANGES, set old status into prevstatus and current status into status - #define X(team) do { \ + #define X(team) MACRO_BEGIN { \ if (team##flag != team##flag_prevframe) { \ team##flag_statuschange_time = time; \ team##flag_prevstatus = team##flag_prevframe; \ team##flag_prevframe = team##flag; \ } \ team##flag_statuschange_elapsedtime = time - team##flag_statuschange_time; \ - } while (0) + } MACRO_END X(red); X(blue); X(yellow); @@ -160,10 +173,10 @@ void HUD_Mod_CTF(vector pos, vector mySize) const float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz #define X(team, cond) \ - string team##_icon, team##_icon_prevstatus; \ + string team##_icon = string_null, team##_icon_prevstatus = string_null; \ int team##_alpha, team##_alpha_prevstatus; \ team##_alpha = team##_alpha_prevstatus = 1; \ - do { \ + MACRO_BEGIN { \ switch (team##flag) { \ case 1: team##_icon = "flag_" #team "_taken"; break; \ case 2: team##_icon = "flag_" #team "_lost"; break; \ @@ -190,19 +203,25 @@ void HUD_Mod_CTF(vector pos, vector mySize) } \ break; \ } \ - } while (0) - X(red, myteam != NUM_TEAM_1); - X(blue, myteam != NUM_TEAM_2); - X(yellow, myteam != NUM_TEAM_3); - X(pink, myteam != NUM_TEAM_4); - X(neutral, true); + } MACRO_END + X(red, myteam != NUM_TEAM_1 && (nteams & BIT(0))); + X(blue, myteam != NUM_TEAM_2 && (nteams & BIT(1))); + X(yellow, myteam != NUM_TEAM_3 && (nteams & BIT(2))); + X(pink, myteam != NUM_TEAM_4 && (nteams & BIT(3))); + X(neutral, ctf_oneflag); #undef X + int tcount = 2; + if(nteams & BIT(2)) + tcount = 3; + if(nteams & BIT(3)) + tcount = 4; + if (ctf_oneflag) { // hacky, but these aren't needed red_icon = red_icon_prevstatus = blue_icon = blue_icon_prevstatus = yellow_icon = yellow_icon_prevstatus = pink_icon = pink_icon_prevstatus = string_null; fs = fs2 = fs3 = 1; - } else switch (team_count) { + } else switch (tcount) { default: case 2: fs = 0.5; fs2 = 0.5; fs3 = 0.5; break; case 3: fs = 1; fs2 = 0.35; fs3 = 0.35; break; @@ -255,13 +274,15 @@ void HUD_Mod_CTF(vector pos, vector mySize) neutralflag_pos = pos; flag_size = e1 * fs * size1 + e2 * size2; - #define X(team) do { \ + #define X(team) MACRO_BEGIN { \ f = bound(0, team##flag_statuschange_elapsedtime * 2, 1); \ + if (team##_icon && ctf_stalemate) \ + drawpic_aspect_skin(team##flag_pos, "flag_stalemate", flag_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); \ if (team##_icon_prevstatus && f < 1) \ drawpic_aspect_skin_expanding(team##flag_pos, team##_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * team##_alpha_prevstatus, DRAWFLAG_NORMAL, f); \ if (team##_icon) \ drawpic_aspect_skin(team##flag_pos, team##_icon, flag_size, '1 1 1', panel_fg_alpha * team##_alpha * f, DRAWFLAG_NORMAL); \ - } while (0) + } MACRO_END X(red); X(blue); X(yellow); @@ -415,7 +436,7 @@ void HUD_Mod_Keepaway(vector pos, vector mySize) float BLINK_FREQ = 5; float kaball_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); - int stat_items = getstati(STAT_ITEMS, 0, 24); + int stat_items = STAT(ITEMS); int kaball = (stat_items/IT_KEY1) & 1; if(kaball != kaball_prevstatus) @@ -451,7 +472,7 @@ void HUD_Mod_NexBall(vector pos, vector mySize) float nb_pb_starttime, dt, p; int stat_items; - stat_items = getstati(STAT_ITEMS, 0, 24); + stat_items = STAT(ITEMS); nb_pb_starttime = STAT(NB_METERSTART); if (stat_items & IT_KEY1) @@ -484,16 +505,36 @@ float srecordtime_change_time; // time when srecordtime last changed 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); + 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 t, score; - float f; // yet another function has this - score = me.(scores[ps_primary]); + float score; + score = me.(scores(ps_primary)); - if(!(scores_flags[ps_primary] & SFL_TIME) || teamplay) // race/cts record display on HUD + if(!(scores_flags(ps_primary) & SFL_TIME) || teamplay) // race/cts record display on HUD return; // no records in the actual race // clientside personal record @@ -502,13 +543,13 @@ void HUD_Mod_Race(vector pos, vector mySize) rr = CTS_RECORD; else rr = RACE_RECORD; - t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time"))); + float t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time"))); if(score && (score < t || !t)) { 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 +573,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(pos, _("Personal best"), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f); - drawstring_aspect_expanding(pos + 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 +583,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; @@ -624,6 +648,7 @@ void HUD_Mod_Race(vector pos, vector mySize) void DrawDomItem(vector myPos, vector mySize, float aspect_ratio, int layout, int i) { + TC(int, layout); TC(int, i); float stat = -1; string pic = ""; vector color = '0 0 0'; @@ -758,6 +783,10 @@ void HUD_ModIcons() else mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1); + if (autocvar_hud_panel_modicons_dynamichud) + HUD_Scale_Enable(); + else + HUD_Scale_Disable(); if(mod_alpha) HUD_Panel_DrawBg(mod_alpha);