From: MirceaKitsune Date: Sun, 6 Nov 2011 15:05:22 +0000 (+0200) Subject: Properly get the string colorpicker working X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=0dca35dc39742e6a4cbf563a9e345632704431cc;p=voretournament%2Fvoretournament.git Properly get the string colorpicker working --- diff --git a/data/qcsrc/menu/mbuiltin.qh b/data/qcsrc/menu/mbuiltin.qh index 84be8012..7c255884 100644 --- a/data/qcsrc/menu/mbuiltin.qh +++ b/data/qcsrc/menu/mbuiltin.qh @@ -348,3 +348,5 @@ string(float, float) getgamedirinfo = #626; #define GETGAMEDIRINFO_NAME 0 #define GETGAMEDIRINFO_DESCRIPTION 1 float log(float f) = #532; + +string(string format, ...) sprintf = #627; diff --git a/data/qcsrc/menu/voret/colorpicker_string.c b/data/qcsrc/menu/voret/colorpicker_string.c index c94faba3..2e0baf20 100644 --- a/data/qcsrc/menu/voret/colorpicker_string.c +++ b/data/qcsrc/menu/voret/colorpicker_string.c @@ -9,9 +9,8 @@ CLASS(VoretColorpickerString) EXTENDS(Image) ATTRIB(VoretColorpickerString, image, string, SKINGFX_COLORPICKER) ATTRIB(VoretColorpickerString, imagemargin, vector, SKINMARGIN_COLORPICKER) ATTRIB(VoretColorpickerString, focusable, float, 1) - METHOD(VoretColorpickerString, focusLeave, void(entity)) - METHOD(VoretColorpickerString, keyDown, float(entity, float, float, float)) METHOD(VoretColorpickerString, draw, void(entity)) + ATTRIB(VoretColorpickerString, disabledAlpha, float, 0.3) ENDCLASS(VoretColorpickerString) entity makeVoretColorpickerString(string theCvar, string theDefaultCvar); #endif @@ -41,9 +40,6 @@ float mousePressVoretColorpickerString(entity me, vector coords) return 1; } -// must match hslimage.c - - float mouseDragVoretColorpickerString(entity me, vector coords) { if(me.disabled) @@ -67,32 +63,24 @@ float mouseReleaseVoretColorpickerString(entity me, vector coords) return 1; } -void focusLeaveVoretColorpickerString(entity me) -{ - me.controlledTextbox.saveCvars(me.controlledTextbox); -} -float keyDownVoretColorpickerString(entity me, float key, float ascii, float shift) -{ - return me.controlledTextbox.keyDown(me.controlledTextbox, key, ascii, shift); -} void drawVoretColorpickerString(entity me) { - drawImage(me); - - float B, C, aC; - C = cvar("r_textcontrast"); - B = cvar("r_textbrightness"); + float save; + save = draw_alpha; + if(me.disabled) + draw_alpha *= me.disabledAlpha; - // for this to work, C/(1-B) must be in 0..1 - // B must be < 1 - // C must be < 1-B - - B = bound(0, B, 1); - C = bound(0, C, 1-B); + drawImage(me); - aC = 1 - C / (1 - B); + vector sz; + sz = draw_PictureSize(strcat(me.src, "_selected")); + sz = globalToBoxSize(sz, draw_scale); - draw_Picture(me.imgOrigin, strcat(me.src, "_m"), me.imgSize, '0 0 0', aC); - draw_Picture(me.imgOrigin, strcat(me.src, "_m"), me.imgSize, me.color, B); + if(!me.disabled) + { + cvar_set(me.cvarName, sprintf("%v", hslimage_color(me.prevcoords, me.imagemargin))); + draw_Picture(me.imgOrigin + me.prevcoords - 0.5 * sz, strcat(me.src, "_selected"), sz, '1 0 1', 1); + } + draw_alpha = save; } #endif