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