From f58f485d61e5004f023f36c7e07df94cf18dfce9 Mon Sep 17 00:00:00 2001 From: terencehill Date: Mon, 1 Jun 2020 13:17:59 +0200 Subject: [PATCH] Move SET_POS_AND_SZ_Y_ASPECT back to miscfuntions.qc, it isn't meant to be used outside of this file --- qcsrc/client/miscfunctions.qc | 17 +++++++++++++++++ qcsrc/client/miscfunctions.qh | 17 ----------------- 2 files changed, 17 insertions(+), 17 deletions(-) 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); -- 2.39.2