]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/items/item.qh
Merge branch 'master' into TimePath/waypointsprites
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / items / item.qh
index cf2779aa02efc505977711a8f36d22593b275b9b..6e566f6cc106b5e369427705d67e164d581a8312 100644 (file)
@@ -1,38 +1,20 @@
 #ifndef GAMEITEM_H
 #define GAMEITEM_H
 #include "../oo.qh"
+#define ITEM_HANDLE(signal, ...) __Item_Send_##signal(__VA_ARGS__)
+/** If you register a new item, make sure to add it to all.inc */
 CLASS(GameItem, Object)
-    METHOD(GameItem, respondTo, bool(entity, int))
+    ATTRIB(GameItem, m_id, int, 0)
+    ATTRIB(GameItem, m_name, string, string_null)
+    ATTRIB(GameItem, m_icon, string, string_null)
+    ATTRIB(GameItem, m_color, vector, '1 1 1')
+    ATTRIB(GameItem, m_waypoint, string, string_null)
+    ATTRIB(GameItem, m_waypointblink, int, 1)
+    METHOD(GameItem, display, void(entity this, void(string name, string icon) returns)) {
+        returns(this.m_name, this.m_icon ? sprintf("/gfx/hud/%s/%s", cvar_string("menu_skin"), this.m_icon) : string_null);
+    }
+    METHOD(GameItem, show, void(entity this)) { print("A game item\n"); }
+    void ITEM_HANDLE(Show, entity this) { this.show(this); }
 ENDCLASS(GameItem)
 
-
-
-#define LAMBDA(...) { __VA_ARGS__ ; }
-
-#define ITEM_SIGNALS(_) \
-    _(Default, void, (entity it), LAMBDA({ it.respondTo(it, SIGNAL); })) \
-    /* Common item signals */
-
-#define ITEM_SIGNAL(id) __Item_Signal_##id
-
-#define ITEM_ENUM(id, ret, params, body) ITEM_SIGNAL(id) ,
-enum { ITEM_SIGNALS(ITEM_ENUM) };
-#undef ITEM_ENUM
-
-#define ITEM_SEND(id, ret, params, body) ret __Item_Send_##id params { const noref int SIGNAL = ITEM_SIGNAL(id); body }
-ITEM_SIGNALS(ITEM_SEND)
-#undef ITEM_SEND
-#define ITEM_SEND(id, ...) __Item_Send_##id(__VA_ARGS__)
-
-
-
-int ITEM_COUNT;
-#define REGISTER_ITEM(id, class, body)          \
-    void RegisterItems_##id() {                 \
-        const noref entity this = NEW(class);   \
-        ITEMS[ITEM_COUNT++] = this;             \
-        body                                    \
-    }                                           \
-    ACCUMULATE_FUNCTION(RegisterItems, RegisterItems_##id)
-
 #endif