]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'sev/hud_ammo_panel' into 'master'
authorMario <zacjardine@y7mail.com>
Mon, 19 Jan 2015 02:42:57 +0000 (02:42 +0000)
committerMario <zacjardine@y7mail.com>
Mon, 19 Jan 2015 02:42:57 +0000 (02:42 +0000)
Sev/hud ammo panel

This branch makes the following additions and changes to the HUD ammo panel:

- New cvar *hud_panel_ammo_noncurrent_alpha*, to set the alpha of all ammo items not currently used (was hardcoded)
- New cvar *hud_panel_ammo_noncurrent_scale*, to scale the size of not currently used ammo items in relation to the current ammo
- Never blacks out the current ammo, even if 0. A red 0 is easier to see and understand than a black item
- The red text color for low ammo is slightly brighter, for better visibility
- In conformance to established color codes, infinite ammo text is now green instead of blue
- Infinite ammo text shows the proper infinity symbol, instead of 999

The purpose of this is to improve consistency and to allow setting appart current from noncurrent ammo,
as an alternative to using *hud_panel_ammo_onlycurrent*.

Luma WIP:
![hud_ammo](https://gitlab.com/uploads/xonotic/xonotic-data.pk3dir/119d9c32a0/hud_ammo.png)

See merge request !84

_hud_descriptions.cfg
hud_luminos.cfg
hud_luminos_minimal.cfg
hud_luminos_minimal_xhair.cfg
hud_luminos_old.cfg
hud_nexuiz.cfg
qcsrc/client/autocvars.qh
qcsrc/client/hud.qc
qcsrc/client/hud_config.qc
qcsrc/menu/xonotic/dialog_hudpanel_ammo.c

index 270bd2bd9294693bcbf787666f7b3b2d341e2141..7d8b0ccf9f02356814b2fb14e3431f8c96dce665 100644 (file)
@@ -66,6 +66,8 @@ seta hud_panel_ammo "" "enable/disable this panel"
 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"
index f3bc914e6a48be696bd9e3b8879eb90d9ab0254f..a37447783d6009448e095c0bfc26a9d894aae7fe 100644 (file)
@@ -70,6 +70,8 @@ seta hud_panel_ammo_bg_alpha ""
 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"
index 050689b38caf95d525f07e83f378649fc49dafff..3128aff4f15c84140e961f7976c3d47e182a18f1 100644 (file)
@@ -70,6 +70,8 @@ seta hud_panel_ammo_bg_alpha ""
 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"
index 8fb6cbe93da88fd67f099c634126551449435fdf..0f424c6f06547e643c6b26f629321f00b00d6553 100644 (file)
@@ -70,6 +70,8 @@ seta hud_panel_ammo_bg_alpha ""
 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"
index 9d71e2e2872cc4f4d6e0624a2d2b5e74064fa5cf..3ee6b927758b0c567ce856a0fb3019f580bc00b8 100644 (file)
@@ -70,6 +70,8 @@ seta hud_panel_ammo_bg_alpha ""
 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"
index 9e4678293d627419612564b5d12d91a4365d56fc..c4aebab73900a22d3bd034984dbd58659cdc5d47 100644 (file)
@@ -70,6 +70,8 @@ seta hud_panel_ammo_bg_alpha ""
 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"
index f06c5bfb3bd0f66e6dbc25ad67f201587b50a7c0..8215b9faf2aeddfe7057eede883513cbc258a4c7 100644 (file)
@@ -221,6 +221,8 @@ float autocvar_hud_panel_ammo;
 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;
index 8a9aab304c4b7fecf0f09ecc3857660aa97a33b1..9e6861ebd06e7d05a4a0fabfc4c305dc4433c3c3 100644 (file)
@@ -879,74 +879,76 @@ void DrawAmmoNades(vector myPos, vector mySize, float draw_expanding, float expa
        }
 }
 
-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;
index 047e012ad65d8670b5502679f1bff01f72cce9c7..78f16f88db99f7b851edc2c426cb6d960527ccee 100644 (file)
@@ -88,6 +88,8 @@ void HUD_Panel_ExportCfg(string cfgname)
                                        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");
index 3c89d0a03ba08c63b1162fe79f422b65ac89a381..15095b2baed2e320a55b5b4c89bdd325142f601d 100644 (file)
@@ -26,8 +26,16 @@ void XonoticHUDAmmoDialog_fill(entity me)
                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