Xonotic
cl_clanarena.qc File Reference
#include "cl_clanarena.qh"
#include <client/draw.qh>
#include <common/mutators/base.qh>
+ Include dependency graph for cl_clanarena.qc:

Go to the source code of this file.

Functions

void DrawCAItem (vector myPos, vector mySize, float aspect_ratio, int layout, int i)
 
void HUD_Mod_CA (vector myPos, vector mySize)
 
void HUD_Mod_CA_Draw (vector myPos, vector mySize, int layout)
 
void HUD_Mod_CA_Export (int fh)
 
 MUTATOR_HOOKFUNCTION (cl_ca, DrawInfoMessages)
 
 REGISTER_MUTATOR (cl_ca, true)
 

Function Documentation

◆ DrawCAItem()

void DrawCAItem ( vector  myPos,
vector  mySize,
float  aspect_ratio,
int  layout,
int  i 
)

Definition at line 19 of file cl_clanarena.qc.

References color, DRAWFLAG_NORMAL, drawpic_aspect_skin, drawstring_aspect(), eX, ftos(), panel_fg_alpha, TC, vec2, and vector().

Referenced by HUD_Mod_CA_Draw().

20 {
21  TC(int, layout); TC(int, i);
22  int stat = -1;
23  string pic = "";
24  vector color = '0 0 0';
25  switch(i)
26  {
27  case 0: stat = STAT(REDALIVE); pic = "player_red"; color = '1 0 0'; break;
28  case 1: stat = STAT(BLUEALIVE); pic = "player_blue"; color = '0 0 1'; break;
29  case 2: stat = STAT(YELLOWALIVE); pic = "player_yellow"; color = '1 1 0'; break;
30  default:
31  case 3: stat = STAT(PINKALIVE); pic = "player_pink"; color = '1 0 1'; break;
32  }
33 
34  if(mySize.x/mySize.y > aspect_ratio)
35  {
36  i = aspect_ratio * mySize.y;
37  myPos.x = myPos.x + (mySize.x - i) / 2;
38  mySize.x = i;
39  }
40  else
41  {
42  i = 1/aspect_ratio * mySize.x;
43  myPos.y = myPos.y + (mySize.y - i) / 2;
44  mySize.y = i;
45  }
46 
47  if(layout)
48  {
49  drawpic_aspect_skin(myPos, pic, vec2(0.5 * mySize.x, mySize.y), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
50  drawstring_aspect(myPos + eX * 0.5 * mySize.x, ftos(stat), vec2(0.5 * mySize.x, mySize.y), color, panel_fg_alpha, DRAWFLAG_NORMAL);
51  }
52  else
53  drawstring_aspect(myPos, ftos(stat), mySize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
54 }
vector color
float panel_fg_alpha
Definition: hud.qh:166
void drawstring_aspect(vector pos, string text, vector sz, vector color, float theAlpha, float drawflag)
Definition: draw.qc:102
#define drawpic_aspect_skin(pos, pic, sz, color, theAlpha, drawflag)
Definition: draw.qh:78
const float DRAWFLAG_NORMAL
Definition: csprogsdefs.qc:317
#define TC(T, sym)
Definition: _all.inc:82
vector(float skel, float bonenum) _skel_get_boneabs_hidden
const vector eX
Definition: vector.qh:44
#define vec2(...)
Definition: vector.qh:90
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HUD_Mod_CA()

void HUD_Mod_CA ( vector  myPos,
vector  mySize 
)

Definition at line 85 of file cl_clanarena.qc.

References autocvar_hud_panel_modicons_ca_layout, HUD_Mod_CA_Draw(), and mod_active.

86 {
87  mod_active = 1; // required in each mod function that always shows something
88 
90 }
bool mod_active
Definition: modicons.qh:7
void HUD_Mod_CA_Draw(vector myPos, vector mySize, int layout)
Definition: cl_clanarena.qc:56
int autocvar_hud_panel_modicons_ca_layout
Definition: cl_clanarena.qh:3
+ Here is the call graph for this function:

◆ HUD_Mod_CA_Draw()

void HUD_Mod_CA_Draw ( vector  myPos,
vector  mySize,
int  layout 
)

Definition at line 56 of file cl_clanarena.qc.

References ceil(), DrawCAItem(), HUD_GetRowCount(), team_count, vec2, and vector().

Referenced by HUD_Mod_CA(), and HUD_Mod_FreezeTag().

57 {
58  int rows, columns;
59  float aspect_ratio;
60  aspect_ratio = (layout) ? 2 : 1;
61  rows = HUD_GetRowCount(team_count, mySize, aspect_ratio);
62  columns = ceil(team_count/rows);
63 
64  int i;
65  float row = 0, column = 0;
66  vector pos = '0 0 0', itemSize;
67  itemSize = vec2(mySize.x / columns, mySize.y / rows);
68  for(i=0; i<team_count; ++i)
69  {
70  pos.x = myPos.x + column * itemSize.x;
71  pos.y = myPos.y + row * itemSize.y;
72 
73  DrawCAItem(pos, itemSize, aspect_ratio, layout, i);
74 
75  ++row;
76  if(row >= rows)
77  {
78  row = 0;
79  ++column;
80  }
81  }
82 }
float HUD_GetRowCount(int item_count, vector size, float item_aspect)
Definition: hud.qc:165
void DrawCAItem(vector myPos, vector mySize, float aspect_ratio, int layout, int i)
Definition: cl_clanarena.qc:19
vector(float skel, float bonenum) _skel_get_boneabs_hidden
float team_count
Definition: main.qh:45
#define vec2(...)
Definition: vector.qh:90
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HUD_Mod_CA_Export()

void HUD_Mod_CA_Export ( int  fh)

Definition at line 7 of file cl_clanarena.qc.

References HUD_Write_Cvar, and REGISTER_MUTATOR().

8 {
9  HUD_Write_Cvar("hud_panel_modicons_ca_layout");
10 }
#define HUD_Write_Cvar(cvar)
Definition: hud_config.qh:38
+ Here is the call graph for this function:

◆ MUTATOR_HOOKFUNCTION()

MUTATOR_HOOKFUNCTION ( cl_ca  ,
DrawInfoMessages   
)

Definition at line 14 of file cl_clanarena.qc.

References ISGAMETYPE, and player_localnum.

15 {
16  return (ISGAMETYPE(CA) && entcs_GetSpecState(player_localnum) == ENTCS_SPEC_IN_SCOREBOARD);
17 }
#define ISGAMETYPE(NAME)
Definition: main.qh:32
float player_localnum
Definition: csprogsdefs.qc:20

◆ REGISTER_MUTATOR()

REGISTER_MUTATOR ( cl_ca  ,
true   
)

Referenced by HUD_Mod_CA_Export().

+ Here is the caller graph for this function: