2 CLASS(XonoticSliderCheckBox) EXTENDS(CheckBox)
3 METHOD(XonoticSliderCheckBox, configureXonoticSliderCheckBox, void(entity, float, float, entity, string))
4 METHOD(XonoticSliderCheckBox, setChecked, void(entity, float))
5 METHOD(XonoticSliderCheckBox, draw, void(entity))
6 ATTRIB(XonoticSliderCheckBox, fontSize, float, SKINFONTSIZE_NORMAL)
7 ATTRIB(XonoticSliderCheckBox, image, string, SKINGFX_CHECKBOX)
9 ATTRIB(XonoticSliderCheckBox, color, vector, SKINCOLOR_CHECKBOX_N)
10 ATTRIB(XonoticSliderCheckBox, colorC, vector, SKINCOLOR_CHECKBOX_C)
11 ATTRIB(XonoticSliderCheckBox, colorF, vector, SKINCOLOR_CHECKBOX_F)
12 ATTRIB(XonoticSliderCheckBox, colorD, vector, SKINCOLOR_CHECKBOX_D)
14 ATTRIB(XonoticSliderCheckBox, alpha, float, SKINALPHA_TEXT)
15 ATTRIB(XonoticSliderCheckBox, disabledAlpha, float, SKINALPHA_DISABLED)
17 ATTRIB(XonoticSliderCheckBox, controlledSlider, entity, NULL)
18 ATTRIB(XonoticSliderCheckBox, offValue, float, -1)
19 ATTRIB(XonoticSliderCheckBox, inverted, float, 0)
20 ATTRIB(XonoticSliderCheckBox, savedValue, float, -1)
21 ENDCLASS(XonoticSliderCheckBox)
22 entity makeXonoticSliderCheckBox(float, float, entity, string);
26 entity makeXonoticSliderCheckBox(float theOffValue, float isInverted, entity theControlledSlider, string theText)
29 me = spawnXonoticSliderCheckBox();
30 me.configureXonoticSliderCheckBox(me, theOffValue, isInverted, theControlledSlider, theText);
33 void XonoticSliderCheckBox_configureXonoticSliderCheckBox(entity me, float theOffValue, float isInverted, entity theControlledSlider, string theText)
35 me.offValue = theOffValue;
36 me.inverted = isInverted;
37 me.checked = (theControlledSlider.value == theOffValue);
38 if(theControlledSlider.value == median(theControlledSlider.valueMin, theControlledSlider.value, theControlledSlider.valueMax))
39 me.savedValue = theControlledSlider.value;
41 me.savedValue = theControlledSlider.valueMin;
42 me.controlledSlider = theControlledSlider;
43 me.configureCheckBox(me, theText, me.fontSize, me.image);
44 me.tooltip = theControlledSlider.tooltip;
45 me.cvarName = theControlledSlider.cvarName; // in case we want to display the cvar in the tooltip
47 void XonoticSliderCheckBox_draw(entity me)
49 me.checked = ((me.controlledSlider.value == me.offValue) != me.inverted);
50 if(me.controlledSlider.value == median(me.controlledSlider.valueMin, me.controlledSlider.value, me.controlledSlider.valueMax))
51 me.savedValue = me.controlledSlider.value;
52 SUPER(XonoticSliderCheckBox).draw(me);
54 void XonoticSliderCheckBox_setChecked(entity me, float val)
59 if(val == me.inverted)
60 me.controlledSlider.setValue(me.controlledSlider, median(me.controlledSlider.valueMin, me.savedValue, me.controlledSlider.valueMax));
62 me.controlledSlider.setValue(me.controlledSlider, me.offValue);