From: FruitieX Date: Fri, 12 Nov 2010 07:24:46 +0000 (+0200) Subject: implement a crosshair preview in the playersetup dialog X-Git-Tag: xonotic-v0.1.0preview~134^2~1 X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=commitdiff_plain;h=78b09b7243662c83f1870fe8a2dc268b0e5d43bd implement a crosshair preview in the playersetup dialog --- diff --git a/qcsrc/menu/xonotic/crosshairbutton.c b/qcsrc/menu/xonotic/crosshairbutton.c index 7ed683d01..134551726 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; @@ -68,21 +72,34 @@ void XonoticCrosshairButton_draw(entity me) 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; + } + 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")) diff --git a/qcsrc/menu/xonotic/dialog_multiplayer_playersetup.c b/qcsrc/menu/xonotic/dialog_multiplayer_playersetup.c index 4f51f957a..4cde74ed2 100644 --- a/qcsrc/menu/xonotic/dialog_multiplayer_playersetup.c +++ b/qcsrc/menu/xonotic/dialog_multiplayer_playersetup.c @@ -112,13 +112,16 @@ void XonoticPlayerSettingsTab_fill(entity me) me.TD(me, 1, 1, e = makeXonoticTextLabel(0, "Crosshair:")); me.TD(me, 1, 2, e = makeXonoticCheckBox(0, "crosshair_per_weapon", "Per weapon")); me.TR(me); - me.TDempty(me, 0.5); + me.TDempty(me, 0.2); for(i = 1; i <= 10; ++i) { me.TDNoMargin(me, 1, 2 / 10, e = makeXonoticCrosshairButton(3, i), '1 1 0'); setDependent(e, "crosshair_per_weapon", 0, 0); } + // show a larger preview of the selected crosshair + me.TDempty(me, 0.2); + me.TDNoMargin(me, 2, 2 / 5, e = makeXonoticCrosshairButton(3, -1), '1 1 0'); // crosshair -1 makes this a preview me.TR(me); - me.TDempty(me, 0.5); + me.TDempty(me, 0.2); for(i = 11; i <= 20; ++i) { me.TDNoMargin(me, 1, 2 / 10, e = makeXonoticCrosshairButton(3, i), '1 1 0'); setDependent(e, "crosshair_per_weapon", 0, 0);