#include "modicons.qh"
+#include <client/miscfunctions.qh>
+#include <client/autocvars.qh>
#include <common/mapinfo.qh>
#include <common/ent_cs.qh>
-#include <server/mutators/mutator/gamemode_ctf.qh> // TODO: remove
+#include <common/scores.qh>
+#include <common/gamemodes/_mod.qh>
// Mod icons (#10)
void DrawCAItem(vector myPos, vector mySize, float aspect_ratio, int layout, int i)
{
- TC(int, layout); TC(int, i);
+ TC(int, layout); TC(int, i);
int stat = -1;
string pic = "";
vector color = '0 0 0';
if(layout)
{
- drawpic_aspect_skin(myPos, pic, vec2(0.7 * mySize.x, mySize.y), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
- drawstring_aspect(myPos + eX * 0.7 * mySize.x, ftos(stat), vec2(0.3 * mySize.x, mySize.y), color, panel_fg_alpha, DRAWFLAG_NORMAL);
+ drawpic_aspect_skin(myPos, pic, vec2(0.5 * mySize.x, mySize.y), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+ drawstring_aspect(myPos + eX * 0.5 * mySize.x, ftos(stat), vec2(0.5 * mySize.x, mySize.y), color, panel_fg_alpha, DRAWFLAG_NORMAL);
}
else
drawstring_aspect(myPos, ftos(stat), mySize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
mod_active = 1; // required in each mod function that always shows something
int layout;
- if(gametype == MAPINFO_TYPE_CA)
+ if(ISGAMETYPE(CA))
layout = autocvar_hud_panel_modicons_ca_layout;
- else //if(gametype == MAPINFO_TYPE_FREEZETAG)
+ else //if(ISGAMETYPE(FREEZETAG))
layout = autocvar_hud_panel_modicons_freezetag_layout;
int rows, columns;
float aspect_ratio;
}
// when status CHANGES, set old status into prevstatus and current status into status
- #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; \
- } MACRO_END
+ #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; \
+ MACRO_END
X(red);
X(blue);
X(yellow);
string team##_icon = string_null, team##_icon_prevstatus = string_null; \
int team##_alpha, team##_alpha_prevstatus; \
team##_alpha = team##_alpha_prevstatus = 1; \
- MACRO_BEGIN { \
+ MACRO_BEGIN \
switch (team##flag) { \
case 1: team##_icon = "flag_" #team "_taken"; break; \
case 2: team##_icon = "flag_" #team "_lost"; break; \
} \
break; \
} \
- } MACRO_END
+ 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)));
neutralflag_pos = pos;
flag_size = e1 * fs * size1 + e2 * size2;
- #define X(team) MACRO_BEGIN { \
+ #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); \
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); \
- } MACRO_END
+ MACRO_END
X(red);
X(blue);
X(yellow);
// 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(strdecolorize(grecordholder[i]) == strdecolorize(net_name))
- return i+1;
- return 0;
+ int rank = 0;
+ string zoned_name = strzone(strdecolorize(entcs_GetName(player_localnum)));
+ for (int i = RANKINGS_CNT - 1; i >= 0; --i)
+ if (strdecolorize(grecordholder[i]) == zoned_name)
+ {
+ rank = i + 1;
+ break;
+ }
+ strfree(zoned_name);
+ return rank;
}
void race_showTime(string text, vector pos, vector timeText_ofs, float theTime, vector textSize, float 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;
- score = me.(scores(ps_primary));
+ entity me = playerslots[player_localnum];
+ float score = me.(scores(ps_primary));
if(!(scores_flags(ps_primary) & SFL_TIME) || teamplay) // race/cts record display on HUD
+ {
+ mod_active = 0; // hide it in this case!
return; // no records in the actual race
+ }
+
+ mod_active = 1;
// clientside personal record
string rr;
- if(gametype == MAPINFO_TYPE_CTS)
+ if(ISGAMETYPE(CTS))
rr = CTS_RECORD;
else
rr = RACE_RECORD;
squareSize = min(mySize.y, mySize.x/2);
vector ofs = vec2(0.5 * max(0, mySize.x/2 - squareSize), 0.5 * (mySize.y - squareSize));
textPos = pos + ofs;
- ofs.y += 0.5 * mySize.x;
+ ofs.x += 0.5 * mySize.x;
medalPos = pos + ofs;
} else {
// text on top
if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
race_status_time = time + 5;
race_status_prev = race_status;
- if (race_status_name_prev)
- strunzone(race_status_name_prev);
- race_status_name_prev = strzone(race_status_name);
+ strcpy(race_status_name_prev, race_status_name);
}
// race "awards"
- float a;
- a = bound(0, race_status_time - time, 1);
-
- string s;
- s = textShortenToWidth(ColorTranslateRGB(race_status_name), squareSize, '1 1 0' * 0.1 * squareSize, stringwidth_colors);
+ float a = bound(0, race_status_time - time, 1);
+ string s = textShortenToWidth(ColorTranslateRGB(race_status_name), squareSize, '1 1 0' * 0.1 * squareSize, stringwidth_colors);
- float rank;
+ float rank = 0;
if(race_status > 0)
rank = race_CheckName(race_status_name);
- else
- rank = 0;
- string rankname;
- rankname = count_ordinal(rank);
-
- vector namepos;
- namepos = medalPos + '0 0.8 0' * squareSize;
- vector rankpos;
- rankpos = medalPos + '0 0.15 0' * squareSize;
+ string rankname = count_ordinal(rank);
+ vector namepos = medalPos + '0 0.8 0' * squareSize;
+ vector rankpos = medalPos + '0 0.15 0' * squareSize;
if(race_status == 0)
drawpic_aspect_skin(medalPos, "race_newfail", '1 1 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
if (race_status_time - time <= 0) {
race_status_prev = -1;
race_status = -1;
- if(race_status_name)
- strunzone(race_status_name);
- race_status_name = string_null;
- if(race_status_name_prev)
- strunzone(race_status_name_prev);
- race_status_name_prev = string_null;
+ strfree(race_status_name);
+ strfree(race_status_name_prev);
}
}
void DrawDomItem(vector myPos, vector mySize, float aspect_ratio, int layout, int i)
{
- TC(int, layout); TC(int, i);
+ TC(int, layout); TC(int, i);
float stat = -1;
string pic = "";
vector color = '0 0 0';