From 452cbdc2cae35ce5acbb3dd50dbf0a867f5e4eaa Mon Sep 17 00:00:00 2001 From: div0 Date: Fri, 25 Dec 2009 15:19:24 +0000 Subject: [PATCH] use draw_fontscale in nexposee for fixing the text scale effect... sorry for that, blub git-svn-id: svn://svn.icculus.org/nexuiz/trunk@8454 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/qcsrc/menu/draw.qc | 29 ++++++++++++++++++++++++++--- data/qcsrc/menu/draw.qh | 8 ++++++++ data/qcsrc/menu/item/container.c | 6 ++++++ data/qcsrc/menu/item/nexposee.c | 19 ++----------------- 4 files changed, 42 insertions(+), 20 deletions(-) diff --git a/data/qcsrc/menu/draw.qc b/data/qcsrc/menu/draw.qc index 8333a392e..504d9bbd9 100644 --- a/data/qcsrc/menu/draw.qc +++ b/data/qcsrc/menu/draw.qc @@ -28,6 +28,7 @@ void draw_reset(float cw, float ch, float ox, float oy) draw_shift = '1 0 0' * ox + '0 1 0' * oy; draw_scale = '1 0 0' * cw + '0 1 0' * ch; draw_alpha = 1; + draw_fontscale = '1 1 0'; } vector globalToBox(vector v, vector theOrigin, vector theScale) @@ -229,12 +230,22 @@ void draw_BorderPicture(vector theOrigin, string pic, vector theSize, vector the } void draw_Text(vector theOrigin, string theText, vector theSize, vector theColor, float theAlpha, float ICanHasKallerz) { + vector fs; if(theSize_x <= 0 || theSize_y <= 0) error("Drawing zero size text?\n"); + if not(cvar("menu_font_size_snapping_fix")) // FIXME remove this, this is to detect old engines + { + fs = draw_fontscale; + draw_fontscale = '1 1 0'; + } if(ICanHasKallerz) - drawcolorcodedstring(boxToGlobal(theOrigin, draw_shift, draw_scale), theText, boxToGlobalSize(theSize, draw_scale), theAlpha * draw_alpha, 0); + drawcolorcodedstring(boxToGlobal(theOrigin, draw_shift, draw_scale), theText, globalToBoxSize(boxToGlobalSize(theSize, draw_scale), draw_fontscale), theAlpha * draw_alpha, 0); else - drawstring(boxToGlobal(theOrigin, draw_shift, draw_scale), theText, boxToGlobalSize(theSize, draw_scale), theColor, theAlpha * draw_alpha, 0); + drawstring(boxToGlobal(theOrigin, draw_shift, draw_scale), theText, globalToBoxSize(boxToGlobalSize(theSize, draw_scale), draw_fontscale), theColor, theAlpha * draw_alpha, 0); + if not(cvar("menu_font_size_snapping_fix")) // FIXME remove this, this is to detect old engines + { + draw_fontscale = fs; + } } void draw_CenterText(vector theOrigin, string theText, vector theSize, vector theColor, float theAlpha, float ICanHasKallerz) { @@ -245,7 +256,19 @@ float draw_TextWidth(string theText, float ICanHasKallerz) { //return strlen(theText); //print("draw_TextWidth \"", theText, "\"\n"); - return stringwidth(theText, ICanHasKallerz); + vector fs; + float r; + if not(cvar("menu_font_size_snapping_fix")) // FIXME remove this, this is to detect old engines + { + fs = draw_fontscale; + draw_fontscale = '1 1 0'; + } + r = stringwidth(theText, ICanHasKallerz) / draw_fontscale_x; + if not(cvar("menu_font_size_snapping_fix")) // FIXME remove this, this is to detect old engines + { + draw_fontscale = fs; + } + return r; } float draw_clipSet; diff --git a/data/qcsrc/menu/draw.qh b/data/qcsrc/menu/draw.qh index f18f83fe0..d61ed0912 100644 --- a/data/qcsrc/menu/draw.qh +++ b/data/qcsrc/menu/draw.qh @@ -1,6 +1,14 @@ +// from the engine +vector drawfontscale; +#define draw_fontscale drawfontscale +#define draw_fontscale_x drawfontscale_x +#define draw_fontscale_y drawfontscale_y +#define draw_fontscale_z drawfontscale_z + vector draw_shift; vector draw_scale; float draw_alpha; +vector draw_fontscale; void draw_reset(float cw, float ch, float ox, float oy); void draw_setMousePointer(string pic, vector theSize, vector theOffset); diff --git a/data/qcsrc/menu/item/container.c b/data/qcsrc/menu/item/container.c index addcd8cc4..53e3eaa1a 100644 --- a/data/qcsrc/menu/item/container.c +++ b/data/qcsrc/menu/item/container.c @@ -31,6 +31,7 @@ ENDCLASS(Container) .float resized; .vector Container_origin; .vector Container_size; +.vector Container_fontscale; .float Container_alpha; #endif @@ -127,11 +128,13 @@ void drawContainer(entity me) vector oldshift; vector oldscale; float oldalpha; + vector oldfontscale; entity e; oldshift = draw_shift; oldscale = draw_scale; oldalpha = draw_alpha; + oldfontscale = draw_fontscale; me.focusable = 0; for(e = me.firstChild; e; e = e.nextSibling) { @@ -141,10 +144,13 @@ void drawContainer(entity me) continue; draw_shift = boxToGlobal(e.Container_origin, oldshift, oldscale); draw_scale = boxToGlobalSize(e.Container_size, oldscale); + if(e.Container_fontscale != '0 0 0') + draw_fontscale = boxToGlobalSize(e.Container_fontscale, oldfontscale); draw_alpha *= e.Container_alpha; e.draw(e); draw_shift = oldshift; draw_scale = oldscale; + draw_fontscale = oldfontscale; draw_alpha = oldalpha; } }; diff --git a/data/qcsrc/menu/item/nexposee.c b/data/qcsrc/menu/item/nexposee.c index 84a979f88..75ebf3701 100644 --- a/data/qcsrc/menu/item/nexposee.c +++ b/data/qcsrc/menu/item/nexposee.c @@ -202,26 +202,11 @@ void drawNexposee(entity me) a = e.Nexposee_smallAlpha * (1 - me.animationFactor); } me.setAlphaOf(me, e, e.Container_alpha * (1 - f) + a * f); + + e.Container_fontscale = globalToBoxSize(e.Container_size, e.Nexposee_initialSize); } drawContainer(me); - - /* - for(e = me.firstChild; e; e = e.nextSibling) - { - vector t, fs; - a0 = e.Container_alpha; - if(a0 < e.Nexposee_smallAlpha) - a = 0.3 * (a0 - 0) / (e.Nexposee_smallAlpha - 0); - else if(a0 < e.Nexposee_mediumAlpha) - a = 0.3 + 0.5 * (a0 - e.Nexposee_smallAlpha) / (e.Nexposee_mediumAlpha - e.Nexposee_smallAlpha); - else - a = 0.8 - 0.8 * (a0 - e.Nexposee_mediumAlpha) / (1 - e.Nexposee_mediumAlpha); - fs = (eX * (1 / draw_scale_x) + eY * (1 / draw_scale_y)) * 36; - t = draw_TextWidth(e.title, FALSE) * eX * fs_x + eY * fs_y; - draw_Text(e.Container_origin + (e.Container_size_x * eX - t) * 0.5 - 0.5 * eY * t_y, e.title, fs, e.color, a, FALSE); - } - */ }; float mousePressNexposee(entity me, vector pos) -- 2.39.2