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