[nexuiz-commits] r8454 - in trunk/data/qcsrc/menu: . item
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Fri Dec 25 10:19:25 EST 2009
Author: div0
Date: 2009-12-25 10:19:24 -0500 (Fri, 25 Dec 2009)
New Revision: 8454
Modified:
trunk/data/qcsrc/menu/draw.qc
trunk/data/qcsrc/menu/draw.qh
trunk/data/qcsrc/menu/item/container.c
trunk/data/qcsrc/menu/item/nexposee.c
Log:
use draw_fontscale in nexposee for fixing the text scale effect... sorry for that, blub
Modified: trunk/data/qcsrc/menu/draw.qc
===================================================================
--- trunk/data/qcsrc/menu/draw.qc 2009-12-25 08:43:47 UTC (rev 8453)
+++ trunk/data/qcsrc/menu/draw.qc 2009-12-25 15:19:24 UTC (rev 8454)
@@ -28,6 +28,7 @@
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_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 @@
{
//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;
Modified: trunk/data/qcsrc/menu/draw.qh
===================================================================
--- trunk/data/qcsrc/menu/draw.qh 2009-12-25 08:43:47 UTC (rev 8453)
+++ trunk/data/qcsrc/menu/draw.qh 2009-12-25 15:19:24 UTC (rev 8454)
@@ -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);
Modified: trunk/data/qcsrc/menu/item/container.c
===================================================================
--- trunk/data/qcsrc/menu/item/container.c 2009-12-25 08:43:47 UTC (rev 8453)
+++ trunk/data/qcsrc/menu/item/container.c 2009-12-25 15:19:24 UTC (rev 8454)
@@ -31,6 +31,7 @@
.float resized;
.vector Container_origin;
.vector Container_size;
+.vector Container_fontscale;
.float Container_alpha;
#endif
@@ -127,11 +128,13 @@
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 @@
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;
}
};
Modified: trunk/data/qcsrc/menu/item/nexposee.c
===================================================================
--- trunk/data/qcsrc/menu/item/nexposee.c 2009-12-25 08:43:47 UTC (rev 8453)
+++ trunk/data/qcsrc/menu/item/nexposee.c 2009-12-25 15:19:24 UTC (rev 8454)
@@ -202,26 +202,11 @@
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)
More information about the nexuiz-commits
mailing list