X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fmenu%2Fxonotic%2Fcrosshairbutton.c;h=26b9bcb8f52361d9a60b9ea794ec3de95a7be8a3;hp=058bfd7eb16638eb4722631ce48d2f022685050d;hb=b8c567206f094ca55fee1a7186e35dd2a9eed5aa;hpb=d2509861580bce6e6f1ffc9e9a26aea2d70b6756 diff --git a/qcsrc/menu/xonotic/crosshairbutton.c b/qcsrc/menu/xonotic/crosshairbutton.c index 058bfd7eb..26b9bcb8f 100644 --- a/qcsrc/menu/xonotic/crosshairbutton.c +++ b/qcsrc/menu/xonotic/crosshairbutton.c @@ -33,11 +33,15 @@ void XonoticCrosshairButton_configureXonoticCrosshairButton(entity me, float the me.loadCvars(me); me.configureRadioButton(me, string_null, me.fontSize, me.image, theGroup, 0); me.srcMulti = 1; - me.src3 = strzone(strcat("/gfx/crosshair", ftos(me.cvarValueFloat))); + if(me.cvarValueFloat == -1) + me.src3 = strzone(strcat("/gfx/crosshair", cvar("crosshair"))); + else + me.src3 = strzone(strcat("/gfx/crosshair", ftos(me.cvarValueFloat))); me.src4 = "/gfx/crosshairdot"; } void XonoticCrosshairButton_setChecked(entity me, float val) { + if(me.cvarValueFloat != -1) // preview shouldn't work as a button if(val != me.checked) { me.checked = val; @@ -65,24 +69,38 @@ void XonoticCrosshairButton_draw(entity me) vector sz, rgb; float a; - rgb = eX * cvar("crosshair_color_red") + eY * cvar("crosshair_color_green") + eZ * cvar("crosshair_color_blue"); - a = cvar("crosshair_color_alpha"); + rgb = stov(cvar_string("crosshair_color")); + a = cvar("crosshair_alpha"); - if(!me.checked && !me.focused) + if(!me.checked && !me.focused && me.cvarValueFloat != -1) { a *= me.disabledAlpha; rgb = '1 1 1'; } + if(me.cvarValueFloat == -1) // update the preview if this is the preview button + { + if(me.src3) + strunzone(me.src3); + me.src3 = strzone(strcat("/gfx/crosshair", cvar_string("crosshair"))); + me.focused = 1; + me.checked = 0; + } + SUPER(XonoticCrosshairButton).draw(me); sz = draw_PictureSize(me.src3); sz = globalToBoxSize(sz, draw_scale); - sz = (10 * '1 1 0' + sz * cvar("crosshair_size")) * 0.05; // (10 * '1 1 0' + ...) * 0.05 here to make visible size changes happen also at bigger sizes - if(sz_x > 0.95) - sz = sz * (0.95 / sz_x); - if(sz_y > 0.95) - sz = sz * (0.95 / sz_y); + if(me.cvarValueFloat == -1) + { + sz = (6 * '1 1 0' + sz * cvar("crosshair_size")) * 0.08; // (6 * '1 1 0' + ...) * 0.08 here to make visible size changes happen also at bigger sizes + if(sz_x > 0.95) + sz = sz * (0.95 / sz_x); + if(sz_y > 0.95) + sz = sz * (0.95 / sz_y); + } + else // show the crosshair picker at full size + sz = '0.95 0.95 0'; draw_Picture('0.5 0.5 0' - 0.5 * sz, me.src3, sz, rgb, a); if(cvar("crosshair_dot"))