Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
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
33void 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
46
47// show spectator list above the board
48void 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)
53vector 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)
60 string text, vector fontsize, float theAlpha, int drawflags, float align );
61
62// Like drawstring but truncates the text to fit maxwidth
63void 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
67void 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
71void 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
75string 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
83
84// client-side minigame session cleanup
86
87// Currently active minigame session
89// minigame_player representing this client
91
92// Execute a minigame command
93#define minigame_cmd(...) minigame_cmd_workaround(0,__VA_ARGS__)
94void 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)
98void minigame_prompt();
99
100
101#define FOREACH_MINIGAME_ENTITY(entityvar) \
102 entityvar=NULL; \
103 while( (entityvar = findentity(entityvar,owner,active_minigame)) )
104
105
106REGISTRY(Minigames, BITS(4))
107REGISTER_REGISTRY(Minigames)
108REGISTRY_CHECK(Minigames)
109
110REGISTRY_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)
#define BITS(n)
Definition bits.qh:9
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
void minigame_drawcolorcodedstring_trunc(float maxwidth, vector pos, string text, vector fontsize, float theAlpha, int drawflags)
void minigame_show_allspecs(vector boardpos, vector boardsize)
void minigame_prompt()
vector minigame_drawstring_wrapped(float maxwidth, vector pos, string text, vector fontsize, vector color, float theAlpha, int drawflags, float align)
entity minigame_self
void minigame_cmd_workaround(float dummy, string...cmdargc)
bool minigame_hud_mouse_in(vector pos, vector sz)
void minigame_hud_simpleboard(vector pos, vector mySize, string board_texture)
void deactivate_minigame()
entity active_minigame
string minigame_texture(string name)
vector minigame_hud_denormalize_size(vector v, vector pos, vector mySize)
vector minigame_drawcolorcodedstring_wrapped(float maxwidth, vector pos, string text, vector fontsize, float theAlpha, int drawflags, float align)
void minigame_drawstring_trunc(float maxwidth, vector pos, string text, vector fontsize, vector color, float theAlpha, int drawflags)
vector minigame_hud_denormalize(vector v, vector pos, vector mySize)
vector minigame_hud_normalize(vector v, vector pos, vector mySize)
float minigame_playerslot
void minigame_drawpic_centered(vector pos, string texture, vector sz, vector color, float thealpha, int drawflags)
vector size
vector color
Definition dynlight.qc:15
string name
Definition menu.qh:30
#define NULL
Definition post.qh:14
#define REGISTER_REGISTRY(id)
Definition registry.qh:229
#define REGISTRY(id, max)
Declare a new registry.
Definition registry.qh:26
#define REGISTRY_CHECK(id)
Definition registry.qh:175
#define REGISTRY_DEFINE_GET(id, null)
Definition registry.qh:40
vector
Definition self.qh:92