Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
draw.qh
Go to the documentation of this file.
1#pragma once
2
4#define draw_beginBoldFont() drawfont = FONT_USER + 2
5#define draw_endBoldFont() drawfont = FONT_USER + 1
6
7float expandingbox_sizefactor_from_fadelerp(float fadelerp);
8
9vector expandingbox_resize_centered_box_offset(float sz, vector boxsize, float boxxsizefactor);
10void drawborderlines(float thickness, vector pos, vector dim, vector color, float theAlpha, float drawflag);
11
12void 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
19float 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
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 drawpic_aspect(pos, _drawpic_picpath, sz, color, theAlpha, drawflag);\
84 _drawpic_picpath = string_null;\
85 MACRO_END
86
87// draw HUD element with image from gfx/hud/hud_skin/foo.tga if it exists, otherwise gfx/hud/default/foo.tga
88#define drawpic_skin(pos,pic,sz,color,theAlpha,drawflag)\
89 MACRO_BEGIN \
90 _drawpic_picpath = strcat(hud_skin_path, "/", pic);\
91 if(precache_pic(_drawpic_picpath) == "")\
92 _drawpic_picpath = strcat("gfx/hud/default/", pic);\
93 drawpic(pos, _drawpic_picpath, sz, color, theAlpha, drawflag);\
94 _drawpic_picpath = string_null;\
95 MACRO_END
96
97void drawpic_aspect_skin_expanding(vector position, string pic, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp);
98
99void drawpic_aspect_skin_expanding_two(vector position, string pic, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp);
100
101// drawstring wrapper to draw a string as large as possible with preserved aspect ratio into a box
102void drawstring_aspect(vector pos, string text, vector sz, vector color, float theAlpha, float drawflag);
103
104// drawstring wrapper to draw a colorcodedstring as large as possible with preserved aspect ratio into a box
105void drawcolorcodedstring_aspect(vector pos, string text, vector sz, float theAlpha, float drawflag);
106
107void drawstring_expanding(vector position, string text, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp);
108
109// drawstring wrapper to draw a string as large as possible with preserved aspect ratio into a box
110void drawstring_aspect_expanding(vector pos, string text, vector sz, vector color, float theAlpha, float drawflag, float fadelerp);
111
112void drawcolorcodedstring_expanding(vector position, string text, vector theScale, float theAlpha, float flag, float fadelerp);
113
114void drawcolorcodedstring_aspect_expanding(vector pos, string text, vector sz, float theAlpha, float drawflag, float fadelerp);
115// this draws the triangles of a model DIRECTLY. Don't expect high performance, really...
116float PolyDrawModelSurface(entity e, float i_s);
117void PolyDrawModel(entity e);
118
119void DrawCircleClippedPic(vector centre, float radi, string pic, float f, vector rgb, float a, float drawflag);
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
float expandingbox_sizefactor_from_fadelerp(float fadelerp)
Definition draw.qc:50
void drawstring_aspect(vector pos, string text, vector sz, vector color, float theAlpha, float drawflag)
Definition draw.qc:110
void drawcolorcodedstring_expanding(vector position, string text, vector theScale, float theAlpha, float flag, float fadelerp)
Definition draw.qc:144
void PolyDrawModel(entity e)
Definition draw.qc:182
vector _drawpic_imgsize
Definition draw.qh:53
void drawpic_aspect_skin_expanding(vector position, string pic, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp)
Definition draw.qc:61
void drawpic_tiled(vector pos, string pic, vector sz, vector area, vector color, float theAlpha, float drawflag)
Definition draw.qc:24
void drawcolorcodedstring_aspect(vector pos, string text, vector sz, float theAlpha, float drawflag)
Definition draw.qc:116
vector _drawpic_sz
Definition draw.qh:54
float _drawpic_oldsz
Definition draw.qh:55
void drawborderlines(float thickness, vector pos, vector dim, vector color, float theAlpha, float drawflag)
Definition draw.qc:5
void drawcolorcodedstring_aspect_expanding(vector pos, string text, vector sz, float theAlpha, float drawflag, float fadelerp)
Definition draw.qc:155
vector expandingbox_resize_centered_box_offset(float sz, vector boxsize, float boxxsizefactor)
Definition draw.qc:55
void drawstring_aspect_expanding(vector pos, string text, vector sz, vector color, float theAlpha, float drawflag, float fadelerp)
Definition draw.qc:139
vector drawfontscale
Definition draw.qh:3
float _drawpic_imgaspect
Definition draw.qh:52
string _drawpic_picpath
Definition draw.qh:56
void DrawCircleClippedPic(vector centre, float radi, string pic, float f, vector rgb, float a, float drawflag)
Definition draw.qc:190
void drawstring_expanding(vector position, string text, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp)
Definition draw.qc:121
float PolyDrawModelSurface(entity e, float i_s)
Definition draw.qc:161
void drawpic_aspect_skin_expanding_two(vector position, string pic, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp)
Definition draw.qc:69
#define stringwidth
vector color
Definition dynlight.qc:15
vector
Definition self.qh:92