]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Clean up the sprite drawing code a little so it isn't duplicated as much
authorMario <mario@smbclan.net>
Mon, 5 Feb 2018 07:39:27 +0000 (17:39 +1000)
committerMario <mario@smbclan.net>
Mon, 5 Feb 2018 07:39:27 +0000 (17:39 +1000)
qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc

index c2f8f298e6c80332ddd730e324ce4ddb93dc1b4b..720d92a57d6fa531df7f8c04c7f0d8fb77ff769e 100644 (file)
@@ -695,10 +695,13 @@ void Draw_WaypointSprite(entity this)
             txt = strtoupper(txt);
     }
 
+    float txt_offset = 0;
+    vector icon_offset;
+
     draw_beginBoldFont();
     if (this.health >= 0)
     {
-        float align, marg;
+        float align = 0, marg;
         if (this.build_finished)
             align = 0.5;
         else
@@ -725,18 +728,17 @@ void Draw_WaypointSprite(entity this)
                 DRAWFLAG_NORMAL
                  );
 
-        if(autocvar_g_waypointsprite_text || !icon_found)
-            o = drawspritetext(o, ang, (SPRITE_HEALTHBAR_WIDTH + 2 * SPRITE_HEALTHBAR_BORDER) * t, rgb, a, waypointsprite_fontsize * '1 1 0', txt);
-        else
-            drawpic(o - vec2(autocvar_g_waypointsprite_iconsize/2, autocvar_g_waypointsprite_iconsize*t + 2*marg + SPRITE_HEALTHBAR_HEIGHT*t), pic, '1 1 0'*autocvar_g_waypointsprite_iconsize, iconcolor, a, DRAWFLAG_NORMAL);
+        txt_offset = (SPRITE_HEALTHBAR_WIDTH + 2 * SPRITE_HEALTHBAR_BORDER) * t;
+        icon_offset = vec2(autocvar_g_waypointsprite_iconsize/2, autocvar_g_waypointsprite_iconsize*t + 2*marg + SPRITE_HEALTHBAR_HEIGHT*t);
     }
     else
-    {
-        if (autocvar_g_waypointsprite_text || !icon_found)
-            o = drawspritetext(o, ang, 0, rgb, a, waypointsprite_fontsize * '1 1 0', txt);
-        else
-            drawpic(o - vec2(autocvar_g_waypointsprite_iconsize/2, autocvar_g_waypointsprite_iconsize*t + 2 + SPRITE_HEALTHBAR_HEIGHT*t), pic, '1 1 0'*autocvar_g_waypointsprite_iconsize, iconcolor, a, DRAWFLAG_NORMAL);
-    }
+        icon_offset = vec2(autocvar_g_waypointsprite_iconsize/2, autocvar_g_waypointsprite_iconsize*t + 2 + SPRITE_HEALTHBAR_HEIGHT*t);
+
+    if (autocvar_g_waypointsprite_text || !icon_found)
+        o = drawspritetext(o, ang, txt_offset, rgb, a, waypointsprite_fontsize * '1 1 0', txt);
+    else
+        drawpic(o - icon_offset, pic, '1 1 0'*autocvar_g_waypointsprite_iconsize, iconcolor, a, DRAWFLAG_NORMAL);
+
     draw_endBoldFont();
 }