float i;
for (i = 0; i < HUD_PANEL_NUM; ++i)
{
- HUD_Panel_GetName(i)
- HUD_Panel_UpdateCvars(panel_name)
+// HUD_Panel_GetName(i)
+// HUD_Panel_UpdateCvarsForId(i)
fputs(fh, strcat("seta hud_", panel_name, " ", ftos(cvar(strcat("hud_", panel_name))), "\n"));
fputs(fh, strcat("seta hud_", panel_name, "_pos \"", cvar_string(strcat("hud_", panel_name, "_pos")), "\"", "\n"));
fclose(fh);
}
-// return active status of panel
-float HUD_Panel_CheckActive(float id)
-{
- if (cvar_or(strcat("hud_", HUD_Panel_GetName(id)), 1))
- return 1;
- return 0;
-}
-
// return smoothly faded size of given panel when a dialog is active
vector HUD_Panel_GetMenuSize(float id)
{
vector mySize;
- mySize = stov(cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_size")));
+ mySize = stov(cvar_string(strcat("hud_", panel_name, "_size")));
mySize = eX * mySize_x * vid_conwidth + eY * mySize_y * vid_conheight;
vector HUD_Panel_GetMenuPos(float id)
{
vector pos;
- pos = stov(cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_pos")));
+ pos = stov(cvar_string(strcat("hud_", panel_name, "_pos")));
pos = eX * pos_x * vid_conwidth + eY * pos_y * vid_conheight;
string color;
// fetch per-panel color
- if(teamplay && cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_color_team")) != "") {
+ if(teamplay && cvar_string(strcat("hud_", panel_name, "_bg_color_team")) != "") {
f = stof(getplayerkey(player_localentnum - 1, "colors"));
- color = vtos(colormapPaletteColor(mod(f, 16), 1) * cvar(strcat("hud_", HUD_Panel_GetName(id), "_bg_color_team")));
+ color = vtos(colormapPaletteColor(mod(f, 16), 1) * cvar(strcat("hud_", panel_name, "_bg_color_team")));
}
else
- color = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_color"));
+ color = cvar_string(strcat("hud_", panel_name, "_bg_color"));
color_vec = stov(color);
if(color == "") { // fetch default color
float HUD_Panel_GetBgAlpha(float id)
{
string alpha;
- alpha = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_alpha"));
+ alpha = cvar_string(strcat("hud_", panel_name, "_bg_alpha"));
if(alpha == "")
alpha = cvar_string("hud_bg_alpha");
- if(hud_configure && disable_menu_alphacheck == 2 && highlightedPanel == id) // do not set a minalpha cap when showing the config dialog for this panel
- alpha = ftos((1 - cvar("_menu_alpha")) * max(cvar("hud_configure_bg_minalpha"), stof(alpha)) + (cvar("_menu_alpha")) * stof(alpha));
- else if(hud_configure)
- alpha = ftos(max(cvar("hud_configure_bg_minalpha"), stof(alpha)));
+ if(autocvar__hud_configure && disable_menu_alphacheck == 2 && highlightedPanel == id) // do not set a minalpha cap when showing the config dialog for this panel
+ alpha = ftos((1 - cvar("_menu_alpha")) * max(autocvar_hud_configure_bg_minalpha, stof(alpha)) + (cvar("_menu_alpha")) * stof(alpha));
+ else if(autocvar__hud_configure)
+ alpha = ftos(max(autocvar_hud_configure_bg_minalpha, stof(alpha)));
- if(hud_configure && !cvar(strcat("hud_", HUD_Panel_GetName(id)))) // ALWAYS show disabled panels at 0.25 alpha when in config mode
+ if(autocvar__hud_configure && !cvar(strcat("hud_", panel_name))) // ALWAYS show disabled panels at 0.25 alpha when in config mode
return 0.25;
if(disable_menu_alphacheck == 2 && highlightedPanel == id) // don't fade this panel when showing the panel-specific menu dialog
float alpha;
alpha = hud_fg_alpha;
- if(hud_configure && !cvar(strcat("hud_", HUD_Panel_GetName(id)))) // ALWAYS show disabled panels at 0.25 alpha when in config mode
+ if(autocvar__hud_configure && !cvar(strcat("hud_", panel_name))) // ALWAYS show disabled panels at 0.25 alpha when in config mode
return 0.25;
if(disable_menu_alphacheck == 2 && highlightedPanel == id) // don't fade this panel when showing the panel-specific menu dialog
float HUD_Panel_GetPadding(float id)
{
string padding;
- padding = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_padding"));
+ padding = cvar_string(strcat("hud_", panel_name, "_bg_padding"));
if(padding == "")
padding = cvar_string("hud_bg_padding");
// draw the background/borders
void HUD_Panel_DrawBg(float id, vector pos, vector mySize, float alpha)
{
- if(!hud_configure && panel_bg == "0")
+ if(!autocvar__hud_configure && panel_bg == "0")
return;
if(panel_bg == "")
panel_bg = cvar_string("hud_bg");
- if(panel_bg == "0" && hud_configure) {
+ if(panel_bg == "0" && autocvar__hud_configure) {
panel_bg = "border"; // we probably want to see a background in config mode at all times...
}
{
string border;
- border = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_border"));
+ border = cvar_string(strcat("hud_", panel_name, "_bg_border"));
if(border == "")
border = cvar_string("hud_bg_border");
draw_BorderPicture(pos - '1 1 0' * borderf, strcat("gfx/hud/", cvar_string("hud_skin"), "/", panel_bg), mySize + '1 1 0' * 2 * borderf, color, alpha, '1 1 0' * (borderf/BORDER_MULTIPLIER));
}
- if(highlightedPanel_prev == id && hud_configure)
+ if(highlightedPanel_prev == id && autocvar__hud_configure)
drawfill(pos - '1 1 0' * borderf, mySize + '1 1 0' * 2 * borderf, '1 1 1', .1 * (1 - cvar("_menu_alpha")), DRAWFLAG_ADDITIVE);
}
}
}
+// TODO: autocvar
#define HUD_Panel_GetProgressBarColor(item) \
stov(cvar_string(strcat("hud_progressbar_", item, "_color")))
targCenter = '0 0 0'; // shut up fteqcc, there IS a reference
for (i = 0; i < HUD_PANEL_NUM; ++i) {
- HUD_Panel_GetName(i);
- HUD_Panel_UpdateCvars(panel_name);
+ HUD_Panel_UpdateCvarsForId(i)
- if(i == id || !panel_active)
+ if(i == id || !panel_enabled)
continue;
targPos = panel_pos;
vector mySize;
mySize = panel_size;
- if(hud_configure_checkcollisions)
+ if(autocvar_hud_configure_checkcollisions)
pos = HUD_Panel_CheckMove(id, pos, mySize);
pos_x = bound(0, pos_x, vid_conwidth - mySize_x);
pos_y = bound(0, pos_y, vid_conheight - mySize_y);
- if(cvar("hud_configure_grid"))
+ if(autocvar_hud_configure_grid)
{
- pos_x = floor((pos_x/vid_conwidth)/bound(0.005, cvar("hud_configure_grid_x"), 0.2) + 0.5) * bound(0.005, cvar("hud_configure_grid_x"), 0.2) * vid_conwidth;
- pos_y = floor((pos_y/vid_conheight)/bound(0.005, cvar("hud_configure_grid_y"), 0.2) + 0.5) * bound(0.005, cvar("hud_configure_grid_y"), 0.2) * vid_conheight;
+ pos_x = floor((pos_x/vid_conwidth)/bound(0.005, autocvar_hud_configure_grid_x, 0.2) + 0.5) * bound(0.005, autocvar_hud_configure_grid_x, 0.2) * vid_conwidth;
+ pos_y = floor((pos_y/vid_conheight)/bound(0.005, autocvar_hud_configure_grid_y, 0.2) + 0.5) * bound(0.005, autocvar_hud_configure_grid_y, 0.2) * vid_conheight;
}
string s;
s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
- cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_pos"), s);
+ cvar_set(strcat("hud_", panel_name, "_pos"), s);
}
// check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
ratio = mySize_x/mySize_y;
for (i = 0; i < HUD_PANEL_NUM; ++i) {
- if(i == id || !HUD_Panel_CheckActive(i))
+ if(i == id || !panel_enabled)
continue;
targPos = panel_pos;
if(id == HUD_PANEL_CHAT) // some panels have their own restrictions, like the chat panel (which actually only moves the engine chat print around). Looks bad if it's too small.
{
mySize_x = max(17 * cvar("con_chatsize"), mySize_x);
- mySize_y = max(2 * cvar("con_chatsize") + 2 * HUD_Panel_GetPadding(id), mySize_y);
+ mySize_y = max(2 * cvar("con_chatsize") + 2 * panel_bg_padding, mySize_y);
}
// collision testing|
drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
// before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
- if(cvar("hud_configure_grid"))
+ if(autocvar_hud_configure_grid)
{
- mySize_x = floor((mySize_x/vid_conwidth)/bound(0.005, cvar("hud_configure_grid_x"), 0.2) + 0.5) * bound(0.005, cvar("hud_configure_grid_x"), 0.2) * vid_conwidth;
- mySize_y = floor((mySize_y/vid_conheight)/bound(0.005, cvar("hud_configure_grid_y"), 0.2) + 0.5) * bound(0.005, cvar("hud_configure_grid_y"), 0.2) * vid_conheight;
+ mySize_x = floor((mySize_x/vid_conwidth)/bound(0.005, autocvar_hud_configure_grid_x, 0.2) + 0.5) * bound(0.005, autocvar_hud_configure_grid_x, 0.2) * vid_conwidth;
+ mySize_y = floor((mySize_y/vid_conheight)/bound(0.005, autocvar_hud_configure_grid_y, 0.2) + 0.5) * bound(0.005, autocvar_hud_configure_grid_y, 0.2) * vid_conheight;
}
- if(hud_configure_checkcollisions)
+ if(autocvar_hud_configure_checkcollisions)
mySize = HUD_Panel_CheckResize(id, mySize, resizeorigin);
// minimum panel size cap, do this once more so we NEVER EVER EVER have a panel smaller than this, JUST IN CASE above code still makes the panel eg negative (impossible to resize back without changing cvars manually then)
string s;
s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
- cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_size"), s);
+ cvar_set(strcat("hud_", panel_name, "_size"), s);
s = strcat(ftos(myPos_x/vid_conwidth), " ", ftos(myPos_y/vid_conheight));
- cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_pos"), s);
+ cvar_set(strcat("hud_", panel_name, "_pos"), s);
}
float mouseClicked;
hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && cvar("hud_configure_checkcollisions"));
float step;
- if(cvar("hud_configure_grid"))
+ if(autocvar_hud_configure_grid)
{
if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
{
if (hudShiftState & S_SHIFT)
- step = bound(0.005, cvar("hud_configure_grid_y"), 0.2) * vid_conheight;
+ step = bound(0.005, autocvar_hud_configure_grid_y, 0.2) * vid_conheight;
else
- step = 2 * bound(0.005, cvar("hud_configure_grid_y"), 0.2) * vid_conheight;
+ step = 2 * bound(0.005, autocvar_hud_configure_grid_y, 0.2) * vid_conheight;
}
else
{
if (hudShiftState & S_SHIFT)
- step = bound(0.005, cvar("hud_configure_grid_x"), 0.2) * vid_conwidth;
+ step = bound(0.005, autocvar_hud_configure_grid_x, 0.2) * vid_conwidth;
else
- step = 2 * bound(0.005, cvar("hud_configure_grid_x"), 0.2) * vid_conwidth;
+ step = 2 * bound(0.005, autocvar_hud_configure_grid_x, 0.2) * vid_conwidth;
}
}
else
highlightedPanel = highlightedPanel_prev;
+ HUD_Panel_UpdateCvarsForId(highlightedPanel)
+
if (hudShiftState & S_ALT) // resize
{
highlightedAction = 1;
}
vector mySize;
- mySize = HUD_Panel_GetSize(highlightedPanel);
- panel_click_resizeorigin = HUD_Panel_GetPos(highlightedPanel);
+ mySize = panel_size;
+ panel_click_resizeorigin = panel_pos;
if(resizeCorner == 1) {
panel_click_resizeorigin += mySize;
mySize_y += step;
{
highlightedAction = 2;
vector pos;
- pos = HUD_Panel_GetPos(highlightedPanel);
+ pos = panel_pos;
if(nPrimary == K_UPARROW)
pos_y -= step;
else if(nPrimary == K_DOWNARROW)
float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
{
- if(!hud_configure)
+ if(!autocvar__hud_configure)
return false;
// allow console bind to work
void HUD_WeaponIcons(void)
{
float id = HUD_PANEL_WEAPONICONS;
- HUD_Panel_GetName(id);
- HUD_Panel_UpdateCvars(panel_name);
+ HUD_Panel_UpdateCvarsForId(id);
float alpha, stat_weapons; // "constants"
vector pos, mySize, accuracy_color;
float i, weapid, fade, weapon_stats, weapon_hit, weapon_damage, weapon_cnt; // variables
}
HUD_Panel_DrawBg(id, pos, mySize, 0);
- padding = HUD_Panel_GetPadding(id);
+ padding = panel_bg_padding;
if(panel_bg_padding)
{
pos += '1 1 0' * panel_bg_padding;
{
float a;
a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
- if(hud_configure)
+ if(autocvar__hud_configure)
a = 100;
vector color;
void HUD_Inventory(void)
{
float id = HUD_PANEL_INVENTORY;
- HUD_Panel_GetName(id);
- HUD_Panel_UpdateCvars(panel_name);
+ HUD_Panel_UpdateCvarsForId(id);
float i, currently_selected;
vector pos, mySize;
mySize = panel_size;
HUD_Panel_DrawBg(id, pos, mySize, 0);
- padding = HUD_Panel_GetPadding(id);
+ padding = panel_bg_padding;
if(panel_bg_padding)
{
pos += '1 1 0' * panel_bg_padding;
for (i = 0; i < AMMO_COUNT; ++i) {
currently_selected = getstati(STAT_ITEMS) & GetAmmoItemCode(i);
if(cvar("hud_inventory_onlycurrent")) {
- if(hud_configure)
+ if(autocvar__hud_configure)
i = 2;
- if (currently_selected || hud_configure)
+ if (currently_selected || autocvar__hud_configure)
DrawAmmoItem(pos, mySize, i, currently_selected);
break;
} else {
vector picpos, numpos;
float iconalign;
- iconalign = cvar(strcat("hud_", HUD_Panel_GetName(id), "_iconalign"));
+ iconalign = cvar(strcat("hud_", panel_name, "_iconalign"));
if(left)
{
if(iconalign == 1 || iconalign == 3) // right align
//
void HUD_Powerups(void) {
float id = HUD_PANEL_POWERUPS;
- HUD_Panel_GetName(id);
- HUD_Panel_UpdateCvars(panel_name);
+ HUD_Panel_UpdateCvarsForId(id);
float stat_items;
stat_items = getstati(STAT_ITEMS);
- if(!hud_configure)
+ if(!autocvar__hud_configure)
{
if not(stat_items & IT_STRENGTH)
if not(stat_items & IT_INVINCIBLE)
mySize = panel_size;
HUD_Panel_DrawBg(id, pos, mySize, 0);
- padding = HUD_Panel_GetPadding(id);
+ padding = panel_bg_padding;
if(panel_bg_padding)
{
pos += '1 1 0' * panel_bg_padding;
strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
- if(hud_configure)
+ if(autocvar__hud_configure)
{
strength_time = 15;
shield_time = 27;
float leftcnt, rightcnt;
float leftexact, rightexact;
float leftalpha, rightalpha;
- if (cvar(strcat("hud_", HUD_Panel_GetName(id), "_flip"))) {
+ if (cvar(strcat("hud_", panel_name, "_flip"))) {
leftname = "strength";
leftcnt = ceil(strength_time);
leftexact = strength_time;
rightalpha = bound(0, rightexact, 1);
float baralign, iconalign;
- baralign = cvar(strcat("hud_", HUD_Panel_GetName(id), "_baralign"));
- iconalign = cvar(strcat("hud_", HUD_Panel_GetName(id), "_iconalign"));
+ baralign = cvar(strcat("hud_", panel_name, "_baralign"));
+ iconalign = cvar(strcat("hud_", panel_name, "_iconalign"));
if (mySize_x/mySize_y > 4)
{
void HUD_HealthArmor(void)
{
float id = HUD_PANEL_HEALTHARMOR;
- HUD_Panel_GetName(id);
- HUD_Panel_UpdateCvars(panel_name);
+ HUD_Panel_UpdateCvarsForId(id);
vector pos, mySize;
pos = panel_pos;
mySize = panel_size;
HUD_Panel_DrawBg(id, pos, mySize, 0);
- padding = HUD_Panel_GetPadding(id);
+ padding = panel_bg_padding;
if(panel_bg_padding)
{
pos += '1 1 0' * panel_bg_padding;
float fuel;
fuel = getstati(GetAmmoStat(4)); // how much fuel do we have?
- if(hud_configure)
+ if(autocvar__hud_configure)
{
armor = 150;
health = 100;
vector numpos;
float baralign, iconalign;
- baralign = cvar(strcat("hud_", HUD_Panel_GetName(id), "_baralign"));
- iconalign = cvar(strcat("hud_", HUD_Panel_GetName(id), "_iconalign"));
+ baralign = cvar(strcat("hud_", panel_name, "_baralign"));
+ iconalign = cvar(strcat("hud_", panel_name, "_iconalign"));
if(cvar("hud_healtharmor") == 2) // combined health and armor display
{
float leftcnt, rightcnt;
float leftactive, rightactive;
float leftalpha, rightalpha;
- if (cvar(strcat("hud_", HUD_Panel_GetName(id), "_flip"))) { // old style layout with armor left/top of health
+ if (cvar(strcat("hud_", panel_name, "_flip"))) { // old style layout with armor left/top of health
leftname = "armor";
leftcnt = armor;
if(leftcnt)
{
float w;
float alsoprint;
- alsoprint = (cvar("hud_notify_print") || !HUD_Panel_CheckActive(4)); // print message to console if: notify panel disabled, or cvar to do so enabled
+ alsoprint = (cvar("hud_notify_print") || !panel_enabled); // print message to console if: notify panel disabled, or cvar to do so enabled
if(msg == MSG_SUICIDE) {
// TODO: cl_gentle
void HUD_Notify (void)
{
float id = HUD_PANEL_NOTIFY;
- HUD_Panel_GetName(id);
- HUD_Panel_UpdateCvars(panel_name);
+ HUD_Panel_UpdateCvarsForId(id);
vector pos, mySize;
pos = panel_pos;
mySize = panel_size;
HUD_Panel_DrawBg(id, pos, mySize, 0);
- padding = HUD_Panel_GetPadding(id);
+ padding = panel_bg_padding;
if(panel_bg_padding)
{
pos += '1 1 0' * panel_bg_padding;
// TODO: less copypaste code below
//
// Y [used by] X
- if(killnotify_actiontype[j] == 0 && !hud_configure)
+ if(killnotify_actiontype[j] == 0 && !autocvar__hud_configure)
{
attacker = textShortenToWidth(killnotify_attackers[j], mySize_x - 2 * height, fontsize, stringwidth_colors);
// X [did action to] Y
else
{
- if(hud_configure)
+ if(autocvar__hud_configure)
{
attacker = textShortenToWidth("Player1", 0.5 * mySize_x - height, fontsize, stringwidth_colors);
victim = textShortenToWidth("Player2", 0.5 * mySize_x - height, fontsize, stringwidth_colors);
pos_victim = pos + eX * 0.5 * ((0.5 * mySize_x - height) - width_victim) + eY * 0.5 * fontsize_y + eX * 0.5 * mySize_x + eX * height + eY * i * height;
weap_pos = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height;
- if(hud_configure) // example actions for config mode
+ if(autocvar__hud_configure) // example actions for config mode
{
drawpic_aspect_skin(weap_pos, strcat("weapon", "electro"), '2 1 0' * height, '1 1 1', HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
drawcolorcodedstring(pos_attacker, attacker, fontsize, HUD_Panel_GetFgAlpha(id) * a, DRAWFLAG_NORMAL);
}
}
}
- if(hud_configure)
+ if(autocvar__hud_configure)
{
s = "^7Press ^3ESC ^7to show HUD options.";
drawcolorcodedstring(o, s, fontsize, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
void HUD_Timer(void)
{
float id = HUD_PANEL_TIMER;
- HUD_Panel_GetName(id);
- HUD_Panel_UpdateCvars(panel_name);
+ HUD_Panel_UpdateCvarsForId(id);
vector pos, mySize;
pos = panel_pos;
mySize = panel_size;
HUD_Panel_DrawBg(id, pos, mySize, 0);
- padding = HUD_Panel_GetPadding(id);
+ padding = panel_bg_padding;
if(panel_bg_padding)
{
pos += '1 1 0' * panel_bg_padding;
void HUD_Radar(void)
{
float id = HUD_PANEL_RADAR;
- HUD_Panel_GetName(id);
- HUD_Panel_UpdateCvars(panel_name);
+ HUD_Panel_UpdateCvarsForId(id);
vector pos, mySize;
pos = panel_pos;
mySize = panel_size;
HUD_Panel_DrawBg(id, pos, mySize, 0);
- padding = HUD_Panel_GetPadding(id);
+ padding = panel_bg_padding;
if(panel_bg_padding)
{
pos += '1 1 0' * panel_bg_padding;
void HUD_Score(void)
{
float id = HUD_PANEL_SCORE;
- HUD_Panel_GetName(id);
- HUD_Panel_UpdateCvars(panel_name);
+ HUD_Panel_UpdateCvarsForId(id);
vector pos, mySize;
pos = panel_pos;
mySize = panel_size;
HUD_Panel_DrawBg(id, pos, mySize, 0);
- padding = HUD_Panel_GetPadding(id);
+ padding = panel_bg_padding;
if(panel_bg_padding)
{
pos += '1 1 0' * panel_bg_padding;
if(pl == me)
pl = pl.sort_next;
- if(hud_configure)
+ if(autocvar__hud_configure)
distribution = 42;
else if(pl)
distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
distribution = 0;
score = me.(scores[ps_primary]);
- if(hud_configure)
+ if(autocvar__hud_configure)
score = 123;
if(distribution >= 5) {
float teamnum;
for(tm = teams.sort_next; tm; tm = tm.sort_next) {
- if(tm.team == COLOR_SPECTATOR || (!tm.team_size && !hud_configure)) // no players? don't display
+ if(tm.team == COLOR_SPECTATOR || (!tm.team_size && !autocvar__hud_configure)) // no players? don't display
continue;
score = tm.(teamscores[ts_primary]);
- if(hud_configure)
+ if(autocvar__hud_configure)
score = 123;
leader = 0;
//
void HUD_RaceTimer (void) {
float id = HUD_PANEL_RACETIMER;
- HUD_Panel_GetName(id);
- HUD_Panel_UpdateCvars(panel_name);
+ HUD_Panel_UpdateCvarsForId(id);
vector pos, mySize;
pos = panel_pos;
mySize = panel_size;
HUD_Panel_DrawBg(id, pos, mySize, 0);
- padding = HUD_Panel_GetPadding(id);
+ padding = panel_bg_padding;
if(panel_bg_padding)
{
pos += '1 1 0' * panel_bg_padding;
float a, t;
string s, forcetime;
- if(hud_configure)
+ 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', HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
void HUD_VoteWindow(void)
{
float id = HUD_PANEL_VOTE;
- HUD_Panel_GetName(id);
- HUD_Panel_UpdateCvars(panel_name);
+ HUD_Panel_UpdateCvarsForId(id);
vector pos, mySize;
pos = panel_pos;
mySize = panel_size;
vote_prev = vote_active;
}
- if(vote_active || hud_configure)
+ if(vote_active || autocvar__hud_configure)
vote_alpha = bound(0, (time - vote_change) * 2, 1);
else
vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
- if(hud_configure)
+ if(autocvar__hud_configure)
{
vote_yescount = 3;
vote_nocount = 2;
a = vote_alpha * bound(cvar_or("hud_vote_alreadyvoted_alpha", 0.75), 1 - vote_highlighted, 1);
HUD_Panel_DrawBg(id, pos, mySize, a);
- padding = HUD_Panel_GetPadding(id);
+ padding = panel_bg_padding;
if(panel_bg_padding)
{
pos += '1 1 0' * panel_bg_padding;
s = "A vote has been called for: ";
drawstring_aspect(pos + eY * (1/12) * mySize_y, s, eX * mySize_x + eY * (3/12) * mySize_y, mySize_y*(3/12), '1 1 1', a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
s = textShortenToWidth(vote_called_vote, mySize_x, '1 1 0' * mySize_y * (3/12), stringwidth_colors); // TODO: broken?
- if(hud_configure)
+ if(autocvar__hud_configure)
s = "Configure the HUD";
drawstring_aspect(pos + eY * (4/12) * mySize_y, s, eX * mySize_x + eY * (2/12) * mySize_y, mySize_y*(2/12), '1 1 1', a * HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
else
mod_active = 0;
- if(hud_configure)
+ if(autocvar__hud_configure)
{
redflag = 1;
blueflag = 2;
void HUD_ModIcons(void)
{
- if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && !hud_configure)
+ if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && !autocvar__hud_configure)
return;
float id = HUD_PANEL_MODICONS;
- HUD_Panel_GetName(id);
- HUD_Panel_UpdateCvars(panel_name);
+ HUD_Panel_UpdateCvarsForId(id);
vector pos, mySize;
pos = panel_pos;
mySize = panel_size;
mod_prev = mod_active;
}
- if(mod_active || hud_configure)
+ if(mod_active || autocvar__hud_configure)
mod_alpha = bound(0, (time - mod_change) * 2, 1);
else
mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
if(mod_alpha)
HUD_Panel_DrawBg(id, pos, mySize, mod_alpha);
- padding = HUD_Panel_GetPadding(id);
+ padding = panel_bg_padding;
if(panel_bg_padding)
{
pos += '1 1 0' * panel_bg_padding;
// these MUST be ran in order to update mod_active
if(gametype == GAME_KEYHUNT)
HUD_Mod_KH(pos, mySize);
- else if(gametype == GAME_CTF || hud_configure)
+ else if(gametype == GAME_CTF || autocvar__hud_configure)
HUD_Mod_CTF(pos, mySize); // forcealpha only needed for ctf icons, as only they are shown in config mode
else if(gametype == GAME_NEXBALL)
HUD_Mod_NexBall(pos, mySize);
void HUD_DrawPressedKeys(void)
{
float id = HUD_PANEL_PRESSEDKEYS;
- HUD_Panel_GetName(id);
- HUD_Panel_UpdateCvars(panel_name);
+ HUD_Panel_UpdateCvarsForId(id);
vector pos, mySize;
pos = panel_pos;
mySize = panel_size;
HUD_Panel_DrawBg(id, pos, mySize, 0);
- padding = HUD_Panel_GetPadding(id);
+ padding = panel_bg_padding;
if(panel_bg_padding)
{
pos += '1 1 0' * panel_bg_padding;
void HUD_Chat(void)
{
float id = HUD_PANEL_CHAT;
- HUD_Panel_GetName(id);
- HUD_Panel_UpdateCvars(panel_name);
+ HUD_Panel_UpdateCvarsForId(id);
vector pos, mySize;
pos = panel_pos;
mySize = panel_size;
HUD_Panel_DrawBg(id, pos, mySize, 0);
- padding = HUD_Panel_GetPadding(id);
+ padding = panel_bg_padding;
if(panel_bg_padding)
{
pos += '1 1 0' * panel_bg_padding;
cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
cvar_set("con_chat", ftos(floor(mySize_y/cvar("con_chatsize") - 0.5)));
- if(hud_configure)
+ if(autocvar__hud_configure)
{
float chatsize;
chatsize = cvar("con_chatsize");
void HUD_EngineInfo(void)
{
float id = HUD_PANEL_ENGINEINFO;
- HUD_Panel_GetName(id);
- HUD_Panel_UpdateCvars(panel_name);
+ HUD_Panel_UpdateCvarsForId(id);
vector pos, mySize;
pos = panel_pos;
mySize = panel_size;
HUD_Panel_DrawBg(id, pos, mySize, 0);
- padding = HUD_Panel_GetPadding(id);
+ padding = panel_bg_padding;
if(panel_bg_padding)
{
pos += '1 1 0' * panel_bg_padding;
hud_fontsize = HUD_GetFontsize("hud_fontsize");
hud_fontsize_spec = HUD_GetFontsize("hud_fontsize_spec");
- hud_configure = cvar("_hud_configure");
-
// Drawing stuff
// HUD configure visible grid
- if(hud_configure && cvar("hud_configure_grid") && cvar("hud_configure_grid_alpha"))
+ if(autocvar__hud_configure && autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha)
{
float i;
// x-axis
- for(i = 0; i < 1/bound(0.005, cvar("hud_configure_grid_x"), 0.2); ++i)
+ for(i = 0; i < 1/bound(0.005, autocvar_hud_configure_grid_x, 0.2); ++i)
{
- drawfill(eX * i * vid_conwidth * bound(0.005, cvar("hud_configure_grid_x"), 0.2), eX + eY * vid_conheight, '0.5 0.5 0.5', cvar("hud_configure_grid_alpha"), DRAWFLAG_NORMAL);
+ drawfill(eX * i * vid_conwidth * bound(0.005, autocvar_hud_configure_grid_x, 0.2), eX + eY * vid_conheight, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
}
// y-axis
- for(i = 0; i < 1/bound(0.005, cvar("hud_configure_grid_y"), 0.2); ++i)
+ for(i = 0; i < 1/bound(0.005, autocvar_hud_configure_grid_y, 0.2); ++i)
{
- drawfill(eY * i * vid_conheight * bound(0.005, cvar("hud_configure_grid_y"), 0.2), eY + eX * vid_conwidth, '0.5 0.5 0.5', cvar("hud_configure_grid_alpha"), DRAWFLAG_NORMAL);
+ drawfill(eY * i * vid_conheight * bound(0.005, autocvar_hud_configure_grid_y, 0.2), eY + eX * vid_conwidth, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
}
}
if(cvar_string("hud_dock") != "" && cvar_string("hud_dock") != "0")
drawpic('0 0 0', strcat("gfx/hud/", cvar_string("hud_skin"), "/", cvar_string("hud_dock")), eX * vid_conwidth + eY * vid_conheight, color_vec, cvar("hud_dock_alpha") * menu_fade_alpha, DRAWFLAG_NORMAL); // no aspect ratio forcing on dock...
- if(HUD_Panel_CheckActive(HUD_PANEL_RADAR) || hud_configure)
+ if(autocvar_hud_radar || autocvar__hud_configure)
if(cvar_string("hud_radar") != "0" && (cvar("hud_radar") == 2 || teamplay))
HUD_Radar();
- if(HUD_Panel_CheckActive(HUD_PANEL_WEAPONICONS) || hud_configure)
+ if(autocvar_hud_weaponicons || autocvar__hud_configure)
HUD_WeaponIcons();
- if(HUD_Panel_CheckActive(HUD_PANEL_INVENTORY) || hud_configure)
+ if(autocvar_hud_inventory || autocvar__hud_configure)
HUD_Inventory();
- if(HUD_Panel_CheckActive(HUD_PANEL_POWERUPS) || hud_configure)
+ if(autocvar_hud_powerups || autocvar__hud_configure)
HUD_Powerups();
- if(HUD_Panel_CheckActive(HUD_PANEL_HEALTHARMOR) || hud_configure)
+ if(autocvar_hud_healtharmor || autocvar__hud_configure)
HUD_HealthArmor();
- if(HUD_Panel_CheckActive(HUD_PANEL_NOTIFY) || hud_configure)
+ if(autocvar_hud_notify || autocvar__hud_configure)
HUD_Notify();
- if(HUD_Panel_CheckActive(HUD_PANEL_TIMER) || hud_configure)
+ if(autocvar_hud_timer || autocvar__hud_configure)
HUD_Timer();
- if(HUD_Panel_CheckActive(HUD_PANEL_SCORE) || hud_configure)
+ if(autocvar_hud_score || autocvar__hud_configure)
HUD_Score();
- if(HUD_Panel_CheckActive(HUD_PANEL_RACETIMER) || hud_configure)
- if(gametype == GAME_RACE || gametype == GAME_CTS || hud_configure)
+ if(autocvar_hud_racetimer || autocvar__hud_configure)
+ if(gametype == GAME_RACE || gametype == GAME_CTS || autocvar__hud_configure)
HUD_RaceTimer();
- if(HUD_Panel_CheckActive(HUD_PANEL_VOTE) || hud_configure)
+ if(autocvar_hud_vote || autocvar__hud_configure)
HUD_VoteWindow();
- if(HUD_Panel_CheckActive(HUD_PANEL_MODICONS) || hud_configure)
+ if(autocvar_hud_modicons || autocvar__hud_configure)
HUD_ModIcons();
- if(HUD_Panel_CheckActive(HUD_PANEL_PRESSEDKEYS) || hud_configure)
- if(spectatee_status > 0 || cvar("hud_pressedkeys") >= 2 || hud_configure)
+ if(autocvar_hud_pressedkeys || autocvar__hud_configure)
+ if(spectatee_status > 0 || cvar("hud_pressedkeys") >= 2 || autocvar__hud_configure)
HUD_DrawPressedKeys();
- if(HUD_Panel_CheckActive(HUD_PANEL_CHAT) || hud_configure)
+ if(autocvar_hud_chat || autocvar__hud_configure)
HUD_Chat();
else
cvar_set("con_chatrect", "0");
- if(HUD_Panel_CheckActive(HUD_PANEL_ENGINEINFO) || hud_configure)
+ if(autocvar_hud_engineinfo || autocvar__hud_configure)
HUD_EngineInfo();
// TODO hud_'ify these
if (cvar("cl_showacceleration"))
HUD_ShowAcceleration();
- if (hud_configure && spectatee_status && hud_configure_prev == -1) // try to join if we are in hud_configure mode, but still spectating, and in the first frame (in order to get rid of motd when launching a server via the menu "HUD Setup" button)
+ if (autocvar__hud_configure && spectatee_status && hud_configure_prev == -1) // try to join if we are in hud_configure mode, but still spectating, and in the first frame (in order to get rid of motd when launching a server via the menu "HUD Setup" button)
localcmd("cmd selectteam auto; cmd join\n");
- hud_configure_prev = hud_configure;
+ hud_configure_prev = autocvar__hud_configure;
- if (!hud_configure) // hud config mode disabled, enable normal alpha stuff again
+ if (!autocvar__hud_configure) // hud config mode disabled, enable normal alpha stuff again
disable_menu_alphacheck = 0;
}
float hud_border_thickness;
float hud_accuracy_border_thickness;
-float hud_configure;
float hud_configure_checkcollisions;
float hud_configure_prev;
string hud_skin_path;
+var float active_panel; // this panel has recently referred the UpdateCvars macro
var string panel_name;
-
var float panel_enabled;
var vector panel_pos;
var vector panel_size;
var string panel_bg;
-var vector panel_bg_color;
-var string panel_bg_color_team;
-var string panel_bg_alpha;
-var string panel_bg_border;
-var string panel_bg_padding;
+var string panel_bg_str; // "_str" vars contain the raw value of the cvar, non-"_str" contains what hud.qc code should use
+var string panel_bg_color;
+var float panel_bg_color_team;
+var string panel_bg_color_team_str;
+var float panel_bg_alpha;
+var string panel_bg_alpha_str;
+var float panel_bg_border;
+var string panel_bg_border_str;
+var float panel_bg_padding;
+var string panel_bg_padding_str;
var float panel_accuracy_yellow;
var float panel_accuracy_onlycurrent;
var float panel_accuracy_flip;
var float panel_accuracy_foreground_alpha;
var float panel_accuracy_alreadyvoted_alpha;
+// Because calling lots of functions in QC apparently cuts fps in half on many machines:
+// ----------------------
+// MACRO HELL STARTS HERE
+// ----------------------
+// Little help for the poor people who have to make sense of this: Start from the bottom
+
+// we probably want to get rid of GetName in the most places in hud.qc, TODO!
// Get name of specified panel id
#define HUD_Panel_GetName(id) \
switch(id) { \
- case HUD_PANEL_WEAPONICONS: panel_name = HUD_PANELNAME_WEAPONICONS; return; \
- case HUD_PANEL_INVENTORY: panel_name = HUD_PANELNAME_INVENTORY; return; \
- case HUD_PANEL_POWERUPS: panel_name = HUD_PANELNAME_POWERUPS; return; \
- case HUD_PANEL_HEALTHARMOR: panel_name = HUD_PANELNAME_HEALTHARMOR; return; \
- case HUD_PANEL_NOTIFY: panel_name = HUD_PANELNAME_NOTIFY; return; \
- case HUD_PANEL_TIMER: panel_name = HUD_PANELNAME_TIMER; return; \
- case HUD_PANEL_RADAR: panel_name = HUD_PANELNAME_RADAR; return; \
- case HUD_PANEL_SCORE: panel_name = HUD_PANELNAME_SCORE; return; \
- case HUD_PANEL_RACETIMER: panel_name = HUD_PANELNAME_RACETIMER; return; \
- case HUD_PANEL_VOTE: panel_name = HUD_PANELNAME_VOTE; return; \
- case HUD_PANEL_MODICONS: panel_name = HUD_PANELNAME_MODICONS; return; \
- case HUD_PANEL_PRESSEDKEYS: panel_name = HUD_PANELNAME_PRESSEDKEYS; return; \
- case HUD_PANEL_CHAT: panel_name = HUD_PANELNAME_CHAT; return; \
- case HUD_PANEL_ENGINEINFO: panel_name = HUD_PANELNAME_ENGINEINFO; return; \
+ case HUD_PANEL_WEAPONICONS: panel_name = HUD_PANELNAME_WEAPONICONS; break; \
+ case HUD_PANEL_INVENTORY: panel_name = HUD_PANELNAME_INVENTORY; break; \
+ case HUD_PANEL_POWERUPS: panel_name = HUD_PANELNAME_POWERUPS; break; \
+ case HUD_PANEL_HEALTHARMOR: panel_name = HUD_PANELNAME_HEALTHARMOR; break; \
+ case HUD_PANEL_NOTIFY: panel_name = HUD_PANELNAME_NOTIFY; break; \
+ case HUD_PANEL_TIMER: panel_name = HUD_PANELNAME_TIMER; break; \
+ case HUD_PANEL_RADAR: panel_name = HUD_PANELNAME_RADAR; break; \
+ case HUD_PANEL_SCORE: panel_name = HUD_PANELNAME_SCORE; break; \
+ case HUD_PANEL_RACETIMER: panel_name = HUD_PANELNAME_RACETIMER; break; \
+ case HUD_PANEL_VOTE: panel_name = HUD_PANELNAME_VOTE; break; \
+ case HUD_PANEL_MODICONS: panel_name = HUD_PANELNAME_MODICONS; break; \
+ case HUD_PANEL_PRESSEDKEYS: panel_name = HUD_PANELNAME_PRESSEDKEYS; break; \
+ case HUD_PANEL_CHAT: panel_name = HUD_PANELNAME_CHAT; break; \
+ case HUD_PANEL_ENGINEINFO: panel_name = HUD_PANELNAME_ENGINEINFO; break; \
+}
+
+// Get value for panel_bg: if "" fetch default, else use panel_bg_str
+// comment on last line of macro: // we probably want to see a background in config mode at all times...
+#define HUD_Panel_GetBg()\
+if(!autocvar__hud_configure && panel_bg_str == "0") {\
+ panel_bg = 0;\
+} else {\
+ if(panel_bg_str == "") {\
+ panel_bg = autocvar_hud_bg;\
+ } if(panel_bg_str == "0" && autocvar__hud_configure) {\
+ panel_bg = "border"; \
+ }\
}
-// Update all cvars of given panel
+// Get value for panel_bg_color_team: if "" fetch default, else use panel_bg_color_team_str
+#define HUD_Panel_GetColorTeam()\
+if(panel_bg_color_team_str == "")\
+ panel_bg_color_team = autocvar_hud_bg_color_team;\
+else\
+ panel_bg_color_team = stof(panel_bg_color_team_str);
+
+// Get value for panel_bg_alpha: if "" fetch default, else use panel_bg_alpha. Also do various menu dialog fadeout/in checks, and minalpha checks
+// comment on line 3 of macro: // do not set a minalpha cap when showing the config dialog for this panel
+#define HUD_Panel_GetBgAlpha()\
+if(panel_bg_alpha_str == "")\
+ panel_bg_alpha_str = autocvar_hud_bg_alpha;\
+panel_bg_alpha = stof(panel_bg_alpha_str);\
+if(autocvar__hud_configure && disable_menu_alphacheck == 2 && highlightedPanel == active_panel)\
+ panel_bg_alpha = (1 - autocvar__menu_alpha) * max(autocvar_hud_configure_bg_minalpha, panel_bg_alpha) + autocvar__menu_alpha) * panel_bg_alpha;\
+else if(autocvar__hud_configure)\
+ panel_bg_alpha = max(autocvar_hud_configure_bg_minalpha, panel_bg_alpha);\
+if(autocvar__hud_configure && !panel_enabled)\
+ panel_bg_alpha = 0.25;\
+if(!(disable_menu_alphacheck == 2 && highlightedPanel == id))\
+ panel_bg_alpha *= menu_fade_alpha;\
+
+#define HUD_Panel_GetBorder()\
+if(panel_bg_border_str == "")\
+ panel_bg_border = autocvar_hud_bg_border;\
+else\
+ panel_bg_border = stof(panel_bg_border_str);
+
+#define HUD_Panel_GetPadding()\
+if(panel_bg_border_padding == "")\
+ panel_bg_padding = autocvar_hud_bg_padding;\
+else\
+ panel_bg_padding = stof(panel_bg_padding_str);\
+panel_bg_padding = min(min(mySize_x, mySize_y)/2 - 5, panel_bg_padding);
+
+// Point to the macros above (stupid max macro length)
+#define HUD_Panel_StringVars()\
+HUD_Panel_GetBg \
+HUD_Panel_GetColorTeam \
+HUD_Panel_GetBgAlpha \
+HUD_Panel_GetBorder \
+HUD_Panel_GetPadding
+
+// Update all common cvars of given panel name
#define HUD_Panel_UpdateCvars(name) \
-panel_enabled = autocvar_hud_##name; \
-panel_pos = autocvar_hud_##name_pos; \
-panel_size = autocvar_hud_##name_size; \
-panel_bg = autocvar_hud_##name_bg; \
-panel_bg_color = autocvar_hud_##name_bg_color; \
-panel_bg_color_team = autocvar_hud_##name_bg_color_team; \
-panel_bg_alpha = autocvar_hud_##name_bg_alpha; \
-panel_bg_border = autocvar_hud_##name_bg_border; \
-panel_bg_padding = autocvar_hud_##name_bg_padding; \
-panel_accuracy_yellow = autocvar_hud_##name_accuracy_yellow; \
-panel_onlycurrent = autocvar_hud_##name_onlycurrent; \
-panel_flip = autocvar_hud_##name_flip; \
-panel_iconalign = autocvar_hud_##name_iconalign; \
-panel_baralign = autocvar_hud_##name_baralign; \
-panel_info_top = autocvar_hud_##name_info_top; \
-panel_alreadyvoted_alpha = autocvar_hud_##name_alreadyvoted_alpha;
+panel_enabled = autocvar_hud_##name##; \
+panel_pos = autocvar_hud_##name##_pos; \
+panel_size = autocvar_hud_##name##_size; \
+panel_bg_str = autocvar_hud_##name##_bg; \
+panel_bg_color = autocvar_hud_##name##_bg_color; \
+panel_bg_color_team_str = autocvar_hud_##name##_bg_color_team; \
+panel_bg_alpha_str = autocvar_hud_##name##_bg_alpha; \
+panel_bg_border_str = autocvar_hud_##name##_bg_border; \
+panel_bg_padding_str = autocvar_hud_##name##_bg_padding; \
+HUD_Panel_StringVars
+
+// Update all common cvars of given panel id
+#define HUD_Panel_UpdateCvarsForId(id) \
+active_panel = id; \
+switch(id) { \
+ case HUD_PANEL_WEAPONICONS: HUD_Panel_UpdateCvars(weaponicons) break; \
+ case HUD_PANEL_INVENTORY: HUD_Panel_UpdateCvars(inventory) break; \
+ case HUD_PANEL_POWERUPS: HUD_Panel_UpdateCvars(powerups) break; \
+ case HUD_PANEL_HEALTHARMOR: HUD_Panel_UpdateCvars(healtharmor) break; \
+ case HUD_PANEL_NOTIFY: HUD_Panel_UpdateCvars(notify) break; \
+ case HUD_PANEL_TIMER: HUD_Panel_UpdateCvars(timer) break; \
+ case HUD_PANEL_RADAR: HUD_Panel_UpdateCvars(radar) break; \
+ case HUD_PANEL_SCORE: HUD_Panel_UpdateCvars(score) break; \
+ case HUD_PANEL_RACETIMER: HUD_Panel_UpdateCvars(racetimer) break; \
+ case HUD_PANEL_VOTE: HUD_Panel_UpdateCvars(vote) break; \
+ case HUD_PANEL_MODICONS: HUD_Panel_UpdateCvars(modicons) break; \
+ case HUD_PANEL_PRESSEDKEYS: HUD_Panel_UpdateCvars(pressedkeys) break; \
+ case HUD_PANEL_CHAT: HUD_Panel_UpdateCvars(chat) break; \
+ case HUD_PANEL_ENGINEINFO: HUD_Panel_UpdateCvars(engineinfo) break; \
+}
+
+/* These cvars have to be placed separately wherever they are needed.
+panel_accuracy_yellow = autocvar_hud_##name##_accuracy_yellow; \
+panel_onlycurrent = autocvar_hud_##name##_onlycurrent; \
+panel_flip = autocvar_hud_##name##_flip; \
+panel_iconalign = autocvar_hud_##name##_iconalign; \
+panel_baralign = autocvar_hud_##name##_baralign; \
+panel_info_top = autocvar_hud_##name##_info_top; \
+panel_alreadyvoted_alpha = autocvar_hud_##name##_alreadyvoted_alpha;
+*/