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 // 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;
54 string _drawpic_picpath;
55 #define drawpic_aspect(pos,pic,mySize,color,theAlpha,drawflag)\
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;\
65 drawpic(pos + eX * (_drawpic_oldsz - _drawpic_sz.x) * 0.5, pic, _drawpic_sz, color, theAlpha, drawflag);\
67 _drawpic_oldsz = _drawpic_sz.y;\
68 _drawpic_sz.y = _drawpic_sz.x / _drawpic_imgaspect;\
70 drawpic(pos + eY * (_drawpic_oldsz - _drawpic_sz.y) * 0.5, pic, _drawpic_sz, color, theAlpha, drawflag);\
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)\
78 _drawpic_picpath = strcat(hud_skin_path, "/", pic);\
79 if(precache_pic(_drawpic_picpath) == "") {\
80 _drawpic_picpath = strcat("gfx/hud/default/", pic);\
82 drawpic_aspect(pos, _drawpic_picpath, sz, color, theAlpha, drawflag);\
83 _drawpic_picpath = string_null;\
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)\
89 _drawpic_picpath = strcat(hud_skin_path, "/", pic);\
90 if(precache_pic(_drawpic_picpath) == "") {\
91 _drawpic_picpath = strcat("gfx/hud/default/", pic);\
93 drawpic(pos, _drawpic_picpath, sz, color, theAlpha, drawflag);\
94 _drawpic_picpath = string_null;\
97 void drawpic_aspect_skin_expanding(vector position, string pic, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp);
99 void drawpic_aspect_skin_expanding_two(vector position, string pic, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp);
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) { \
106 sz.x = sz.y * textaspect; \
107 pos.x += (oldsz - sz.x) * 0.5; \
110 sz.y = sz.x / textaspect; \
111 pos.y += (oldsz - sz.y) * 0.5; \
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);
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);
121 vector drawfontscale;
122 void drawstring_expanding(vector position, string text, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp);
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);
127 void drawcolorcodedstring_expanding(vector position, string text, vector theScale, float theAlpha, float flag, float fadelerp);
129 void drawcolorcodedstring_aspect_expanding(vector pos, string text, vector sz, float theAlpha, float drawflag, float fadelerp);
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);
135 void DrawCircleClippedPic(vector centre, float radius, string pic, float f, vector rgb, float a, float drawflag);
137 const vector GETPLAYERORIGIN_ERROR = '1123581321 2357111317 3141592653'; // way out of bounds for anything on the map
138 vector getplayerorigin(int pl);
140 float getplayeralpha(float pl);
142 vector getcsqcplayercolor(float pl);
144 float getplayerisdead(float pl);
146 void URI_Get_Callback(int id, float status, string data);
148 void draw_beginBoldFont();
150 void draw_endBoldFont();
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;
158 string acc_color_levels;
159 void Accuracy_LoadLevels();
161 void Accuracy_LoadColors();
163 vector Accuracy_GetColor(float accuracy);