X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fclient%2Fmiscfunctions.qh;h=f23a3976b55c6fcaba36a0ec2d5301f80ab0ba8f;hb=83e2013a3aa40f8e5cfeac82e83c9abdd7a038b8;hp=f0a259e0ce696c56fddc1e0de331de7b61dd8a56;hpb=632c547367cea91f7df73f4af95d79556dbc83d4;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/client/miscfunctions.qh b/qcsrc/client/miscfunctions.qh index f0a259e0ce..f23a3976b5 100644 --- a/qcsrc/client/miscfunctions.qh +++ b/qcsrc/client/miscfunctions.qh @@ -31,7 +31,7 @@ vector HUD_GetFontsize(string cvarname); float PreviewExists(string name); -vector rotate(vector v, float a); +vector Rotate(vector v, float a); #define IS_DEAD(s) (((s).classname == "csqcmodel") ? (s).csqcmodel_isdead : ((s).health <= 0)) @@ -45,8 +45,8 @@ float cvar_or(string cv, float v); 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 +#define draw_beginBoldFont() drawfont = FONT_USER + 2 +#define draw_endBoldFont() drawfont = FONT_USER + 1 float expandingbox_sizefactor_from_fadelerp(float fadelerp); @@ -66,13 +66,10 @@ void HUD_Scale_Enable(); 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 +// The following functions / macros must be called from within +// the panel HUD / scoreboard code so that pos and size are scaled +// when the hud_dynamic code is running. +// Make use of stringwidth_builtin and draw*_builtin everywhere else. float stringwidth(string text, float handleColors, vector sz); @@ -97,6 +94,15 @@ float stringwidth(string text, float handleColors, vector sz); #define drawsetcliparea(xposition, yposition, w, h) \ drawsetcliparea_builtin(HUD_ShiftX(xposition), HUD_ShiftY(yposition), HUD_ScaleX(w), HUD_ScaleY(h)) +// Since drawsubpic usually gets called multiple times from within an +// utility function, instead of scaling pos and size in every call +// we scale them once for all in the beginning of that utility function. +// That's why drawsubpic isn't remapped. +/* +#define drawsubpic(position, size, pic, srcPosition, srcSize, rgb, alpha, flag) \ + drawsubpic_builtin(HUD_Shift(position), HUD_Scale(size), pic, HUD_Shift(srcPosition), HUD_Scale(srcSize), rgb, alpha, flag) +*/ + // drawpic wrapper to draw an image as large as possible with preserved aspect ratio into a box float _drawpic_imgaspect; vector _drawpic_imgsize; @@ -113,12 +119,12 @@ string _drawpic_picpath; _drawpic_oldsz = _drawpic_sz.x;\ _drawpic_sz.x = _drawpic_sz.y * _drawpic_imgaspect;\ if(_drawpic_sz.x)\ - drawpic(pos + eX * (_drawpic_oldsz - _drawpic_sz.x) * 0.5, pic, _drawpic_sz, color, theAlpha, drawflag);\ + drawpic(pos + eX * 0.5 * (_drawpic_oldsz - _drawpic_sz.x), pic, _drawpic_sz, color, theAlpha, drawflag);\ } else {\ _drawpic_oldsz = _drawpic_sz.y;\ _drawpic_sz.y = _drawpic_sz.x / _drawpic_imgaspect;\ if(_drawpic_sz.y)\ - drawpic(pos + eY * (_drawpic_oldsz - _drawpic_sz.y) * 0.5, pic, _drawpic_sz, color, theAlpha, drawflag);\ + drawpic(pos + eY * 0.5 * (_drawpic_oldsz - _drawpic_sz.y), pic, _drawpic_sz, color, theAlpha, drawflag);\ }\ }\ } MACRO_END @@ -181,6 +187,8 @@ void drawcolorcodedstring_expanding(vector position, string text, vector theScal void drawcolorcodedstring_aspect_expanding(vector pos, string text, vector sz, float theAlpha, float drawflag, float fadelerp); +void update_mousepos(); + // this draws the triangles of a model DIRECTLY. Don't expect high performance, really... float PolyDrawModelSurface(entity e, float i_s); void PolyDrawModel(entity e);