else if(length_ratio < 0)
return;
+ theOrigin = HUD_Shift(theOrigin);
+ theSize = HUD_Scale(theSize);
+
vector square;
vector width, height;
if(vertical) {
if(!theAlpha)
return;
+ pos = HUD_Shift(pos);
+ mySize = HUD_Scale(mySize);
+
string pic;
pic = strcat(hud_skin_path, "/num_leading");
if(precache_pic(pic) == "") {
void calc_followmodel_ofs(entity view);
void Hud_Dynamic_Frame()
{
- hud_dynamic_ofs = '0 0 0';
+ vector ofs = '0 0 0';
+ hud_scale = '1 1 0';
+ hud_shift = '0 0 0';
if (autocvar_hud_dynamic_follow)
{
entity view = CSQCModel_server2csqc(player_localentnum - 1);
calc_followmodel_ofs(view);
- hud_dynamic_ofs -= cl_followmodel_ofs * autocvar_hud_dynamic_follow_scale;
+ ofs = -cl_followmodel_ofs * autocvar_hud_dynamic_follow_scale;
}
- if (fabs(hud_dynamic_ofs.x) < 0.001) hud_dynamic_ofs.x = 0;
- if (fabs(hud_dynamic_ofs.y) < 0.001) hud_dynamic_ofs.y = 0;
- if (fabs(hud_dynamic_ofs.z) < 0.001) hud_dynamic_ofs.z = 0;
- hud_dynamic_ofs.x = bound(-0.1, hud_dynamic_ofs.x, 0.1);
- hud_dynamic_ofs.y = bound(-0.1, hud_dynamic_ofs.y, 0.1);
- hud_dynamic_ofs.z = bound(-0.1, hud_dynamic_ofs.z, 0.1);
+ if (fabs(ofs.x) < 0.001) ofs.x = 0;
+ if (fabs(ofs.y) < 0.001) ofs.y = 0;
+ if (fabs(ofs.z) < 0.001) ofs.z = 0;
+ ofs.x = bound(-0.1, ofs.x, 0.1);
+ ofs.y = bound(-0.1, ofs.y, 0.1);
+ ofs.z = bound(-0.1, ofs.z, 0.1);
+
+ hud_shift.x = ofs.y * vid_conwidth;
+ hud_shift.y = ofs.z * vid_conheight;
+ hud_shift.z = ofs.x;
+
+ hud_scale.x = (1 + hud_shift.z);
+ hud_scale.y = hud_scale.x;
float health = STAT(HEALTH);
if(autocvar_hud_dynamic_shake > 0 && !autocvar__hud_configure && health > 0)
hud_dynamic_shake_factor = 0;
}
}
+
+ if(hud_dynamic_shake_factor > 0)
+ {
+ hud_shift.x += hud_dynamic_shake_realofs.x;
+ hud_shift.y += hud_dynamic_shake_realofs.y;
+ }
+
+ hud_scale_center.x = 0.5 * vid_conwidth;
+ hud_scale_center.y = 0.5 * vid_conheight;
+
+ hud_scale_current = hud_scale;
+ hud_shift_current = hud_shift;
}
void HUD_Main()
HUD_Configure_Frame();
+ Hud_Dynamic_Frame();
+
// panels that we want to be active together with the scoreboard
// they must fade only when the menu does
if(scoreboard_fade_alpha == 1)
return;
}
- Hud_Dynamic_Frame();
-
// Drawing stuff
if (hud_skin_prev != autocvar_hud_skin)
{
#define HUD_PANEL(NAME) HUD_PANEL_##NAME
// draw the background/borders
-#define HUD_Panel_DrawBg(theAlpha) MACRO_BEGIN { \
- if(panel.current_panel_bg != "0" && panel.current_panel_bg != "") \
- draw_BorderPicture(panel_pos - '1 1 0' * panel_bg_border, panel.current_panel_bg, panel_size + '1 1 0' * 2 * panel_bg_border, panel_bg_color, panel_bg_alpha * theAlpha, '1 1 0' * (panel_bg_border/BORDER_MULTIPLIER));\
+#define HUD_Panel_DrawBg(theAlpha) MACRO_BEGIN { \
+ if(panel.current_panel_bg != "0" && panel.current_panel_bg != "") \
+ draw_BorderPicture( \
+ HUD_Shift(panel_pos - '1 1 0' * panel_bg_border), \
+ panel.current_panel_bg, \
+ HUD_Scale(panel_size + '1 1 0' * 2 * panel_bg_border), \
+ panel_bg_color, \
+ panel_bg_alpha * theAlpha, \
+ HUD_Scale('1 1 0' * (panel_bg_border/BORDER_MULTIPLIER)) \
+ ); \
} MACRO_END
int panel_order[hud_panels_MAX];
vector cl_followmodel_ofs;
float cl_followmodel_time;
-vector hud_dynamic_ofs;
+vector hud_scale;
+vector hud_scale_current;
+vector hud_shift;
+vector hud_shift_current;
+vector hud_scale_center;
float stringwidth_colors(string s, vector theSize);
float stringwidth_nocolors(string s, vector theSize);
panel_bg_padding = panel.current_panel_bg_padding; \
panel_fg_alpha = panel.current_panel_fg_alpha * hud_fade_alpha; \
} \
- if(hud_dynamic_shake_factor > 0) panel_pos += hud_dynamic_shake_realofs; \
- if(hud_dynamic_ofs.y) panel_pos.x += hud_dynamic_ofs.y * vid_conwidth; \
- if(hud_dynamic_ofs.z) panel_pos.y += hud_dynamic_ofs.z * vid_conheight; \
- if(hud_dynamic_ofs.x) { \
- panel_size.x += hud_dynamic_ofs.x * panel_size.x; \
- panel_size.y += hud_dynamic_ofs.x * panel_size.y; \
- panel_pos.x += hud_dynamic_ofs.x * (panel_pos.x - vid_conwidth * 0.5); \
- panel_pos.y += hud_dynamic_ofs.x * (panel_pos.y - vid_conheight * 0.5); \
- } \
} MACRO_END
#define HUD_Panel_UpdatePosSize() MACRO_BEGIN { \
pos = panel_pos;
mySize = panel_size;
+ HUD_Scale_Enable();
HUD_Panel_DrawBg(1);
if(panel_bg_padding)
{
}
}
+ HUD_Scale_Enable();
HUD_Panel_DrawBg(1);
if (!centerprint_showing)
// finally set the size based on the new theAlpha from subsequent fading
sz = sz * (autocvar_hud_panel_centerprint_fade_subsequent_minfontsize + a * (1 - autocvar_hud_panel_centerprint_fade_subsequent_minfontsize));
- drawfontscale = sz * '1 1 0';
+ drawfontscale = hud_scale * sz;
if (centerprint_countdown_num[j])
n = tokenizebyseparator(strreplace("^COUNT", count_seconds(centerprint_countdown_num[j]), centerprint_messages[j]), "\n");
getWrappedLine_remaining = argv(k);
while(getWrappedLine_remaining)
{
- ts = getWrappedLine(panel_size.x * sz, fontsize, stringwidth_colors);
+ ts = getWrappedLine(panel_size.x * hud_scale.x * sz, fontsize, stringwidth_colors);
if (ts != "")
pos.y -= fontsize.y;
else
getWrappedLine_remaining = argv(k);
while(getWrappedLine_remaining)
{
- ts = getWrappedLine(panel_size.x * sz, fontsize, stringwidth_colors);
+ ts = getWrappedLine(panel_size.x * hud_scale.x * sz, fontsize, stringwidth_colors);
if (ts != "")
{
if (align)
- pos.x = panel_pos.x + (panel_size.x - stringwidth(ts, true, fontsize)) * align;
+ pos.x = panel_pos.x + (panel_size.x - stringwidth(ts, true, fontsize) * sz) * align;
if (a > 0.5/255.0) // Otherwise guaranteed invisible - don't show. This is checked a second time after some multiplications with other factors were done so temporary changes of these cannot cause flicker.
- drawcolorcodedstring(pos + eY * 0.5 * (1 - sz) * fontsize.y, ts, fontsize, a, DRAWFLAG_NORMAL);
+ drawcolorcodedstring(pos + eY * 0.5 * (1 - sz * hud_scale.x) * fontsize.y, ts, fontsize, a, DRAWFLAG_NORMAL);
pos.y += fontsize.y;
}
else
if (pos.y < panel_pos.y) // check if the next message can be shown
{
- drawfontscale = '1 1 0';
+ drawfontscale = hud_scale;
return;
}
}
if(pos.y > panel_pos.y + panel_size.y - fontsize.y) // check if the next message can be shown
{
- drawfontscale = '1 1 0';
+ drawfontscale = hud_scale;
return;
}
}
}
- drawfontscale = '1 1 0';
+ drawfontscale = hud_scale;
if (all_messages_expired)
{
centerprint_showing = false;
pos = panel_pos;
mySize = panel_size;
+ HUD_Scale_Disable();
HUD_Panel_DrawBg(1);
if(panel_bg_padding)
pos = panel_pos;
mySize = panel_size;
+ HUD_Scale_Enable();
HUD_Panel_DrawBg(1);
if(panel_bg_padding)
{
pos = panel_pos;
mySize = panel_size;
+ HUD_Scale_Enable();
HUD_Panel_DrawBg(1);
if(panel_bg_padding)
{
pos = panel_pos;
mySize = panel_size;
+ HUD_Scale_Enable();
HUD_Panel_DrawBg(1);
if(panel_bg_padding)
{
else
mod_alpha = bound(0, 1 - (time - mod_change) * 2, 1);
+ HUD_Scale_Enable();
if(mod_alpha)
HUD_Panel_DrawBg(mod_alpha);
return;
HUD_Panel_UpdateCvars();
+ HUD_Scale_Enable();
HUD_Panel_DrawBg(1);
if (!autocvar__hud_configure)
draw_beginBoldFont();
+ HUD_Scale_Enable();
HUD_Panel_DrawBg(1);
if(panel_bg_padding)
{
// Draw panel background
HUD_Panel_UpdateCvars();
+ HUD_Scale_Enable();
HUD_Panel_DrawBg(1);
// Set drawing area
pos = panel_pos;
mySize = panel_size;
+ HUD_Scale_Enable();
HUD_Panel_DrawBg(1);
if(panel_bg_padding)
{
pos = panel_pos;
mySize = panel_size;
+ HUD_Scale_Enable();
HUD_Panel_DrawBg(1);
if(panel_bg_padding)
{
pos = panel_pos;
mySize = panel_size;
+ HUD_Scale_Enable();
HUD_Panel_DrawBg(1);
if(panel_bg_padding)
{
int color2;
float scale2d, normalsize, bigsize;
- teamradar_origin2d = pos + 0.5 * mySize;
+ teamradar_origin2d = HUD_Shift(pos + 0.5 * mySize);
teamradar_size2d = mySize;
if(minimapname == "")
teamradar_loadcvars();
scale2d = vlen_maxnorm2d(mi_picmax - mi_picmin);
- teamradar_size2d = mySize;
+ teamradar_size2d = HUD_Scale(mySize);
teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
pos = panel_pos;
mySize = panel_size;
+ HUD_Scale_Enable();
HUD_Panel_DrawBg(1);
if(panel_bg_padding)
{
pos = panel_pos;
mySize = panel_size;
+ HUD_Scale_Enable();
HUD_Panel_DrawBg(1);
if(panel_bg_padding)
{
mySize = panel_size;
a = vote_alpha * (vote_highlighted ? autocvar_hud_panel_vote_alreadyvoted_alpha : 1);
+ HUD_Scale_Enable();
HUD_Panel_DrawBg(a);
a = panel_fg_alpha * a;
}
// draw the background, then change the virtual size of it to better fit other items inside
+ HUD_Scale_Enable();
HUD_Panel_DrawBg(1);
if(center.x == -1)
panel_pos.y = pos.y;
panel_size.x = xmax - xmin;
panel_size.y = ymax - ymin;
+ HUD_Scale_Disable();
HUD_Panel_DrawBg(1);
if(panel_bg_padding)
void drawpic_tiled(vector pos, string pic, vector sz, vector area, vector color, float theAlpha, float drawflag)
{
+ pos = HUD_Shift(pos);
+ sz = HUD_Scale(sz);
+ area = HUD_Scale(area);
+
vector current_pos = '0 0 0', end_pos, new_size = '0 0 0', ratio = '0 0 0';
end_pos = pos + area;
drawpic_skin(position, pic, theScale, rgb, theAlpha * fadelerp, flag);
}
+void HUD_Scale_Disable()
+{
+ hud_scale = '1 1 0';
+ hud_shift = '0 0 0';
+ drawfontscale = hud_scale;
+}
+
+void HUD_Scale_Enable()
+{
+ hud_scale = hud_scale_current;
+ hud_shift = hud_shift_current;
+ drawfontscale = hud_scale;
+}
+
+vector HUD_Scale(vector v)
+{
+ v.x = HUD_ScaleX(v.x);
+ v.y = HUD_ScaleY(v.y);
+ return v;
+}
+
+vector HUD_Shift(vector v)
+{
+ v.x = HUD_ShiftX(v.x);
+ v.y = HUD_ShiftY(v.y);
+ return v;
+}
+
+float stringwidth(string text, float handleColors, vector sz)
+{
+ vector dfs = drawfontscale;
+ drawfontscale = '1 1 0';
+ float r = stringwidth_builtin(text, handleColors, sz);
+ drawfontscale = dfs;
+ return r;
+}
+
// drawstring wrapper to draw a string as large as possible with preserved aspect ratio into a box
void drawstring_aspect(vector pos, string text, vector sz, vector color, float theAlpha, float drawflag) {
SET_POS_AND_SZ_Y_ASPECT(false);
float sz;
sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
+ drawfontscale = hud_scale * sz;
+ vector dfs = drawfontscale;
drawfontscale = sz * '1 1 0';
- drawstring(position + expandingbox_resize_centered_box_offset(sz, theScale, stringwidth(text, false, theScale * (sz / drawfontscale.x)) / (theScale.x * sz)), text, theScale * (sz / drawfontscale.x), rgb, theAlpha * (1 - fadelerp), flag);
+ float textaspect = stringwidth_builtin(text, false, theScale * (sz / drawfontscale.x)) / (theScale.x * sz);
+ drawfontscale = dfs;
+ drawstring(position + expandingbox_resize_centered_box_offset(sz, theScale, textaspect), text, HUD_Scale(theScale * (sz / drawfontscale.x)), rgb, theAlpha * (1 - fadelerp), flag);
// width parameter:
- // (scale_x * sz / drawfontscale_x) * drawfontscale_x * SIZE1 / (scale_x * sz)
+ // (scale_x * sz / drawfontscale.x) * drawfontscale.x * SIZE1 / (scale_x * sz)
// SIZE1
- drawfontscale = '1 1 0';
+ drawfontscale = hud_scale;
}
// drawstring wrapper to draw a string as large as possible with preserved aspect ratio into a box
float sz;
sz = expandingbox_sizefactor_from_fadelerp(fadelerp);
- drawfontscale = sz * '1 1 0';
- drawcolorcodedstring(position + expandingbox_resize_centered_box_offset(sz, theScale, stringwidth(text, true, theScale * (sz / drawfontscale.x)) / (theScale.x * sz)), text, theScale * (sz / drawfontscale.x), theAlpha * (1 - fadelerp), flag);
- drawfontscale = '1 1 0';
+ drawfontscale = hud_scale * sz;
+ // eventually replace with drawcolorcodedstring
+ drawcolorcodedstring(position + expandingbox_resize_centered_box_offset(sz, theScale, stringwidth_builtin(text, true, theScale * (sz / drawfontscale.x)) / (theScale.x * sz)), text, theScale * (sz / drawfontscale.x), theAlpha * (1 - fadelerp), flag);
+ drawfontscale = hud_scale;
}
void drawcolorcodedstring_aspect_expanding(vector pos, string text, vector sz, float theAlpha, float drawflag, float fadelerp) {
vector project_3d_to_2d(vector vec);
+vector drawfontscale;
#define draw_beginBoldFont() MACRO_BEGIN { drawfont = FONT_USER + 2; } MACRO_END
#define draw_endBoldFont() MACRO_BEGIN { drawfont = FONT_USER + 1; } MACRO_END
void drawpic_tiled(vector pos, string pic, vector sz, vector area, vector color, float theAlpha, float drawflag);
+void HUD_Scale_Disable();
+void HUD_Scale_Enable();
+
+#define HUD_ScaleX(f) (f * hud_scale.x)
+#define HUD_ScaleY(f) (f * hud_scale.y)
+#define HUD_ShiftX(f) (f + hud_shift.x + hud_shift.z * (f - hud_scale_center.x))
+#define HUD_ShiftY(f) (f + hud_shift.y + hud_shift.z * (f - hud_scale_center.y))
+vector HUD_Scale(vector v);
+vector HUD_Shift(vector v);
+
+// call draw*_builtin (and stringwidth_builtin) functions only when
+// pos and size don't have to be scaled by the hud_dynamic code
+// (typically outside the real HUD code)
+
+// NOTE: drawsubpic usually gets called multiple times within an utility function
+// so instead of remapping it, scaling pos and size in every call,
+// we prefer to scale pos and size once for all in the utility function
+
+float stringwidth(string text, float handleColors, vector sz);
+
+#define drawpic(position, pic, size, rgb, alpha, flag) \
+ drawpic_builtin(HUD_Shift(position), pic, HUD_Scale(size), rgb, alpha, flag)
+
+#define drawcharacter(position, character, scale, rgb, alpha, flag) \
+ drawcharacter_builtin(HUD_Shift(position), text, scale, rgb, alpha, flag)
+
+#define drawstring(position, text, scale, rgb, alpha, flag) \
+ drawstring_builtin(HUD_Shift(position), text, scale, rgb, alpha, flag)
+
+#define drawcolorcodedstring(position, text, scale, alpha, flag) \
+ drawcolorcodedstring_builtin(HUD_Shift(position), text, scale, alpha, flag)
+
+#define drawcolorcodedstring2(position, text, scale, rgb, alpha, flag) \
+ drawcolorcodedstring2_builtin(HUD_Shift(position), text, scale, rgb, alpha, flag)
+
+#define drawfill(position, size, rgb, alpha, flag) \
+ drawfill_builtin(HUD_Shift(position), HUD_Scale(size), rgb, alpha, flag)
+
+#define drawsetcliparea(xposition, yposition, w, h) \
+ drawsetcliparea_builtin(HUD_ShiftX(xposition), HUD_ShiftY(yposition), HUD_ScaleX(w), HUD_ScaleY(h))
+
// drawpic wrapper to draw an image as large as possible with preserved aspect ratio into a box
float _drawpic_imgaspect;
vector _drawpic_imgsize;
#define SET_POS_AND_SZ_Y_ASPECT(allow_colors) MACRO_BEGIN { \
float textaspect, oldsz; \
+ vector dfs = drawfontscale; \
+ drawfontscale = '1 1 0'; \
textaspect = stringwidth(text, allow_colors, '1 1 1' * sz.y) / sz.y; \
+ drawfontscale = dfs; \
if(sz.x/sz.y > textaspect) { \
oldsz = sz.x; \
sz.x = sz.y * textaspect; \
// drawstring wrapper to draw a colorcodedstring as large as possible with preserved aspect ratio into a box
void drawcolorcodedstring_aspect(vector pos, string text, vector sz, float theAlpha, float drawflag);
-vector drawfontscale;
void drawstring_expanding(vector position, string text, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp);
// drawstring wrapper to draw a string as large as possible with preserved aspect ratio into a box
HUD_Panel_UpdateCvars();
+ HUD_Scale_Enable();
HUD_Panel_DrawBg(1);
if(panel_bg_padding)
void draw_teamradar_icon(vector coord, entity icon, entity pingdata, vector rgb, float a)
{
coord = teamradar_texcoord_to_2dcoord(teamradar_3dcoord_to_texcoord(coord));
- drawpic(coord - '4 4 0', strcat("gfx/teamradar_icon_", ftos(icon.m_radaricon)), '8 8 0', rgb, a, 0);
+ drawpic_builtin(coord - '4 4 0', strcat("gfx/teamradar_icon_", ftos(icon.m_radaricon)), '8 8 0', rgb, a, 0);
if(pingdata)
{
if(dt >= 1 || dt <= 0)
continue;
vector v = '2 2 0' * teamradar_size * dt;
- drawpic(coord - 0.5 * v, "gfx/teamradar_ping", v, '1 1 1', (1 - dt) * a, DRAWFLAG_ADDITIVE);
+ drawpic_builtin(coord - 0.5 * v, "gfx/teamradar_ping", v, '1 1 1', (1 - dt) * a, DRAWFLAG_ADDITIVE);
}
}
}
HUD_Main();
HUD_DrawScoreboard();
+ HUD_Scale_Disable();
}
// crosshair goes VERY LAST
lasthud = hud;
+ HUD_Scale_Disable();
+
if(autocvar__hud_showbinds_reload) // menu can set this one
{
db_close(binddb);
if (pos.z < 0) continue;
pos.z = 0;
pos.y += ofs * sz;
- drawcolorcodedstring2(pos,
+ drawcolorcodedstring2_builtin(pos,
sprintf("%d: '%s'@%s", (it.debug ? it.sv_entnum : etof(it)),
it.classname, it.sourceLoc),
sz * '1 1 0', rgb, 0.5, DRAWFLAG_NORMAL);
HUD_Panel_UpdateCvars();
+ HUD_Scale_Disable();
HUD_Panel_DrawBg(1);
if(panel_bg_padding)
// Required function, draw the game status panel
void bd_hud_status(vector pos, vector mySize)
{
+ HUD_Scale_Disable();
HUD_Panel_DrawBg(1);
vector ts;
ts = minigame_drawstring_wrapped(mySize_x,pos,active_minigame.descriptor.message,
// Required function, draw the game status panel
void c4_hud_status(vector pos, vector mySize)
{
+ HUD_Scale_Disable();
HUD_Panel_DrawBg(1);
vector ts;
ts = minigame_drawstring_wrapped(mySize_x,pos,active_minigame.descriptor.message,
// Required function, draw the game status panel
void nmm_hud_status(vector pos, vector mySize)
{
+ HUD_Scale_Disable();
HUD_Panel_DrawBg(1);
vector ts;
// Required function, draw the game status panel
void pong_hud_status(vector pos, vector mySize)
{
+ HUD_Scale_Disable();
HUD_Panel_DrawBg(1);
vector ts;
ts = minigame_drawstring_wrapped(mySize_x,pos,active_minigame.descriptor.message,
// Required function, draw the game status panel
void pp_hud_status(vector pos, vector mySize)
{
+ HUD_Scale_Disable();
HUD_Panel_DrawBg(1);
vector ts;
ts = minigame_drawstring_wrapped(mySize_x,pos,active_minigame.descriptor.message,
// Required function, draw the game status panel
void ps_hud_status(vector pos, vector mySize)
{
+ HUD_Scale_Disable();
HUD_Panel_DrawBg(1);
vector ts;
ts = minigame_drawstring_wrapped(mySize_x,pos,active_minigame.descriptor.message,
// Required function, draw the game status panel
void snake_hud_status(vector pos, vector mySize)
{
+ HUD_Scale_Disable();
HUD_Panel_DrawBg(1);
vector ts;
ts = minigame_drawstring_wrapped(mySize_x,pos,active_minigame.descriptor.message,
// Required function, draw the game status panel
void ttt_hud_status(vector pos, vector mySize)
{
+ HUD_Scale_Disable();
HUD_Panel_DrawBg(1);
vector ts;
ts = minigame_drawstring_wrapped(mySize_x,pos,active_minigame.descriptor.message,
s = strreplace("{health}", sprintf("%d", this.m_damage), s);
s = strreplace("{armor}", sprintf("%d", this.m_armordamage), s);
s = strreplace("{total}", sprintf("%d", this.m_damage + this.m_armordamage), s);
- drawcolorcodedstring2(pos, s, this.m_size * '1 1 0', rgb, this.alpha, DRAWFLAG_NORMAL);
+ drawcolorcodedstring2_builtin(pos, s, this.m_size * '1 1 0', rgb, this.alpha, DRAWFLAG_NORMAL);
}
}
ATTRIB(DamageText, draw2d, void(DamageText), DamageText_draw2d)
}
}
+ HUD_Scale_Enable();
HUD_Panel_DrawBg(1);
float row = 0, column = 0;
string(string name) precache_cubemap = #317;
vector(string picname) draw_getimagesize = #318;
void(string name) freepic = #319;
-float(vector position, float character, vector scale, vector rgb, float alpha, float flag) drawcharacter = #320;
-float(vector position, string text, vector scale, vector rgb, float alpha, float flag) drawstring = #321;
-float(vector position, string pic, vector size, vector rgb, float alpha, float flag) drawpic = #322;
-float(vector position, vector size, vector rgb, float alpha, float flag) drawfill = #323;
-void(float x, float y, float width, float height) drawsetcliparea = #324;
+float(vector position, float character, vector scale, vector rgb, float alpha, float flag) drawcharacter_builtin = #320;
+float(vector position, string text, vector scale, vector rgb, float alpha, float flag) drawstring_builtin = #321;
+float(vector position, string pic, vector size, vector rgb, float alpha, float flag) drawpic_builtin = #322;
+float(vector position, vector size, vector rgb, float alpha, float flag) drawfill_builtin = #323;
+void(float x, float y, float width, float height) drawsetcliparea_builtin = #324;
void(void) drawresetcliparea = #325;
-float(vector position, string text, vector scale, float alpha, float flag) drawcolorcodedstring = #326;
-vector(vector position, string text, vector scale, vector rgb, float alpha, float flag) drawcolorcodedstring2 = #326;
+float(vector position, string text, vector scale, float alpha, float flag) drawcolorcodedstring_builtin = #326;
+vector(vector position, string text, vector scale, vector rgb, float alpha, float flag) drawcolorcodedstring2_builtin = #326;
float(float stnum) getstatf = #330;
float(float stnum, ...) getstati = #331; // can optionally take first bit and count
// fix_* parms let you fix badly made fonts by applying some transformations to them
// fix_scale : per-character center-oriented scale (doesn't change line height at all)
// fix_voffset : vertical offset for each character, it's a multiplier to character height
-float stringwidth(string text, float allowColorCodes, vector size) = #327; // get a width of string with given font and char size
+float stringwidth_builtin(string text, float allowColorCodes, vector size) = #327; // get a width of string with given font and char size
float stringwidth_menu(string text, float allowColorCodes, vector size) = #468; // in menu.dat it has different builtin #
//description: engine support for custom fonts in console, hud, qc etc.
// limits:
{
if (theBorderSize.x < 0 && theBorderSize.y < 0) // draw whole image as it is
{
- drawpic(theOrigin, pic, theSize, theColor, theAlpha, 0);
+ drawpic_builtin(theOrigin, pic, theSize, theColor, theAlpha, 0);
return;
}
if (theBorderSize.x == 0 && theBorderSize.y == 0) // no border
void drawstringright(vector position, string text, vector theScale, vector rgb, float theAlpha, int flag)
{
position.x -= 2 / 3 * strlen(text) * theScale.x;
- drawstring(position, text, theScale, rgb, theAlpha, flag);
+ drawstring_builtin(position, text, theScale, rgb, theAlpha, flag);
}
void drawstringcenter(vector position, string text, vector theScale, vector rgb, float theAlpha, int flag)
{
position.x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * theScale.x);
- drawstring(position, text, theScale, rgb, theAlpha, flag);
+ drawstring_builtin(position, text, theScale, rgb, theAlpha, flag);
}
#endif
#include "sort.qh"
#include "oo.qh"
-#ifndef SVQC
+#ifdef CSQC
+ float stringwidth_colors(string s, vector theSize)
+ {
+ return stringwidth_builtin(s, true, theSize);
+ }
+
+ float stringwidth_nocolors(string s, vector theSize)
+ {
+ return stringwidth_builtin(s, false, theSize);
+ }
+#endif
+#ifdef MENUQC
float stringwidth_colors(string s, vector theSize)
{
return stringwidth(s, true, theSize);