3 void DrawNadeProgressBar(vector myPos, vector mySize, float progress, vector color)
5 HUD_Panel_DrawProgressBar(
6 myPos + eX * autocvar_hud_panel_ammo_progressbar_xoffset * mySize.x,
7 mySize - eX * autocvar_hud_panel_ammo_progressbar_xoffset * mySize.x,
8 autocvar_hud_panel_ammo_progressbar_name,
10 autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
13 void DrawAmmoNades(vector myPos, vector mySize, bool draw_expanding, float expand_time)
15 float bonusNades = getstatf(STAT_NADE_BONUS);
16 float bonusProgress = getstatf(STAT_NADE_BONUS_SCORE);
17 float bonusType = getstati(STAT_NADE_BONUS_TYPE);
18 Nade def = Nades_from(bonusType);
19 vector nadeColor = def.m_color;
20 string nadeIcon = def.m_icon;
22 vector iconPos, textPos;
24 if(autocvar_hud_panel_ammo_iconalign)
26 iconPos = myPos + eX * 2 * mySize.y;
32 textPos = myPos + eX * mySize.y;
35 if(bonusNades > 0 || bonusProgress > 0)
37 DrawNadeProgressBar(myPos, mySize, bonusProgress, nadeColor);
39 if(autocvar_hud_panel_ammo_text)
40 drawstring_aspect(textPos, ftos(bonusNades), eX * (2/3) * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
43 drawpic_aspect_skin_expanding(iconPos, nadeIcon, '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, expand_time);
45 drawpic_aspect_skin(iconPos, nadeIcon, '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
49 void DrawAmmoItem(vector myPos, vector mySize, .int ammoType, bool isCurrent, bool isInfinite)
51 if(ammoType == ammo_none)
54 // Initialize variables
57 if(autocvar__hud_configure)
59 isCurrent = (ammoType == ammo_rockets); // Rockets always current
63 ammo = getstati(GetAmmoStat(ammoType));
67 float scale = bound(0, autocvar_hud_panel_ammo_noncurrent_scale, 1);
68 myPos = myPos + (mySize - mySize * scale) * 0.5;
69 mySize = mySize * scale;
72 vector iconPos, textPos;
73 if(autocvar_hud_panel_ammo_iconalign)
75 iconPos = myPos + eX * 2 * mySize.y;
81 textPos = myPos + eX * mySize.y;
84 bool isShadowed = (ammo <= 0 && !isCurrent && !isInfinite);
86 vector iconColor = isShadowed ? '0 0 0' : '1 1 1';
89 textColor = '0.2 0.95 0';
93 textColor = '0.8 0.04 0';
99 alpha = panel_fg_alpha;
101 alpha = panel_fg_alpha * bound(0, autocvar_hud_panel_ammo_noncurrent_alpha, 1) * 0.5;
103 alpha = panel_fg_alpha * bound(0, autocvar_hud_panel_ammo_noncurrent_alpha, 1);
105 string text = isInfinite ? "\xE2\x88\x9E" : ftos(ammo); // Use infinity symbol (U+221E)
110 drawpic_aspect_skin(myPos, "ammo_current_bg", mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
112 if(ammo > 0 && autocvar_hud_panel_ammo_progressbar)
113 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);
115 if(autocvar_hud_panel_ammo_text)
116 drawstring_aspect(textPos, text, eX * (2/3) * mySize.x + eY * mySize.y, textColor, alpha, DRAWFLAG_NORMAL);
118 drawpic_aspect_skin(iconPos, GetAmmoPicture(ammoType), '1 1 0' * mySize.y, iconColor, alpha, DRAWFLAG_NORMAL);
123 float nade_statuschange_time;
127 if(hud != HUD_NORMAL) return;
128 if(!autocvar__hud_configure)
130 if(!autocvar_hud_panel_ammo) return;
131 if(spectatee_status == -1) return;
134 HUD_Panel_UpdateCvars();
136 draw_beginBoldFont();
145 pos += '1 1 0' * panel_bg_padding;
146 mySize -= '2 2 0' * panel_bg_padding;
149 int rows = 0, columns, row, column;
150 float nade_cnt = getstatf(STAT_NADE_BONUS), nade_score = getstatf(STAT_NADE_BONUS_SCORE);
151 bool draw_nades = (nade_cnt > 0 || nade_score > 0);
152 float nade_statuschange_elapsedtime;
153 int total_ammo_count;
156 if (autocvar_hud_panel_ammo_onlycurrent)
157 total_ammo_count = 1;
159 total_ammo_count = AMMO_COUNT;
164 if (nade_cnt != nade_prevframe)
166 nade_statuschange_time = time;
167 nade_prevstatus = nade_prevframe;
168 nade_prevframe = nade_cnt;
172 nade_prevstatus = nade_prevframe = nade_statuschange_time = 0;
174 rows = HUD_GetRowCount(total_ammo_count, mySize, 3);
175 columns = ceil((total_ammo_count)/rows);
176 ammo_size = eX * mySize.x*(1/columns) + eY * mySize.y*(1/rows);
178 vector offset = '0 0 0'; // fteqcc sucks
180 if(ammo_size.x/ammo_size.y > 3)
182 newSize = 3 * ammo_size.y;
183 offset.x = ammo_size.x - newSize;
185 ammo_size.x = newSize;
189 newSize = 1/3 * ammo_size.x;
190 offset.y = ammo_size.y - newSize;
192 ammo_size.y = newSize;
196 bool infinite_ammo = (getstati(STAT_ITEMS, 0, 24) & IT_UNLIMITED_WEAPON_AMMO);
198 if(autocvar_hud_panel_ammo_onlycurrent)
200 if(autocvar__hud_configure)
202 DrawAmmoItem(pos, ammo_size, ammo_rockets, true, false);
209 (get_weaponinfo(switchweapon)).ammo_field,
226 for(i = 0; i < AMMO_COUNT; ++i)
228 ammotype = GetAmmoFieldFromNum(i);
230 pos + eX * column * (ammo_size.x + offset.x) + eY * row * (ammo_size.y + offset.y),
233 ((get_weaponinfo(switchweapon)).ammo_field == ammotype),
248 nade_statuschange_elapsedtime = time - nade_statuschange_time;
250 float f = bound(0, nade_statuschange_elapsedtime*2, 1);
252 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);