+#include "hud.qh"
+#include "_all.qh"
+
+#include "hud_config.qh"
#include "scoreboard.qh"
+#include "sortlist.qh"
#include "teamradar.qh"
+#include "t_items.qh"
+
#include "../common/buffs.qh"
+#include "../common/constants.qh"
#include "../common/counting.qh"
+#include "../common/deathtypes.qh"
#include "../common/mapinfo.qh"
#include "../common/nades.qh"
-#include "../server/t_items.qh"
+
+#include "../server/mutators/gamemode_ctf.qh"
+
+#include "../common/stats.qh"
+
+#include "../csqcmodellib/cl_player.qh"
+
+#include "../warpzonelib/mathlib.qh"
/*
==================
return bound(1, floor((sqrt(4 * item_aspect * aspect * item_count + aspect * aspect) + aspect + 0.5) / 2), item_count);
}
-vector HUD_GetTableSize(int item_count, vector psize, float item_aspect)
+vector HUD_GetTableSize_BestItemAR(int item_count, vector psize, float item_aspect)
{
float columns, rows;
float ratio, best_ratio = 0;
vector color;
// check to see if we want to continue
- if(hud != HUD_NORMAL) { return; }
+ if(intermission == 2) return;
+ if(hud != HUD_NORMAL) return;
if(!autocvar__hud_configure)
{
// update generic hud functions
HUD_Panel_UpdateCvars();
- draw_beginBoldFont();
-
// figure out weapon order (how the weapons are sorted) // TODO make this configurable
if(weaponorder_bypriority != autocvar_cl_weaponpriority || !weaponorder[0])
{
// might as well commit suicide now, no reason to live ;)
if (weapon_count == 0)
- {
- draw_endBoldFont();
return;
- }
vector old_panel_size = panel_size;
vector padded_panel_size = panel_size - '2 2 0' * panel_bg_padding;
// get the all-weapons layout
- vector table_size = HUD_GetTableSize(WEP_COUNT, padded_panel_size, aspect);
+ vector table_size = HUD_GetTableSize_BestItemAR(WEP_COUNT, padded_panel_size, aspect);
columns = table_size.x;
rows = table_size.y;
weapon_size.x = padded_panel_size.x / columns;
HUD_Panel_DrawBg(1);
if(center.x == -1)
- {
- draw_endBoldFont();
return;
- }
if(panel_bg_padding)
{
if(!rows) // if rows is > 0 onlyowned code has already updated these vars
{
- vector table_size = HUD_GetTableSize(WEP_COUNT, panel_size, aspect);
+ vector table_size = HUD_GetTableSize_BestItemAR(WEP_COUNT, panel_size, aspect);
columns = table_size.x;
rows = table_size.y;
weapon_size.x = panel_size.x / columns;
// draw items
row = column = 0;
vector label_size = '1 1 0' * min(weapon_size.x, weapon_size.y) * bound(0, autocvar_hud_panel_weapons_label_scale, 1);
+ vector noncurrent_pos = '0 0 0';
+ vector noncurrent_size = weapon_size * bound(0, autocvar_hud_panel_weapons_noncurrent_scale, 1);
+ float noncurrent_alpha = panel_fg_alpha * bound(0, autocvar_hud_panel_weapons_noncurrent_alpha, 1);
+ bool isCurrent;
+
for(i = 0; i <= WEP_LAST-WEP_FIRST; ++i)
{
// retrieve information about the current weapon to be drawn
self = weaponorder[i];
weapon_id = self.impulse;
+ isCurrent = (self.weapon == switchweapon);
// skip if this weapon doesn't exist
if(!self || weapon_id < 0) { continue; }
continue;
// figure out the drawing position of weapon
- weapon_pos = (panel_pos
- + eX * column * weapon_size.x
- + eY * row * weapon_size.y);
+ weapon_pos = (panel_pos + eX * column * weapon_size.x + eY * row * weapon_size.y);
+ noncurrent_pos.x = weapon_pos.x + (weapon_size.x - noncurrent_size.x) / 2;
+ noncurrent_pos.y = weapon_pos.y + (weapon_size.y - noncurrent_size.y) / 2;
// draw background behind currently selected weapon
- if(self.weapon == switchweapon)
+ if(isCurrent)
drawpic_aspect_skin(weapon_pos, "weapon_current_bg", weapon_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
// draw the weapon accuracy
if(weapons_stat & WepSet_FromWeapon(self.weapon))
{
// draw the weapon image
- drawpic_aspect_skin(weapon_pos, self.model2, weapon_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+ if(isCurrent)
+ drawpic_aspect_skin(weapon_pos, self.model2, weapon_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+ else
+ drawpic_aspect_skin(noncurrent_pos, self.model2, noncurrent_size, '1 1 1', noncurrent_alpha, DRAWFLAG_NORMAL);
// draw weapon label string
switch(autocvar_hud_panel_weapons_label)
}
else // draw a "ghost weapon icon" if you don't have the weapon
{
- drawpic_aspect_skin(weapon_pos, self.model2, weapon_size, '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
+ drawpic_aspect_skin(noncurrent_pos, self.model2, noncurrent_size, '0.2 0.2 0.2', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
}
// draw the complain message
}
}
}
-
- draw_endBoldFont();
}
// Ammo (#1)
-void DrawNadeScoreBar(vector myPos, vector mySize, vector color)
+void DrawNadeProgressBar(vector myPos, vector mySize, float progress, vector color)
{
-
HUD_Panel_DrawProgressBar(
myPos + eX * autocvar_hud_panel_ammo_progressbar_xoffset * mySize.x,
mySize - eX * autocvar_hud_panel_ammo_progressbar_xoffset * mySize.x,
autocvar_hud_panel_ammo_progressbar_name,
- getstatf(STAT_NADE_BONUS_SCORE), 0, 0, color,
+ progress, 0, 0, color,
autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
-
}
void DrawAmmoNades(vector myPos, vector mySize, bool draw_expanding, float expand_time)
{
- float theAlpha = 1, a, b;
- vector nade_color, picpos, numpos;
-
- nade_color = Nade_Color(getstati(STAT_NADE_BONUS_TYPE));
+ float bonusNades = getstatf(STAT_NADE_BONUS);
+ float bonusProgress = getstatf(STAT_NADE_BONUS_SCORE);
+ float bonusType = getstati(STAT_NADE_BONUS_TYPE);
+ vector nadeColor = Nade_Color(bonusType);
+ string nadeIcon = Nade_Icon(bonusType);
- a = getstatf(STAT_NADE_BONUS);
- b = getstatf(STAT_NADE_BONUS_SCORE);
+ vector iconPos, textPos;
if(autocvar_hud_panel_ammo_iconalign)
{
- numpos = myPos;
- picpos = myPos + eX * 2 * mySize.y;
+ iconPos = myPos + eX * 2 * mySize.y;
+ textPos = myPos;
}
else
{
- numpos = myPos + eX * mySize.y;
- picpos = myPos;
+ iconPos = myPos;
+ textPos = myPos + eX * mySize.y;
}
- DrawNadeScoreBar(myPos, mySize, nade_color);
-
- if(b > 0 || a > 0)
+ if(bonusNades > 0 || bonusProgress > 0)
{
+ DrawNadeProgressBar(myPos, mySize, bonusProgress, nadeColor);
+
if(autocvar_hud_panel_ammo_text)
- drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
+ drawstring_aspect(textPos, ftos(bonusNades), eX * (2/3) * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
if(draw_expanding)
- drawpic_aspect_skin_expanding(picpos, "nade_nbg", '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL, expand_time);
+ drawpic_aspect_skin_expanding(iconPos, nadeIcon, '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, expand_time);
- drawpic_aspect_skin(picpos, "nade_bg" , '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
- drawpic_aspect_skin(picpos, "nade_nbg" , '1 1 0' * mySize.y, nade_color, panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
+ drawpic_aspect_skin(iconPos, nadeIcon, '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
}
}
float nade_statuschange_time;
void HUD_Ammo(void)
{
+ if(intermission == 2) return;
if(hud != HUD_NORMAL) return;
if(!autocvar__hud_configure)
{
void HUD_Powerups(void)
{
float strength_time, shield_time, superweapons_time;
+ if(intermission == 2) return;
if(!autocvar__hud_configure)
{
if(!autocvar_hud_panel_powerups) return;
// Health/armor (#3)
//
-// prev_* vars contain the health/armor at the previous FRAME
-// set to -1 when player is dead or was not playing
-int prev_health, prev_armor;
-float health_damagetime, armor_damagetime;
-int health_beforedamage, armor_beforedamage;
-// old_p_* vars keep track of previous values when smoothing value changes of the progressbar
-int old_p_health, old_p_armor;
-float old_p_healthtime, old_p_armortime;
-// prev_p_* vars contain the health/armor progressbar value at the previous FRAME
-// set to -1 to forcedly stop effects when we switch spectated player (e.g. from playerX: 70h to playerY: 50h)
-int prev_p_health, prev_p_armor;
void HUD_HealthArmor(void)
{
int armor, health, fuel;
+ if(intermission == 2) return;
if(!autocvar__hud_configure)
{
if(!autocvar_hud_panel_healtharmor) return;
}
HUD_Panel_UpdateCvars();
+
+ draw_beginBoldFont();
+
vector pos, mySize;
pos = panel_pos;
mySize = panel_size;
HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", fuel/100, is_vertical, fuel_baralign, autocvar_hud_progressbar_fuel_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
}
}
+
+ draw_endBoldFont();
}
// Notification area (#4)
void HUD_Notify(void)
{
+ if(intermission == 2) return;
if (!autocvar__hud_configure)
if (!autocvar_hud_panel_notify)
return;
void HUD_Timer(void)
{
+ if(intermission == 2) return;
if(!autocvar__hud_configure)
{
if(!autocvar_hud_panel_timer) return;
//
void HUD_Radar(void)
{
+ if(intermission == 2) return;
if (!autocvar__hud_configure)
{
if (hud_panel_radar_maximized)
void HUD_Score(void)
{
+ if(intermission == 2) return;
if(!autocvar__hud_configure)
{
if(!autocvar_hud_panel_score) return;
vector distribution_color;
entity tm, pl, me;
- me = playerslots[player_localentnum - 1];
+ me = playerslots[current_player];
if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
string timer, distrtimer;
//
void HUD_RaceTimer (void)
{
+ if(intermission == 2) return;
if(!autocvar__hud_configure)
{
if(!autocvar_hud_panel_racetimer) return;
HUD_Panel_UpdateCvars();
- draw_beginBoldFont();
-
vector pos, mySize;
pos = panel_pos;
mySize = panel_size;
if(autocvar__hud_configure)
{
s = "0:13:37";
+ draw_beginBoldFont();
drawstring(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(s, false, '0.60 0.60 0' * mySize.y), s, '0.60 0.60 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+ draw_endBoldFont();
s = _("^1Intermediate 1 (+15.42)");
drawcolorcodedstring(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(s, true, '1 1 0' * 0.20 * mySize.y) + eY * 0.60 * mySize.y, s, '1 1 0' * 0.20 * mySize.y, panel_fg_alpha, DRAWFLAG_NORMAL);
s = sprintf(_("^1PENALTY: %.1f (%s)"), 2, "missing a checkpoint");
}
}
+ draw_beginBoldFont();
+
if(forcetime != "")
{
a = bound(0, (time - race_checkpointtime) / 0.5, 1);
s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
drawstring(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(s, false, '0.6 0.6 0' * mySize.y), s, '0.6 0.6 0' * mySize.y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
}
+
+ draw_endBoldFont();
}
else
{
}
}
}
-
- draw_endBoldFont();
}
// Vote window (#9)
//
-int vote_yescount;
-int vote_nocount;
-int vote_needed;
-int vote_highlighted; // currently selected vote
-
-int vote_active; // is there an active vote?
-int vote_prev; // previous state of vote_active to check for a change
-float vote_alpha;
-float vote_change; // "time" when vote_active changed
void HUD_Vote(void)
{
+ if(intermission == 2) return;
if(autocvar_cl_allow_uid2name == -1 && (gametype == MAPINFO_TYPE_CTS || gametype == MAPINFO_TYPE_RACE || (serverflags & SERVERFLAG_PLAYERSTATS)))
{
vote_active = 1;
}
// CTF HUD modicon section
-float redflag_prevframe, blueflag_prevframe; // status during previous frame
-int redflag_prevstatus, blueflag_prevstatus; // last remembered status
-float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
+int redflag_prevframe, blueflag_prevframe, yellowflag_prevframe, pinkflag_prevframe, neutralflag_prevframe; // status during previous frame
+int redflag_prevstatus, blueflag_prevstatus, yellowflag_prevstatus, pinkflag_prevstatus, neutralflag_prevstatus; // last remembered status
+float redflag_statuschange_time, blueflag_statuschange_time, yellowflag_statuschange_time, pinkflag_statuschange_time, neutralflag_statuschange_time; // time when the status changed
void HUD_Mod_CTF_Reset(void)
{
- redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
+ redflag_prevstatus = blueflag_prevstatus = yellowflag_prevstatus = pinkflag_prevstatus = neutralflag_prevstatus = 0;
+ redflag_prevframe = blueflag_prevframe = yellowflag_prevframe = pinkflag_prevframe = neutralflag_prevframe = 0;
+ redflag_statuschange_time = blueflag_statuschange_time = yellowflag_statuschange_time = pinkflag_statuschange_time = neutralflag_statuschange_time = 0;
}
void HUD_Mod_CTF(vector pos, vector mySize)
{
- vector redflag_pos, blueflag_pos;
+ vector redflag_pos, blueflag_pos, yellowflag_pos, pinkflag_pos, neutralflag_pos;
vector flag_size;
float f; // every function should have that
- int redflag, blueflag; // current status
- float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
- int stat_items;
+ 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
+ bool ctf_oneflag; // one-flag CTF mode enabled/disabled
+ int stat_items = getstati(STAT_CTF_FLAGSTATUS, 0, 24);
+ float fs, fs2, fs3, size1, size2;
+ vector e1, e2;
- stat_items = getstati(STAT_ITEMS, 0, 24);
- redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
- blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
+ redflag = (stat_items/CTF_RED_FLAG_TAKEN) & 3;
+ blueflag = (stat_items/CTF_BLUE_FLAG_TAKEN) & 3;
+ yellowflag = (stat_items/CTF_YELLOW_FLAG_TAKEN) & 3;
+ pinkflag = (stat_items/CTF_PINK_FLAG_TAKEN) & 3;
+ neutralflag = (stat_items/CTF_NEUTRAL_FLAG_TAKEN) & 3;
+
+ ctf_oneflag = (stat_items & CTF_FLAG_NEUTRAL);
- if(redflag || blueflag)
- mod_active = 1;
- else
- mod_active = 0;
+ mod_active = (redflag || blueflag || yellowflag || pinkflag || neutralflag);
- if(autocvar__hud_configure)
- {
+ if (autocvar__hud_configure) {
redflag = 1;
blueflag = 2;
+ if (team_count >= 3)
+ yellowflag = 2;
+ if (team_count >= 4)
+ 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
- if (redflag != redflag_prevframe)
- {
- redflag_statuschange_time = time;
- redflag_prevstatus = redflag_prevframe;
- redflag_prevframe = redflag;
- }
-
- if (blueflag != blueflag_prevframe)
- {
- blueflag_statuschange_time = time;
- blueflag_prevstatus = blueflag_prevframe;
- blueflag_prevframe = blueflag;
- }
-
- redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
- blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
-
- float BLINK_FACTOR = 0.15;
- float BLINK_BASE = 0.85;
+ #define X(team) do { \
+ 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)
+ X(red);
+ X(blue);
+ X(yellow);
+ X(pink);
+ X(neutral);
+ #undef X
+
+ const float BLINK_FACTOR = 0.15;
+ const float BLINK_BASE = 0.85;
// note:
// RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
// thus
// BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
// ensure RMS == 1
- float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
-
- string red_icon, red_icon_prevstatus;
- float red_alpha, red_alpha_prevstatus;
- red_alpha = red_alpha_prevstatus = 1;
- switch(redflag) {
- case 1: red_icon = "flag_red_taken"; break;
- case 2: red_icon = "flag_red_lost"; break;
- case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
- default:
- if((stat_items & IT_CTF_SHIELDED) && (myteam == NUM_TEAM_2))
- red_icon = "flag_red_shielded";
- else
- red_icon = string_null;
- break;
- }
- switch(redflag_prevstatus) {
- case 1: red_icon_prevstatus = "flag_red_taken"; break;
- case 2: red_icon_prevstatus = "flag_red_lost"; break;
- case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
+ const float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
+
+ #define X(team, cond) \
+ string team##_icon, team##_icon_prevstatus; \
+ int team##_alpha, team##_alpha_prevstatus; \
+ team##_alpha = team##_alpha_prevstatus = 1; \
+ do { \
+ switch (team##flag) { \
+ case 1: team##_icon = "flag_" #team "_taken"; break; \
+ case 2: team##_icon = "flag_" #team "_lost"; break; \
+ case 3: team##_icon = "flag_" #team "_carrying"; team##_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break; \
+ default: \
+ if ((stat_items & CTF_SHIELDED) && (cond)) { \
+ team##_icon = "flag_" #team "_shielded"; \
+ } else { \
+ team##_icon = string_null; \
+ } \
+ break; \
+ } \
+ switch (team##flag_prevstatus) { \
+ case 1: team##_icon_prevstatus = "flag_" #team "_taken"; break; \
+ case 2: team##_icon_prevstatus = "flag_" #team "_lost"; break; \
+ case 3: team##_icon_prevstatus = "flag_" #team "_carrying"; team##_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break; \
+ default: \
+ if (team##flag == 3) { \
+ team##_icon_prevstatus = "flag_" #team "_carrying"; /* make it more visible */\
+ } else if((stat_items & CTF_SHIELDED) && (cond)) { \
+ team##_icon_prevstatus = "flag_" #team "_shielded"; \
+ } else { \
+ team##_icon_prevstatus = string_null; \
+ } \
+ 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);
+ #undef X
+
+ 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) {
default:
- if(redflag == 3)
- red_icon_prevstatus = "flag_red_carrying"; // make it more visible
- else if((stat_items & IT_CTF_SHIELDED) && (myteam == NUM_TEAM_2))
- red_icon_prevstatus = "flag_red_shielded";
- else
- red_icon_prevstatus = string_null;
- break;
+ case 2: fs = 0.5; fs2 = 0.5; fs3 = 0.5; break;
+ case 3: fs = 1; fs2 = 0.35; fs3 = 0.35; break;
+ case 4: fs = 0.75; fs2 = 0.25; fs3 = 0.5; break;
}
- string blue_icon, blue_icon_prevstatus;
- float blue_alpha, blue_alpha_prevstatus;
- blue_alpha = blue_alpha_prevstatus = 1;
- switch(blueflag) {
- case 1: blue_icon = "flag_blue_taken"; break;
- case 2: blue_icon = "flag_blue_lost"; break;
- case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
- default:
- if((stat_items & IT_CTF_SHIELDED) && (myteam == NUM_TEAM_1))
- blue_icon = "flag_blue_shielded";
- else
- blue_icon = string_null;
- break;
- }
- switch(blueflag_prevstatus) {
- case 1: blue_icon_prevstatus = "flag_blue_taken"; break;
- case 2: blue_icon_prevstatus = "flag_blue_lost"; break;
- case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
- default:
- if(blueflag == 3)
- blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible
- else if((stat_items & IT_CTF_SHIELDED) && (myteam == NUM_TEAM_1))
- blue_icon_prevstatus = "flag_blue_shielded";
- else
- blue_icon_prevstatus = string_null;
- break;
+ if (mySize_x > mySize_y) {
+ size1 = mySize_x;
+ size2 = mySize_y;
+ e1 = eX;
+ e2 = eY;
+ } else {
+ size1 = mySize_y;
+ size2 = mySize_x;
+ e1 = eY;
+ e2 = eX;
}
- if(mySize.x > mySize.y) {
- if (myteam == NUM_TEAM_1) { // always draw own flag on left
+ switch (myteam) {
+ default:
+ case NUM_TEAM_1: {
redflag_pos = pos;
- blueflag_pos = pos + eX * 0.5 * mySize.x;
- } else {
- blueflag_pos = pos;
- redflag_pos = pos + eX * 0.5 * mySize.x;
+ blueflag_pos = pos + eX * fs2 * size1;
+ yellowflag_pos = pos - eX * fs2 * size1;
+ pinkflag_pos = pos + eX * fs3 * size1;
+ break;
}
- flag_size = eX * 0.5 * mySize.x + eY * mySize.y;
- } else {
- if (myteam == NUM_TEAM_1) { // always draw own flag on left
- redflag_pos = pos;
- blueflag_pos = pos + eY * 0.5 * mySize.y;
- } else {
+ case NUM_TEAM_2: {
+ redflag_pos = pos + eX * fs2 * size1;
blueflag_pos = pos;
- redflag_pos = pos + eY * 0.5 * mySize.y;
+ yellowflag_pos = pos - eX * fs2 * size1;
+ pinkflag_pos = pos + eX * fs3 * size1;
+ break;
+ }
+ case NUM_TEAM_3: {
+ redflag_pos = pos + eX * fs3 * size1;
+ blueflag_pos = pos - eX * fs2 * size1;
+ yellowflag_pos = pos;
+ pinkflag_pos = pos + eX * fs2 * size1;
+ break;
+ }
+ case NUM_TEAM_4: {
+ redflag_pos = pos - eX * fs2 * size1;
+ blueflag_pos = pos + eX * fs3 * size1;
+ yellowflag_pos = pos + eX * fs2 * size1;
+ pinkflag_pos = pos;
+ break;
}
- flag_size = eY * 0.5 * mySize.y + eX * mySize.x;
}
-
- f = bound(0, redflag_statuschange_elapsedtime*2, 1);
- if(red_icon_prevstatus && f < 1)
- drawpic_aspect_skin_expanding(redflag_pos, red_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * red_alpha_prevstatus, DRAWFLAG_NORMAL, f);
- if(red_icon)
- drawpic_aspect_skin(redflag_pos, red_icon, flag_size, '1 1 1', panel_fg_alpha * red_alpha * f, DRAWFLAG_NORMAL);
-
- f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
- if(blue_icon_prevstatus && f < 1)
- drawpic_aspect_skin_expanding(blueflag_pos, blue_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);
- if(blue_icon)
- drawpic_aspect_skin(blueflag_pos, blue_icon, flag_size, '1 1 1', panel_fg_alpha * blue_alpha * f, DRAWFLAG_NORMAL);
+ neutralflag_pos = pos;
+ flag_size = e1 * fs * size1 + e2 * size2;
+
+ #define X(team) do { \
+ f = bound(0, team##flag_statuschange_elapsedtime * 2, 1); \
+ 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)
+ X(red);
+ X(blue);
+ X(yellow);
+ X(pink);
+ X(neutral);
+ #undef X
}
// Keyhunt HUD modicon section
void HUD_ModIcons(void)
{
+ if(intermission == 2) return;
if(!autocvar__hud_configure)
{
if(!autocvar_hud_panel_modicons) return;
//
void HUD_PressedKeys(void)
{
+ if(intermission == 2) return;
if(!autocvar__hud_configure)
{
if(!autocvar_hud_panel_pressedkeys) return;
HUD_Panel_UpdateCvars();
+ if(intermission == 2)
+ {
+ // reserve some more space to the mapvote panel
+ // by resizing and moving chat panel to the bottom
+ panel_size.y = min(panel_size.y, vid_conheight * 0.2);
+ panel_pos.y = vid_conheight - panel_size.y - panel_bg_border * 2;
+ chat_posy = panel_pos.y;
+ chat_sizey = panel_size.y;
+ }
if(autocvar__con_chat_maximized && !autocvar__hud_configure) // draw at full screen height if maximized
{
panel_pos.y = panel_bg_border;
float frametimeavg2; // 2 frames ago
void HUD_EngineInfo(void)
{
+ //if(intermission == 2) return;
if(!autocvar__hud_configure)
{
if(!autocvar_hud_panel_engineinfo) return;
} while(0)
void HUD_InfoMessages(void)
{
+ if(intermission == 2) return;
if(!autocvar__hud_configure)
{
if(!autocvar_hud_panel_infomessages) return;
if(spectatee_status == -1)
s = _("^1Observing");
else
- s = sprintf(_("^1Spectating: ^7%s"), GetPlayerName(player_localentnum - 1));
+ s = sprintf(_("^1Spectating: ^7%s"), GetPlayerName(current_player));
drawInfoMessage(s);
if(spectatee_status == -1)
//
vector acc_prevspeed;
float acc_prevtime, acc_avg, top_speed, top_speed_time;
+float physics_update_time, discrete_speed, discrete_acceleration;
void HUD_Physics(void)
{
+ if(intermission == 2) return;
if(!autocvar__hud_configure)
{
if(!autocvar_hud_panel_physics) return;
acc_prevspeed = vel;
acc_prevtime = time;
- f = bound(0, f * 10, 1);
- acc_avg = acc_avg * (1 - f) + acceleration * f;
+ if(autocvar_hud_panel_physics_acceleration_movingaverage)
+ {
+ f = bound(0, f * 10, 1);
+ acc_avg = acc_avg * (1 - f) + acceleration * f;
+ acceleration = acc_avg;
+ }
+ }
+
+ int acc_decimals = 2;
+ if(time > physics_update_time)
+ {
+ // workaround for ftos_decimals returning a negative 0
+ if(discrete_acceleration > -1 / pow(10, acc_decimals) && discrete_acceleration < 0)
+ discrete_acceleration = 0;
+ discrete_acceleration = acceleration;
+ discrete_speed = speed;
+ physics_update_time += autocvar_hud_panel_physics_update_interval;
}
//compute layout
//else
//tmp_offset_x = 0;
tmp_offset.y = (panel_size.y - tmp_size.y) / 2;
- drawstring_aspect(panel_pos + speed_offset + tmp_offset, ftos(speed), tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+ drawstring_aspect(panel_pos + speed_offset + tmp_offset, ftos(discrete_speed), tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
//draw speed unit
if (speed_baralign)
f = acceleration/autocvar_hud_panel_physics_acceleration_max;
if (autocvar_hud_panel_physics_acceleration_progressbar_nonlinear)
- f = sqrt(f);
+ f = (f >= 0 ? sqrt(f) : -sqrt(-f));
if (acceleration_progressbar_scale) // allow progressbar to go out of panel bounds
{
HUD_Panel_DrawProgressBar(panel_pos + acceleration_offset + tmp_offset, tmp_size, "accelbar", f, 0, acceleration_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
}
- tmp_size.x = panel_size.x;
- tmp_size.y = panel_size.y * text_scale;
- tmp_offset.x = 0;
- tmp_offset.y = (panel_size.y - tmp_size.y) / 2;
- if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 3)
- drawstring_aspect(panel_pos + acceleration_offset + tmp_offset, strcat(ftos_decimals(acceleration, 2), "g"), tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+
+ if(autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 3)
+ {
+ tmp_size.x = panel_size.x;
+ tmp_size.y = panel_size.y * text_scale;
+ tmp_offset.x = 0;
+ tmp_offset.y = (panel_size.y - tmp_size.y) / 2;
+
+ drawstring_aspect(panel_pos + acceleration_offset + tmp_offset, strcat(ftos_decimals(discrete_acceleration, acc_decimals), "g"), tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+ }
draw_endBoldFont();
}
float hud_configure_cp_generation_time;
void HUD_CenterPrint (void)
{
+ if(intermission == 2) return;
if(!autocvar__hud_configure)
{
if(!autocvar_hud_panel_centerprint) return;
reset_centerprint_messages();
if (time > hud_configure_cp_generation_time)
{
- float r;
- r = random();
- if (r > 0.75)
- centerprint_generic(floor(r*1000), strcat(sprintf("^3Countdown message at time %s", seconds_tostring(time)), ", seconds left: ^COUNT"), 1, 10);
- else if (r > 0.5)
- centerprint_generic(0, sprintf("^1Multiline message at time %s that\n^1lasts longer than normal", seconds_tostring(time)), 20, 0);
+ if(HUD_PANEL(CENTERPRINT) == highlightedPanel)
+ {
+ float r;
+ r = random();
+ if (r > 0.8)
+ centerprint_generic(floor(r*1000), strcat(sprintf("^3Countdown message at time %s", seconds_tostring(time)), ", seconds left: ^COUNT"), 1, 10);
+ else if (r > 0.55)
+ centerprint_generic(0, sprintf("^1Multiline message at time %s that\n^1lasts longer than normal", seconds_tostring(time)), 20, 0);
+ else
+ centerprint_hud(sprintf("Message at time %s", seconds_tostring(time)));
+ hud_configure_cp_generation_time = time + 1 + random()*4;
+ }
else
- centerprint_hud(sprintf("Message at time %s", seconds_tostring(time)));
- hud_configure_cp_generation_time = time + 1 + random()*4;
+ {
+ centerprint_generic(0, sprintf("Centerprint message", seconds_tostring(time)), 10, 0);
+ hud_configure_cp_generation_time = time + 10 - random()*3;
+ }
}
}
//
void HUD_Buffs(void)
{
+ if(intermission == 2) return;
int buffs = getstati(STAT_BUFFS, 0, 24);
if(!autocvar__hud_configure)
{
draw_endBoldFont();
}
+// ItemsTime (#XX)
+//
+const float ITEMSTIME_MAXITEMS = 10;
+float ItemsTime_time[ITEMSTIME_MAXITEMS];
+float ItemsTime_availableTime[ITEMSTIME_MAXITEMS];
+string GetItemsTimePicture(float i)
+{
+ switch(i)
+ {
+ case 0: return "item_large_armor";
+ case 1: return "item_mega_health";
+ case 2: return "item_strength";
+ case 3: return "item_shield";
+ case 4: return "item_mega_health";
+ case 5: return "item_strength";
+ case 6: return "item_shield";
+ case 7: return "fuelregen";
+ case 8: return "jetpack";
+ case 9: return "superweapons";
+ default: return "";
+ }
+}
+
+void DrawItemsTimeItem(vector myPos, vector mySize, float ar, float itemcode, float item_time, bool item_available, float item_availableTime)
+{
+ float t = 0;
+ vector color = '0 0 0';
+ float picalpha;
+
+ if(autocvar_hud_panel_itemstime_hidespawned)
+ picalpha = 1;
+ else if(item_available)
+ {
+ float BLINK_FACTOR = 0.15;
+ float BLINK_BASE = 0.85;
+ float BLINK_FREQ = 5;
+ picalpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ);
+ }
+ else
+ picalpha = 0.3;
+ t = floor(item_time - time + 0.999);
+ if(t < 5)
+ color = '0.7 0 0';
+ else if(t < 10)
+ color = '0.7 0.7 0';
+ else
+ color = '1 1 1';
+
+ vector picpos, numpos;
+ if(autocvar_hud_panel_itemstime_iconalign)
+ {
+ numpos = myPos;
+ picpos = myPos + eX * (ar - 1) * mySize_y;
+ }
+ else
+ {
+ numpos = myPos + eX * mySize_y;
+ picpos = myPos;
+ }
+
+ if(t > 0 && autocvar_hud_panel_itemstime_progressbar)
+ {
+ vector p_pos, p_size;
+ if(autocvar_hud_panel_itemstime_progressbar_reduced)
+ {
+ p_pos = numpos;
+ p_size = eX * ((ar - 1)/ar) * mySize_x + eY * mySize_y;
+ }
+ else
+ {
+ p_pos = myPos;
+ p_size = mySize;
+ }
+ HUD_Panel_DrawProgressBar(p_pos, p_size, autocvar_hud_panel_itemstime_progressbar_name, t/autocvar_hud_panel_itemstime_progressbar_maxtime, 0, autocvar_hud_panel_itemstime_iconalign, color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+ }
+
+ if(t > 0 && autocvar_hud_panel_itemstime_text)
+ drawstring_aspect(numpos, ftos(t), eX * ((ar - 1)/ar) * mySize_x + eY * mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL);
+ if(item_availableTime)
+ drawpic_aspect_skin_expanding(picpos, GetItemsTimePicture(itemcode), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * picalpha, DRAWFLAG_NORMAL, item_availableTime);
+ drawpic_aspect_skin(picpos, GetItemsTimePicture(itemcode), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * picalpha, DRAWFLAG_NORMAL);
+}
+
+void HUD_ItemsTime(void)
+{
+ if(!autocvar__hud_configure)
+ {
+ if(!(
+ (autocvar_hud_panel_itemstime == 1 && spectatee_status != 0)
+ || (autocvar_hud_panel_itemstime == 2 && (spectatee_status != 0 || warmup_stage))
+ )) { return; }
+
+ ItemsTime_time[0] = getstatf(STAT_ARMOR_LARGE_TIME);
+ ItemsTime_time[1] = getstatf(STAT_HEALTH_MEGA_TIME);
+ ItemsTime_time[2] = getstatf(STAT_INVISIBLE_TIME);
+ ItemsTime_time[3] = getstatf(STAT_SPEED_TIME);
+ ItemsTime_time[4] = getstatf(STAT_EXTRALIFE_TIME);
+ ItemsTime_time[5] = getstatf(STAT_STRENGTH_TIME);
+ ItemsTime_time[6] = getstatf(STAT_SHIELD_TIME);
+ ItemsTime_time[7] = getstatf(STAT_FUELREGEN_TIME);
+ ItemsTime_time[8] = getstatf(STAT_JETPACK_TIME);
+ ItemsTime_time[9] = getstatf(STAT_SUPERWEAPONS_TIME);
+ }
+ else
+ {
+ // do not show here mutator-dependent items
+ ItemsTime_time[0] = time + 0;
+ ItemsTime_time[1] = time + 8;
+ ItemsTime_time[2] = -1; // mutator-dependent
+ ItemsTime_time[3] = -1; // mutator-dependent
+ ItemsTime_time[4] = -1; // mutator-dependent
+ ItemsTime_time[5] = time + 0;
+ ItemsTime_time[6] = time + 4;
+ ItemsTime_time[7] = time + 49;
+ ItemsTime_time[8] = -1;
+ ItemsTime_time[9] = time + 28;
+ }
+
+ float i;
+ float count = 0;
+ if (!autocvar_hud_panel_itemstime_hidespawned)
+ for (i = 0; i < ITEMSTIME_MAXITEMS; ++i)
+ count += (ItemsTime_time[i] != -1);
+ else
+ for (i = 0; i < ITEMSTIME_MAXITEMS; ++i)
+ count += (ItemsTime_time[i] > time);
+ if (count == 0)
+ return;
+
+ HUD_Panel_UpdateCvars();
+
+ vector pos, mySize;
+ pos = panel_pos;
+ mySize = panel_size;
+
+ if(panel_bg_padding)
+ {
+ pos += '1 1 0' * panel_bg_padding;
+ mySize -= '2 2 0' * panel_bg_padding;
+ }
+
+ float rows, columns;
+ float ar = max(2, autocvar_hud_panel_itemstime_ratio) + 1;
+ rows = HUD_GetRowCount(count, mySize, ar);
+ columns = ceil(count/rows);
+
+ vector itemstime_size = eX * mySize.x*(1/columns) + eY * mySize.y*(1/rows);
+
+ vector offset = '0 0 0';
+ float newSize;
+ if(autocvar_hud_panel_itemstime_dynamicsize)
+ {
+ if(autocvar__hud_configure)
+ if(menu_enabled != 2)
+ HUD_Panel_DrawBg(1); // also draw the bg of the entire panel
+
+ // reduce panel to avoid spacing items
+ if(itemstime_size.x / itemstime_size.y < ar)
+ {
+ newSize = rows * itemstime_size.x / ar;
+ pos.y += (mySize.y - newSize) / 2;
+ mySize.y = newSize;
+ itemstime_size.y = mySize.y / rows;
+ }
+ else
+ {
+ newSize = columns * itemstime_size.y * ar;
+ pos.x += (mySize.x - newSize) / 2;
+ mySize.x = newSize;
+ itemstime_size.x = mySize.x / columns;
+ }
+ panel_pos = pos - '1 1 0' * panel_bg_padding;
+ panel_size = mySize + '2 2 0' * panel_bg_padding;
+ }
+ else
+ {
+ if(itemstime_size.x/itemstime_size.y > ar)
+ {
+ newSize = ar * itemstime_size.y;
+ offset.x = itemstime_size.x - newSize;
+ pos.x += offset.x/2;
+ itemstime_size.x = newSize;
+ }
+ else
+ {
+ newSize = 1/ar * itemstime_size.x;
+ offset.y = itemstime_size.y - newSize;
+ pos.y += offset.y/2;
+ itemstime_size.y = newSize;
+ }
+ }
+
+ HUD_Panel_DrawBg(1);
+
+ float row = 0, column = 0;
+ bool item_available;
+ for (i = 0; i < ITEMSTIME_MAXITEMS; ++i) {
+ if (ItemsTime_time[i] == -1)
+ continue;
+
+ float item_time = ItemsTime_time[i];
+ if(item_time < -1)
+ {
+ item_available = true;
+ item_time = -item_time;
+ }
+ else
+ item_available = (item_time <= time);
+
+ if(ItemsTime_time[i] >= 0)
+ {
+ if(time <= ItemsTime_time[i])
+ ItemsTime_availableTime[i] = 0;
+ else if(ItemsTime_availableTime[i] == 0)
+ ItemsTime_availableTime[i] = time;
+ }
+ else if(ItemsTime_availableTime[i] == 0)
+ ItemsTime_availableTime[i] = time;
+
+ float f = (time - ItemsTime_availableTime[i]) * 2;
+ f = (f > 1) ? 0 : bound(0, f, 1);
+
+ if(autocvar_hud_panel_itemstime_hidespawned)
+ if(item_available)
+ continue;
+
+ DrawItemsTimeItem(pos + eX * column * (itemstime_size.x + offset.x) + eY * row * (itemstime_size.y + offset.y), itemstime_size, ar, i, item_time, item_available, f);
+ ++row;
+ if(row >= rows)
+ {
+ row = 0;
+ column = column + 1;
+ }
+ }
+}
/*
==================
HUD_Configure_Frame();
- if(intermission == 2) // no hud during mapvote
- hud_fade_alpha = 0;
-
// panels that we want to be active together with the scoreboard
// they must fade only when the menu does
if(scoreboard_fade_alpha == 1)
hud_skin_prev = strzone(autocvar_hud_skin);
}
- current_player = player_localentnum;
-
// draw the dock
if(autocvar_hud_dock != "" && autocvar_hud_dock != "0")
{
{
string hud_dock_color = autocvar_hud_dock_color;
if(hud_dock_color == "shirt") {
- f = stof(getplayerkeyvalue(current_player - 1, "colors"));
+ f = stof(getplayerkeyvalue(current_player, "colors"));
color = colormapPaletteColor(floor(f / 16), 0);
}
else if(hud_dock_color == "pants") {
- f = stof(getplayerkeyvalue(current_player - 1, "colors"));
+ f = stof(getplayerkeyvalue(current_player, "colors"));
color = colormapPaletteColor(f % 16, 1);
}
else
for(i = 0; i < HUD_PANEL_NUM; ++i)
panel_order[i] = -1;
string s = "";
- float p_num, warning = false;
- float argc = tokenize_console(autocvar__hud_panelorder);
+ int p_num;
+ bool warning = false;
+ int argc = tokenize_console(autocvar__hud_panelorder);
if (argc > HUD_PANEL_NUM)
warning = true;
//first detect wrong/missing panel numbers
for(i = 0; i < HUD_PANEL_NUM; ++i) {
- p_num = stof(argv(i));
+ p_num = stoi(argv(i));
if (p_num >= 0 && p_num < HUD_PANEL_NUM) { //correct panel number?
if (panel_order[p_num] == -1) //found for the first time?
s = strcat(s, ftos(p_num), " ");
}
hud_draw_maximized = 0;
- // draw panels in order specified by panel_order array
+ // draw panels in the order specified by panel_order array
for(i = HUD_PANEL_NUM - 1; i >= 0; --i)
(panel = hud_panel[panel_order[i]]).panel_draw();