]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
make them fade out/in :o
authorFruitieX <fruitiex@gmail.com>
Wed, 13 Apr 2011 13:18:42 +0000 (16:18 +0300)
committerFruitieX <fruitiex@gmail.com>
Wed, 13 Apr 2011 13:18:42 +0000 (16:18 +0300)
qcsrc/client/shownames.qc

index 2e351fe42c8a27b90795c515400f3eb26f084b80..b1e971f3538156f9dc9d63eddd36e7cbde1e832e 100644 (file)
@@ -11,16 +11,20 @@ void Draw_ShowNames()
 
     if(self.sameteam || (!self.sameteam && autocvar_hud_shownames_enemies))
     {
-        float a;
-        a = autocvar_hud_panel_fg_alpha;
-
         InterpolateOrigin_Do();
 
         if(!self.sameteam)
         {
             traceline(self.origin, view_origin, 1, self);
-            if(trace_endpos != view_origin)
-                return;
+            if(trace_endpos != view_origin) // fade out
+            {
+                self.alpha = max(0, self.alpha - 4 * frametime);
+                if(!self.alpha)
+                    return;
+            }
+            else // fade in
+                self.alpha = min(1, self.alpha + 4 * frametime);
+
 
             /* WIP, why does trace_ent != self not work as intended here?
             if(autocvar_hud_shownames_enemies != 2) // player has to point at enemy if so
@@ -32,6 +36,11 @@ void Draw_ShowNames()
             }*/
         }
 
+        // otherwise, increase alpha until 1
+
+        float a;
+        a = autocvar_hud_panel_fg_alpha * self.alpha;
+
         // draw the sprite image
         vector o;
         o = project_3d_to_2d(self.origin);