]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Spectator HUD: Added weapon display
authorz411 <z411@omaera.org>
Sat, 7 Nov 2020 18:44:49 +0000 (15:44 -0300)
committerz411 <z411@omaera.org>
Sat, 7 Nov 2020 18:44:49 +0000 (15:44 -0300)
qcsrc/client/hud/panel/spect.qc
qcsrc/common/ent_cs.qc
qcsrc/common/ent_cs.qh
qcsrc/server/weapons/weaponsystem.qc

index 92eff46dbab99d7fd15a1abe7b832a8e59ccf7f9..fc8fd89aaddd01a3b67d82a245d2e960fd0a4316 100644 (file)
@@ -27,8 +27,8 @@ void HUD_SpectHUD_drawTeamPlayers(vector pos, entity tm, vector rgb, bool invert
        vector tmp_over;
        vector line_sz = vec2((vid_conwidth - 1) / 7, hud_fontsize.y * 1.5);
        vector line_sz_sub = vec2((vid_conwidth - 1) / 7, hud_fontsize.y);
-       vector total_sz = vec2(line_sz.x, line_sz.y + line_sz_sub.y);
-       string tmp_str;
+       
+       string playername;
        float a = panel_fg_alpha * 0.8;
        entity pl;
        
@@ -44,33 +44,73 @@ void HUD_SpectHUD_drawTeamPlayers(vector pos, entity tm, vector rgb, bool invert
                
                float health = 0;
                float armor = 0;
+               string icon = "";
+               vector icon_size = '0 0 0';
+               vector icon_rgb = '1 1 1';
                
+               // Position and size calculation vectors
                tmp_over = pos;
-               tmp_str = textShortenToWidth(entcs_GetName(pl.sv_entnum), line_sz.x * 0.8, hud_fontsize, stringwidth_colors);
+               vector total_sz = vec2(line_sz.x, line_sz.y + line_sz_sub.y);
+               
+               if(pl.eliminated) {
+                       // z411 TODO : Unhardcode luma
+                       icon = "gfx/hud/luma/notify_death.tga";
+                       icon_rgb = rgb;
+               } else {
+                       entity entcs = entcs_receiver(pl.sv_entnum);
+                       if(entcs.m_entcs_private) {
+                               health = (entcs.healthvalue / autocvar_hud_panel_healtharmor_maxhealth) * line_sz.x;
+                               armor = (GetResource(entcs, RES_ARMOR) / autocvar_hud_panel_healtharmor_maxarmor) * line_sz_sub.x;
+                                       
+                               Weapon wep = REGISTRY_GET(Weapons, entcs.activewepid);
+                               icon = strcat("gfx/hud/luma/", wep.model2);
+                       } else {
+                               if(tm.team == NUM_TEAM_1)
+                                       icon = "gfx/hud/luma/player_red";
+                               else if(tm.team == NUM_TEAM_2)
+                                       icon = "gfx/hud/luma/player_blue";
+                               else
+                                       icon = "gfx/hud/luma/player_neutral";
+                       }
+               }
                
-               entity entcs = entcs_receiver(pl.sv_entnum);
-               if(entcs.m_entcs_private) {
-                       health = (entcs.healthvalue / autocvar_hud_panel_healtharmor_maxhealth) * line_sz.x;
-                       armor = (GetResource(entcs, RES_ARMOR) / autocvar_hud_panel_healtharmor_maxarmor) * line_sz_sub.x;
+               // Draw weapon
+               if(icon != "")  {
+                       vector tmp_sz = draw_getimagesize(icon);
+                       icon_size = vec2(total_sz.y*(tmp_sz.x/tmp_sz.y), total_sz.y);
+                       total_sz.x += icon_size.x;
+                               
+                       if(invert) {
+                               pos.x -= icon_size.x;
+                               tmp_over.x -= icon_size.x;
+                       }
+                       drawpic(pos, icon, icon_size, icon_rgb, panel_fg_alpha, DRAWFLAG_NORMAL);
+                       pos.x += icon_size.x;
                }
                
+               // Get player's name
+               playername = textShortenToWidth(entcs_GetName(pl.sv_entnum), line_sz.x * 0.8, hud_fontsize, stringwidth_colors);
+               
                // Draw health and name
                drawfill(pos, line_sz, rgb * 0.7, a * 0.3, DRAWFLAG_NORMAL);
                if(health)
                        drawfill(pos, vec2(health, line_sz.y), rgb * 0.7, a, DRAWFLAG_NORMAL);
-               drawcolorcodedstring(pos + eY * ((line_sz.y - hud_fontsize.y) / 2) + eX * (hud_fontsize.x * 0.5), tmp_str, hud_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
+               drawcolorcodedstring(pos + eY * ((line_sz.y - hud_fontsize.y) / 2) + eX * (hud_fontsize.x * 0.5), playername, hud_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
                pos.y += line_sz.y;
                
                // Draw armor
                if(armor)
                        drawfill(pos, vec2(armor, line_sz_sub.y), rgb, a, DRAWFLAG_NORMAL);
-               pos.y += line_sz_sub.y * 2;
                
                // Highlight current player
                if(pl.sv_entnum == current_player)
                        drawfill(tmp_over, total_sz, '1 1 1', 0.3, DRAWFLAG_NORMAL);
                if(pl.eliminated)
-                       drawfill(tmp_over, total_sz, '0 0 0', 0.3, DRAWFLAG_NORMAL);
+                       drawfill(tmp_over, total_sz, '0 0 0', 0.4, DRAWFLAG_NORMAL);
+               
+               if(!invert)
+                       pos.x -= icon_size.x;
+               pos.y += line_sz_sub.y * 2;
        }
 }
 
index e785aea53ba3ae620ee873d3a2eada1dccdb3186..7a06825ba727262d76c9ca5135f41784ddd726f1 100644 (file)
@@ -161,6 +161,11 @@ ENTCS_PROP(SOLID, true, sv_solid, solid, ENTCS_SET_NORMAL,
        { WriteByte(chan, ent.sv_solid); },
        { ent.sv_solid = ReadByte(); })
 
+// z411 weapon
+ENTCS_PROP(ACTIVEWEPID, false, activewepid, activewepid, ENTCS_SET_NORMAL,
+       { WriteByte(chan, ent.activewepid); },
+       { ent.activewepid = ReadByte(); })
+
 #ifdef SVQC
 
        int ENTCS_PUBLICMASK = 0;
index 30ee83bbcb4d96b017ce43968b3b6f3cc3bf8a38..3faef872fce3564aa727ce4f57bbe181388e9362 100644 (file)
@@ -21,6 +21,7 @@ REGISTER_NET_TEMP(CLIENT_ENTCS)
 .bool has_sv_origin;
 #endif
 .int sv_solid;
+.int activewepid; // z411
 
 #ifdef SVQC
 /*
index 37c09eb0becf16595bf8b9460923ab44c8028d8e..1958c951985c0cd7ecb1b6c30816e006cc4cb11e 100644 (file)
@@ -548,6 +548,7 @@ void W_WeaponFrame(Player actor, .entity weaponentity)
                                this.m_weapon = newwep;
                                this.weaponname = newwep.mdl;
                                this.bulletcounter = 0;
+                               actor.activewepid = newwep.m_id; // z411
                                newwep.wr_setup(newwep, actor, weaponentity);
                                this.state = WS_RAISE;