]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/minigames/cl_minigames.qh
Cleanup
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / minigames / cl_minigames.qh
index 404f24a619e3d4816f9628b5f0b356951ad5d30c..ab5ffc7ea8697667421b20b8386d396065e2af5b 100644 (file)
@@ -41,31 +41,31 @@ vector minigame_hud_denormalize(vector v, vector pos, vector mySize);
 vector minigame_hud_denormalize_size(vector v, vector pos, vector mySize);
 
 // Check if the mouse is inside the given area
-float minigame_hud_mouse_in(vector pos, vector sz);
+bool minigame_hud_mouse_in(vector pos, vector sz);
 
 // Like drawstring, but wrapping words to fit maxwidth
 // returns the size of the drawn area
 // align selects the string alignment (0 = left, 0.5 = center, 1 = right)
-vector minigame_drawstring_wrapped( float maxwidth, vector pos, string text, 
-       vector fontsize, vector color, float theAlpha, float drawflags, float align );
+vector minigame_drawstring_wrapped( float maxwidth, vector pos, string text,
+       vector fontsize, vector color, float theAlpha, int drawflags, float align );
 
 // Like drawcolorcodedstring, but wrapping words to fit maxwidth
 // returns the size of the drawn area
 // align selects the string alignment (0 = left, 0.5 = center, 1 = right)
-vector minigame_drawcolorcodedstring_wrapped( float maxwidth, vector pos, 
-       string text, vector fontsize, float theAlpha, float drawflags, float align );
+vector minigame_drawcolorcodedstring_wrapped( float maxwidth, vector pos,
+       string text, vector fontsize, float theAlpha, int drawflags, float align );
 
 // Like drawstring but truncates the text to fit maxwidth
-void minigame_drawstring_trunc(float maxwidth, vector pos, string text, 
-       vector fontsize, vector color, float theAlpha, float drawflags );
+void minigame_drawstring_trunc(float maxwidth, vector pos, string text,
+       vector fontsize, vector color, float theAlpha, int drawflags );
 
 // Like drawcolorcodedstring but truncates the text to fit maxwidth
-void minigame_drawcolorcodedstring_trunc(float maxwidth, vector pos, string text, 
-       vector fontsize, float theAlpha, float drawflags );
+void minigame_drawcolorcodedstring_trunc(float maxwidth, vector pos, string text,
+       vector fontsize, float theAlpha, int drawflags );
 
 // like drawpic but pos represent the center rather than the topleft corner
-void minigame_drawpic_centered( vector pos, string texture, vector sz, 
-       vector color, float thealpha, float drawflags );
+void minigame_drawpic_centered( vector pos, string texture, vector sz,
+       vector color, float thealpha, int drawflags );
 
 // Get full path of a minigame texture
 string minigame_texture(string name);
@@ -77,9 +77,6 @@ string minigame_texture(string name);
 // For minigame_player: player server slot, don't use for anything else
 .float minigame_playerslot;
 
-// register all minigames
-void initialize_minigames();
-
 // client-side minigame session cleanup
 void deactivate_minigame();
 
@@ -98,10 +95,7 @@ float minigame_isactive()
 #define minigame_cmd(...) minigame_cmd_workaround(0,__VA_ARGS__)
 void minigame_cmd_workaround(float dummy, string...cmdargc);
 
-// Read a minigame entity from the server
-void ent_read_minigame();
-
-// Prompt the player to play in the current minigame 
+// Prompt the player to play in the current minigame
 // (ie: it's their turn and they should get back to the minigame)
 void minigame_prompt();
 
@@ -114,6 +108,25 @@ void HUD_MinigameMenu_CustomEntry(entity parent, string message, string event_ar
 
 #define FOREACH_MINIGAME_ENTITY(entityvar) \
        entityvar=world; \
-       while( (entityvar = findentity(entityvar,owner,active_minigame)) ) 
+       while( (entityvar = findentity(entityvar,owner,active_minigame)) )
+
+
+REGISTRY(Minigames, BITS(3))
+#define Minigames_from(i) _Minigames_from(i, NULL)
+REGISTER_REGISTRY(RegisterMinigames)
+#define REGISTER_MINIGAME(name,nicename) \
+    REGISTER(RegisterMinigames, MINIGAME, Minigames, name, m_id, new(minigame_descriptor)); \
+    void name##_hud_board(vector, vector); \
+    void name##_hud_status(vector, vector); \
+    int name##_client_event(entity, string, ...); \
+    REGISTER_INIT_POST(MINIGAME, name) { \
+        make_pure(this); \
+        this.netname = strzone(strtolower(#name)); \
+        this.message = nicename; \
+        this.minigame_hud_board = name##_hud_board; \
+               this.minigame_hud_status = name##_hud_status; \
+               this.minigame_event = name##_client_event; \
+    } \
+    REGISTER_INIT(MINIGAME, name)
 
 #endif