]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/client/miscfunctions.qh
Makefile: use `-I.`
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / miscfunctions.qh
1 #ifndef CLIENT_MISCFUNCTIONS_H
2 #define CLIENT_MISCFUNCTIONS_H
3
4 entity players;
5 entity teams;
6 float team_count; // real teams
7
8 const int INITPRIO_FIRST                                = 0;
9 const int INITPRIO_GAMETYPE                     = 0;
10 const int INITPRIO_GAMETYPE_FALLBACK    = 1;
11 const int INITPRIO_FINDTARGET                   = 10;
12 const int INITPRIO_DROPTOFLOOR                  = 20;
13 const int INITPRIO_SETLOCATION                  = 90;
14 const int INITPRIO_LINKDOORS                    = 91;
15 const int INITPRIO_LAST                                 = 99;
16
17 void AuditLists();
18
19 float RegisterPlayer(entity player);
20
21 void RemovePlayer(entity player);
22
23 void MoveToLast(entity e);
24
25 float RegisterTeam(entity Team);
26
27 void RemoveTeam(entity Team);
28
29 entity GetTeam(int Team, bool add);
30
31 vector HUD_GetFontsize(string cvarname);
32
33 float PreviewExists(string name);
34
35 vector rotate(vector v, float a);
36
37
38 // decolorizes and team colors the player name when needed
39 string playername(string thename, float teamid);
40
41 float cvar_or(string cv, float v);
42
43 vector project_3d_to_2d(vector vec);
44
45 #define draw_beginBoldFont()    MACRO_BEGIN { drawfont = FONT_USER + 2; } MACRO_END
46 #define draw_endBoldFont()      MACRO_BEGIN { drawfont = FONT_USER + 1; } MACRO_END
47
48 float expandingbox_sizefactor_from_fadelerp(float fadelerp);
49
50 vector expandingbox_resize_centered_box_offset(float sz, vector boxsize, float boxxsizefactor);
51
52 void drawborderlines(float thickness, vector pos, vector dim, vector color, float theAlpha, float drawflag);
53
54 void drawpic_tiled(vector pos, string pic, vector sz, vector area, vector color, float theAlpha, float drawflag);
55
56 // drawpic wrapper to draw an image as large as possible with preserved aspect ratio into a box
57 float _drawpic_imgaspect;
58 vector _drawpic_imgsize;
59 vector _drawpic_sz;
60 float _drawpic_oldsz;
61 string _drawpic_picpath;
62 #define drawpic_aspect(pos,pic,mySize,color,theAlpha,drawflag)\
63         MACRO_BEGIN {\
64                 _drawpic_imgsize = draw_getimagesize(pic);\
65                 if(_drawpic_imgsize != '0 0 0') {\
66                         _drawpic_imgaspect = _drawpic_imgsize.x/_drawpic_imgsize.y;\
67                         _drawpic_sz = mySize;\
68                         if(_drawpic_sz.x/_drawpic_sz.y > _drawpic_imgaspect) {\
69                                 _drawpic_oldsz = _drawpic_sz.x;\
70                                 _drawpic_sz.x = _drawpic_sz.y * _drawpic_imgaspect;\
71                                 if(_drawpic_sz.x)\
72                                         drawpic(pos + eX * (_drawpic_oldsz - _drawpic_sz.x) * 0.5, pic, _drawpic_sz, color, theAlpha, drawflag);\
73                         } else {\
74                                 _drawpic_oldsz = _drawpic_sz.y;\
75                                 _drawpic_sz.y = _drawpic_sz.x / _drawpic_imgaspect;\
76                                 if(_drawpic_sz.y)\
77                                         drawpic(pos + eY * (_drawpic_oldsz - _drawpic_sz.y) * 0.5, pic, _drawpic_sz, color, theAlpha, drawflag);\
78                         }\
79                 }\
80         } MACRO_END
81
82 // draw HUD element with image from gfx/hud/hud_skin/foo.tga if it exists, otherwise gfx/hud/default/foo.tga
83 #define drawpic_aspect_skin(pos,pic,sz,color,theAlpha,drawflag)\
84         MACRO_BEGIN {\
85                 _drawpic_picpath = strcat(hud_skin_path, "/", pic);\
86                 if(precache_pic(_drawpic_picpath) == "") {\
87                         _drawpic_picpath = strcat("gfx/hud/default/", pic);\
88                 }\
89                 drawpic_aspect(pos, _drawpic_picpath, sz, color, theAlpha, drawflag);\
90                 _drawpic_picpath = string_null;\
91         } MACRO_END
92
93 // draw HUD element with image from gfx/hud/hud_skin/foo.tga if it exists, otherwise gfx/hud/default/foo.tga
94 #define drawpic_skin(pos,pic,sz,color,theAlpha,drawflag)\
95         MACRO_BEGIN {\
96                 _drawpic_picpath = strcat(hud_skin_path, "/", pic);\
97                 if(precache_pic(_drawpic_picpath) == "") {\
98                         _drawpic_picpath = strcat("gfx/hud/default/", pic);\
99                 }\
100                 drawpic(pos, _drawpic_picpath, sz, color, theAlpha, drawflag);\
101                 _drawpic_picpath = string_null;\
102         } MACRO_END
103
104 void drawpic_aspect_skin_expanding(vector position, string pic, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp);
105
106 void drawpic_aspect_skin_expanding_two(vector position, string pic, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp);
107
108 #define SET_POS_AND_SZ_Y_ASPECT(allow_colors) MACRO_BEGIN {                                                                                                                     \
109         float textaspect, oldsz;                                                                                                                                                                                \
110         textaspect = stringwidth(text, allow_colors, '1 1 1' * sz.y) / sz.y;                                                                                    \
111         if(sz.x/sz.y > textaspect) {                                                                                                                                                                    \
112                 oldsz = sz.x;                                                                                                                                                                                           \
113                 sz.x = sz.y * textaspect;                                                                                                                                                                       \
114                 pos.x += (oldsz - sz.x) * 0.5;                                                                                                                                                          \
115         } else {                                                                                                                                                                                                                \
116                 oldsz = sz.y;                                                                                                                                                                                           \
117                 sz.y = sz.x / textaspect;                                                                                                                                                                       \
118                 pos.y += (oldsz - sz.y) * 0.5;                                                                                                                                                          \
119         }                                                                                                                                                                                                                               \
120 } MACRO_END
121
122 // drawstring wrapper to draw a string as large as possible with preserved aspect ratio into a box
123 void drawstring_aspect(vector pos, string text, vector sz, vector color, float theAlpha, float drawflag);
124
125 // drawstring wrapper to draw a colorcodedstring as large as possible with preserved aspect ratio into a box
126 void drawcolorcodedstring_aspect(vector pos, string text, vector sz, float theAlpha, float drawflag);
127
128 vector drawfontscale;
129 void drawstring_expanding(vector position, string text, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp);
130
131 // drawstring wrapper to draw a string as large as possible with preserved aspect ratio into a box
132 void drawstring_aspect_expanding(vector pos, string text, vector sz, vector color, float theAlpha, float drawflag, float fadelerp);
133
134 void drawcolorcodedstring_expanding(vector position, string text, vector theScale, float theAlpha, float flag, float fadelerp);
135
136 void drawcolorcodedstring_aspect_expanding(vector pos, string text, vector sz, float theAlpha, float drawflag, float fadelerp);
137
138 // this draws the triangles of a model DIRECTLY. Don't expect high performance, really...
139 float PolyDrawModelSurface(entity e, float i_s);
140 void PolyDrawModel(entity e);
141
142 void DrawCircleClippedPic(vector centre, float radi, string pic, float f, vector rgb, float a, float drawflag);
143
144 const int MAX_ACCURACY_LEVELS = 10;
145 float acc_lev[MAX_ACCURACY_LEVELS];
146 vector acc_col[MAX_ACCURACY_LEVELS];
147 float acc_col_loadtime;
148 int acc_levels;
149 string acc_color_levels;
150 void Accuracy_LoadLevels();
151
152 void Accuracy_LoadColors();
153
154 vector Accuracy_GetColor(float accuracy);
155
156 #endif