]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
New feature for hud_shownames: crosshairdistance - Basically, when enabled only show...
authorSamual <samual@xonotic.org>
Thu, 20 Oct 2011 04:29:35 +0000 (00:29 -0400)
committerSamual <samual@xonotic.org>
Thu, 20 Oct 2011 04:29:35 +0000 (00:29 -0400)
_hud_common.cfg
qcsrc/client/autocvars.qh
qcsrc/client/shownames.qc
qcsrc/client/shownames.qh

index 1f14c116f0894b6c758a8c4ade20e32a91bfa950..c46bbee713bf099c6bf74b45e474ee7baea0a559 100644 (file)
@@ -73,7 +73,10 @@ seta hud_contents_water_alpha 0.5 "alpha of the water"
 seta hud_contents_water_color "0.4 0.3 0.3" "color blend when inside water"
 
 seta hud_shownames 1 "draw names and health/armor of nearby players"
-seta hud_shownames_enemies 2 "1 = draw names of enemies you point at (TODO), 2 = draw names of all enemies in view"
+seta hud_shownames_enemies 1 "show tags for enemies as well"
+seta hud_shownames_crosshairdistance 0 "if set, only draw tags which came within this distance of your crosshair (25 recommended)"
+seta hud_shownames_crosshairdistance_time 5 "how many seconds the tag is still visible after pointing at them"
+seta hud_shownames_crosshairdistance_antioverlap 0 "allow antioverlap to work as normal even with crosshairdistance on"
 seta hud_shownames_self 0 "also include your own name to be shown when third person camera mode is on (chase_active/cl_eventchase)"
 seta hud_shownames_status 1 "1 = draw health/armor status of teammates"
 seta hud_shownames_statusbar_height 4 "height of status bar"
@@ -85,5 +88,5 @@ seta hud_shownames_resize 1 "enable resizing of the names, then the size cvars w
 seta hud_shownames_mindistance 1000 "start fading alpha/size at this distance"
 seta hud_shownames_maxdistance 5000 "alpha/size is 0 at this distance"
 seta hud_shownames_antioverlap 1 "if two tags get too close to each other, fade out the one further away from you"
-seta hud_shownames_antioverlap_distance 100 "2d distance to other tag after which to fade out"
+seta hud_shownames_antioverlap_distance 50 "2d distance to other tag after which to fade out"
 seta hud_shownames_offset 52 "offset (along z-axis) tag from player origin by this many units"
\ No newline at end of file
index 897bb24e73753c9191f9d71fab1adad287fcfe63..b0a11ad1826df9c5dd41e56079faa3e623d24982 100644 (file)
@@ -319,6 +319,9 @@ float autocvar_hud_showbinds;
 float autocvar_hud_showbinds_limit;
 float autocvar_hud_shownames;
 float autocvar_hud_shownames_enemies;
+float autocvar_hud_shownames_crosshairdistance;
+float autocvar_hud_shownames_crosshairdistance_time;
+float autocvar_hud_shownames_crosshairdistance_antioverlap;
 float autocvar_hud_shownames_self;
 float autocvar_hud_shownames_status;
 float autocvar_hud_shownames_statusbar_height;
index b13f6122c268cdaaa1b4cd18a0783ff70387d82d..21e8bcd420799ac3688e938abcefcc780cf67fd4 100644 (file)
@@ -4,9 +4,10 @@
 // self.armorvalue
 // self.sameteam = player is on same team as local client
 // self.fadedelay = time to wait before name tag starts fading in for enemies
+// self.pointtime = last time you pointed at this player
 //
 const float SHOWNAMES_FADESPEED = 4;
-const float SHOWNAMES_FADEDELAY = 0.5;
+const float SHOWNAMES_FADEDELAY = 0.4;
 void Draw_ShowNames(entity ent)
 {
        if(!autocvar_hud_shownames)
@@ -21,9 +22,9 @@ void Draw_ShowNames(entity ent)
        if(ent.sameteam || (!ent.sameteam && autocvar_hud_shownames_enemies))
        {
                ent.origin_z += autocvar_hud_shownames_offset;
-
+       
                float hit;
-               if(ent.sameteam)
+               if(ent.sameteam && !autocvar_hud_shownames_crosshairdistance)
                {
                        hit = 1;
                }
@@ -36,10 +37,12 @@ void Draw_ShowNames(entity ent)
                                hit = 1;
                }
 
+               // handle tag fading
+               float overlap, onscreen, crosshairdistance;
                vector o, eo;
+               
                o = project_3d_to_2d(ent.origin);
-               float overlap, onscreen;
-
+               
                if(autocvar_hud_shownames_antioverlap)
                {
                        // fade tag out if another tag that is closer to you overlaps
@@ -62,6 +65,18 @@ void Draw_ShowNames(entity ent)
                }
 
                onscreen = (o_z >= 0 && o_x >= 0 && o_y >= 0 && o_x <= vid_conwidth && o_y <= vid_conheight);
+               crosshairdistance = sqrt( pow(o_x - vid_conwidth/2, 2) + pow(o_y - vid_conheight/2, 2) );
+               
+               if(autocvar_hud_shownames_crosshairdistance)
+               {
+                       if(autocvar_hud_shownames_crosshairdistance > crosshairdistance)
+                               ent.pointtime = time;
+                               
+                       if not(ent.pointtime + autocvar_hud_shownames_crosshairdistance_time > time)
+                               overlap = TRUE;
+                       else
+                               overlap = (autocvar_hud_shownames_crosshairdistance_antioverlap ? overlap : FALSE); // override what antioverlap says unless allowed by cvar.
+               }
                
                if(!ent.fadedelay)
                        ent.fadedelay = time + SHOWNAMES_FADEDELAY;
index d30f1acce3801f0d4b948465fcb518286ac317a7..adbfa57120376e5091f3c957d05557b9873de870 100644 (file)
@@ -2,4 +2,4 @@
 .float armorvalue;
 .float sameteam;
 .float fadedelay;
-
+.float pointtime;