]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
support resizing the name and enable by default
authorFruitieX <fruitiex@gmail.com>
Wed, 13 Apr 2011 14:47:26 +0000 (17:47 +0300)
committerFruitieX <fruitiex@gmail.com>
Wed, 13 Apr 2011 14:47:26 +0000 (17:47 +0300)
defaultXonotic.cfg
qcsrc/client/autocvars.qh
qcsrc/client/shownames.qc

index 68a3acb70999203bc4ec2b90f8ac6bbbde453b3d..089c11a627a9bdbf1b15f1cfb28efaef576ba5a8 100644 (file)
@@ -1487,9 +1487,10 @@ seta hud_shownames_status 2 "1 = draw health/armor status of teammates, 2 = same
 seta hud_shownames_height 15 "height of icons"
 seta hud_shownames_aspect 8 "aspect ratio of total drawing area per name"
 seta hud_shownames_fontsize 8 "font size"
-seta hud_shownames_mindistance 1000 "start fading alpha at this distance"
-seta hud_shownames_maxdistance 2000 "alpha is 0 at this distance"
-
+seta hud_shownames_alpha 0.7 "alpha"
+seta hud_shownames_resize 1 "enable resizing of the names, then the size cvars will correspond to the maximum size"
+seta hud_shownames_mindistance 1000 "start fading alpha/size at this distance"
+seta hud_shownames_maxdistance 2000 "alpha/size is 0 at this distance"
 
 // scoreboard
 seta scoreboard_columns default
index 50db354117b5c82afcb6237bf249d22512c7b377..fc3c1f8e1c79d552f820b14fd8bd023f5a73b963 100644 (file)
@@ -278,6 +278,8 @@ float autocvar_hud_shownames_status;
 float autocvar_hud_shownames_height;
 float autocvar_hud_shownames_aspect;
 float autocvar_hud_shownames_fontsize;
+float autocvar_hud_shownames_alpha;
+float autocvar_hud_shownames_resize;
 float autocvar_hud_shownames_mindistance;
 float autocvar_hud_shownames_maxdistance;
 string autocvar_hud_skin;
index bd3e7fd052b60a3a12bde9cfdc8dc5147011a7d4..66391197ad85537a3c7e48b2c2ecfc33e0ad2aeb 100644 (file)
@@ -38,18 +38,25 @@ void Draw_ShowNames()
 
         // otherwise, increase alpha until 1
 
+        float dist;
+        dist = vlen(self.origin - view_origin);
+
         float a;
-        a = autocvar_hud_panel_fg_alpha;
+        a = autocvar_hud_shownames_alpha;
         if(self.alpha)
             a *= self.alpha;
         if(autocvar_hud_shownames_maxdistance)
         {
-            float dist;
-            dist = vlen(self.origin - view_origin);
-
+            if(dist >= autocvar_hud_shownames_maxdistance)
+                return;
             a *= ((autocvar_hud_shownames_maxdistance - autocvar_hud_shownames_mindistance) - max(0, dist - autocvar_hud_shownames_mindistance)) / (autocvar_hud_shownames_maxdistance - autocvar_hud_shownames_mindistance);
         }
 
+        float resize;
+        resize = 1;
+        if(autocvar_hud_shownames_resize) // limit resize so its never smaller than 0.5... gets unreadable
+            resize = 0.5 + 0.5 * ((autocvar_hud_shownames_maxdistance - autocvar_hud_shownames_mindistance) - max(0, dist - autocvar_hud_shownames_mindistance)) / (autocvar_hud_shownames_maxdistance - autocvar_hud_shownames_mindistance);
+
         // draw the sprite image
         vector o;
         o = project_3d_to_2d(self.origin);
@@ -62,9 +69,16 @@ void Draw_ShowNames()
             mySize = (eX * autocvar_hud_shownames_aspect + eY) * autocvar_hud_shownames_height;
             myPos = o - '0.5 0 0' * mySize_x - '0 1 0' * mySize_y;
 
-            vector iconpos, iconsize;
-            vector namepos;
-            float namesize;
+            // size scaling
+            mySize_x *= resize;
+            mySize_y *= resize;
+
+            myPos_x += 0.5 * (mySize_x / resize - mySize_x);
+            myPos_y += (mySize_y / resize - mySize_y);
+
+            vector iconpos, iconsize; // these determine icon position/size, if any
+            vector namepos; // this is where the origin of the string
+            float namesize; // total area where we can draw the string
 
             iconpos = myPos;
 
@@ -92,11 +106,12 @@ void Draw_ShowNames()
                 }
             }
 
-            namepos = myPos + eX * 2 * iconsize_y + eY * 0.5 * (autocvar_hud_shownames_height - autocvar_hud_shownames_fontsize);
+            namepos = myPos + eX * 2 * iconsize_y + eY * 0.5 * resize * (autocvar_hud_shownames_height - autocvar_hud_shownames_fontsize);
             namesize = mySize_x - 2 * iconsize_y;
 
             string s;
             s = GetPlayerName(self.the_entnum-1);
+            drawfontscale = '1 1 0' * resize;
             s = textShortenToWidth(s, namesize, '1 1 0' * autocvar_hud_shownames_fontsize, stringwidth_colors);
 
             float width;
@@ -105,6 +120,7 @@ void Draw_ShowNames()
             if (width != namesize)
                 namepos_x += (namesize - width) / 2;
             drawcolorcodedstring(namepos, s, '1 1 0' * autocvar_hud_shownames_fontsize, a, DRAWFLAG_NORMAL);
+            drawfontscale = '1 1 0';
         }
     }
 }