]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/client/draw.qh
Fix FL_WEAPON flag overlapping FL_JUMPRELEASED. This unintentional change was introdu...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / draw.qh
1 #pragma once
2
3 vector drawfontscale;
4 #define draw_beginBoldFont() drawfont = FONT_USER + 2
5 #define draw_endBoldFont() drawfont = FONT_USER + 1
6
7 float expandingbox_sizefactor_from_fadelerp(float fadelerp);
8
9 vector expandingbox_resize_centered_box_offset(float sz, vector boxsize, float boxxsizefactor);
10 void drawborderlines(float thickness, vector pos, vector dim, vector color, float theAlpha, float drawflag);
11
12 void drawpic_tiled(vector pos, string pic, vector sz, vector area, vector color, float theAlpha, float drawflag);
13
14 // The following functions / macros must be called from within
15 // the panel HUD / scoreboard code so that pos and size are scaled
16 // when the hud_dynamic code is running.
17 // Make use of stringwidth_builtin and draw*_builtin everywhere else.
18
19 float stringwidth(string text, float handleColors, vector sz);
20
21 #define drawpic(position, pic, size, rgb, alpha, flag) \
22         drawpic_builtin(HUD_Shift(position), pic, HUD_Scale(size), rgb, alpha, flag)
23
24 #define drawcharacter(position, character, scale, rgb, alpha, flag) \
25         drawcharacter_builtin(HUD_Shift(position), text, scale, rgb, alpha, flag)
26
27 #define drawstring(position, text, scale, rgb, alpha, flag) \
28         drawstring_builtin(HUD_Shift(position), text, scale, rgb, alpha, flag)
29
30 #define drawcolorcodedstring(position, text, scale, alpha, flag) \
31         drawcolorcodedstring_builtin(HUD_Shift(position), text, scale, alpha, flag)
32
33 #define drawcolorcodedstring2(position, text, scale, rgb, alpha, flag) \
34         drawcolorcodedstring2_builtin(HUD_Shift(position), text, scale, rgb, alpha, flag)
35
36 #define drawfill(position, size, rgb, alpha, flag) \
37         drawfill_builtin(HUD_Shift(position), HUD_Scale(size), rgb, alpha, flag)
38
39 #define drawsetcliparea(xposition, yposition, w, h) \
40         drawsetcliparea_builtin(HUD_ShiftX(xposition), HUD_ShiftY(yposition), HUD_ScaleX(w), HUD_ScaleY(h))
41
42 // Since drawsubpic usually gets called multiple times from within an
43 // utility function, instead of scaling pos and size in every call
44 // we scale them once for all in the beginning of that utility function.
45 // That's why drawsubpic isn't remapped.
46 /*
47 #define drawsubpic(position, size, pic, srcPosition, srcSize, rgb, alpha, flag) \
48         drawsubpic_builtin(HUD_Shift(position), HUD_Scale(size), pic, HUD_Shift(srcPosition), HUD_Scale(srcSize), rgb, alpha, flag)
49 */
50
51 // drawpic wrapper to draw an image as large as possible with preserved aspect ratio into a box
52 float _drawpic_imgaspect;
53 vector _drawpic_imgsize;
54 vector _drawpic_sz;
55 float _drawpic_oldsz;
56 string _drawpic_picpath;
57 #define drawpic_aspect(pos,pic,mySize,color,theAlpha,drawflag)\
58         MACRO_BEGIN \
59                 _drawpic_imgsize = draw_getimagesize(pic);\
60                 if(_drawpic_imgsize != '0 0 0') {\
61                         _drawpic_imgaspect = _drawpic_imgsize.x/_drawpic_imgsize.y;\
62                         _drawpic_sz = mySize;\
63                         if(_drawpic_sz.x/_drawpic_sz.y > _drawpic_imgaspect) {\
64                                 _drawpic_oldsz = _drawpic_sz.x;\
65                                 _drawpic_sz.x = _drawpic_sz.y * _drawpic_imgaspect;\
66                                 if(_drawpic_sz.x)\
67                                         drawpic(pos + eX * 0.5 * (_drawpic_oldsz - _drawpic_sz.x), pic, _drawpic_sz, color, theAlpha, drawflag);\
68                         } else {\
69                                 _drawpic_oldsz = _drawpic_sz.y;\
70                                 _drawpic_sz.y = _drawpic_sz.x / _drawpic_imgaspect;\
71                                 if(_drawpic_sz.y)\
72                                         drawpic(pos + eY * 0.5 * (_drawpic_oldsz - _drawpic_sz.y), pic, _drawpic_sz, color, theAlpha, drawflag);\
73                         }\
74                 }\
75         MACRO_END
76
77 // draw HUD element with image from gfx/hud/hud_skin/foo.tga if it exists, otherwise gfx/hud/default/foo.tga
78 #define drawpic_aspect_skin(pos,pic,sz,color,theAlpha,drawflag)\
79         MACRO_BEGIN \
80                 _drawpic_picpath = strcat(hud_skin_path, "/", pic);\
81                 if(precache_pic(_drawpic_picpath) == "") {\
82                         _drawpic_picpath = strcat("gfx/hud/default/", pic);\
83                 }\
84                 drawpic_aspect(pos, _drawpic_picpath, sz, color, theAlpha, drawflag);\
85                 _drawpic_picpath = string_null;\
86         MACRO_END
87
88 // draw HUD element with image from gfx/hud/hud_skin/foo.tga if it exists, otherwise gfx/hud/default/foo.tga
89 #define drawpic_skin(pos,pic,sz,color,theAlpha,drawflag)\
90         MACRO_BEGIN \
91                 _drawpic_picpath = strcat(hud_skin_path, "/", pic);\
92                 if(precache_pic(_drawpic_picpath) == "") {\
93                         _drawpic_picpath = strcat("gfx/hud/default/", pic);\
94                 }\
95                 drawpic(pos, _drawpic_picpath, sz, color, theAlpha, drawflag);\
96                 _drawpic_picpath = string_null;\
97         MACRO_END
98
99 void drawpic_aspect_skin_expanding(vector position, string pic, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp);
100
101 void drawpic_aspect_skin_expanding_two(vector position, string pic, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp);
102
103 // drawstring wrapper to draw a string as large as possible with preserved aspect ratio into a box
104 void drawstring_aspect(vector pos, string text, vector sz, vector color, float theAlpha, float drawflag);
105
106 // drawstring wrapper to draw a colorcodedstring as large as possible with preserved aspect ratio into a box
107 void drawcolorcodedstring_aspect(vector pos, string text, vector sz, float theAlpha, float drawflag);
108
109 void drawstring_expanding(vector position, string text, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp);
110
111 // drawstring wrapper to draw a string as large as possible with preserved aspect ratio into a box
112 void drawstring_aspect_expanding(vector pos, string text, vector sz, vector color, float theAlpha, float drawflag, float fadelerp);
113
114 void drawcolorcodedstring_expanding(vector position, string text, vector theScale, float theAlpha, float flag, float fadelerp);
115
116 void drawcolorcodedstring_aspect_expanding(vector pos, string text, vector sz, float theAlpha, float drawflag, float fadelerp);
117 // this draws the triangles of a model DIRECTLY. Don't expect high performance, really...
118 float PolyDrawModelSurface(entity e, float i_s);
119 void PolyDrawModel(entity e);
120
121 void DrawCircleClippedPic(vector centre, float radi, string pic, float f, vector rgb, float a, float drawflag);