1 #ifndef MISCFUNCTIONS_H
2 #define MISCFUNCTIONS_H
6 float team_count; // real teams
10 float RegisterPlayer(entity player);
12 void RemovePlayer(entity player);
14 void MoveToLast(entity e);
16 float RegisterTeam(entity Team);
18 void RemoveTeam(entity Team);
20 entity GetTeam(int Team, bool add);
22 vector HUD_GetFontsize(string cvarname);
24 float PreviewExists(string name);
26 vector rotate(vector v, float a);
28 int ColorTranslateMode;
30 string ColorTranslateRGB(string s);
32 // decolorizes and team colors the player name when needed
33 string playername(string thename, float teamid);
35 float cvar_or(string cv, float v);
37 vector project_3d_to_2d(vector vec);
39 void dummyfunction(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8);
41 float expandingbox_sizefactor_from_fadelerp(float fadelerp);
43 vector expandingbox_resize_centered_box_offset(float sz, vector boxsize, float boxxsizefactor);
45 void drawborderlines(float thickness, vector pos, vector dim, vector color, float theAlpha, float drawflag);
47 void drawpic_tiled(vector pos, string pic, vector sz, vector area, vector color, float theAlpha, float drawflag);
49 void defer(float fdelay, void() func);
51 void defer_clear(entity ent);
53 // drawpic wrapper to draw an image as large as possible with preserved aspect ratio into a box
54 float _drawpic_imgaspect;
55 vector _drawpic_imgsize;
58 string _drawpic_picpath;
59 #define drawpic_aspect(pos,pic,mySize,color,theAlpha,drawflag)\
61 _drawpic_imgsize = draw_getimagesize(pic);\
62 if(_drawpic_imgsize != '0 0 0') {\
63 _drawpic_imgaspect = _drawpic_imgsize.x/_drawpic_imgsize.y;\
64 _drawpic_sz = mySize;\
65 if(_drawpic_sz.x/_drawpic_sz.y > _drawpic_imgaspect) {\
66 _drawpic_oldsz = _drawpic_sz.x;\
67 _drawpic_sz.x = _drawpic_sz.y * _drawpic_imgaspect;\
69 drawpic(pos + eX * (_drawpic_oldsz - _drawpic_sz.x) * 0.5, pic, _drawpic_sz, color, theAlpha, drawflag);\
71 _drawpic_oldsz = _drawpic_sz.y;\
72 _drawpic_sz.y = _drawpic_sz.x / _drawpic_imgaspect;\
74 drawpic(pos + eY * (_drawpic_oldsz - _drawpic_sz.y) * 0.5, pic, _drawpic_sz, color, theAlpha, drawflag);\
79 // draw HUD element with image from gfx/hud/hud_skin/foo.tga if it exists, otherwise gfx/hud/default/foo.tga
80 #define drawpic_aspect_skin(pos,pic,sz,color,theAlpha,drawflag)\
82 _drawpic_picpath = strcat(hud_skin_path, "/", pic);\
83 if(precache_pic(_drawpic_picpath) == "") {\
84 _drawpic_picpath = strcat("gfx/hud/default/", pic);\
86 drawpic_aspect(pos, _drawpic_picpath, sz, color, theAlpha, drawflag);\
87 _drawpic_picpath = string_null;\
90 // draw HUD element with image from gfx/hud/hud_skin/foo.tga if it exists, otherwise gfx/hud/default/foo.tga
91 #define drawpic_skin(pos,pic,sz,color,theAlpha,drawflag)\
93 _drawpic_picpath = strcat(hud_skin_path, "/", pic);\
94 if(precache_pic(_drawpic_picpath) == "") {\
95 _drawpic_picpath = strcat("gfx/hud/default/", pic);\
97 drawpic(pos, _drawpic_picpath, sz, color, theAlpha, drawflag);\
98 _drawpic_picpath = string_null;\
101 void drawpic_aspect_skin_expanding(vector position, string pic, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp);
103 void drawpic_aspect_skin_expanding_two(vector position, string pic, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp);
105 #define SET_POS_AND_SZ_Y_ASPECT(allow_colors) do { \
106 float textaspect, oldsz; \
107 textaspect = stringwidth(text, allow_colors, '1 1 1' * sz.y) / sz.y; \
108 if(sz.x/sz.y > textaspect) { \
110 sz.x = sz.y * textaspect; \
111 pos.x += (oldsz - sz.x) * 0.5; \
114 sz.y = sz.x / textaspect; \
115 pos.y += (oldsz - sz.y) * 0.5; \
119 // drawstring wrapper to draw a string as large as possible with preserved aspect ratio into a box
120 void drawstring_aspect(vector pos, string text, vector sz, vector color, float theAlpha, float drawflag);
122 // drawstring wrapper to draw a colorcodedstring as large as possible with preserved aspect ratio into a box
123 void drawcolorcodedstring_aspect(vector pos, string text, vector sz, float theAlpha, float drawflag);
125 vector drawfontscale;
126 void drawstring_expanding(vector position, string text, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp);
128 // drawstring wrapper to draw a string as large as possible with preserved aspect ratio into a box
129 void drawstring_aspect_expanding(vector pos, string text, vector sz, vector color, float theAlpha, float drawflag, float fadelerp);
131 void drawcolorcodedstring_expanding(vector position, string text, vector theScale, float theAlpha, float flag, float fadelerp);
133 void drawcolorcodedstring_aspect_expanding(vector pos, string text, vector sz, float theAlpha, float drawflag, float fadelerp);
135 // this draws the triangles of a model DIRECTLY. Don't expect high performance, really...
136 float PolyDrawModelSurface(entity e, float i_s);
137 void PolyDrawModel(entity e);
139 void DrawCircleClippedPic(vector centre, float radius, string pic, float f, vector rgb, float a, float drawflag);
141 const vector GETPLAYERORIGIN_ERROR = '1123581321 2357111317 3141592653'; // way out of bounds for anything on the map
142 vector getplayerorigin(int pl);
144 float getplayeralpha(float pl);
146 vector getcsqcplayercolor(float pl);
148 float getplayerisdead(float pl);
150 void URI_Get_Callback(int id, float status, string data);
152 void draw_beginBoldFont();
154 void draw_endBoldFont();
157 const int MAX_ACCURACY_LEVELS = 10;
158 float acc_lev[MAX_ACCURACY_LEVELS];
159 vector acc_col[MAX_ACCURACY_LEVELS];
160 float acc_col_loadtime;
162 string acc_color_levels;
163 void Accuracy_LoadLevels();
165 void Accuracy_LoadColors();
167 vector Accuracy_GetColor(float accuracy);