Xonotic
cl_minigames.qh File Reference
+ Include dependency graph for cl_minigames.qh:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define FOREACH_MINIGAME_ENTITY(entityvar)
 
#define minigame_cmd(...)   minigame_cmd_workaround(0,__VA_ARGS__)
 
#define minigame_hud_fitsqare(pos, mySize)
 
#define minigame_hud_panelarea(pos, mySize, panelID)
 
#define REGISTER_MINIGAME(name, nicename)
 

Functions

void deactivate_minigame ()
 
void minigame_cmd_workaround (float dummy, string...cmdargc)
 
void minigame_drawcolorcodedstring_trunc (float maxwidth, vector pos, string text, vector fontsize, float theAlpha, int drawflags)
 
vector minigame_drawcolorcodedstring_wrapped (float maxwidth, vector pos, string text, vector fontsize, float theAlpha, int drawflags, float align)
 
void minigame_drawpic_centered (vector pos, string texture, vector sz, vector color, float thealpha, int drawflags)
 
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)
 
vector minigame_hud_denormalize (vector v, vector pos, vector mySize)
 
vector minigame_hud_denormalize_size (vector v, vector pos, vector mySize)
 
bool minigame_hud_mouse_in (vector pos, vector sz)
 
vector minigame_hud_normalize (vector v, vector pos, vector mySize)
 
void minigame_hud_simpleboard (vector pos, vector mySize, string board_texture)
 
void minigame_prompt ()
 
string minigame_texture (string name)
 
 void (vector pos, vector size) minigame_hud_board
 

Variables

entity active_minigame
 
float minigame_playerslot
 
entity minigame_self
 

Macro Definition Documentation

◆ FOREACH_MINIGAME_ENTITY

#define FOREACH_MINIGAME_ENTITY (   entityvar)
Value:
entityvar=NULL; \
while( (entityvar = findentity(entityvar,owner,active_minigame)) )
entity owner
Definition: main.qh:73
entity active_minigame
Definition: cl_minigames.qh:85
#define NULL
Definition: post.qh:17

Definition at line 98 of file cl_minigames.qh.

Referenced by bd_close_editor(), c4_move(), nmm_in_mill(), pp_next_match(), ps_move(), and ttt_next_match().

◆ minigame_cmd

◆ minigame_hud_fitsqare

#define minigame_hud_fitsqare (   pos,
  mySize 
)
Value:
if ( mySize##_x > mySize##_y ) \
{ \
pos##_x += (mySize##_x-mySize##_y)/2; \
mySize##_x = mySize##_y; \
} \
else \
{ \
pos##_y += (mySize##_y-mySize##_x)/2; \
mySize##_x = mySize##_x; \
} \
{ \
pos += '1 1 0' * panel_bg_padding; \
mySize -= '2 2 0' * panel_bg_padding; \
}
float panel_bg_padding
Definition: hud.qh:171

Definition at line 7 of file cl_minigames.qh.

Referenced by bd_close_editor(), c4_move(), nmm_in_mill(), pp_next_match(), ps_move(), and ttt_next_match().

◆ minigame_hud_panelarea

#define minigame_hud_panelarea (   pos,
  mySize,
  panelID 
)
Value:
pos = stov(cvar_string(strcat("hud_panel_", HUD_PANEL(panelID).panel_name, "_pos"))); \
mySize = stov(cvar_string(strcat("hud_panel_", HUD_PANEL(panelID).panel_name, "_size"))); \
pos##_x *= vid_conwidth; pos##_y *= vid_conheight; \
mySize##_x *= vid_conwidth; mySize##_y *= vid_conheight;
float vid_conheight
float vid_conwidth
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
#define HUD_PANEL(NAME)
Definition: hud.qh:51

Definition at line 26 of file cl_minigames.qh.

◆ REGISTER_MINIGAME

#define REGISTER_MINIGAME (   name,
  nicename 
)
Value:
REGISTER(Minigames, MINIGAME_##name, m_id, new_pure(minigame_descriptor)); \
void name##_hud_board(vector, vector); \
void name##_hud_status(vector, vector); \
int name##_client_event(entity, string, ...); \
REGISTER_INIT(MINIGAME_##name) { \
this.netname = strzone(strtolower(#name)); \
this.message = nicename; \
this.minigame_hud_board = name##_hud_board; \
this.minigame_hud_status = name##_hud_status; \
this.minigame_event = name##_client_event; \
} \
REGISTER_INIT(MINIGAME_##name)
#define REGISTER(...)
Register a new entity with a registry.
Definition: registry.qh:87
entity() spawn
int m_id
Definition: effect.qh:19
vector(float skel, float bonenum) _skel_get_boneabs_hidden
#define new_pure(class)
purely logical entities (.origin doesn't work)
Definition: oo.qh:62

Definition at line 108 of file cl_minigames.qh.

Function Documentation

◆ deactivate_minigame()

void deactivate_minigame ( )

Definition at line 83 of file cl_minigames.qc.

References active_minigame, auto_close_minigamemenu, entity(), findentity(), HUD_MinigameMenu_Close(), HUD_MinigameMenu_CurrentButton(), minigame_autoclean_entity(), minigame_self, NULL, and owner.

Referenced by activate_minigame(), HUD_MinigameMenu_ClickQuit(), minigame_entremove(), minigame_player_entremove(), and Shutdown().

84 {
85  if ( !active_minigame )
86  return;
87 
88  active_minigame.minigame_event(active_minigame,"deactivate");
89  entity e = NULL;
90  while( (e = findentity(e, owner, active_minigame)) )
91  if ( e.minigame_autoclean )
92  {
94  }
95 
98 
100  {
103  }
104  else
106 }
entity() spawn
void HUD_MinigameMenu_Close(entity this, entity actor, entity trigger)
entity owner
Definition: main.qh:73
entity active_minigame
Definition: cl_minigames.qh:85
#define NULL
Definition: post.qh:17
void HUD_MinigameMenu_CurrentButton()
MINIGAME_SIMPLELINKED_ENTITIES void minigame_autoclean_entity(entity e)
Definition: cl_minigames.qc:75
entity minigame_self
Definition: cl_minigames.qh:87
bool auto_close_minigamemenu
Definition: cl_minigames.qc:82
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ minigame_cmd_workaround()

void minigame_cmd_workaround ( float  dummy,
string...  cmdargc 
)

Definition at line 362 of file cl_minigames.qc.

References cmd(), localcmd, and strcat().

363 {
364  string cmd;
365  cmd = "cmd minigame ";
366  float i;
367  for ( i = 0; i < cmdargc; i++ )
368  cmd = strcat(cmd,...(i,string));
369  localcmd(strcat(cmd,"\n"));
370 }
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
+ Here is the call graph for this function:

◆ minigame_drawcolorcodedstring_trunc()

void minigame_drawcolorcodedstring_trunc ( float  maxwidth,
vector  pos,
string  text,
vector  fontsize,
float  theAlpha,
int  drawflags 
)

Definition at line 347 of file cl_minigames.qc.

References drawcolorcodedstring(), and textShortenToWidth().

Referenced by HUD_MinigameMenu_DrawColoredEntry(), and ttt_next_match().

349 {
350  string line = textShortenToWidth(text,maxwidth,fontsize,stringwidth_colors);
351  drawcolorcodedstring(pos, line, fontsize, theAlpha, drawflags);
352 }
string textShortenToWidth(string theText, float maxWidth, vector theFontSize, textLengthUpToWidth_widthFunction_t tw)
Definition: util.qc:956
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ minigame_drawcolorcodedstring_wrapped()

vector minigame_drawcolorcodedstring_wrapped ( float  maxwidth,
vector  pos,
string  text,
vector  fontsize,
float  theAlpha,
int  drawflags,
float  align 
)

Definition at line 321 of file cl_minigames.qc.

References drawcolorcodedstring(), getWrappedLine_remaining, minigame_getWrappedLine(), and vector().

Referenced by c4_move(), nmm_in_mill(), and pp_next_match().

323 {
325  vector mypos = pos;
326  while ( getWrappedLine_remaining )
327  {
328  string line = minigame_getWrappedLine(maxwidth,fontsize,stringwidth_colors);
329  if ( line == "" )
330  break;
331  mypos_x = pos_x + (maxwidth - stringwidth_colors(line, fontsize)) * align;
332  drawcolorcodedstring(mypos, line, fontsize, theAlpha, drawflags);
333  mypos_y += fontsize_y;
334  }
335  mypos_x = maxwidth;
336  mypos_y -= pos_y;
337  return mypos;
338 }
string minigame_getWrappedLine(float w, vector theFontSize, textLengthUpToWidth_widthFunction_t tw)
string getWrappedLine_remaining
Definition: util.qh:108
vector(float skel, float bonenum) _skel_get_boneabs_hidden
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ minigame_drawpic_centered()

void minigame_drawpic_centered ( vector  pos,
string  texture,
vector  sz,
vector  color,
float  thealpha,
int  drawflags 
)

Definition at line 354 of file cl_minigames.qc.

References drawpic().

Referenced by bd_close_editor(), c4_move(), nmm_in_mill(), pp_next_match(), ps_move(), and ttt_next_match().

356 {
357  drawpic( pos-sz/2, texture, sz, color, thealpha, drawflags );
358 }
vector color
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ minigame_drawstring_trunc()

void minigame_drawstring_trunc ( float  maxwidth,
vector  pos,
string  text,
vector  fontsize,
vector  color,
float  theAlpha,
int  drawflags 
)

Definition at line 340 of file cl_minigames.qc.

References drawstring(), and textShortenToWidth().

Referenced by HUD_MinigameMenu_DrawEntry().

342 {
343  string line = textShortenToWidth(text,maxwidth,fontsize,stringwidth_nocolors);
344  drawstring(pos, line, fontsize, color, theAlpha, drawflags);
345 }
vector color
string textShortenToWidth(string theText, float maxWidth, vector theFontSize, textLengthUpToWidth_widthFunction_t tw)
Definition: util.qc:956
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ minigame_drawstring_wrapped()

vector minigame_drawstring_wrapped ( float  maxwidth,
vector  pos,
string  text,
vector  fontsize,
vector  color,
float  theAlpha,
int  drawflags,
float  align 
)

Definition at line 302 of file cl_minigames.qc.

References drawstring(), getWrappedLine_remaining, minigame_getWrappedLine(), and vector().

Referenced by ttt_next_match().

304 {
306  vector mypos = pos;
307  while ( getWrappedLine_remaining )
308  {
309  string line = minigame_getWrappedLine(maxwidth,fontsize,stringwidth_nocolors);
310  if ( line == "" )
311  break;
312  mypos_x = pos_x + (maxwidth - stringwidth_nocolors(line, fontsize)) * align;
313  drawstring(mypos, line, fontsize, color, theAlpha, drawflags);
314  mypos_y += fontsize_y;
315  }
316  mypos_x = maxwidth;
317  mypos_y -= pos_y;
318  return mypos;
319 }
vector color
string minigame_getWrappedLine(float w, vector theFontSize, textLengthUpToWidth_widthFunction_t tw)
string getWrappedLine_remaining
Definition: util.qh:108
vector(float skel, float bonenum) _skel_get_boneabs_hidden
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ minigame_hud_denormalize()

vector minigame_hud_denormalize ( vector  v,
vector  pos,
vector  mySize 
)

Definition at line 16 of file cl_minigames.qc.

References v.

Referenced by bd_close_editor(), c4_move(), nmm_in_mill(), pp_next_match(), ps_move(), and ttt_next_match().

17 {
18  v_x = pos_x + v_x * mySize_x;
19  v_y = pos_y + v_y * mySize_y;
20  return v;
21 }
vector v
Definition: ent_cs.qc:116
+ Here is the caller graph for this function:

◆ minigame_hud_denormalize_size()

vector minigame_hud_denormalize_size ( vector  v,
vector  pos,
vector  mySize 
)

Definition at line 23 of file cl_minigames.qc.

References v.

Referenced by bd_close_editor(), c4_move(), nmm_in_mill(), pp_next_match(), ps_move(), and ttt_next_match().

24 {
25  v_x = v_x * mySize_x;
26  v_y = v_y * mySize_y;
27  return v;
28 }
vector v
Definition: ent_cs.qc:116
+ Here is the caller graph for this function:

◆ minigame_hud_mouse_in()

bool minigame_hud_mouse_in ( vector  pos,
vector  sz 
)

Definition at line 39 of file cl_minigames.qc.

40 {
41  return mousepos_x >= pos_x && mousepos_x < pos_x + sz_x &&
42  mousepos_y >= pos_y && mousepos_y < pos_y + sz_y ;
43 }

◆ minigame_hud_normalize()

vector minigame_hud_normalize ( vector  v,
vector  pos,
vector  mySize 
)

Definition at line 31 of file cl_minigames.qc.

References v.

32 {
33  v_x = ( v_x - pos_x ) / mySize_x;
34  v_y = ( v_y - pos_y ) / mySize_y;
35  return v;
36 }
vector v
Definition: ent_cs.qc:116

◆ minigame_hud_simpleboard()

void minigame_hud_simpleboard ( vector  pos,
vector  mySize,
string  board_texture 
)

Definition at line 4 of file cl_minigames.qc.

References BORDER_MULTIPLIER, draw_BorderPicture(), DRAWFLAG_NORMAL, drawpic(), panel, panel_bg_alpha, panel_bg_border, and panel_bg_color.

Referenced by bd_close_editor(), c4_move(), nmm_in_mill(), pp_next_match(), ps_move(), and ttt_next_match().

5 {
6  if(panel.current_panel_bg != "0" && panel.current_panel_bg != "")
7  draw_BorderPicture(pos - '1 1 0' * panel_bg_border,
8  panel.current_panel_bg,
9  mySize + '1 1 0' * 2 * panel_bg_border,
12  drawpic(pos, board_texture, mySize, '1 1 1', panel_bg_alpha, DRAWFLAG_NORMAL);
13 }
float panel_bg_border
Definition: hud.qh:169
const float BORDER_MULTIPLIER
Definition: hud.qh:109
float panel_bg_alpha
Definition: hud.qh:167
const float DRAWFLAG_NORMAL
Definition: csprogsdefs.qc:317
entity panel
Definition: hud.qh:144
vector panel_bg_color
Definition: hud.qh:162
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ minigame_prompt()

void minigame_prompt ( )

Definition at line 374 of file cl_minigames.qc.

References active_minigame, HUD_MinigameMenu_IsOpened(), and HUD_Notify_Push().

375 {
377  {
378  HUD_Notify_Push(sprintf("minigames/%s/icon_notif",active_minigame.descriptor.netname),
379  _("It's your turn"), "");
380  }
381 }
bool HUD_MinigameMenu_IsOpened()
entity active_minigame
Definition: cl_minigames.qh:85
void HUD_Notify_Push(string icon, string attacker, string victim)
Definition: notify.qc:19
+ Here is the call graph for this function:

◆ minigame_texture()

string minigame_texture ( string  name)

Definition at line 49 of file cl_minigames.qc.

References autocvar_menu_skin, minigame_texture_skin(), and precache_pic().

Referenced by bd_close_editor(), c4_move(), HUD_MinigameMenu_ClickCreate(), HUD_MinigameMenu_ClickJoin(), nmm_in_mill(), pp_next_match(), ps_move(), and ttt_next_match().

50 {
52  if ( precache_pic(path) == "" )
53  path = minigame_texture_skin("default", name);
54  return path;
55 }
string minigame_texture_skin(string skinname, string name)
Definition: cl_minigames.qc:45
string autocvar_menu_skin
Definition: mapvoting.qh:7
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ void()

void ( vector  pos,
vector  size 
)

Variable Documentation

◆ active_minigame

◆ minigame_playerslot

float minigame_playerslot

◆ minigame_self