2 CLASS(XonoticCrosshairButton) EXTENDS(RadioButton)
3 METHOD(XonoticCrosshairButton, configureXonoticCrosshairButton, void(entity, float, float))
4 METHOD(XonoticCrosshairButton, setChecked, void(entity, float))
5 METHOD(XonoticCrosshairButton, draw, void(entity))
6 ATTRIB(XonoticCrosshairButton, fontSize, float, SKINFONTSIZE_NORMAL)
7 ATTRIB(XonoticCrosshairButton, image, string, SKINGFX_CROSSHAIRBUTTON)
9 ATTRIB(XonoticCrosshairButton, useDownAsChecked, float, 1)
10 ATTRIB(XonoticCrosshairButton, src3, string, string_null)
12 ATTRIB(XonoticCrosshairButton, cvarName, string, string_null)
13 ATTRIB(XonoticCrosshairButton, cvarValueFloat, float, 0)
14 METHOD(XonoticCrosshairButton, loadCvars, void(entity))
15 METHOD(XonoticCrosshairButton, saveCvars, void(entity))
16 ENDCLASS(XonoticCrosshairButton)
17 entity makeXonoticCrosshairButton(float, float);
21 entity makeXonoticCrosshairButton(float theGroup, float theCrosshair)
24 me = spawnXonoticCrosshairButton();
25 me.configureXonoticCrosshairButton(me, theGroup, theCrosshair);
28 void XonoticCrosshairButton_configureXonoticCrosshairButton(entity me, float theGroup, float theCrosshair)
30 me.cvarName = "crosshair";
31 me.cvarValueFloat = theCrosshair;
33 me.configureRadioButton(me, string_null, me.fontSize, me.image, theGroup, 0);
35 me.src3 = strzone(strcat("/gfx/crosshair", ftos(me.cvarValueFloat)));
37 void XonoticCrosshairButton_setChecked(entity me, float val)
45 void XonoticCrosshairButton_loadCvars(entity me)
50 me.checked = (cvar(me.cvarName) == me.cvarValueFloat);
52 void XonoticCrosshairButton_saveCvars(entity me)
58 cvar_set(me.cvarName, ftos(me.cvarValueFloat));
59 // TODO on an apply button, read _cl_color and execute the color command for it
61 void XonoticCrosshairButton_draw(entity me)
66 rgb = eX * cvar("crosshair_color_red") + eY * cvar("crosshair_color_green") + eZ * cvar("crosshair_color_blue");
67 a = cvar("crosshair_color_alpha");
69 if(!me.checked && !me.focused)
71 a *= me.disabledAlpha;
75 SUPER(XonoticCrosshairButton).draw(me);
77 sz = draw_PictureSize(me.src3);
78 sz = globalToBoxSize(sz, draw_scale);
79 sz = sz * cvar("crosshair_size");
81 sz = sz * (0.95 / sz_x);
83 sz = sz * (0.95 / sz_y);
85 draw_Picture('0.5 0.5 0' - 0.5 * sz, me.src3, sz, rgb, a);