1 #ifndef MISCFUNCTIONS_H
2 #define MISCFUNCTIONS_H
6 float team_count; // real teams
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;
17 .void(void) initialize_entity;
18 .int initialize_entity_order;
19 .entity initialize_entity_next;
20 entity initialize_entity_first;
22 void InitializeEntity(entity e, void(void) func, int order);
24 void InitializeEntitiesRun();
28 float RegisterPlayer(entity player);
30 void RemovePlayer(entity player);
32 void MoveToLast(entity e);
34 float RegisterTeam(entity Team);
36 void RemoveTeam(entity Team);
38 entity GetTeam(int Team, bool add);
40 vector HUD_GetFontsize(string cvarname);
42 float PreviewExists(string name);
44 vector rotate(vector v, float a);
46 int ColorTranslateMode;
48 string ColorTranslateRGB(string s);
50 // decolorizes and team colors the player name when needed
51 string playername(string thename, float teamid);
53 float cvar_or(string cv, float v);
55 vector project_3d_to_2d(vector vec);
57 void dummyfunction(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8);
59 float expandingbox_sizefactor_from_fadelerp(float fadelerp);
61 vector expandingbox_resize_centered_box_offset(float sz, vector boxsize, float boxxsizefactor);
63 void drawborderlines(float thickness, vector pos, vector dim, vector color, float theAlpha, float drawflag);
65 void drawpic_tiled(vector pos, string pic, vector sz, vector area, vector color, float theAlpha, float drawflag);
67 void defer(float fdelay, void() func);
69 void defer_clear(entity ent);
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;
76 string _drawpic_picpath;
77 #define drawpic_aspect(pos,pic,mySize,color,theAlpha,drawflag)\
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;\
87 drawpic(pos + eX * (_drawpic_oldsz - _drawpic_sz.x) * 0.5, pic, _drawpic_sz, color, theAlpha, drawflag);\
89 _drawpic_oldsz = _drawpic_sz.y;\
90 _drawpic_sz.y = _drawpic_sz.x / _drawpic_imgaspect;\
92 drawpic(pos + eY * (_drawpic_oldsz - _drawpic_sz.y) * 0.5, pic, _drawpic_sz, color, theAlpha, drawflag);\
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)\
100 _drawpic_picpath = strcat(hud_skin_path, "/", pic);\
101 if(precache_pic(_drawpic_picpath) == "") {\
102 _drawpic_picpath = strcat("gfx/hud/default/", pic);\
104 drawpic_aspect(pos, _drawpic_picpath, sz, color, theAlpha, drawflag);\
105 _drawpic_picpath = string_null;\
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)\
111 _drawpic_picpath = strcat(hud_skin_path, "/", pic);\
112 if(precache_pic(_drawpic_picpath) == "") {\
113 _drawpic_picpath = strcat("gfx/hud/default/", pic);\
115 drawpic(pos, _drawpic_picpath, sz, color, theAlpha, drawflag);\
116 _drawpic_picpath = string_null;\
119 void drawpic_aspect_skin_expanding(vector position, string pic, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp);
121 void drawpic_aspect_skin_expanding_two(vector position, string pic, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp);
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) { \
128 sz.x = sz.y * textaspect; \
129 pos.x += (oldsz - sz.x) * 0.5; \
132 sz.y = sz.x / textaspect; \
133 pos.y += (oldsz - sz.y) * 0.5; \
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);
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);
143 vector drawfontscale;
144 void drawstring_expanding(vector position, string text, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp);
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);
149 void drawcolorcodedstring_expanding(vector position, string text, vector theScale, float theAlpha, float flag, float fadelerp);
151 void drawcolorcodedstring_aspect_expanding(vector pos, string text, vector sz, float theAlpha, float drawflag, float fadelerp);
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);
157 void DrawCircleClippedPic(vector centre, float radius, string pic, float f, vector rgb, float a, float drawflag);
159 const vector GETPLAYERORIGIN_ERROR = '1123581321 2357111317 3141592653'; // way out of bounds for anything on the map
160 vector getplayerorigin(int pl);
162 float getplayeralpha(float pl);
164 vector getcsqcplayercolor(float pl);
166 float getplayerisdead(float pl);
168 void URI_Get_Callback(int id, float status, string data);
170 void draw_beginBoldFont();
172 void draw_endBoldFont();
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;
180 string acc_color_levels;
181 void Accuracy_LoadLevels();
183 void Accuracy_LoadColors();
185 vector Accuracy_GetColor(float accuracy);