3 #include <client/hud/hud.qh>
4 #include <client/view.qh>
7 vector teamscore_fontsize;
8 vector teamname_fontsize;
10 void HUD_SpectHUD_Export(int fh)
12 // allow saving cvars that aesthetically change the panel into hud skin files
15 void HUD_SpectHUD_drawCurrentName(vector pos)
20 string s = entcs_GetName(current_player);
21 tmp.x -= stringwidth_colors(s, hud_fontsize * 2) / 2;
22 drawcolorcodedstring(tmp, s, hud_fontsize * 2, panel_fg_alpha, DRAWFLAG_NORMAL);
26 tmp.x -= stringwidth_colors(s, hud_fontsize) / 2;
27 tmp.y -= hud_fontsize.y;
28 drawcolorcodedstring(tmp, s, hud_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
31 void HUD_SpectHUD_drawTeamPlayers(vector pos, entity tm, vector rgb, bool invert)
34 vector line_sz = vec2((vid_conwidth - 1) / 7, hud_fontsize.y * 1.5);
35 vector line_sz_sub = vec2((vid_conwidth - 1) / 7, hud_fontsize.y);
38 float a = panel_fg_alpha * 0.8;
42 pos.x -= line_sz.x + hud_fontsize.x;
44 pos.x += hud_fontsize.x;
46 for(pl = players.sort_next; pl; pl = pl.sort_next)
48 if(pl.team != tm.team)
54 vector icon_size = '0 0 0';
55 vector icon_rgb = '1 1 1';
57 // Position and size calculation vectors
59 vector total_sz = vec2(line_sz.x, line_sz.y + line_sz_sub.y);
62 // z411 TODO : Unhardcode luma
63 icon = "gfx/hud/luma/notify_death.tga";
66 entity entcs = entcs_receiver(pl.sv_entnum);
67 if(entcs.m_entcs_private) {
68 health = (entcs.healthvalue / autocvar_hud_panel_healtharmor_maxhealth) * line_sz.x;
69 armor = (GetResource(entcs, RES_ARMOR) / autocvar_hud_panel_healtharmor_maxarmor) * line_sz_sub.x;
71 Weapon wep = REGISTRY_GET(Weapons, entcs.activewepid);
72 icon = strcat("gfx/hud/luma/", wep.model2);
74 if(tm.team == NUM_TEAM_1)
75 icon = "gfx/hud/luma/player_red";
76 else if(tm.team == NUM_TEAM_2)
77 icon = "gfx/hud/luma/player_blue";
78 else if(tm.team == NUM_TEAM_3)
79 icon = "gfx/hud/luma/player_yellow";
80 else if(tm.team == NUM_TEAM_4)
81 icon = "gfx/hud/luma/player_pink";
83 icon = "gfx/hud/luma/player_neutral";
89 vector tmp_sz = draw_getimagesize(icon);
90 icon_size = vec2(total_sz.y*(tmp_sz.x/tmp_sz.y), total_sz.y);
91 total_sz.x += icon_size.x;
95 tmp_over.x -= icon_size.x;
97 drawpic(pos, icon, icon_size, icon_rgb, panel_fg_alpha, DRAWFLAG_NORMAL);
102 playername = textShortenToWidth(entcs_GetName(pl.sv_entnum), line_sz.x * 0.8, hud_fontsize, stringwidth_colors);
104 // Draw health and name
105 drawfill(pos, line_sz, rgb * 0.7, a * 0.3, DRAWFLAG_NORMAL);
107 drawfill(pos, vec2(health, line_sz.y), rgb * 0.7, a, DRAWFLAG_NORMAL);
108 drawcolorcodedstring(pos + eY * ((line_sz.y - hud_fontsize.y) / 2) + eX * (hud_fontsize.x * 0.5), playername, hud_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
113 drawfill(pos, vec2(armor, line_sz_sub.y), rgb, a, DRAWFLAG_NORMAL);
115 // Highlight current player
116 if(pl.sv_entnum == current_player && spectatee_status != -1)
117 drawfill(tmp_over, total_sz, '1 1 1', 0.3, DRAWFLAG_NORMAL);
119 drawfill(tmp_over, total_sz, '0 0 0', 0.4, DRAWFLAG_NORMAL);
122 pos.x -= icon_size.x;
123 pos.y += line_sz_sub.y * 2;
128 void HUD_SpectHUD_drawTeamScore(vector pos, entity tm, vector rgb, bool invert)
136 tmp_str = ftos(tm.(teamscores(ts_primary)));
139 pos.x -= teamscore_size.x;
141 drawfill(pos, teamscore_size, rgb * 0.8, 0.3, DRAWFLAG_NORMAL);
144 tmp.x += (teamscore_size.x - stringwidth(tmp_str, true, teamscore_fontsize)) / 2;
145 tmp.y += (teamscore_size.y - teamscore_fontsize.y) / 2;
147 draw_beginBoldFont();
148 drawstring(tmp, tmp_str, teamscore_fontsize, rgb, panel_fg_alpha, DRAWFLAG_NORMAL);
152 tmp_str = Team_CustomName(tm.team);
156 tmp.x -= stringwidth_colors(tmp_str, teamname_fontsize) + teamname_fontsize.x * 0.5;
158 tmp.x += teamscore_size.x + teamname_fontsize.x * 0.5;
159 tmp.y += (teamscore_size.y - teamname_fontsize.y) / 2;
161 drawcolorcodedstring(tmp, tmp_str, teamname_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
164 void HUD_SpectHUD_drawDuelScore(vector pos, entity pl, bool invert)
170 vector health_sz = vec2((vid_conwidth - 1) / 6, teamscore_size.y * 0.4);
171 vector armor_sz = vec2(health_sz.x, health_sz.y / 4);
176 entity entcs = entcs_receiver(pl.sv_entnum);
177 if(entcs.m_entcs_private) {
178 health = (entcs.healthvalue / autocvar_hud_panel_healtharmor_maxhealth) * health_sz.x;
179 armor = (GetResource(entcs, RES_ARMOR) / autocvar_hud_panel_healtharmor_maxarmor) * armor_sz.x;
183 tmp_str = ftos(pl.(scores(ps_primary)));
186 pos.x -= teamscore_size.x;
188 drawfill(pos, teamscore_size, '0 0 0', 0.3, DRAWFLAG_NORMAL);
191 tmp.x += (teamscore_size.x - stringwidth(tmp_str, true, teamscore_fontsize)) / 2;
192 tmp.y += (teamscore_size.y - teamscore_fontsize.y) / 2;
194 draw_beginBoldFont();
195 drawstring(tmp, tmp_str, teamscore_fontsize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
198 // Player health/armor
200 tmp_in.y += ((teamscore_size.y / 2) - health_sz.y) / 2;
205 tmp.x -= health_sz.x;
207 tmp.x += teamscore_size.x;
209 drawfill(tmp, health_sz, '0 0 0', 0.3, DRAWFLAG_NORMAL);
217 tmp.x += teamscore_size.x;
219 drawfill(tmp, vec2(health, health_sz.y), '1 0 0', 0.7, DRAWFLAG_NORMAL);
224 tmp.y += health_sz.y - armor_sz.y;
229 tmp.x += teamscore_size.x;
231 drawfill(tmp, vec2(armor, armor_sz.y), '0 1 0', 0.7, DRAWFLAG_NORMAL);
235 tmp_str = entcs_GetName(pl.sv_entnum);
239 tmp.x -= stringwidth_colors(tmp_str, teamname_fontsize) + teamname_fontsize.x * 0.5;
241 tmp.x += teamscore_size.x + teamname_fontsize.x * 0.5;
242 tmp.y += ((teamscore_size.y / 2) - teamname_fontsize.y) / 2;
243 tmp.y += teamscore_size.y / 2;
245 drawcolorcodedstring(tmp, tmp_str, teamname_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
250 if(!spectatee_status) return;
253 float ammo_y, timer_width;
257 HUD_Panel_LoadCvars();
259 hud_fontsize = HUD_GetFontsize("hud_fontsize");
262 if (autocvar_hud_spectatorplayernamedisplay)
264 if(spectatee_status != -1) {
265 ammo_y = stov(cvar_string("hud_panel_ammo_pos")).y * vid_conheight;
266 pos = panel_pos + vec2((vid_conwidth - 1) / 2, (ammo_y - (hud_fontsize.y * 2)));
267 HUD_SpectHUD_drawCurrentName(pos);
271 if (teamplay && autocvar_hud_spectatorteamdisplay)
274 teamscore_fontsize = hud_fontsize * 3;
275 teamname_fontsize = hud_fontsize * 2;
276 teamscore_size = vec2(teamscore_fontsize.x * 1.5, teamscore_fontsize.y * 1.25);
277 timer_width = stov(cvar_string("hud_panel_timer_size")).x * vid_conwidth;
280 pos = panel_pos + vec2((vid_conwidth - 1) / 2, 0);
281 tm = GetTeam(NUM_TEAM_1, false);
282 rgb = Team_ColorRGB(tm.team);
283 pos.x -= (timer_width * 1.3) / 2;
284 HUD_SpectHUD_drawTeamScore(pos, tm, rgb, true);
286 pos = panel_pos + vec2(0, (vid_conheight - 1) / 4 + hud_fontsize.y);
287 HUD_SpectHUD_drawTeamPlayers(pos, tm, rgb, false);
290 pos = panel_pos + vec2((vid_conwidth - 1) / 2, 0);
291 tm = GetTeam(NUM_TEAM_2, false);
292 rgb = Team_ColorRGB(tm.team);
293 pos.x += (timer_width * 1.3) / 2;
294 HUD_SpectHUD_drawTeamScore(pos, tm, rgb, false);
296 pos = panel_pos + vec2(vid_conwidth - 1, (vid_conheight - 1) / 4 + hud_fontsize.y);
297 HUD_SpectHUD_drawTeamPlayers(pos, tm, rgb, true);
300 pos = panel_pos + vec2((vid_conwidth - 1) / 2, 41);
301 tm = GetTeam(NUM_TEAM_3, false);
302 rgb = Team_ColorRGB(tm.team);
303 pos.x -= (timer_width * 1.3) / 2;
304 HUD_SpectHUD_drawTeamScore(pos, tm, rgb, true);
306 pos = panel_pos + vec2(0, (vid_conheight + 450) / 4 + hud_fontsize.y);
307 HUD_SpectHUD_drawTeamPlayers(pos, tm, rgb, false);
310 pos = panel_pos + vec2((vid_conwidth - 1) / 2, 41);
311 tm = GetTeam(NUM_TEAM_4, false);
312 rgb = Team_ColorRGB(tm.team);
313 pos.x += (timer_width * 1.3) / 2;
314 HUD_SpectHUD_drawTeamScore(pos, tm, rgb, false);
316 pos = panel_pos + vec2(vid_conwidth - 1, (vid_conheight + 450) / 4 + hud_fontsize.y);
317 HUD_SpectHUD_drawTeamPlayers(pos, tm, rgb, true);
318 } else if(gametype == MAPINFO_TYPE_DUEL && autocvar_hud_spectatordueldisplay) {
320 teamscore_fontsize = hud_fontsize * 3;
321 teamname_fontsize = hud_fontsize * 1.5;
322 teamscore_size = vec2(teamscore_fontsize.x * 1.5, teamscore_fontsize.y * 1.25);
323 timer_width = stov(cvar_string("hud_panel_timer_size")).x * vid_conwidth;
325 entity pl_left = players.sort_next;
326 entity pl_right = pl_left.sort_next;
329 pos = panel_pos + vec2((vid_conwidth - 1) / 2, 0);
330 pos.x -= (timer_width * 1.3) / 2;
331 HUD_SpectHUD_drawDuelScore(pos, pl_left, true);
334 pos = panel_pos + vec2((vid_conwidth - 1) / 2, 0);
335 pos.x += (timer_width * 1.3) / 2;
336 HUD_SpectHUD_drawDuelScore(pos, pl_right, false);