]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Standardize display and describe methods
authorotta8634 <k9wolf@pm.me>
Thu, 9 Jan 2025 05:00:10 +0000 (13:00 +0800)
committerotta8634 <k9wolf@pm.me>
Thu, 9 Jan 2025 05:00:10 +0000 (13:00 +0800)
Previously they were implemented a bit differently for each class, for some reason.

qcsrc/common/items/item.qh
qcsrc/common/mapinfo.qh
qcsrc/common/monsters/monster.qh
qcsrc/common/mutators/base.qh
qcsrc/common/mutators/mutator/buffs/buffs.qh
qcsrc/common/mutators/mutator/nades/nades.qh
qcsrc/common/mutators/mutator/powerups/powerups.qh
qcsrc/common/turrets/turret.qh
qcsrc/common/vehicles/vehicle.qh
qcsrc/common/weapons/weapon.qh
qcsrc/menu/xonotic/guide/pages.qc

index 299bd45b5193672bd09097c8916827c5a8a62408..b44d9c7a6e580f9c694fef13e324ba44f7be650c 100644 (file)
@@ -136,7 +136,7 @@ CLASS(GameItem, Object)
     METHOD(GameItem, describe, string(GameItem this))
     {
         TC(GameItem, this);
-        return SUPER(Object).describe(this);
+        return SUPER(GameItem).describe(this);
     }
 #endif
     METHOD(GameItem, display, void(GameItem this, void(string name, string icon) returns))
index 1cedeaf1d264e967c432ab83967281de65ea5fbd..659d8c040fb458ed72cfdb533f62a84b2bcf293d 100644 (file)
@@ -102,14 +102,13 @@ CLASS(Gametype, Object)
     METHOD(Gametype, describe, string(Gametype this))
     {
         TC(Gametype, this);
-               return SUPER(Object).describe(this);
+               return SUPER(Gametype).describe(this);
     }
 #endif
-
     METHOD(Gametype, display, void(Gametype this, void(string name, string icon) returns))
     {
         TC(Gametype, this);
-        returns(this.message, strcat("gametype_", this.mdl));
+        returns(this.m_name, this.mdl ? strcat("gametype_", this.mdl) : string_null);
     }
 
     METHOD(Gametype, gametype_init, void(Gametype this, string hname, string sname, string g_name, int gflags, string mutators, string defaults, string gdescription))
index 87b0d186eed6fc166a085745000a1e8c90cfbc56..fcd4b5d72e00e0e5e4fda5321a4790488fb3bd97 100644 (file)
@@ -58,8 +58,15 @@ CLASS(Monster, Object)
     /** (BOTH?) sets animations for monster */
     METHOD(Monster, mr_anim, bool(Monster this, entity actor)) { TC(Monster, this); return false; }
 #ifdef MENUQC
-    METHOD(Monster, describe, string(Monster this)) { TC(Monster, this); return SUPER(Object).describe(this); }
+    METHOD(Monster, describe, string(Monster this)) {
+        TC(Monster, this);
+        return SUPER(Monster).describe(this);
+    }
 #endif
+    METHOD(Monster, display, void(Monster this, void(string name, string icon) returns)) {
+        TC(Monster, this);
+        returns(this.m_name, this.m_icon ? sprintf("/gfx/hud/%s/%s", cvar_string("menu_skin"), this.m_icon) : string_null);
+    }
 ENDCLASS(Monster)
 
 
index de637b0770f476e42098bd6ddc9d76d1dfc930b0..eb8b30ca734197421990cae313cd4e40f12dc26a 100644 (file)
@@ -160,12 +160,13 @@ CLASS(Mutator, Object)
     ATTRIB(Mutator, mutatorname, string);
     ATTRIB(Mutator, mutatorfunc, mutatorfunc_t);
     ATTRIB(Mutator, mutatorcheck, bool());
-    METHOD(Mutator, describe, string(entity this)) {
+    METHOD(Mutator, describe, string(Mutator this)) {
         TC(Mutator, this);
         return SUPER(Mutator).describe(this);
     }
-    METHOD(Mutator, display, void(entity this, void(string name, string icon) returns)) {
-        returns(this.m_name, this.m_icon);
+    METHOD(Mutator, display, void(Mutator this, void(string name, string icon) returns)) {
+        TC(Mutator, this);
+        returns(this.m_name, this.m_icon ? sprintf("/gfx/hud/%s/%s", cvar_string("menu_skin"), this.m_icon) : string_null);
     }
 ENDCLASS(Mutator)
 
index 0f571931be8950767793b96410125934deaa25b9..a590c73cd14f3c921d1477d8eb85cd1b72287e86 100644 (file)
@@ -22,19 +22,19 @@ CLASS(Buff, StatusEffects)
        ATTRIB(Buff, m_skin, int, 0);
        ATTRIB(Buff, m_lifetime, float, 60);
        ATTRIB(Buff, m_sprite, string, "");
-       METHOD(Buff, display, void(entity this, void(string name, string icon) returns)) {
-               returns(this.m_name, sprintf("/gfx/hud/%s/%s", cvar_string("menu_skin"), this.m_icon));
+       METHOD(Buff, display, void(Buff this, void(string name, string icon) returns)) {
+               TC(Buff, this);
+               returns(this.m_name, this.m_icon ? sprintf("/gfx/hud/%s/%s", cvar_string("menu_skin"), this.m_icon) : string_null);
        }
 #ifdef SVQC
-       METHOD(Buff, m_time, float(Buff this))
-       {
+       METHOD(Buff, m_time, float(Buff this)) {
                return cvar(strcat("g_buffs_", this.netname, "_time"));
        }
 #endif
 #ifdef MENUQC
        METHOD(Buff, describe, string(Buff this)) {
                TC(Buff, this);
-               return SUPER(Object).describe(this);
+               return SUPER(Buff).describe(this);
        }
 #endif
 ENDCLASS(Buff)
index b72481fe3092048ae31b94abf1d619d9a2252e73..cedf5d35c3d39fec515104fac2cbc7b97e1d0ca5 100644 (file)
@@ -125,13 +125,14 @@ CLASS(Nade, Object)
     ATTRIB(Nade, m_alpha, float, 1);
     ATTRIBARRAY(Nade, m_projectile, int, 2);
     ATTRIBARRAY(Nade, m_trail, entity, 2);
-    METHOD(Nade, display, void(entity this, void(string name, string icon) returns)) {
-        returns(this.m_name, sprintf("/gfx/hud/%s/%s", cvar_string("menu_skin"), this.m_icon));
+    METHOD(Nade, display, void(Nade this, void(string name, string icon) returns)) {
+        TC(Nade, this);
+        returns(this.m_name, this.m_icon ? sprintf("/gfx/hud/%s/%s", cvar_string("menu_skin"), this.m_icon) : string_null);
     }
 #ifdef MENUQC
     METHOD(Nade, describe, string(Nade this)) {
         TC(Nade, this);
-        return SUPER(Object).describe(this);
+        return SUPER(Nade).describe(this);
     }
 #endif
 ENDCLASS(Nade)
index 42e43d3849f5807687c350e3c040a9bda4bb4a84..e27f454d699ed74c5fba031fdcdd35d72a4a89d0 100644 (file)
@@ -13,7 +13,7 @@ CLASS(Powerup, Pickup)
     METHOD(Powerup, describe, string(Powerup this))
     {
         TC(Powerup, this);
-        return SUPER(Object).describe(this);
+        return SUPER(Powerup).describe(this);
     }
 #endif
 ENDCLASS(Powerup)
index 700e67a66f9f63c4e587d0eb0876f613c96e0914..31e26e3f8eb1d214c2fae918d92271031d0a1f19 100644 (file)
@@ -5,6 +5,8 @@
 CLASS(Turret, Object)
     ATTRIB(Turret, m_id, int, 0);
 
+    /** icon */
+    ATTRIB(Turret, m_icon, string);
     /** short name */
     ATTRIB(Turret, netname, string);
     /** human readable name */
@@ -25,7 +27,8 @@ CLASS(Turret, Object)
     ATTRIB(Turret, m_maxs, vector, '0 0 0');
 
     METHOD(Turret, display, void(Turret this, void(string name, string icon) returns)) {
-        returns(this.m_name, string_null);
+        TC(Turret, this);
+        returns(this.m_name, this.m_icon ? sprintf("/gfx/hud/%s/%s", cvar_string("menu_skin"), this.m_icon) : string_null);
     }
     /** (BOTH) setup turret data */
     METHOD(Turret, tr_setup, void(Turret this, entity it)) {
@@ -58,7 +61,7 @@ CLASS(Turret, Object)
 #ifdef MENUQC
     METHOD(Turret, describe, string(Turret this)) {
         TC(Turret, this);
-        return SUPER(Object).describe(this);
+        return SUPER(Turret).describe(this);
     }
 #endif
 ENDCLASS(Turret)
index dd6960fd136e45af76a1c0877eda23de76d5603a..5837ba1f5f49513e36e0afbbe4b56e445d05cd95 100644 (file)
@@ -40,10 +40,11 @@ CLASS(Vehicle, Object)
 #ifdef MENUQC
     METHOD(Vehicle, describe, string(Vehicle this)) {
         TC(Vehicle, this);
-        return SUPER(Object).describe(this);
+        return SUPER(Vehicle).describe(this);
     }
 #endif
-    METHOD(Vehicle, display, void(entity this, void(string name, string icon) returns)) {
+    METHOD(Vehicle, display, void(Vehicle this, void(string name, string icon) returns)) {
+        TC(Vehicle, this);
         returns(this.m_name, this.m_icon ? sprintf("/gfx/hud/%s/%s", cvar_string("menu_skin"), this.m_icon) : string_null);
     }
 
index bfa169666be14c9de813a2c2cb63cc0ea5b48498..f9f1d6f5bb590a2fb571b06a6add1f5e3d621554 100644 (file)
@@ -126,13 +126,14 @@ CLASS(Weapon, Object)
        METHOD(Weapon, wr_pickup, void(Weapon this, entity actor, .entity weaponentity)) {}
        /** (SERVER) update cvar based properties */
        METHOD(Weapon, wr_update, void(Weapon this)) {}
-       METHOD(Weapon, display, void(entity this, void(string name, string icon) returns)) {
+       METHOD(Weapon, display, void(Weapon this, void(string name, string icon) returns)) {
+               TC(Weapon, this);
                returns(this.m_name, this.model2 ? sprintf("/gfx/hud/%s/%s", cvar_string("menu_skin"), this.model2) : string_null);
        }
 #ifdef MENUQC
        METHOD(Weapon, describe, string(Weapon this)) {
                TC(Weapon, this);
-               return SUPER(Object).describe(this);
+               return SUPER(Weapon).describe(this);
        }
 #endif
 ENDCLASS(Weapon)
index b6b9af2adfe8125acd459c46eb1446278df3435c..aa8c70d6ff16600b37218bdfbb7ec244ff74e8b3 100644 (file)
@@ -7,12 +7,13 @@ METHOD(GuidePage, describe, string(GuidePage this))
 }
 METHOD(GuidePage, display, void(GuidePage this, void(string name, string icon) returns))
 {
+       TC(GuidePage, this);
        string icon_str;
        if (this.m_title == _("Introduction"))
                icon_str = "gametype_dm";
        else if (this.m_title == _("Movement"))
                icon_str = "gametype_inv";
        else
-               icon_str = "nopreview_map";
+               icon_str = string_null;
        returns(this.m_title, icon_str);
 }