1 #include "radiobutton.qh"
3 entity makeXonoticRadioButton_T(float theGroup, string theCvar, string theValue, string theText, string theTooltip)
6 me = NEW(XonoticRadioButton);
7 me.configureXonoticRadioButton(me, theGroup, theCvar, theValue, theText, theTooltip);
10 entity makeXonoticRadioButton(float theGroup, string theCvar, string theValue, string theText)
12 return makeXonoticRadioButton_T(theGroup, theCvar, theValue, theText, string_null);
14 void XonoticRadioButton_configureXonoticRadioButton(entity me, float theGroup, string theCvar, string theValue, string theText, string theTooltip)
16 me.controlledCvar = (theCvar) ? theCvar : string_null;
17 me.cvarValue = theValue;
19 setZonedTooltip(me, theTooltip, theCvar);
20 me.configureRadioButton(me, theText, me.fontSize, me.image, theGroup, 0);
22 void XonoticRadioButton_setChecked(entity me, float val)
30 void XonoticRadioButton_loadCvars(entity me)
36 if(me.cvarValueIsAnotherCvar)
37 me.checked = (cvar_string(me.controlledCvar) == cvar_string(me.cvarValue));
39 me.checked = (cvar_string(me.controlledCvar) == me.cvarValue);
46 me.checked = boolean(cvar(me.controlledCvar));
51 // this is the "generic" selection... but at this time, not
52 // everything is constructed yet.
53 // we need to set this later in draw()
58 void XonoticRadioButton_draw(entity me)
61 if (!me.controlledCvar)
63 // this is the "other" option
64 // always select this if none other is
68 for(e = me.parent.firstChild; e; e = e.nextSibling)
69 if(e.group == me.group)
75 SUPER(XonoticRadioButton).draw(me);
77 void XonoticRadioButton_saveCvars(entity me)
85 if(me.cvarValueIsAnotherCvar)
86 cvar_set(me.controlledCvar, cvar_string(me.cvarValue));
88 cvar_set(me.controlledCvar, me.cvarValue);
90 else if(me.cvarOffValue)
91 cvar_set(me.controlledCvar, me.cvarOffValue);
98 cvar_set(me.controlledCvar, ftos(me.checked));