1 #include "radiobutton.qh"
4 #include "../item/radiobutton.qc"
5 CLASS(XonoticRadioButton, RadioButton)
6 METHOD(XonoticRadioButton, configureXonoticRadioButton, void(entity, float, string, string, string, string));
7 METHOD(XonoticRadioButton, draw, void(entity));
8 METHOD(XonoticRadioButton, setChecked, void(entity, float));
9 ATTRIB(XonoticRadioButton, fontSize, float, SKINFONTSIZE_NORMAL)
10 ATTRIB(XonoticRadioButton, image, string, SKINGFX_RADIOBUTTON)
11 ATTRIB(XonoticRadioButton, color, vector, SKINCOLOR_RADIOBUTTON_N)
12 ATTRIB(XonoticRadioButton, colorC, vector, SKINCOLOR_RADIOBUTTON_C)
13 ATTRIB(XonoticRadioButton, colorF, vector, SKINCOLOR_RADIOBUTTON_F)
14 ATTRIB(XonoticRadioButton, colorD, vector, SKINCOLOR_RADIOBUTTON_D)
16 ATTRIB(XonoticRadioButton, cvarName, string, string_null)
17 ATTRIB(XonoticRadioButton, cvarValue, string, string_null)
18 ATTRIB(XonoticRadioButton, cvarOffValue, string, string_null)
19 ATTRIB(XonoticRadioButton, cvarValueIsAnotherCvar, float, 0)
20 METHOD(XonoticRadioButton, loadCvars, void(entity));
21 METHOD(XonoticRadioButton, saveCvars, void(entity));
23 ATTRIB(XonoticRadioButton, alpha, float, SKINALPHA_TEXT)
24 ATTRIB(XonoticRadioButton, disabledAlpha, float, SKINALPHA_DISABLED)
25 ENDCLASS(XonoticRadioButton)
26 entity makeXonoticRadioButton_T(float, string, string, string, string theTooltip);
27 entity makeXonoticRadioButton(float, string, string, string);
31 entity makeXonoticRadioButton_T(float theGroup, string theCvar, string theValue, string theText, string theTooltip)
34 me = NEW(XonoticRadioButton);
35 me.configureXonoticRadioButton(me, theGroup, theCvar, theValue, theText, theTooltip);
38 entity makeXonoticRadioButton(float theGroup, string theCvar, string theValue, string theText)
40 return makeXonoticRadioButton_T(theGroup, theCvar, theValue, theText, string_null);
42 void XonoticRadioButton_configureXonoticRadioButton(entity me, float theGroup, string theCvar, string theValue, string theText, string theTooltip)
44 me.cvarName = (theCvar) ? theCvar : string_null;
45 me.cvarValue = theValue;
47 setZonedTooltip(me, theTooltip, theCvar);
48 me.configureRadioButton(me, theText, me.fontSize, me.image, theGroup, 0);
50 void XonoticRadioButton_setChecked(entity me, float val)
58 void XonoticRadioButton_loadCvars(entity me)
64 if(me.cvarValueIsAnotherCvar)
65 me.checked = (cvar_string(me.cvarName) == cvar_string(me.cvarValue));
67 me.checked = (cvar_string(me.cvarName) == me.cvarValue);
74 me.checked = boolean(cvar(me.cvarName));
79 // this is the "generic" selection... but at this time, not
80 // everything is constructed yet.
81 // we need to set this later in draw()
86 void XonoticRadioButton_draw(entity me)
91 // this is the "other" option
92 // always select this if none other is
96 for(e = me.parent.firstChild; e; e = e.nextSibling)
97 if(e.group == me.group)
101 me.setChecked(me, 1);
103 SUPER(XonoticRadioButton).draw(me);
105 void XonoticRadioButton_saveCvars(entity me)
113 if(me.cvarValueIsAnotherCvar)
114 cvar_set(me.cvarName, cvar_string(me.cvarValue));
116 cvar_set(me.cvarName, me.cvarValue);
118 else if(me.cvarOffValue)
119 cvar_set(me.cvarName, me.cvarOffValue);
126 cvar_set(me.cvarName, ftos(me.checked));