From: terencehill Date: Mon, 1 Jun 2020 11:17:59 +0000 (+0200) Subject: Move SET_POS_AND_SZ_Y_ASPECT back to miscfuntions.qc, it isn't meant to be used outsi... X-Git-Tag: xonotic-v0.8.5~974 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=f58f485d61e5004f023f36c7e07df94cf18dfce9;p=xonotic%2Fxonotic-data.pk3dir.git Move SET_POS_AND_SZ_Y_ASPECT back to miscfuntions.qc, it isn't meant to be used outside of this file --- diff --git a/qcsrc/client/miscfunctions.qc b/qcsrc/client/miscfunctions.qc index 1af1b971f..e6f036842 100644 --- a/qcsrc/client/miscfunctions.qc +++ b/qcsrc/client/miscfunctions.qc @@ -332,6 +332,23 @@ float stringwidth(string text, float handleColors, vector sz) return r; } +#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; \ + pos.x += (oldsz - sz.x) * 0.5; \ + } else { \ + oldsz = sz.y; \ + sz.y = sz.x / textaspect; \ + pos.y += (oldsz - sz.y) * 0.5; \ + } \ +MACRO_END + // 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); diff --git a/qcsrc/client/miscfunctions.qh b/qcsrc/client/miscfunctions.qh index 3397ab705..5641215ae 100644 --- a/qcsrc/client/miscfunctions.qh +++ b/qcsrc/client/miscfunctions.qh @@ -158,23 +158,6 @@ void drawpic_aspect_skin_expanding(vector position, string pic, vector theScale, void drawpic_aspect_skin_expanding_two(vector position, string pic, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp); -#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; \ - pos.x += (oldsz - sz.x) * 0.5; \ - } else { \ - oldsz = sz.y; \ - sz.y = sz.x / textaspect; \ - pos.y += (oldsz - sz.y) * 0.5; \ - } \ -MACRO_END - // 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);