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