Xonotic
cl_minigames.qh
Go to the documentation of this file.
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
37 
38 // De-normalize (2D vector) v from relative coordinate inside pos mySize
40 
41 // De-normalize (2D vector) v from relative size inside pos mySize
43 
44 // Check if the mouse is inside the given area
45 bool minigame_hud_mouse_in(vector pos, vector sz);
46 
47 // Like drawstring, but wrapping words to fit maxwidth
48 // returns the size of the drawn area
49 // align selects the string alignment (0 = left, 0.5 = center, 1 = right)
50 vector minigame_drawstring_wrapped( float maxwidth, vector pos, string text,
51  vector fontsize, vector color, float theAlpha, int drawflags, float align );
52 
53 // Like drawcolorcodedstring, but wrapping words to fit maxwidth
54 // returns the size of the drawn area
55 // align selects the string alignment (0 = left, 0.5 = center, 1 = right)
57  string text, vector fontsize, float theAlpha, int drawflags, float align );
58 
59 // Like drawstring but truncates the text to fit maxwidth
60 void minigame_drawstring_trunc(float maxwidth, vector pos, string text,
61  vector fontsize, vector color, float theAlpha, int drawflags );
62 
63 // Like drawcolorcodedstring but truncates the text to fit maxwidth
64 void minigame_drawcolorcodedstring_trunc(float maxwidth, vector pos, string text,
65  vector fontsize, float theAlpha, int drawflags );
66 
67 // like drawpic but pos represent the center rather than the topleft corner
68 void minigame_drawpic_centered( vector pos, string texture, vector sz,
69  vector color, float thealpha, int drawflags );
70 
71 // Get full path of a minigame texture
72 string minigame_texture(string name);
73 
74 // For minigame descriptors: hud function for the game board
75 .void(vector pos, vector size) minigame_hud_board;
76 // For minigame descriptors: hud function for the game status
77 .void(vector pos, vector size) minigame_hud_status;
78 // For minigame_player: player server slot, don't use for anything else
80 
81 // client-side minigame session cleanup
82 void deactivate_minigame();
83 
84 // Currently active minigame session
86 // minigame_player representing this client
88 
89 // Execute a minigame command
90 #define minigame_cmd(...) minigame_cmd_workaround(0,__VA_ARGS__)
91 void minigame_cmd_workaround(float dummy, string...cmdargc);
92 
93 // Prompt the player to play in the current minigame
94 // (ie: it's their turn and they should get back to the minigame)
95 void minigame_prompt();
96 
97 
98 #define FOREACH_MINIGAME_ENTITY(entityvar) \
99  entityvar=NULL; \
100  while( (entityvar = findentity(entityvar,owner,active_minigame)) )
101 
102 
103 REGISTRY(Minigames, BITS(4))
104 REGISTER_REGISTRY(Minigames)
105 REGISTRY_CHECK(Minigames)
106 
107 REGISTRY_DEFINE_GET(Minigames, NULL)
108 #define REGISTER_MINIGAME(name,nicename) \
109  REGISTER(Minigames, MINIGAME_##name, m_id, new_pure(minigame_descriptor)); \
110  void name##_hud_board(vector, vector); \
111  void name##_hud_status(vector, vector); \
112  int name##_client_event(entity, string, ...); \
113  REGISTER_INIT(MINIGAME_##name) { \
114  this.netname = strzone(strtolower(#name)); \
115  this.message = nicename; \
116  this.minigame_hud_board = name##_hud_board; \
117  this.minigame_hud_status = name##_hud_status; \
118  this.minigame_event = name##_client_event; \
119  } \
120  REGISTER_INIT(MINIGAME_##name)
vector color
float minigame_playerslot
Definition: cl_minigames.qh:79
entity() spawn
void minigame_cmd_workaround(float dummy, string...cmdargc)
#define REGISTRY_CHECK(id)
Definition: registry.qh:175
vector size
Definition: csprogsdefs.qc:114
vector minigame_hud_normalize(vector v, vector pos, vector mySize)
Definition: cl_minigames.qc:31
#define REGISTER_REGISTRY(id)
Definition: registry.qh:212
#define REGISTRY_DEFINE_GET(id, null)
Definition: registry.qh:40
void minigame_prompt()
entity active_minigame
Definition: cl_minigames.qh:85
vector minigame_hud_denormalize_size(vector v, vector pos, vector mySize)
Definition: cl_minigames.qc:23
#define REGISTRY(id, max)
Declare a new registry.
Definition: registry.qh:26
vector minigame_drawcolorcodedstring_wrapped(float maxwidth, vector pos, string text, vector fontsize, float theAlpha, int drawflags, float align)
#define NULL
Definition: post.qh:17
void minigame_drawpic_centered(vector pos, string texture, vector sz, vector color, float thealpha, int drawflags)
vector(float skel, float bonenum) _skel_get_boneabs_hidden
vector minigame_hud_denormalize(vector v, vector pos, vector mySize)
Definition: cl_minigames.qc:16
vector v
Definition: ent_cs.qc:116
bool minigame_hud_mouse_in(vector pos, vector sz)
Definition: cl_minigames.qc:39
void minigame_hud_simpleboard(vector pos, vector mySize, string board_texture)
Definition: cl_minigames.qc:4
void deactivate_minigame()
Definition: cl_minigames.qc:83
void minigame_drawcolorcodedstring_trunc(float maxwidth, vector pos, string text, vector fontsize, float theAlpha, int drawflags)
string minigame_texture(string name)
Definition: cl_minigames.qc:49
entity minigame_self
Definition: cl_minigames.qh:87
void minigame_drawstring_trunc(float maxwidth, vector pos, string text, vector fontsize, vector color, float theAlpha, int drawflags)
vector minigame_drawstring_wrapped(float maxwidth, vector pos, string text, vector fontsize, vector color, float theAlpha, int drawflags, float align)
#define BITS(n)
Definition: bits.qh:9