1 #include "checkbox_slider_invalid.qh"
2 #ifndef CHECKBOX_SLIDER_INVALID_H
3 #define CHECKBOX_SLIDER_INVALID_H
4 #include "../item/checkbox.qc"
5 CLASS(XonoticSliderCheckBox, CheckBox)
6 METHOD(XonoticSliderCheckBox, configureXonoticSliderCheckBox, void(entity, float, float, entity, string));
7 METHOD(XonoticSliderCheckBox, setChecked, void(entity, float));
8 METHOD(XonoticSliderCheckBox, draw, void(entity));
9 ATTRIB(XonoticSliderCheckBox, fontSize, float, SKINFONTSIZE_NORMAL)
10 ATTRIB(XonoticSliderCheckBox, image, string, SKINGFX_CHECKBOX)
12 ATTRIB(XonoticSliderCheckBox, color, vector, SKINCOLOR_CHECKBOX_N)
13 ATTRIB(XonoticSliderCheckBox, colorC, vector, SKINCOLOR_CHECKBOX_C)
14 ATTRIB(XonoticSliderCheckBox, colorF, vector, SKINCOLOR_CHECKBOX_F)
15 ATTRIB(XonoticSliderCheckBox, colorD, vector, SKINCOLOR_CHECKBOX_D)
17 ATTRIB(XonoticSliderCheckBox, alpha, float, SKINALPHA_TEXT)
18 ATTRIB(XonoticSliderCheckBox, disabledAlpha, float, SKINALPHA_DISABLED)
20 ATTRIB(XonoticSliderCheckBox, controlledSlider, entity, NULL)
21 ATTRIB(XonoticSliderCheckBox, offValue, float, -1)
22 ATTRIB(XonoticSliderCheckBox, inverted, float, 0)
23 ATTRIB(XonoticSliderCheckBox, savedValue, float, -1)
24 ENDCLASS(XonoticSliderCheckBox)
25 entity makeXonoticSliderCheckBox(float, float, entity, string);
29 entity makeXonoticSliderCheckBox(float theOffValue, float isInverted, entity theControlledSlider, string theText)
32 me = NEW(XonoticSliderCheckBox);
33 me.configureXonoticSliderCheckBox(me, theOffValue, isInverted, theControlledSlider, theText);
36 void XonoticSliderCheckBox_configureXonoticSliderCheckBox(entity me, float theOffValue, float isInverted, entity theControlledSlider, string theText)
38 me.offValue = theOffValue;
39 me.inverted = isInverted;
40 me.checked = (theControlledSlider.value == theOffValue);
41 if(theControlledSlider.value == median(theControlledSlider.valueMin, theControlledSlider.value, theControlledSlider.valueMax))
42 me.savedValue = theControlledSlider.value;
44 me.savedValue = theControlledSlider.valueMin;
45 me.controlledSlider = theControlledSlider;
46 me.configureCheckBox(me, theText, me.fontSize, me.image);
47 me.cvarName = theControlledSlider.cvarName; // in case we want to display the cvar in the tooltip
48 me.tooltip = theControlledSlider.tooltip;
50 void XonoticSliderCheckBox_draw(entity me)
52 me.checked = ((me.controlledSlider.value == me.offValue) != me.inverted);
53 if(me.controlledSlider.value == median(me.controlledSlider.valueMin, me.controlledSlider.value, me.controlledSlider.valueMax))
54 me.savedValue = me.controlledSlider.value;
55 SUPER(XonoticSliderCheckBox).draw(me);
57 void XonoticSliderCheckBox_setChecked(entity me, float val)
62 if(val == me.inverted)
63 me.controlledSlider.setValue(me.controlledSlider, median(me.controlledSlider.valueMin, me.savedValue, me.controlledSlider.valueMax));
65 me.controlledSlider.setValue(me.controlledSlider, me.offValue);