1 #ifndef CHECKBOX_SLIDER_INVALID_H
2 #define CHECKBOX_SLIDER_INVALID_H
3 #include "../item/checkbox.qc"
4 CLASS(XonoticSliderCheckBox, CheckBox)
5 METHOD(XonoticSliderCheckBox, configureXonoticSliderCheckBox, void(entity, float, float, entity, string))
6 METHOD(XonoticSliderCheckBox, setChecked, void(entity, float))
7 METHOD(XonoticSliderCheckBox, draw, void(entity))
8 ATTRIB(XonoticSliderCheckBox, fontSize, float, SKINFONTSIZE_NORMAL)
9 ATTRIB(XonoticSliderCheckBox, image, string, SKINGFX_CHECKBOX)
11 ATTRIB(XonoticSliderCheckBox, color, vector, SKINCOLOR_CHECKBOX_N)
12 ATTRIB(XonoticSliderCheckBox, colorC, vector, SKINCOLOR_CHECKBOX_C)
13 ATTRIB(XonoticSliderCheckBox, colorF, vector, SKINCOLOR_CHECKBOX_F)
14 ATTRIB(XonoticSliderCheckBox, colorD, vector, SKINCOLOR_CHECKBOX_D)
16 ATTRIB(XonoticSliderCheckBox, alpha, float, SKINALPHA_TEXT)
17 ATTRIB(XonoticSliderCheckBox, disabledAlpha, float, SKINALPHA_DISABLED)
19 ATTRIB(XonoticSliderCheckBox, controlledSlider, entity, NULL)
20 ATTRIB(XonoticSliderCheckBox, offValue, float, -1)
21 ATTRIB(XonoticSliderCheckBox, inverted, float, 0)
22 ATTRIB(XonoticSliderCheckBox, savedValue, float, -1)
23 ENDCLASS(XonoticSliderCheckBox)
24 entity makeXonoticSliderCheckBox(float, float, entity, string);
28 entity makeXonoticSliderCheckBox(float theOffValue, float isInverted, entity theControlledSlider, string theText)
31 me = NEW(XonoticSliderCheckBox);
32 me.configureXonoticSliderCheckBox(me, theOffValue, isInverted, theControlledSlider, theText);
35 void XonoticSliderCheckBox_configureXonoticSliderCheckBox(entity me, float theOffValue, float isInverted, entity theControlledSlider, string theText)
37 me.offValue = theOffValue;
38 me.inverted = isInverted;
39 me.checked = (theControlledSlider.value == theOffValue);
40 if(theControlledSlider.value == median(theControlledSlider.valueMin, theControlledSlider.value, theControlledSlider.valueMax))
41 me.savedValue = theControlledSlider.value;
43 me.savedValue = theControlledSlider.valueMin;
44 me.controlledSlider = theControlledSlider;
45 me.configureCheckBox(me, theText, me.fontSize, me.image);
46 me.tooltip = theControlledSlider.tooltip;
47 me.cvarName = theControlledSlider.cvarName; // in case we want to display the cvar in the tooltip
49 void XonoticSliderCheckBox_draw(entity me)
51 me.checked = ((me.controlledSlider.value == me.offValue) != me.inverted);
52 if(me.controlledSlider.value == median(me.controlledSlider.valueMin, me.controlledSlider.value, me.controlledSlider.valueMax))
53 me.savedValue = me.controlledSlider.value;
54 SUPER(XonoticSliderCheckBox).draw(me);
56 void XonoticSliderCheckBox_setChecked(entity me, float val)
61 if(val == me.inverted)
62 me.controlledSlider.setValue(me.controlledSlider, median(me.controlledSlider.valueMin, me.savedValue, me.controlledSlider.valueMax));
64 me.controlledSlider.setValue(me.controlledSlider, me.offValue);