seta hud_panel_ammo_pos "" "position of this panel"
seta hud_panel_ammo_size "" "size of this panel"
seta hud_panel_ammo_onlycurrent "" "1 = show only current ammo type"
+seta hud_panel_ammo_noncurrent_alpha "" "alpha of noncurrent ammo types"
+seta hud_panel_ammo_noncurrent_scale "" "scale of noncurrent ammo types, relative to the current ammo type"
seta hud_panel_ammo_iconalign "" "0 = align icons to the left, 1 = align icons to the right"
seta hud_panel_ammo_bg "" "if set to something else than \"\" = override default background"
seta hud_panel_ammo_bg_color "" "if set to something else than \"\" = override default panel background color"
seta hud_panel_ammo_bg_border ""
seta hud_panel_ammo_bg_padding ""
seta hud_panel_ammo_onlycurrent "0"
+seta hud_panel_ammo_noncurrent_alpha "0.7"
+seta hud_panel_ammo_noncurrent_scale "1"
seta hud_panel_ammo_iconalign "0"
seta hud_panel_ammo_progressbar "0"
seta hud_panel_ammo_progressbar_name "progressbar"
seta hud_panel_ammo_bg_border ""
seta hud_panel_ammo_bg_padding ""
seta hud_panel_ammo_onlycurrent "0"
+seta hud_panel_ammo_noncurrent_alpha "0.7"
+seta hud_panel_ammo_noncurrent_scale "1"
seta hud_panel_ammo_iconalign "0"
seta hud_panel_ammo_progressbar "0"
seta hud_panel_ammo_progressbar_name "progressbar"
seta hud_panel_ammo_bg_border ""
seta hud_panel_ammo_bg_padding ""
seta hud_panel_ammo_onlycurrent "1"
+seta hud_panel_ammo_noncurrent_alpha "0.7"
+seta hud_panel_ammo_noncurrent_scale "1"
seta hud_panel_ammo_iconalign "0"
seta hud_panel_ammo_progressbar "1"
seta hud_panel_ammo_progressbar_name "progressbar_ammo"
seta hud_panel_ammo_bg_border ""
seta hud_panel_ammo_bg_padding ""
seta hud_panel_ammo_onlycurrent "0"
+seta hud_panel_ammo_noncurrent_alpha "0.7"
+seta hud_panel_ammo_noncurrent_scale "1"
seta hud_panel_ammo_iconalign "0"
seta hud_panel_ammo_progressbar "0"
seta hud_panel_ammo_progressbar_name "progressbar"
seta hud_panel_ammo_bg_border ""
seta hud_panel_ammo_bg_padding ""
seta hud_panel_ammo_onlycurrent "0"
+seta hud_panel_ammo_noncurrent_alpha "0.7"
+seta hud_panel_ammo_noncurrent_scale "1"
seta hud_panel_ammo_iconalign "0"
seta hud_panel_ammo_progressbar "0"
seta hud_panel_ammo_progressbar_name "progressbar"
float autocvar_hud_panel_ammo_iconalign;
float autocvar_hud_panel_ammo_maxammo;
float autocvar_hud_panel_ammo_onlycurrent;
+float autocvar_hud_panel_ammo_noncurrent_alpha = 0.7;
+float autocvar_hud_panel_ammo_noncurrent_scale = 1;
float autocvar_hud_panel_ammo_progressbar;
string autocvar_hud_panel_ammo_progressbar_name;
float autocvar_hud_panel_ammo_progressbar_xoffset;
}
}
-void DrawAmmoItem(vector myPos, vector mySize, .float ammotype, float currently_selected, float infinite_ammo)
+void DrawAmmoItem(vector myPos, vector mySize, .float ammoType, float isCurrent, float isInfinite)
{
- float a = 0;
- if(ammotype != ammo_none)
+ if(ammoType == ammo_none)
+ return;
+
+ // Initialize variables
+
+ float ammo;
+ if(autocvar__hud_configure)
{
- if(autocvar__hud_configure)
- {
- currently_selected = (ammotype == ammo_rockets); //rockets always selected
- a = 60;
- }
- else
- {
- // how much ammo do we have of this ammotype?
- a = getstati(GetAmmoStat(ammotype));
- }
+ isCurrent = (ammoType == ammo_rockets); // Rockets always current
+ ammo = 60;
}
else
+ ammo = getstati(GetAmmoStat(ammoType));
+
+ if(!isCurrent)
{
- #if 0
- infinite_ammo = TRUE;
- #else
- return; // just don't draw infinite ammo at all.
- #endif
+ float scale = bound(0, autocvar_hud_panel_ammo_noncurrent_scale, 1);
+ myPos = myPos + (mySize - mySize * scale) * 0.5;
+ mySize = mySize * scale;
}
- vector color;
- if(infinite_ammo)
- color = '0 0.5 0.75';
- else if(a < 10)
- color = '0.7 0 0';
- else
- color = '1 1 1';
-
- float theAlpha;
- if(currently_selected)
- theAlpha = 1;
- else
- theAlpha = 0.7;
-
- vector picpos, numpos;
+ 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;
}
- if(currently_selected)
+ float isShadowed = (ammo <= 0 && !isCurrent && !isInfinite);
+
+ vector iconColor = isShadowed ? '0 0 0' : '1 1 1';
+ vector textColor;
+ if(isInfinite)
+ textColor = '0.2 0.95 0';
+ else if(isShadowed)
+ textColor = '0 0 0';
+ else if(ammo < 10)
+ textColor = '0.8 0.04 0';
+ else
+ textColor = '1 1 1';
+
+ float alpha;
+ if(isCurrent)
+ alpha = panel_fg_alpha;
+ else if(isShadowed)
+ alpha = panel_fg_alpha * bound(0, autocvar_hud_panel_ammo_noncurrent_alpha, 1) * 0.5;
+ else
+ alpha = panel_fg_alpha * bound(0, autocvar_hud_panel_ammo_noncurrent_alpha, 1);
+
+ string text = isInfinite ? "\xE2\x88\x9E" : ftos(ammo); // Use infinity symbol (U+221E)
+
+ // Draw item
+
+ if(isCurrent)
drawpic_aspect_skin(myPos, "ammo_current_bg", mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
- if(a > 0 && autocvar_hud_panel_ammo_progressbar)
- 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, a/autocvar_hud_panel_ammo_maxammo, 0, 0, color, autocvar_hud_progressbar_alpha * panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
+ if(ammo > 0 && autocvar_hud_panel_ammo_progressbar)
+ 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, ammo/autocvar_hud_panel_ammo_maxammo, 0, 0, textColor, autocvar_hud_progressbar_alpha * alpha, DRAWFLAG_NORMAL);
if(autocvar_hud_panel_ammo_text)
- {
- if(a > 0 || infinite_ammo)
- drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
- else // "ghost" ammo count
- drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, '0 0 0', panel_fg_alpha * theAlpha * 0.5, DRAWFLAG_NORMAL);
- }
- if(a > 0 || infinite_ammo)
- drawpic_aspect_skin(picpos, GetAmmoPicture(ammotype), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
- else // "ghost" ammo icon
- drawpic_aspect_skin(picpos, GetAmmoPicture(ammotype), '1 1 0' * mySize_y, '0 0 0', panel_fg_alpha * theAlpha * 0.5, DRAWFLAG_NORMAL);
+ drawstring_aspect(textPos, text, eX * (2/3) * mySize_x + eY * mySize_y, textColor, alpha, DRAWFLAG_NORMAL);
+
+ drawpic_aspect_skin(iconPos, GetAmmoPicture(ammoType), '1 1 0' * mySize_y, iconColor, alpha, DRAWFLAG_NORMAL);
}
float nade_prevstatus;
break;
case HUD_PANEL_AMMO:
HUD_Write_PanelCvar_q("_onlycurrent");
+ HUD_Write_PanelCvar_q("_noncurrent_alpha");
+ HUD_Write_PanelCvar_q("_noncurrent_scale");
HUD_Write_PanelCvar_q("_iconalign");
HUD_Write_PanelCvar_q("_progressbar");
HUD_Write_PanelCvar_q("_progressbar_name");
me.TD(me, 1, 3.8, e = makeXonoticCheckBox(0, "hud_panel_ammo_onlycurrent", _("Show only current ammo type")));
me.TR(me);
me.TDempty(me, 0.2);
- me.TD(me, 1, 1.4, e = makeXonoticTextLabel(0, _("Align icon:")));
- me.TD(me, 1, 2.4/2, e = makeXonoticRadioButton(2, "hud_panel_ammo_iconalign", "0", _("Left")));
- me.TD(me, 1, 2.4/2, e = makeXonoticRadioButton(2, "hud_panel_ammo_iconalign", "1", _("Right")));
+ me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, _("Noncurrent alpha:")));
+ me.TD(me, 1, 2.6, e = makeXonoticSlider(0, 1, 0.1, "hud_panel_ammo_noncurrent_alpha"));
+ me.TR(me);
+ me.TDempty(me, 0.2);
+ me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, _("Noncurrent scale:")));
+ me.TD(me, 1, 2.6, e = makeXonoticSlider(0, 1, 0.1, "hud_panel_ammo_noncurrent_scale"));
+ me.TR(me);
+ me.TDempty(me, 0.2);
+ me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, _("Align icon:")));
+ me.TD(me, 1, 2.6/2, e = makeXonoticRadioButton(2, "hud_panel_ammo_iconalign", "0", _("Left")));
+ me.TD(me, 1, 2.6/2, e = makeXonoticRadioButton(2, "hud_panel_ammo_iconalign", "1", _("Right")));
}
#endif