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 TC(bool, isCurrent); TC(bool, isInfinite);
22 if(ammoType == ammo_none)
25 // Initialize variables
28 if(autocvar__hud_configure)
30 isCurrent = (ammoType == ammo_rockets); // Rockets always current
34 ammo = getstati(GetAmmoStat(ammoType));
38 float scale = bound(0, autocvar_hud_panel_ammo_noncurrent_scale, 1);
39 myPos = myPos + (mySize - mySize * scale) * 0.5;
40 mySize = mySize * scale;
43 vector iconPos, textPos;
44 if(autocvar_hud_panel_ammo_iconalign)
46 iconPos = myPos + eX * 2 * mySize.y;
52 textPos = myPos + eX * mySize.y;
55 bool isShadowed = (ammo <= 0 && !isCurrent && !isInfinite);
57 vector iconColor = isShadowed ? '0 0 0' : '1 1 1';
60 textColor = '0.2 0.95 0';
64 textColor = '0.8 0.04 0';
70 alpha = panel_fg_alpha;
72 alpha = panel_fg_alpha * bound(0, autocvar_hud_panel_ammo_noncurrent_alpha, 1) * 0.5;
74 alpha = panel_fg_alpha * bound(0, autocvar_hud_panel_ammo_noncurrent_alpha, 1);
76 string text = isInfinite ? "\xE2\x88\x9E" : ftos(ammo); // Use infinity symbol (U+221E)
81 drawpic_aspect_skin(myPos, "ammo_current_bg", mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
83 if(ammo > 0 && autocvar_hud_panel_ammo_progressbar)
84 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);
86 if(autocvar_hud_panel_ammo_text)
87 drawstring_aspect(textPos, text, eX * (2/3) * mySize.x + eY * mySize.y, textColor, alpha, DRAWFLAG_NORMAL);
89 drawpic_aspect_skin(iconPos, GetAmmoPicture(ammoType), '1 1 0' * mySize.y, iconColor, alpha, DRAWFLAG_NORMAL);
94 float nade_statuschange_time;
98 if(hud != HUD_NORMAL) return;
99 if(!autocvar__hud_configure)
101 if((!autocvar_hud_panel_ammo) || (spectatee_status == -1))
103 if(STAT(HEALTH) < 1 && autocvar_hud_panel_ammo_hide_ondeath)
107 HUD_Panel_UpdateCvars();
109 draw_beginBoldFont();
115 if (autocvar_hud_panel_ammo_dynamichud)
122 pos += '1 1 0' * panel_bg_padding;
123 mySize -= '2 2 0' * panel_bg_padding;
126 int rows = 0, columns, row, column;
127 float nade_cnt = STAT(NADE_BONUS), nade_score = STAT(NADE_BONUS_SCORE);
128 bool draw_nades = (nade_cnt > 0 || nade_score > 0);
129 float nade_statuschange_elapsedtime;
130 int total_ammo_count;
133 if (autocvar_hud_panel_ammo_onlycurrent)
134 total_ammo_count = 1;
136 total_ammo_count = AMMO_COUNT;
141 if (nade_cnt != nade_prevframe)
143 nade_statuschange_time = time;
144 nade_prevstatus = nade_prevframe;
145 nade_prevframe = nade_cnt;
149 nade_prevstatus = nade_prevframe = nade_statuschange_time = 0;
151 rows = HUD_GetRowCount(total_ammo_count, mySize, 3);
152 columns = ceil((total_ammo_count)/rows);
153 ammo_size = eX * mySize.x*(1/columns) + eY * mySize.y*(1/rows);
155 vector offset = '0 0 0';
157 if(ammo_size.x/ammo_size.y > 3)
159 newSize = 3 * ammo_size.y;
160 offset.x = ammo_size.x - newSize;
162 ammo_size.x = newSize;
166 newSize = 1/3 * ammo_size.x;
167 offset.y = ammo_size.y - newSize;
169 ammo_size.y = newSize;
172 Weapon wep = switchweapon;
174 bool infinite_ammo = (STAT(ITEMS) & IT_UNLIMITED_WEAPON_AMMO);
176 if(autocvar_hud_panel_ammo_onlycurrent)
178 if(autocvar__hud_configure)
180 DrawAmmoItem(pos, ammo_size, ammo_rockets, true, false);
204 for(i = 0; i < AMMO_COUNT; ++i)
206 ammotype = GetAmmoFieldFromNum(i);
208 pos + eX * column * (ammo_size.x + offset.x) + eY * row * (ammo_size.y + offset.y),
211 (wep.ammo_field == ammotype),
226 nade_statuschange_elapsedtime = time - nade_statuschange_time;
228 float f = bound(0, nade_statuschange_elapsedtime*2, 1);
230 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);