From a9d919352a88805a3b8f83a206f43e9db72994a2 Mon Sep 17 00:00:00 2001 From: terencehill Date: Mon, 8 Nov 2010 01:12:07 +0100 Subject: [PATCH] Colorpickers now load and remember (when they get re-enabled) the color position --- qcsrc/menu/xonotic/colorpicker.c | 19 +++++++++++++++++++ qcsrc/menu/xonotic/colorpicker_string.c | 6 ++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/qcsrc/menu/xonotic/colorpicker.c b/qcsrc/menu/xonotic/colorpicker.c index b888358c3..66f292a03 100644 --- a/qcsrc/menu/xonotic/colorpicker.c +++ b/qcsrc/menu/xonotic/colorpicker.c @@ -51,6 +51,25 @@ vector hslimage_color(vector v, vector margin) return hsl_to_rgb(v_x * 6 * eX + eY + v_y / 0.875 * eZ); } +vector color_hslimage(vector v, vector margin) +{ + vector pos; + v = rgb_to_hsl(v); + if (v_y) + { + pos_x = v_x / 6; + pos_y = v_z * 0.875; + } + else // grey scale + { + pos_x = v_z; + pos_y = 0.875 + 0.07; + } + pos_x = margin_x + pos_x * (1 - 2 * margin_x); + pos_y = margin_y + pos_y * (1 - 2 * margin_y); + return pos; +} + float XonoticColorpicker_mouseDrag(entity me, vector coords) { float i; diff --git a/qcsrc/menu/xonotic/colorpicker_string.c b/qcsrc/menu/xonotic/colorpicker_string.c index 363355304..fd411d545 100644 --- a/qcsrc/menu/xonotic/colorpicker_string.c +++ b/qcsrc/menu/xonotic/colorpicker_string.c @@ -28,7 +28,7 @@ void XonoticColorpickerString_configureXonoticColorpickerString(entity me, strin { me.cvarName = theCvar; me.configureImage(me, me.image); - me.prevcoords = '1 1 0'; + me.prevcoords = color_hslimage(stov(cvar_string(theCvar)), me.imagemargin); } float XonoticColorpickerString_mousePress(entity me, vector coords) @@ -74,9 +74,7 @@ void XonoticColorpickerString_draw(entity me) sz = draw_PictureSize(strcat(me.src, "_selected")); sz = globalToBoxSize(sz, draw_scale); - if(me.disabled) - me.prevcoords = '1 1 0'; - else + if(!me.disabled) draw_Picture(me.imgOrigin + me.prevcoords - 0.5 * sz, strcat(me.src, "_selected"), sz, '1 1 1', 1); draw_alpha = save; } -- 2.39.2