]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Experimental support for waypoint icons (drawing of icon currently broken)
authorMario <mario@smbclan.net>
Sun, 4 Feb 2018 17:41:55 +0000 (03:41 +1000)
committerMario <mario@smbclan.net>
Sun, 4 Feb 2018 17:41:55 +0000 (03:41 +1000)
defaultClient.cfg
qcsrc/common/mutators/events.qh
qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc
qcsrc/common/mutators/mutator/waypoints/waypointsprites.qh

index e4904ff58134dea57a745398fb65123d1f3b035c..6b8c0f7d621825bc66215d64b5749b1d6a9906ce 100644 (file)
@@ -385,6 +385,7 @@ set g_waypointsprite_timealphaexponent 1
 seta g_waypointsprite_turrets 1 "disable turret waypoints"
 seta g_waypointsprite_turrets_maxdist 5000 "max distance for turret waypoints"
 seta g_waypointsprite_uppercase 1
+seta g_waypointsprite_text 0 "Always show text instead of icons, setting this to 0 will still use text if the icon is unavailable"
 
 alias "g_waypointsprite_personal"      "impulse 30"
 alias "g_waypointsprite_personal_p"    "impulse 31"
index 107a82030c1f99d76d2aa1140d207c3798a0e150..cf858487058de2bbeac734fff836481bae3e4504 100644 (file)
@@ -65,6 +65,7 @@ MUTATOR_HOOKABLE(IsFlying, EV_IsFlying);
     /**/ i(string, MUTATOR_ARGV_1_string) \
     /**/ o(vector, MUTATOR_ARGV_2_vector) \
     /**/ o(string, MUTATOR_ARGV_3_string) \
+    /**/ o(string, MUTATOR_ARGV_4_string) \
     /**/
 MUTATOR_HOOKABLE(WP_Format, EV_WP_Format);
 
index 6dec163fa237c97f0492f9dfc83a32fadb79f425..6ad7bf5c6fea012e8adab0a0b644ec6ddfc3ecac 100644 (file)
@@ -265,6 +265,25 @@ string spritelookuptext(entity this, string s)
 
     return s;
 }
+
+string spritelookupicon(entity this, string s)
+{
+    // TODO: needs icons! //if (s == WP_RaceStartFinish.netname) return (race_checkpointtime || race_mycheckpointtime) ? _("Finish") : _("Start");
+    if (s == WP_Weapon.netname) return Weapons_from(this.wp_extra).model2;
+    if (s == WP_Item.netname) return Items_from(this.wp_extra).m_icon;
+    //if (s == WP_Monster.netname) return get_monsterinfo(this.wp_extra).m_icon;
+    if (MUTATOR_CALLHOOK(WP_Format, this, s))
+    {
+        return M_ARGV(4, string);
+    }
+
+    // need to loop, as our netname could be one of three
+    FOREACH(Waypoints, it.netname == s, {
+        return it.m_icon;
+    });
+
+    return s;
+}
 #endif
 
 #ifdef CSQC
@@ -646,20 +665,40 @@ void Draw_WaypointSprite(entity this)
 
     o = drawspritearrow(o, ang, rgb, a, SPRITE_ARROW_SCALE * t);
 
-    string txt;
-    if (autocvar_g_waypointsprite_spam && waypointsprite_count >= autocvar_g_waypointsprite_spam)
-        txt = _("Spam");
-    else
-        txt = spritelookuptext(this, spriteimage);
-    if (this.helpme && time < this.helpme)
-        txt = sprintf(_("%s needing help!"), txt);
-    if (autocvar_g_waypointsprite_uppercase)
-        txt = strtoupper(txt);
+    string spr_icon = spritelookupicon(this, spriteimage);
+    string pic = spr_icon;
+    bool icon_found = !(!spr_icon || spr_icon == "");
+    if (icon_found) // it's valid, but let's make sure it exists!
+    {
+        pic = strcat(hud_skin_path, "/", spr_icon);
+        if(precache_pic(pic) == "")
+        {
+            pic = strcat("gfx/hud/default/", spr_icon);
+            if(!precache_pic(pic))
+                icon_found = false;
+        }
+    }
+
+    string txt = string_null;
+    if (autocvar_g_waypointsprite_text || !icon_found)
+    {
+        if (autocvar_g_waypointsprite_spam && waypointsprite_count >= autocvar_g_waypointsprite_spam)
+            txt = _("Spam");
+        else
+            txt = spritelookuptext(this, spriteimage);
+        if (this.helpme && time < this.helpme)
+            txt = sprintf(_("%s needing help!"), txt);
+        if (autocvar_g_waypointsprite_uppercase)
+            txt = strtoupper(txt);
+    }
 
     draw_beginBoldFont();
     if (this.health >= 0)
     {
-        o = drawspritetext(o, ang, (SPRITE_HEALTHBAR_WIDTH + 2 * SPRITE_HEALTHBAR_BORDER) * t, rgb, a, waypointsprite_fontsize * '1 1 0', txt);
+        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_aspect(o, pic, vec2(SPRITE_HEALTHBAR_WIDTH * t, SPRITE_HEALTHBAR_HEIGHT * t), rgb, a, DRAWFLAG_NORMAL);
 
         float align, marg;
         if (this.build_finished)
@@ -690,7 +729,10 @@ void Draw_WaypointSprite(entity this)
     }
     else
     {
-        o = drawspritetext(o, ang, 0, rgb, a, waypointsprite_fontsize * '1 1 0', txt);
+        if (autocvar_g_waypointsprite_text || !icon_found)
+            o = drawspritetext(o, ang, 0, rgb, a, waypointsprite_fontsize * '1 1 0', txt);
+        else
+            drawpic_aspect(o, pic, vec2(SPRITE_HEALTHBAR_WIDTH * t, SPRITE_HEALTHBAR_HEIGHT * t), rgb, a, DRAWFLAG_NORMAL);
     }
     draw_endBoldFont();
 }
index 6a8d57157c010f0fbb10c9fa22b9865292b31bea..d032a26ee0b70271b6f1c917dff1cb881c786625 100644 (file)
@@ -53,6 +53,7 @@ float autocvar_g_waypointsprite_timealphaexponent;
 bool autocvar_g_waypointsprite_turrets = true;
 float autocvar_g_waypointsprite_turrets_maxdist = 5000;
 bool autocvar_g_waypointsprite_uppercase;
+bool autocvar_g_waypointsprite_text;
 
 float waypointsprite_fadedistance;
 float waypointsprite_normdistance;