3 #include <client/autocvars.qh>
4 #include <client/defs.qh>
5 #include <client/miscfunctions.qh>
6 #include <client/view.qh>
7 #include <common/t_items.qh>
8 #include <common/wepent.qh>
12 void DrawNadeProgressBar(vector myPos, vector mySize, float progress, vector color)
14 HUD_Panel_DrawProgressBar(
15 myPos + eX * autocvar_hud_panel_ammo_progressbar_xoffset * mySize.x,
16 mySize - eX * autocvar_hud_panel_ammo_progressbar_xoffset * mySize.x,
17 autocvar_hud_panel_ammo_progressbar_name,
18 progress, 0, 0, color,
19 autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
22 void DrawAmmoNades(vector myPos, vector mySize, bool draw_expanding, float expand_time); // TODO: mutator
24 void DrawAmmoItem(vector myPos, vector mySize, .int ammoType, bool isCurrent, bool isInfinite)
26 TC(bool, isCurrent); TC(bool, isInfinite);
27 if(ammoType == ammo_none)
30 // Initialize variables
33 if(autocvar__hud_configure)
35 isCurrent = (ammoType == ammo_rockets); // Rockets always current
39 ammo = getstati(GetAmmoStat(ammoType));
43 float scale = bound(0, autocvar_hud_panel_ammo_noncurrent_scale, 1);
44 myPos = myPos + (mySize - mySize * scale) * 0.5;
45 mySize = mySize * scale;
48 vector iconPos, textPos;
49 if(autocvar_hud_panel_ammo_iconalign)
51 iconPos = myPos + eX * 2 * mySize.y;
57 textPos = myPos + eX * mySize.y;
60 bool isShadowed = (ammo <= 0 && !isCurrent && !isInfinite);
62 vector iconColor = isShadowed ? '0 0 0' : '1 1 1';
65 textColor = '0.2 0.95 0';
69 textColor = '0.8 0.04 0';
75 alpha = panel_fg_alpha;
77 alpha = panel_fg_alpha * bound(0, autocvar_hud_panel_ammo_noncurrent_alpha, 1) * 0.5;
79 alpha = panel_fg_alpha * bound(0, autocvar_hud_panel_ammo_noncurrent_alpha, 1);
81 string text = isInfinite ? "\xE2\x88\x9E" : ftos(ammo); // Use infinity symbol (U+221E)
86 drawpic_aspect_skin(myPos, "ammo_current_bg", mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
88 if(ammo > 0 && autocvar_hud_panel_ammo_progressbar)
89 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);
91 if(autocvar_hud_panel_ammo_text)
92 drawstring_aspect(textPos, text, eX * (2/3) * mySize.x + eY * mySize.y, textColor, alpha, DRAWFLAG_NORMAL);
94 drawpic_aspect_skin(iconPos, GetAmmoPicture(ammoType), '1 1 0' * mySize.y, iconColor, alpha, DRAWFLAG_NORMAL);
99 float nade_statuschange_time;
103 if(hud != HUD_NORMAL) return;
104 if(!autocvar__hud_configure)
106 if((!autocvar_hud_panel_ammo) || (spectatee_status == -1))
108 if(STAT(HEALTH) < 1 && autocvar_hud_panel_ammo_hide_ondeath)
112 HUD_Panel_LoadCvars();
114 draw_beginBoldFont();
120 if (autocvar_hud_panel_ammo_dynamichud)
127 pos += '1 1 0' * panel_bg_padding;
128 mySize -= '2 2 0' * panel_bg_padding;
131 int rows = 0, columns, row, column;
132 float nade_cnt = STAT(NADE_BONUS), nade_score = STAT(NADE_BONUS_SCORE);
133 bool draw_nades = (nade_cnt > 0 || nade_score > 0);
134 float nade_statuschange_elapsedtime;
135 int total_ammo_count;
138 if (autocvar_hud_panel_ammo_onlycurrent)
139 total_ammo_count = 1;
141 total_ammo_count = AMMO_COUNT;
146 if (nade_cnt != nade_prevframe)
148 nade_statuschange_time = time;
149 nade_prevstatus = nade_prevframe;
150 nade_prevframe = nade_cnt;
154 nade_prevstatus = nade_prevframe = nade_statuschange_time = 0;
156 rows = HUD_GetRowCount(total_ammo_count, mySize, 3);
157 columns = ceil((total_ammo_count)/rows);
158 ammo_size = vec2(mySize.x / columns, mySize.y / rows);
160 vector offset = '0 0 0';
162 if(ammo_size.x/ammo_size.y > 3)
164 newSize = 3 * ammo_size.y;
165 offset.x = ammo_size.x - newSize;
167 ammo_size.x = newSize;
171 newSize = 1/3 * ammo_size.x;
172 offset.y = ammo_size.y - newSize;
174 ammo_size.y = newSize;
177 entity wepent = viewmodels[0]; // TODO: unhardcode
179 Weapon wep = wepent.switchweapon;
181 bool infinite_ammo = (STAT(ITEMS) & IT_UNLIMITED_WEAPON_AMMO);
183 if(autocvar_hud_panel_ammo_onlycurrent)
185 if(autocvar__hud_configure)
187 DrawAmmoItem(pos, ammo_size, ammo_rockets, true, false);
211 for(i = 0; i < AMMO_COUNT; ++i)
213 ammotype = GetAmmoFieldFromNum(i);
215 pos + vec2(column * (ammo_size.x + offset.x), row * (ammo_size.y + offset.y)),
218 (wep.ammo_field == ammotype),
233 nade_statuschange_elapsedtime = time - nade_statuschange_time;
235 float f = bound(0, nade_statuschange_elapsedtime*2, 1);
237 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);