4 // Get a square in the center of the avaliable area
5 // \note macro to pass by reference pos and mySize
6 #define minigame_hud_fitsqare(pos, mySize) \
7 if ( mySize##_x > mySize##_y ) \
9 pos##_x += (mySize##_x-mySize##_y)/2; \
10 mySize##_x = mySize##_y; \
14 pos##_y += (mySize##_y-mySize##_x)/2; \
15 mySize##_x = mySize##_x; \
17 if(panel_bg_padding) \
19 pos += '1 1 0' * panel_bg_padding; \
20 mySize -= '2 2 0' * panel_bg_padding; \
23 // Get position and size of a panel
24 // \note macro to pass by reference pos and mySize
25 #define minigame_hud_panelarea(pos, mySize, panelID) \
26 pos = stov(cvar_string(strcat("hud_panel_", HUD_PANEL(panelID).panel_name, "_pos"))); \
27 mySize = stov(cvar_string(strcat("hud_panel_", HUD_PANEL(panelID).panel_name, "_size"))); \
28 pos##_x *= vid_conwidth; pos##_y *= vid_conheight; \
29 mySize##_x *= vid_conwidth; mySize##_y *= vid_conheight;
31 // draw a panel border and the given texture
32 void minigame_hud_simpleboard(vector pos, vector mySize, string board_texture);
34 // Normalize (2D vector) v to relative coordinate inside pos mySize
35 vector minigame_hud_normalize(vector v, vector pos, vector mySize);
37 // De-normalize (2D vector) v from relative coordinate inside pos mySize
38 vector minigame_hud_denormalize(vector v, vector pos, vector mySize);
40 // De-normalize (2D vector) v from relative size inside pos mySize
41 vector minigame_hud_denormalize_size(vector v, vector pos, vector mySize);
43 // Check if the mouse is inside the given area
44 bool minigame_hud_mouse_in(vector pos, vector sz);
46 // Like drawstring, but wrapping words to fit maxwidth
47 // returns the size of the drawn area
48 // align selects the string alignment (0 = left, 0.5 = center, 1 = right)
49 vector minigame_drawstring_wrapped( float maxwidth, vector pos, string text,
50 vector fontsize, vector color, float theAlpha, int drawflags, float align );
52 // Like drawcolorcodedstring, but wrapping words to fit maxwidth
53 // returns the size of the drawn area
54 // align selects the string alignment (0 = left, 0.5 = center, 1 = right)
55 vector minigame_drawcolorcodedstring_wrapped( float maxwidth, vector pos,
56 string text, vector fontsize, float theAlpha, int drawflags, float align );
58 // Like drawstring but truncates the text to fit maxwidth
59 void minigame_drawstring_trunc(float maxwidth, vector pos, string text,
60 vector fontsize, vector color, float theAlpha, int drawflags );
62 // Like drawcolorcodedstring but truncates the text to fit maxwidth
63 void minigame_drawcolorcodedstring_trunc(float maxwidth, vector pos, string text,
64 vector fontsize, float theAlpha, int drawflags );
66 // like drawpic but pos represent the center rather than the topleft corner
67 void minigame_drawpic_centered( vector pos, string texture, vector sz,
68 vector color, float thealpha, int drawflags );
70 // Get full path of a minigame texture
71 string minigame_texture(string name);
73 // For minigame descriptors: hud function for the game board
74 .void(vector pos, vector size) minigame_hud_board;
75 // For minigame descriptors: hud function for the game status
76 .void(vector pos, vector size) minigame_hud_status;
77 // For minigame_player: player server slot, don't use for anything else
78 .float minigame_playerslot;
80 // client-side minigame session cleanup
81 void deactivate_minigame();
83 // Currently active minigame session
84 entity active_minigame;
85 // minigame_player representing this client
88 // Whethere there's an active minigame
89 float minigame_isactive()
91 return active_minigame != world;
94 // Execute a minigame command
95 #define minigame_cmd(...) minigame_cmd_workaround(0,__VA_ARGS__)
96 void minigame_cmd_workaround(float dummy, string...cmdargc);
98 // Prompt the player to play in the current minigame
99 // (ie: it's their turn and they should get back to the minigame)
100 void minigame_prompt();
102 float HUD_MinigameMenu_IsOpened();
103 void HUD_MinigameMenu_Close();
104 float HUD_Minigame_Showpanels();
105 // Adds a game-specific entry to the menu
106 void HUD_MinigameMenu_CustomEntry(entity parent, string message, string event_arg);
109 #define FOREACH_MINIGAME_ENTITY(entityvar) \
111 while( (entityvar = findentity(entityvar,owner,active_minigame)) )
114 REGISTRY(Minigames, BITS(3))
115 #define Minigames_from(i) _Minigames_from(i, NULL)
116 REGISTER_REGISTRY(RegisterMinigames)
117 #define REGISTER_MINIGAME(name,nicename) \
118 REGISTER(RegisterMinigames, MINIGAME, Minigames, name, m_id, new(minigame_descriptor)); \
119 void name##_hud_board(vector, vector); \
120 void name##_hud_status(vector, vector); \
121 int name##_client_event(entity, string, ...); \
122 REGISTER_INIT_POST(MINIGAME, name) { \
124 this.netname = strzone(strtolower(#name)); \
125 this.message = nicename; \
126 this.minigame_hud_board = name##_hud_board; \
127 this.minigame_hud_status = name##_hud_status; \
128 this.minigame_event = name##_client_event; \
130 REGISTER_INIT(MINIGAME, name)