]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/client/miscfunctions.qh
b223d88b9ee1408f755ad627acf9c6aeff6558a6
[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 string ColorTranslateRGB(string s);
39
40 // decolorizes and team colors the player name when needed
41 string playername(string thename, float teamid);
42
43 float cvar_or(string cv, float v);
44
45 vector project_3d_to_2d(vector vec);
46
47 void dummyfunction(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8);
48
49 float expandingbox_sizefactor_from_fadelerp(float fadelerp);
50
51 vector expandingbox_resize_centered_box_offset(float sz, vector boxsize, float boxxsizefactor);
52
53 void drawborderlines(float thickness, vector pos, vector dim, vector color, float theAlpha, float drawflag);
54
55 void drawpic_tiled(vector pos, string pic, vector sz, vector area, vector color, float theAlpha, float drawflag);
56
57 // drawpic wrapper to draw an image as large as possible with preserved aspect ratio into a box
58 float _drawpic_imgaspect;
59 vector _drawpic_imgsize;
60 vector _drawpic_sz;
61 float _drawpic_oldsz;
62 string _drawpic_picpath;
63 #define drawpic_aspect(pos,pic,mySize,color,theAlpha,drawflag)\
64         do {\
65                 _drawpic_imgsize = draw_getimagesize(pic);\
66                 if(_drawpic_imgsize != '0 0 0') {\
67                         _drawpic_imgaspect = _drawpic_imgsize.x/_drawpic_imgsize.y;\
68                         _drawpic_sz = mySize;\
69                         if(_drawpic_sz.x/_drawpic_sz.y > _drawpic_imgaspect) {\
70                                 _drawpic_oldsz = _drawpic_sz.x;\
71                                 _drawpic_sz.x = _drawpic_sz.y * _drawpic_imgaspect;\
72                                 if(_drawpic_sz.x)\
73                                         drawpic(pos + eX * (_drawpic_oldsz - _drawpic_sz.x) * 0.5, pic, _drawpic_sz, color, theAlpha, drawflag);\
74                         } else {\
75                                 _drawpic_oldsz = _drawpic_sz.y;\
76                                 _drawpic_sz.y = _drawpic_sz.x / _drawpic_imgaspect;\
77                                 if(_drawpic_sz.y)\
78                                         drawpic(pos + eY * (_drawpic_oldsz - _drawpic_sz.y) * 0.5, pic, _drawpic_sz, color, theAlpha, drawflag);\
79                         }\
80                 }\
81         } while(0)
82
83 // draw HUD element with image from gfx/hud/hud_skin/foo.tga if it exists, otherwise gfx/hud/default/foo.tga
84 #define drawpic_aspect_skin(pos,pic,sz,color,theAlpha,drawflag)\
85         do{\
86                 _drawpic_picpath = strcat(hud_skin_path, "/", pic);\
87                 if(precache_pic(_drawpic_picpath) == "") {\
88                         _drawpic_picpath = strcat("gfx/hud/default/", pic);\
89                 }\
90                 drawpic_aspect(pos, _drawpic_picpath, sz, color, theAlpha, drawflag);\
91                 _drawpic_picpath = string_null;\
92         } while(0)
93
94 // draw HUD element with image from gfx/hud/hud_skin/foo.tga if it exists, otherwise gfx/hud/default/foo.tga
95 #define drawpic_skin(pos,pic,sz,color,theAlpha,drawflag)\
96         do{\
97                 _drawpic_picpath = strcat(hud_skin_path, "/", pic);\
98                 if(precache_pic(_drawpic_picpath) == "") {\
99                         _drawpic_picpath = strcat("gfx/hud/default/", pic);\
100                 }\
101                 drawpic(pos, _drawpic_picpath, sz, color, theAlpha, drawflag);\
102                 _drawpic_picpath = string_null;\
103         } while(0)
104
105 void drawpic_aspect_skin_expanding(vector position, string pic, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp);
106
107 void drawpic_aspect_skin_expanding_two(vector position, string pic, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp);
108
109 #define SET_POS_AND_SZ_Y_ASPECT(allow_colors) do {                                                                                                                                      \
110         float textaspect, oldsz;                                                                                                                                                                                \
111         textaspect = stringwidth(text, allow_colors, '1 1 1' * sz.y) / sz.y;                                                                                    \
112         if(sz.x/sz.y > textaspect) {                                                                                                                                                                    \
113                 oldsz = sz.x;                                                                                                                                                                                           \
114                 sz.x = sz.y * textaspect;                                                                                                                                                                       \
115                 pos.x += (oldsz - sz.x) * 0.5;                                                                                                                                                          \
116         } else {                                                                                                                                                                                                                \
117                 oldsz = sz.y;                                                                                                                                                                                           \
118                 sz.y = sz.x / textaspect;                                                                                                                                                                       \
119                 pos.y += (oldsz - sz.y) * 0.5;                                                                                                                                                          \
120         }                                                                                                                                                                                                                               \
121 } while(0)
122
123 // drawstring wrapper to draw a string as large as possible with preserved aspect ratio into a box
124 void drawstring_aspect(vector pos, string text, vector sz, vector color, float theAlpha, float drawflag);
125
126 // drawstring wrapper to draw a colorcodedstring as large as possible with preserved aspect ratio into a box
127 void drawcolorcodedstring_aspect(vector pos, string text, vector sz, float theAlpha, float drawflag);
128
129 vector drawfontscale;
130 void drawstring_expanding(vector position, string text, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp);
131
132 // drawstring wrapper to draw a string as large as possible with preserved aspect ratio into a box
133 void drawstring_aspect_expanding(vector pos, string text, vector sz, vector color, float theAlpha, float drawflag, float fadelerp);
134
135 void drawcolorcodedstring_expanding(vector position, string text, vector theScale, float theAlpha, float flag, float fadelerp);
136
137 void drawcolorcodedstring_aspect_expanding(vector pos, string text, vector sz, float theAlpha, float drawflag, float fadelerp);
138
139 // this draws the triangles of a model DIRECTLY. Don't expect high performance, really...
140 float PolyDrawModelSurface(entity e, float i_s);
141 void PolyDrawModel(entity e);
142
143 void DrawCircleClippedPic(vector centre, float radi, string pic, float f, vector rgb, float a, float drawflag);
144
145 const vector GETPLAYERORIGIN_ERROR = '1123581321 2357111317 3141592653'; // way out of bounds for anything on the map
146 vector getplayerorigin(int pl);
147
148 float getplayeralpha(float pl);
149
150 vector getcsqcplayercolor(float pl);
151
152 float getplayerisdead(float pl);
153
154 void URI_Get_Callback(int id, float status, string data);
155
156 void draw_beginBoldFont();
157
158 void draw_endBoldFont();
159
160
161 const int MAX_ACCURACY_LEVELS = 10;
162 float acc_lev[MAX_ACCURACY_LEVELS];
163 vector acc_col[MAX_ACCURACY_LEVELS];
164 float acc_col_loadtime;
165 int acc_levels;
166 string acc_color_levels;
167 void Accuracy_LoadLevels();
168
169 void Accuracy_LoadColors();
170
171 vector Accuracy_GetColor(float accuracy);
172
173 #endif