5 float team_count; // real teams
7 const int INITPRIO_FIRST = 0;
8 const int INITPRIO_GAMETYPE = 0;
9 const int INITPRIO_GAMETYPE_FALLBACK = 1;
10 const int INITPRIO_FINDTARGET = 10;
11 const int INITPRIO_DROPTOFLOOR = 20;
12 const int INITPRIO_SETLOCATION = 90;
13 const int INITPRIO_LINKDOORS = 91;
14 const int INITPRIO_LAST = 99;
18 float RegisterPlayer(entity player);
20 void RemovePlayer(entity player);
22 void MoveToLast(entity e);
24 float RegisterTeam(entity Team);
26 void RemoveTeam(entity Team);
28 entity GetTeam(int Team, bool add);
30 vector HUD_GetFontsize(string cvarname);
32 float PreviewExists(string name);
34 vector Rotate(vector v, float a);
37 #define IS_DEAD(s) (((s).classname == "csqcmodel") ? (s).csqcmodel_isdead : (GetResource((s), RES_HEALTH) <= 0))
40 // decolorizes and team colors the player name when needed
41 string playername(string thename, float teamid);
43 float cvar_or(string cv, float v);
45 vector project_3d_to_2d(vector vec);
48 #define draw_beginBoldFont() drawfont = FONT_USER + 2
49 #define draw_endBoldFont() drawfont = FONT_USER + 1
51 float expandingbox_sizefactor_from_fadelerp(float fadelerp);
53 vector expandingbox_resize_centered_box_offset(float sz, vector boxsize, float boxxsizefactor);
55 float blink(float base, float range, float freq);
57 void drawborderlines(float thickness, vector pos, vector dim, vector color, float theAlpha, float drawflag);
59 void drawpic_tiled(vector pos, string pic, vector sz, vector area, vector color, float theAlpha, float drawflag);
61 void HUD_Scale_Disable();
62 void HUD_Scale_Enable();
64 #define HUD_ScaleX(f) (f * hud_scale.x)
65 #define HUD_ScaleY(f) (f * hud_scale.y)
66 #define HUD_ShiftX(f) (f + hud_shift.x + hud_shift.z * (f - hud_scale_center.x))
67 #define HUD_ShiftY(f) (f + hud_shift.y + hud_shift.z * (f - hud_scale_center.y))
68 vector HUD_Scale(vector v);
69 vector HUD_Shift(vector v);
71 // The following functions / macros must be called from within
72 // the panel HUD / scoreboard code so that pos and size are scaled
73 // when the hud_dynamic code is running.
74 // Make use of stringwidth_builtin and draw*_builtin everywhere else.
76 float stringwidth(string text, float handleColors, vector sz);
78 #define drawpic(position, pic, size, rgb, alpha, flag) \
79 drawpic_builtin(HUD_Shift(position), pic, HUD_Scale(size), rgb, alpha, flag)
81 #define drawcharacter(position, character, scale, rgb, alpha, flag) \
82 drawcharacter_builtin(HUD_Shift(position), text, scale, rgb, alpha, flag)
84 #define drawstring(position, text, scale, rgb, alpha, flag) \
85 drawstring_builtin(HUD_Shift(position), text, scale, rgb, alpha, flag)
87 #define drawcolorcodedstring(position, text, scale, alpha, flag) \
88 drawcolorcodedstring_builtin(HUD_Shift(position), text, scale, alpha, flag)
90 #define drawcolorcodedstring2(position, text, scale, rgb, alpha, flag) \
91 drawcolorcodedstring2_builtin(HUD_Shift(position), text, scale, rgb, alpha, flag)
93 #define drawfill(position, size, rgb, alpha, flag) \
94 drawfill_builtin(HUD_Shift(position), HUD_Scale(size), rgb, alpha, flag)
96 #define drawsetcliparea(xposition, yposition, w, h) \
97 drawsetcliparea_builtin(HUD_ShiftX(xposition), HUD_ShiftY(yposition), HUD_ScaleX(w), HUD_ScaleY(h))
99 // Since drawsubpic usually gets called multiple times from within an
100 // utility function, instead of scaling pos and size in every call
101 // we scale them once for all in the beginning of that utility function.
102 // That's why drawsubpic isn't remapped.
104 #define drawsubpic(position, size, pic, srcPosition, srcSize, rgb, alpha, flag) \
105 drawsubpic_builtin(HUD_Shift(position), HUD_Scale(size), pic, HUD_Shift(srcPosition), HUD_Scale(srcSize), rgb, alpha, flag)
108 // drawpic wrapper to draw an image as large as possible with preserved aspect ratio into a box
109 float _drawpic_imgaspect;
110 vector _drawpic_imgsize;
112 float _drawpic_oldsz;
113 string _drawpic_picpath;
114 #define drawpic_aspect(pos,pic,mySize,color,theAlpha,drawflag)\
116 _drawpic_imgsize = draw_getimagesize(pic);\
117 if(_drawpic_imgsize != '0 0 0') {\
118 _drawpic_imgaspect = _drawpic_imgsize.x/_drawpic_imgsize.y;\
119 _drawpic_sz = mySize;\
120 if(_drawpic_sz.x/_drawpic_sz.y > _drawpic_imgaspect) {\
121 _drawpic_oldsz = _drawpic_sz.x;\
122 _drawpic_sz.x = _drawpic_sz.y * _drawpic_imgaspect;\
124 drawpic(pos + eX * 0.5 * (_drawpic_oldsz - _drawpic_sz.x), pic, _drawpic_sz, color, theAlpha, drawflag);\
126 _drawpic_oldsz = _drawpic_sz.y;\
127 _drawpic_sz.y = _drawpic_sz.x / _drawpic_imgaspect;\
129 drawpic(pos + eY * 0.5 * (_drawpic_oldsz - _drawpic_sz.y), pic, _drawpic_sz, color, theAlpha, drawflag);\
134 // draw HUD element with image from gfx/hud/hud_skin/foo.tga if it exists, otherwise gfx/hud/default/foo.tga
135 #define drawpic_aspect_skin(pos,pic,sz,color,theAlpha,drawflag)\
137 _drawpic_picpath = strcat(hud_skin_path, "/", pic);\
138 if(precache_pic(_drawpic_picpath) == "") {\
139 _drawpic_picpath = strcat("gfx/hud/default/", pic);\
141 drawpic_aspect(pos, _drawpic_picpath, sz, color, theAlpha, drawflag);\
142 _drawpic_picpath = string_null;\
145 // draw HUD element with image from gfx/hud/hud_skin/foo.tga if it exists, otherwise gfx/hud/default/foo.tga
146 #define drawpic_skin(pos,pic,sz,color,theAlpha,drawflag)\
148 _drawpic_picpath = strcat(hud_skin_path, "/", pic);\
149 if(precache_pic(_drawpic_picpath) == "") {\
150 _drawpic_picpath = strcat("gfx/hud/default/", pic);\
152 drawpic(pos, _drawpic_picpath, sz, color, theAlpha, drawflag);\
153 _drawpic_picpath = string_null;\
156 void drawpic_aspect_skin_expanding(vector position, string pic, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp);
158 void drawpic_aspect_skin_expanding_two(vector position, string pic, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp);
160 #define SET_POS_AND_SZ_Y_ASPECT(allow_colors) MACRO_BEGIN \
161 float textaspect, oldsz; \
162 vector dfs = drawfontscale; \
163 drawfontscale = '1 1 0'; \
164 textaspect = stringwidth(text, allow_colors, '1 1 1' * sz.y) / sz.y; \
165 drawfontscale = dfs; \
166 if(sz.x/sz.y > textaspect) { \
168 sz.x = sz.y * textaspect; \
169 pos.x += (oldsz - sz.x) * 0.5; \
172 sz.y = sz.x / textaspect; \
173 pos.y += (oldsz - sz.y) * 0.5; \
177 // drawstring wrapper to draw a string as large as possible with preserved aspect ratio into a box
178 void drawstring_aspect(vector pos, string text, vector sz, vector color, float theAlpha, float drawflag);
180 // drawstring wrapper to draw a colorcodedstring as large as possible with preserved aspect ratio into a box
181 void drawcolorcodedstring_aspect(vector pos, string text, vector sz, float theAlpha, float drawflag);
183 void drawstring_expanding(vector position, string text, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp);
185 // drawstring wrapper to draw a string as large as possible with preserved aspect ratio into a box
186 void drawstring_aspect_expanding(vector pos, string text, vector sz, vector color, float theAlpha, float drawflag, float fadelerp);
188 void drawcolorcodedstring_expanding(vector position, string text, vector theScale, float theAlpha, float flag, float fadelerp);
190 void drawcolorcodedstring_aspect_expanding(vector pos, string text, vector sz, float theAlpha, float drawflag, float fadelerp);
192 void update_mousepos();
194 // this draws the triangles of a model DIRECTLY. Don't expect high performance, really...
195 float PolyDrawModelSurface(entity e, float i_s);
196 void PolyDrawModel(entity e);
198 void DrawCircleClippedPic(vector centre, float radi, string pic, float f, vector rgb, float a, float drawflag);
200 const int MAX_ACCURACY_LEVELS = 10;
201 float acc_lev[MAX_ACCURACY_LEVELS];
202 vector acc_col[MAX_ACCURACY_LEVELS];
203 float acc_col_loadtime;
205 string acc_color_levels;
206 void Accuracy_LoadLevels();
208 void Accuracy_LoadColors();
210 vector Accuracy_GetColor(float accuracy);