3 #include <common/t_items.qh>
7 void DrawNadeProgressBar(vector myPos, vector mySize, float progress, vector color)
9 HUD_Panel_DrawProgressBar(
10 myPos + eX * autocvar_hud_panel_ammo_progressbar_xoffset * mySize.x,
11 mySize - eX * autocvar_hud_panel_ammo_progressbar_xoffset * mySize.x,
12 autocvar_hud_panel_ammo_progressbar_name,
13 progress, 0, 0, color,
14 autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
17 void DrawAmmoNades(vector myPos, vector mySize, bool draw_expanding, float expand_time); // TODO: mutator
19 void DrawAmmoItem(vector myPos, vector mySize, .int ammoType, bool isCurrent, bool isInfinite)
21 if(ammoType == ammo_none)
24 // Initialize variables
27 if(autocvar__hud_configure)
29 isCurrent = (ammoType == ammo_rockets); // Rockets always current
33 ammo = getstati(GetAmmoStat(ammoType));
37 float scale = bound(0, autocvar_hud_panel_ammo_noncurrent_scale, 1);
38 myPos = myPos + (mySize - mySize * scale) * 0.5;
39 mySize = mySize * scale;
42 vector iconPos, textPos;
43 if(autocvar_hud_panel_ammo_iconalign)
45 iconPos = myPos + eX * 2 * mySize.y;
51 textPos = myPos + eX * mySize.y;
54 bool isShadowed = (ammo <= 0 && !isCurrent && !isInfinite);
56 vector iconColor = isShadowed ? '0 0 0' : '1 1 1';
59 textColor = '0.2 0.95 0';
63 textColor = '0.8 0.04 0';
69 alpha = panel_fg_alpha;
71 alpha = panel_fg_alpha * bound(0, autocvar_hud_panel_ammo_noncurrent_alpha, 1) * 0.5;
73 alpha = panel_fg_alpha * bound(0, autocvar_hud_panel_ammo_noncurrent_alpha, 1);
75 string text = isInfinite ? "\xE2\x88\x9E" : ftos(ammo); // Use infinity symbol (U+221E)
80 drawpic_aspect_skin(myPos, "ammo_current_bg", mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
82 if(ammo > 0 && autocvar_hud_panel_ammo_progressbar)
83 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);
85 if(autocvar_hud_panel_ammo_text)
86 drawstring_aspect(textPos, text, eX * (2/3) * mySize.x + eY * mySize.y, textColor, alpha, DRAWFLAG_NORMAL);
88 drawpic_aspect_skin(iconPos, GetAmmoPicture(ammoType), '1 1 0' * mySize.y, iconColor, alpha, DRAWFLAG_NORMAL);
93 float nade_statuschange_time;
97 if(hud != HUD_NORMAL) return;
98 if(!autocvar__hud_configure)
100 if(!autocvar_hud_panel_ammo) return;
101 if(spectatee_status == -1) return;
104 HUD_Panel_UpdateCvars();
106 draw_beginBoldFont();
115 pos += '1 1 0' * panel_bg_padding;
116 mySize -= '2 2 0' * panel_bg_padding;
119 int rows = 0, columns, row, column;
120 float nade_cnt = STAT(NADE_BONUS), nade_score = STAT(NADE_BONUS_SCORE);
121 bool draw_nades = (nade_cnt > 0 || nade_score > 0);
122 float nade_statuschange_elapsedtime;
123 int total_ammo_count;
126 if (autocvar_hud_panel_ammo_onlycurrent)
127 total_ammo_count = 1;
129 total_ammo_count = AMMO_COUNT;
134 if (nade_cnt != nade_prevframe)
136 nade_statuschange_time = time;
137 nade_prevstatus = nade_prevframe;
138 nade_prevframe = nade_cnt;
142 nade_prevstatus = nade_prevframe = nade_statuschange_time = 0;
144 rows = HUD_GetRowCount(total_ammo_count, mySize, 3);
145 columns = ceil((total_ammo_count)/rows);
146 ammo_size = eX * mySize.x*(1/columns) + eY * mySize.y*(1/rows);
148 vector offset = '0 0 0';
150 if(ammo_size.x/ammo_size.y > 3)
152 newSize = 3 * ammo_size.y;
153 offset.x = ammo_size.x - newSize;
155 ammo_size.x = newSize;
159 newSize = 1/3 * ammo_size.x;
160 offset.y = ammo_size.y - newSize;
162 ammo_size.y = newSize;
165 Weapon wep = switchweapon;
167 bool infinite_ammo = (STAT(ITEMS) & IT_UNLIMITED_WEAPON_AMMO);
169 if(autocvar_hud_panel_ammo_onlycurrent)
171 if(autocvar__hud_configure)
173 DrawAmmoItem(pos, ammo_size, ammo_rockets, true, false);
197 for(i = 0; i < AMMO_COUNT; ++i)
199 ammotype = GetAmmoFieldFromNum(i);
201 pos + eX * column * (ammo_size.x + offset.x) + eY * row * (ammo_size.y + offset.y),
204 (wep.ammo_field == ammotype),
219 nade_statuschange_elapsedtime = time - nade_statuschange_time;
221 float f = bound(0, nade_statuschange_elapsedtime*2, 1);
223 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);