+#if defined(CSQC)
+ #include "../dpdefs/csprogsdefs.qh"
+ #include "defs.qh"
+ #include "../common/constants.qh"
+ #include "../common/stats.qh"
+ #include "../warpzonelib/mathlib.qh"
+ #include "../common/teams.qh"
+ #include "../common/util.qh"
+ #include "../common/nades.qh"
+ #include "../common/buffs.qh"
+ #include "../common/counting.qh"
+ #include "../common/weapons/weapons.qh"
+ #include "../common/mapinfo.qh"
+ #include "autocvars.qh"
+ #include "../common/deathtypes.qh"
+ #include "teamradar.qh"
+ #include "hud.qh"
+ #include "scoreboard.qh"
+ #include "main.qh"
+ #include "../csqcmodellib/cl_player.qh"
+ #include "../server/t_items.qh"
+#elif defined(MENUQC)
+#elif defined(SVQC)
+#endif
+
/*
==================
Misc HUD functions
float stringwidth_colors(string s, vector theSize)
{
- return stringwidth(s, TRUE, theSize);
+ return stringwidth(s, true, theSize);
}
float stringwidth_nocolors(string s, vector theSize)
{
- return stringwidth(s, FALSE, theSize);
+ return stringwidth(s, false, theSize);
}
void drawstringright(vector position, string text, vector theScale, vector rgb, float theAlpha, float flag)
*/
// draw the background/borders
-#define HUD_Panel_DrawBg(theAlpha)\
-if(panel.current_panel_bg != "0" && panel.current_panel_bg != "")\
- draw_BorderPicture(panel_pos - '1 1 0' * panel_bg_border, panel.current_panel_bg, panel_size + '1 1 0' * 2 * panel_bg_border, panel_bg_color, panel_bg_alpha * theAlpha, '1 1 0' * (panel_bg_border/BORDER_MULTIPLIER))
+#define HUD_Panel_DrawBg(theAlpha) do { \
+ if(panel.current_panel_bg != "0" && panel.current_panel_bg != "") \
+ draw_BorderPicture(panel_pos - '1 1 0' * panel_bg_border, panel.current_panel_bg, panel_size + '1 1 0' * 2 * panel_bg_border, panel_bg_color, panel_bg_alpha * theAlpha, '1 1 0' * (panel_bg_border/BORDER_MULTIPLIER));\
+} while(0)
//basically the same code of draw_ButtonPicture and draw_VertButtonPicture for the menu
void HUD_Panel_DrawProgressBar(vector theOrigin, vector theSize, string pic, float length_ratio, float vertical, float baralign, vector theColor, float theAlpha, float drawflag)
{
if(autocvar__hud_configure)
{
- DrawAmmoItem(pos, ammo_size, ammo_rockets, TRUE, FALSE);
+ DrawAmmoItem(pos, ammo_size, ammo_rockets, true, false);
}
else
{
pos,
ammo_size,
(get_weaponinfo(switchweapon)).ammo_field,
- TRUE,
+ true,
infinite_ammo
);
}
if (attacker != "")
{
attacker = textShortenToWidth(attacker, name_maxwidth, font_size, stringwidth_colors);
- attacker_pos = pos + attacker_right - eX * stringwidth(attacker, TRUE, font_size) + name_top;
+ attacker_pos = pos + attacker_right - eX * stringwidth(attacker, true, font_size) + name_top;
drawcolorcodedstring(attacker_pos, attacker, font_size, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
}
}
if (team_count)
score_color = Team_ColorRGB(ColorByTeam(floor((i - first_pl) / players_per_team))) * 0.8;
s = textShortenToWidth(s, name_size, fontsize, stringwidth_colors);
- drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, TRUE, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
+ drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, true, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
drawstring(pos + eX * (name_size + spacing_size), ftos(score), fontsize, score_color, panel_fg_alpha, DRAWFLAG_NORMAL);
pos.y += fontsize.y;
}
if (team_count)
score_color = Team_ColorRGB(pl.team) * 0.8;
s = textShortenToWidth(GetPlayerName(pl.sv_entnum), name_size, fontsize, stringwidth_colors);
- drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, TRUE, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
+ drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, true, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
drawstring(pos + eX * (name_size + spacing_size), ftos(pl.(scores[ps_primary])), fontsize, score_color, panel_fg_alpha, DRAWFLAG_NORMAL);
pos.y += fontsize.y;
++i;
if(autocvar__hud_configure)
{
s = "0:13:37";
- 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);
+ 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);
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);
+ 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");
- drawcolorcodedstring(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.20 * mySize.y) + eY * 0.80 * mySize.y, s, '1 1 0' * 0.20 * mySize.y, panel_fg_alpha, DRAWFLAG_NORMAL);
+ drawcolorcodedstring(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(s, true, '1 1 0' * 0.20 * mySize.y) + eY * 0.80 * mySize.y, s, '1 1 0' * 0.20 * mySize.y, panel_fg_alpha, DRAWFLAG_NORMAL);
}
else if(race_checkpointtime)
{
if(s != "" && a > 0)
{
- drawcolorcodedstring(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.2 * mySize.y) + eY * 0.6 * mySize.y, s, '1 1 0' * 0.2 * mySize.y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
+ drawcolorcodedstring(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(s, true, '1 1 0' * 0.2 * mySize.y) + eY * 0.6 * mySize.y, s, '1 1 0' * 0.2 * mySize.y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
}
if(race_penaltytime)
if(a > 0)
{
s = sprintf(_("^1PENALTY: %.1f (%s)"), race_penaltytime * 0.1, race_penaltyreason);
- drawcolorcodedstring(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.2 * mySize.y) + eY * 0.8 * mySize.y, s, '1 1 0' * 0.2 * mySize.y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
+ drawcolorcodedstring(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(s, true, '1 1 0' * 0.2 * mySize.y) + eY * 0.8 * mySize.y, s, '1 1 0' * 0.2 * mySize.y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
}
}
if(forcetime != "")
{
a = bound(0, (time - race_checkpointtime) / 0.5, 1);
- drawstring_expanding(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(forcetime, FALSE, '1 1 0' * 0.6 * mySize.y), forcetime, '1 1 0' * 0.6 * mySize.y, '1 1 1', panel_fg_alpha, 0, a);
+ drawstring_expanding(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(forcetime, false, '1 1 0' * 0.6 * mySize.y), forcetime, '1 1 0' * 0.6 * mySize.y, '1 1 1', panel_fg_alpha, 0, a);
}
else
a = 1;
if(race_laptime && race_checkpoint != 255)
{
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);
+ 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);
}
}
else
{
a = bound(0, 2 - (time - race_mycheckpointtime), 1);
s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -(race_mycheckpointenemy == ""), race_mycheckpointlapsdelta, race_mycheckpointenemy);
- drawcolorcodedstring(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.2 * mySize.y) + eY * 0.6 * mySize.y, s, '1 1 0' * 0.2 * mySize.y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
+ drawcolorcodedstring(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(s, true, '1 1 0' * 0.2 * mySize.y) + eY * 0.6 * mySize.y, s, '1 1 0' * 0.2 * mySize.y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
}
if(race_othercheckpointtime && race_othercheckpointenemy != "")
{
a = bound(0, 2 - (time - race_othercheckpointtime), 1);
s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -(race_othercheckpointenemy == ""), race_othercheckpointlapsdelta, race_othercheckpointenemy);
- drawcolorcodedstring(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.2 * mySize.y) + eY * 0.6 * mySize.y, s, '1 1 0' * 0.2 * mySize.y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
+ drawcolorcodedstring(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(s, true, '1 1 0' * 0.2 * mySize.y) + eY * 0.6 * mySize.y, s, '1 1 0' * 0.2 * mySize.y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
}
if(race_penaltytime && !race_penaltyaccumulator)
s = sprintf(_("^1PENALTY: %.1f (%s)"), (t - time) * 0.1, race_penaltyreason);
else
s = sprintf(_("^2PENALTY: %.1f (%s)"), 0, race_penaltyreason);
- drawcolorcodedstring(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.2 * mySize.y) + eY * 0.6 * mySize.y, s, '1 1 0' * 0.2 * mySize.y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
+ drawcolorcodedstring(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(s, true, '1 1 0' * 0.2 * mySize.y) + eY * 0.6 * mySize.y, s, '1 1 0' * 0.2 * mySize.y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
}
}
}
// Info messages panel (#14)
//
-#define drawInfoMessage(s)\
- if(autocvar_hud_panel_infomessages_flip)\
- o_x = pos.x + mySize.x - stringwidth(s, TRUE, fontsize);\
- drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);\
- o.y += fontsize.y;
+#define drawInfoMessage(s) do { \
+ if(autocvar_hud_panel_infomessages_flip) \
+ o_x = pos.x + mySize.x - stringwidth(s, true, fontsize); \
+ drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL); \
+ o.y += fontsize.y; \
+} while(0)
void HUD_InfoMessages(void)
{
if(!autocvar__hud_configure)
s = _("^1Observing");
else
s = sprintf(_("^1Spectating: ^7%s"), GetPlayerName(player_localentnum - 1));
- drawInfoMessage(s)
+ drawInfoMessage(s);
if(spectatee_status == -1)
s = sprintf(_("^1Press ^3%s^1 to spectate"), getcommandkey("primary fire", "+fire"));
else
s = sprintf(_("^1Press ^3%s^1 or ^3%s^1 for next or previous player"), getcommandkey("next weapon", "weapnext"), getcommandkey("previous weapon", "weapprev"));
- drawInfoMessage(s)
+ drawInfoMessage(s);
if(spectatee_status == -1)
s = sprintf(_("^1Use ^3%s^1 or ^3%s^1 to change the speed"), getcommandkey("next weapon", "weapnext"), getcommandkey("previous weapon", "weapprev"));
else
s = sprintf(_("^1Press ^3%s^1 to observe"), getcommandkey("secondary fire", "+fire2"));
- drawInfoMessage(s)
+ drawInfoMessage(s);
s = sprintf(_("^1Press ^3%s^1 for gamemode info"), getcommandkey("server info", "+show_info"));
- drawInfoMessage(s)
+ drawInfoMessage(s);
if(gametype == MAPINFO_TYPE_LMS)
{
}
else
s = sprintf(_("^1Press ^3%s^1 to join"), getcommandkey("jump", "+jump"));
- drawInfoMessage(s)
+ drawInfoMessage(s);
//show restart countdown:
if (time < getstatf(STAT_GAMESTARTTIME)) {
if(warmup_stage && !intermission)
{
s = _("^2Currently in ^1warmup^2 stage!");
- drawInfoMessage(s)
+ drawInfoMessage(s);
}
string blinkcolor;
else
s = _("^2Waiting for others to ready up...");
}
- drawInfoMessage(s)
+ drawInfoMessage(s);
}
else if(warmup_stage && !intermission && !spectatee_status)
{
s = sprintf(_("^2Press ^3%s^2 to end warmup"), getcommandkey("ready", "ready"));
- drawInfoMessage(s)
+ drawInfoMessage(s);
}
if(teamplay && !intermission && !spectatee_status && gametype != MAPINFO_TYPE_CA && teamnagger)
if (tm.team != NUM_SPECTATOR)
if (tm.team_size == ts_max)
s = strcat(s, sprintf(_(" Press ^3%s%s to adjust"), getcommandkey("team menu", "menu_showteamselect"), blinkcolor));
- drawInfoMessage(s)
+ drawInfoMessage(s);
}
}
}
else
{
s = _("^7Press ^3ESC ^7to show HUD options.");
- drawInfoMessage(s)
+ drawInfoMessage(s);
s = _("^3Doubleclick ^7a panel for panel-specific options.");
- drawInfoMessage(s)
+ drawInfoMessage(s);
s = _("^3CTRL ^7to disable collision testing, ^3SHIFT ^7and");
- drawInfoMessage(s)
+ drawInfoMessage(s);
s = _("^3ALT ^7+ ^3ARROW KEYS ^7for fine adjustments.");
- drawInfoMessage(s)
+ drawInfoMessage(s);
}
}
return;
if (!centerprint_showing)
- centerprint_showing = TRUE;
+ centerprint_showing = true;
for (i=0, j=cpm_index; i<CENTERPRINT_MAX_MSGS; ++i, ++j)
{
float a, sz, align, current_msg_posY = 0, msg_size;
vector pos;
string ts;
- float all_messages_expired = TRUE;
+ float all_messages_expired = true;
pos = panel_pos;
if (autocvar_hud_panel_centerprint_flip)
continue;
}
- all_messages_expired = FALSE;
+ all_messages_expired = false;
// fade the centerprint_hud in/out
if(centerprint_time[j] < 0) // Expired but forced. Expire time is the fade-in time.
if (ts != "")
{
if (align)
- pos_x = panel_pos.x + (panel_size.x - stringwidth(ts, TRUE, fontsize)) * align;
+ pos_x = panel_pos.x + (panel_size.x - stringwidth(ts, true, fontsize)) * align;
if (a > 0.5/255.0) // Otherwise guaranteed invisible - don't show. This is checked a second time after some multiplications with other factors were done so temporary changes of these cannot cause flicker.
drawcolorcodedstring(pos + eY * 0.5 * (1 - sz) * fontsize.y, ts, fontsize, a, DRAWFLAG_NORMAL);
pos.y += fontsize.y;
drawfontscale = '1 1 0';
if (all_messages_expired)
{
- centerprint_showing = FALSE;
+ centerprint_showing = false;
reset_centerprint_messages();
}
}