]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/minigames/cl_minigames.qh
Run whitespace.sh
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / minigames / cl_minigames.qh
1 #ifndef CL_MINIGAMES_H
2 #define CL_MINIGAMES_H
3
4 #include "../../dpdefs/keycodes.qh"
5
6 // Get a square in the center of the avaliable area
7 // \note macro to pass by reference pos and mySize
8 #define minigame_hud_fitsqare(pos, mySize) \
9         if ( mySize##_x > mySize##_y ) \
10         { \
11                 pos##_x += (mySize##_x-mySize##_y)/2; \
12                 mySize##_x = mySize##_y; \
13         } \
14         else \
15         { \
16                 pos##_y += (mySize##_y-mySize##_x)/2; \
17                 mySize##_x = mySize##_x; \
18         } \
19         if(panel_bg_padding) \
20         { \
21                 pos += '1 1 0' * panel_bg_padding; \
22                 mySize -= '2 2 0' * panel_bg_padding; \
23         }
24
25 // Get position and size of a panel
26 // \note macro to pass by reference pos and mySize
27 #define minigame_hud_panelarea(pos, mySize, panelID) \
28         pos = stov(cvar_string(strcat("hud_panel_", HUD_PANEL(panelID).panel_name, "_pos"))); \
29         mySize = stov(cvar_string(strcat("hud_panel_", HUD_PANEL(panelID).panel_name, "_size"))); \
30         pos##_x *= vid_conwidth; pos##_y *= vid_conheight; \
31         mySize##_x *= vid_conwidth; mySize##_y *= vid_conheight;
32
33 // draw a panel border and the given texture
34 void minigame_hud_simpleboard(vector pos, vector mySize, string board_texture);
35
36 // Normalize (2D vector) v to relative coordinate inside pos mySize
37 vector minigame_hud_normalize(vector v, vector pos, vector mySize);
38
39 // De-normalize (2D vector) v from relative coordinate inside pos mySize
40 vector minigame_hud_denormalize(vector v, vector pos, vector mySize);
41
42 // De-normalize (2D vector) v from relative size inside pos mySize
43 vector minigame_hud_denormalize_size(vector v, vector pos, vector mySize);
44
45 // Check if the mouse is inside the given area
46 bool minigame_hud_mouse_in(vector pos, vector sz);
47
48 // Like drawstring, but wrapping words to fit maxwidth
49 // returns the size of the drawn area
50 // align selects the string alignment (0 = left, 0.5 = center, 1 = right)
51 vector minigame_drawstring_wrapped( float maxwidth, vector pos, string text,
52         vector fontsize, vector color, float theAlpha, int drawflags, float align );
53
54 // Like drawcolorcodedstring, but wrapping words to fit maxwidth
55 // returns the size of the drawn area
56 // align selects the string alignment (0 = left, 0.5 = center, 1 = right)
57 vector minigame_drawcolorcodedstring_wrapped( float maxwidth, vector pos,
58         string text, vector fontsize, float theAlpha, int drawflags, float align );
59
60 // Like drawstring but truncates the text to fit maxwidth
61 void minigame_drawstring_trunc(float maxwidth, vector pos, string text,
62         vector fontsize, vector color, float theAlpha, int drawflags );
63
64 // Like drawcolorcodedstring but truncates the text to fit maxwidth
65 void minigame_drawcolorcodedstring_trunc(float maxwidth, vector pos, string text,
66         vector fontsize, float theAlpha, int drawflags );
67
68 // like drawpic but pos represent the center rather than the topleft corner
69 void minigame_drawpic_centered( vector pos, string texture, vector sz,
70         vector color, float thealpha, int drawflags );
71
72 // Get full path of a minigame texture
73 string minigame_texture(string name);
74
75 // For minigame descriptors: hud function for the game board
76 .void(vector pos, vector size) minigame_hud_board;
77 // For minigame descriptors: hud function for the game status
78 .void(vector pos, vector size) minigame_hud_status;
79 // For minigame_player: player server slot, don't use for anything else
80 .float minigame_playerslot;
81
82 // register all minigames
83 void initialize_minigames();
84
85 // client-side minigame session cleanup
86 void deactivate_minigame();
87
88 // Currently active minigame session
89 entity active_minigame;
90 // minigame_player representing this client
91 entity minigame_self;
92
93 // Whethere there's an active minigame
94 float minigame_isactive()
95 {
96         return active_minigame != world;
97 }
98
99 // Execute a minigame command
100 #define minigame_cmd(...) minigame_cmd_workaround(0,__VA_ARGS__)
101 void minigame_cmd_workaround(float dummy, string...cmdargc);
102
103 // Read a minigame entity from the server
104 void ent_read_minigame();
105
106 // Prompt the player to play in the current minigame
107 // (ie: it's their turn and they should get back to the minigame)
108 void minigame_prompt();
109
110 float HUD_MinigameMenu_IsOpened();
111 void HUD_MinigameMenu_Close();
112 float HUD_Minigame_Showpanels();
113 // Adds a game-specific entry to the menu
114 void HUD_MinigameMenu_CustomEntry(entity parent, string message, string event_arg);
115
116
117 #define FOREACH_MINIGAME_ENTITY(entityvar) \
118         entityvar=world; \
119         while( (entityvar = findentity(entityvar,owner,active_minigame)) )
120
121 #endif