]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud/panel/ammo.qc
Merge branch 'master' into Lyberta/StandaloneOverkillWeapons
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud / panel / ammo.qc
index 236a585985e8c983696284464d02b62277feb090..7bae78cb6c5ab38385ea6a0b1cbdbc338be2a732 100644 (file)
@@ -1,3 +1,7 @@
+#include "ammo.qh"
+
+#include <common/t_items.qh>
+
 // Ammo (#1)
 
 void DrawNadeProgressBar(vector myPos, vector mySize, float progress, vector color)
@@ -14,6 +18,7 @@ void DrawAmmoNades(vector myPos, vector mySize, bool draw_expanding, float expan
 
 void DrawAmmoItem(vector myPos, vector mySize, .int ammoType, bool isCurrent, bool isInfinite)
 {
+    TC(bool, isCurrent); TC(bool, isInfinite);
        if(ammoType == ammo_none)
                return;
 
@@ -93,11 +98,13 @@ void HUD_Ammo()
        if(hud != HUD_NORMAL) return;
        if(!autocvar__hud_configure)
        {
-               if(!autocvar_hud_panel_ammo) return;
-               if(spectatee_status == -1) return;
+               if((!autocvar_hud_panel_ammo) || (spectatee_status == -1))
+                       return;
+               if(STAT(HEALTH) < 1 && autocvar_hud_panel_ammo_hide_ondeath)
+                       return;
        }
 
-       HUD_Panel_UpdateCvars();
+       HUD_Panel_LoadCvars();
 
        draw_beginBoldFont();
 
@@ -105,7 +112,11 @@ void HUD_Ammo()
        pos = panel_pos;
        mySize = panel_size;
 
-       HUD_Panel_DrawBg(1);
+       if (autocvar_hud_panel_ammo_dynamichud)
+               HUD_Scale_Enable();
+       else
+               HUD_Scale_Disable();
+       HUD_Panel_DrawBg();
        if(panel_bg_padding)
        {
                pos += '1 1 0' * panel_bg_padding;
@@ -113,7 +124,7 @@ void HUD_Ammo()
        }
 
        int rows = 0, columns, row, column;
-       float nade_cnt = getstatf(STAT_NADE_BONUS), nade_score = getstatf(STAT_NADE_BONUS_SCORE);
+       float nade_cnt = STAT(NADE_BONUS), nade_score = STAT(NADE_BONUS_SCORE);
        bool draw_nades = (nade_cnt > 0 || nade_score > 0);
        float nade_statuschange_elapsedtime;
        int total_ammo_count;
@@ -139,9 +150,9 @@ void HUD_Ammo()
 
        rows = HUD_GetRowCount(total_ammo_count, mySize, 3);
        columns = ceil((total_ammo_count)/rows);
-       ammo_size = eX * mySize.x*(1/columns) + eY * mySize.y*(1/rows);
+       ammo_size = vec2(mySize.x / columns, mySize.y / rows);
 
-       vector offset = '0 0 0'; // fteqcc sucks
+       vector offset = '0 0 0';
        float newSize;
        if(ammo_size.x/ammo_size.y > 3)
        {
@@ -158,8 +169,11 @@ void HUD_Ammo()
                ammo_size.y = newSize;
        }
 
+       entity wepent = viewmodels[0]; // TODO: unhardcode
+
+       Weapon wep = wepent.switchweapon;
        int i;
-       bool infinite_ammo = (getstati(STAT_ITEMS, 0, 24) & IT_UNLIMITED_WEAPON_AMMO);
+       bool infinite_ammo = (STAT(ITEMS) & IT_UNLIMITED_WEAPON_AMMO);
        row = column = 0;
        if(autocvar_hud_panel_ammo_onlycurrent)
        {
@@ -172,7 +186,7 @@ void HUD_Ammo()
                        DrawAmmoItem(
                                pos,
                                ammo_size,
-                               (get_weaponinfo(switchweapon)).ammo_field,
+                               wep.ammo_field,
                                true,
                                infinite_ammo
                        );
@@ -193,10 +207,10 @@ void HUD_Ammo()
                {
                        ammotype = GetAmmoFieldFromNum(i);
                        DrawAmmoItem(
-                               pos + eX * column * (ammo_size.x + offset.x) + eY * row * (ammo_size.y + offset.y),
+                               pos + vec2(column * (ammo_size.x + offset.x), row * (ammo_size.y + offset.y)),
                                ammo_size,
                                ammotype,
-                               ((get_weaponinfo(switchweapon)).ammo_field == ammotype),
+                               (wep.ammo_field == ammotype),
                                infinite_ammo
                        );
 
@@ -215,7 +229,7 @@ void HUD_Ammo()
 
                float f = bound(0, nade_statuschange_elapsedtime*2, 1);
 
-               DrawAmmoNades(pos + eX * column * (ammo_size.x + offset.x) + eY * row * (ammo_size.y + offset.y), ammo_size, nade_prevstatus < nade_cnt && nade_cnt != 0 && f < 1, f);
+               DrawAmmoNades(pos + vec2(column * (ammo_size.x + offset.x), row * (ammo_size.y + offset.y)), ammo_size, nade_prevstatus < nade_cnt && nade_cnt != 0 && f < 1, f);
        }
 
        draw_endBoldFont();