X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fmenu%2Fdraw.qc;h=ae6967e367565fc02c38f08f57c77ac0ccca706d;hb=a0a09daade95eb6c4a0ad85680440392ae4f6e6a;hp=05e7af227adccb9040870bc7e690e405a7b1d400;hpb=244e5081c5c503c307e557c98ac864f6c9731475;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/menu/draw.qc b/qcsrc/menu/draw.qc index 05e7af227..ae6967e36 100644 --- a/qcsrc/menu/draw.qc +++ b/qcsrc/menu/draw.qc @@ -1,7 +1,6 @@ -#if defined(CSQC) -#elif defined(MENUQC) -#elif defined(SVQC) -#endif +#include "draw.qh" +#include "../common/util.qh" +#include "../common/constants.qh" string draw_mousepointer; vector draw_mousepointer_offset; @@ -28,16 +27,6 @@ void draw_reset(float cw, float ch, float ox, float oy) draw_endBoldFont(); } -void draw_beginBoldFont() -{ - drawfont = FONT_USER+3; -} - -void draw_endBoldFont() -{ - drawfont = FONT_USER+0; -} - vector globalToBox(vector v, vector theOrigin, vector theScale) { v -= theOrigin; @@ -282,7 +271,7 @@ 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) { if(theSize.x <= 0 || theSize.y <= 0) { - dprint("Drawing zero size text?\n"); + LOG_TRACE("Drawing zero size text?"); return; } @@ -323,32 +312,55 @@ float draw_CondensedFontFactor(string theText, float ICanHasKallerz, vector Size return 1.0; } -float draw_clipSet; +IntrusiveList draw_clip; +STATIC_INIT(draw_clip) { draw_clip = IL_NEW(); } +CLASS(ClipFrame, Object) + ATTRIB(ClipFrame, clip_shift, vector, '0 0 0'); + ATTRIB(ClipFrame, clip_scale, vector, '0 0 0'); +ENDCLASS(ClipFrame) + +void _draw_SetClip(vector o, vector s) +{ + ClipFrame prev = IL_PEEK(draw_clip); + if (prev) { + o.x = bound(prev.clip_shift.x, o.x, prev.clip_shift.x + prev.clip_scale.x); + o.y = bound(prev.clip_shift.y, o.y, prev.clip_shift.y + prev.clip_scale.y); + s.x = bound(0, s.x, prev.clip_scale.x - (o.x - prev.clip_shift.x)); + s.y = bound(0, s.y, prev.clip_scale.y - (o.y - prev.clip_shift.y)); + } + ClipFrame e = NEW(ClipFrame); + e.clip_shift = o; + e.clip_scale = s; + IL_PUSH(draw_clip, e); + drawsetcliparea(o.x, o.y, s.x, s.y); +} + void draw_SetClip() { - if(draw_clipSet) - error("Already clipping, no stack implemented here, sorry"); - drawsetcliparea(draw_shift.x, draw_shift.y, draw_scale.x, draw_scale.y); - draw_clipSet = 1; + _draw_SetClip(draw_shift, draw_scale); } void draw_SetClipRect(vector theOrigin, vector theScale) { - vector o, s; - if(draw_clipSet) - error("Already clipping, no stack implemented here, sorry"); - o = boxToGlobal(theOrigin, draw_shift, draw_scale); - s = boxToGlobalSize(theScale, draw_scale); - drawsetcliparea(o.x, o.y, s.x, s.y); - draw_clipSet = 1; + _draw_SetClip( + boxToGlobal(theOrigin, draw_shift, draw_scale), + boxToGlobalSize(theScale, draw_scale) + ); } void draw_ClearClip() { - if(!draw_clipSet) - error("Not clipping, can't clear it then"); + if (IL_EMPTY(draw_clip)) { + LOG_FATAL("Not clipping, can't clear it then"); + } + entity currentSettings = IL_PEEK(draw_clip); + IL_REMOVE(draw_clip, currentSettings); + delete(currentSettings); drawresetcliparea(); - draw_clipSet = 0; + ClipFrame e = IL_PEEK(draw_clip); + if (e) { + drawsetcliparea(e.clip_shift.x, e.clip_shift.y, e.clip_scale.x, e.clip_scale.y); + } } string draw_TextShortenToWidth(string theText, float maxWidth, float ICanHasKallerz, vector SizeThxBye)