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); // TODO: mutator
15 void DrawAmmoItem(vector myPos, vector mySize, .int ammoType, bool isCurrent, bool isInfinite)
17 if(ammoType == ammo_none)
20 // Initialize variables
23 if(autocvar__hud_configure)
25 isCurrent = (ammoType == ammo_rockets); // Rockets always current
29 ammo = getstati(GetAmmoStat(ammoType));
33 float scale = bound(0, autocvar_hud_panel_ammo_noncurrent_scale, 1);
34 myPos = myPos + (mySize - mySize * scale) * 0.5;
35 mySize = mySize * scale;
38 vector iconPos, textPos;
39 if(autocvar_hud_panel_ammo_iconalign)
41 iconPos = myPos + eX * 2 * mySize.y;
47 textPos = myPos + eX * mySize.y;
50 bool isShadowed = (ammo <= 0 && !isCurrent && !isInfinite);
52 vector iconColor = isShadowed ? '0 0 0' : '1 1 1';
55 textColor = '0.2 0.95 0';
59 textColor = '0.8 0.04 0';
65 alpha = panel_fg_alpha;
67 alpha = panel_fg_alpha * bound(0, autocvar_hud_panel_ammo_noncurrent_alpha, 1) * 0.5;
69 alpha = panel_fg_alpha * bound(0, autocvar_hud_panel_ammo_noncurrent_alpha, 1);
71 string text = isInfinite ? "\xE2\x88\x9E" : ftos(ammo); // Use infinity symbol (U+221E)
76 drawpic_aspect_skin(myPos, "ammo_current_bg", mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
78 if(ammo > 0 && autocvar_hud_panel_ammo_progressbar)
79 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);
81 if(autocvar_hud_panel_ammo_text)
82 drawstring_aspect(textPos, text, eX * (2/3) * mySize.x + eY * mySize.y, textColor, alpha, DRAWFLAG_NORMAL);
84 drawpic_aspect_skin(iconPos, GetAmmoPicture(ammoType), '1 1 0' * mySize.y, iconColor, alpha, DRAWFLAG_NORMAL);
89 float nade_statuschange_time;
93 if(hud != HUD_NORMAL) return;
94 if(!autocvar__hud_configure)
96 if(!autocvar_hud_panel_ammo) return;
97 if(spectatee_status == -1) return;
100 HUD_Panel_UpdateCvars();
102 draw_beginBoldFont();
111 pos += '1 1 0' * panel_bg_padding;
112 mySize -= '2 2 0' * panel_bg_padding;
115 int rows = 0, columns, row, column;
116 float nade_cnt = STAT(NADE_BONUS), nade_score = STAT(NADE_BONUS_SCORE);
117 bool draw_nades = (nade_cnt > 0 || nade_score > 0);
118 float nade_statuschange_elapsedtime;
119 int total_ammo_count;
122 if (autocvar_hud_panel_ammo_onlycurrent)
123 total_ammo_count = 1;
125 total_ammo_count = AMMO_COUNT;
130 if (nade_cnt != nade_prevframe)
132 nade_statuschange_time = time;
133 nade_prevstatus = nade_prevframe;
134 nade_prevframe = nade_cnt;
138 nade_prevstatus = nade_prevframe = nade_statuschange_time = 0;
140 rows = HUD_GetRowCount(total_ammo_count, mySize, 3);
141 columns = ceil((total_ammo_count)/rows);
142 ammo_size = eX * mySize.x*(1/columns) + eY * mySize.y*(1/rows);
144 vector offset = '0 0 0'; // fteqcc sucks
146 if(ammo_size.x/ammo_size.y > 3)
148 newSize = 3 * ammo_size.y;
149 offset.x = ammo_size.x - newSize;
151 ammo_size.x = newSize;
155 newSize = 1/3 * ammo_size.x;
156 offset.y = ammo_size.y - newSize;
158 ammo_size.y = newSize;
162 bool infinite_ammo = (getstati(STAT_ITEMS, 0, 24) & IT_UNLIMITED_WEAPON_AMMO);
164 if(autocvar_hud_panel_ammo_onlycurrent)
166 if(autocvar__hud_configure)
168 DrawAmmoItem(pos, ammo_size, ammo_rockets, true, false);
175 (get_weaponinfo(switchweapon)).ammo_field,
192 for(i = 0; i < AMMO_COUNT; ++i)
194 ammotype = GetAmmoFieldFromNum(i);
196 pos + eX * column * (ammo_size.x + offset.x) + eY * row * (ammo_size.y + offset.y),
199 ((get_weaponinfo(switchweapon)).ammo_field == ammotype),
214 nade_statuschange_elapsedtime = time - nade_statuschange_time;
216 float f = bound(0, nade_statuschange_elapsedtime*2, 1);
218 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);