2 CLASS(XonoticRadioButton) EXTENDS(RadioButton)
3 METHOD(XonoticRadioButton, configureXonoticRadioButton, void(entity, float, string, string, string))
4 METHOD(XonoticRadioButton, draw, void(entity))
5 METHOD(XonoticRadioButton, setChecked, void(entity, float))
6 ATTRIB(XonoticRadioButton, fontSize, float, SKINFONTSIZE_NORMAL)
7 ATTRIB(XonoticRadioButton, image, string, SKINGFX_RADIOBUTTON)
8 ATTRIB(XonoticRadioButton, color, vector, SKINCOLOR_RADIOBUTTON_N)
9 ATTRIB(XonoticRadioButton, colorC, vector, SKINCOLOR_RADIOBUTTON_C)
10 ATTRIB(XonoticRadioButton, colorF, vector, SKINCOLOR_RADIOBUTTON_F)
11 ATTRIB(XonoticRadioButton, colorD, vector, SKINCOLOR_RADIOBUTTON_D)
13 ATTRIB(XonoticRadioButton, cvarName, string, string_null)
14 ATTRIB(XonoticRadioButton, cvarValue, string, string_null)
15 ATTRIB(XonoticRadioButton, cvarOffValue, string, string_null)
16 ATTRIB(XonoticRadioButton, getCvarValueFromCvar, float, 0)
17 METHOD(XonoticRadioButton, loadCvars, void(entity))
18 METHOD(XonoticRadioButton, saveCvars, void(entity))
20 ATTRIB(XonoticRadioButton, alpha, float, SKINALPHA_TEXT)
21 ATTRIB(XonoticRadioButton, disabledAlpha, float, SKINALPHA_DISABLED)
22 ENDCLASS(XonoticRadioButton)
23 entity makeXonoticRadioButton(float, string, string, string);
27 entity makeXonoticRadioButton(float theGroup, string theCvar, string theValue, string theText)
30 me = spawnXonoticRadioButton();
31 me.configureXonoticRadioButton(me, theGroup, theCvar, theValue, theText);
34 void XonoticRadioButton_configureXonoticRadioButton(entity me, float theGroup, string theCvar, string theValue, string theText)
38 me.cvarName = theCvar;
39 me.cvarValue = theValue;
40 me.tooltip = getZonedTooltipForIdentifier(theCvar);
43 me.configureRadioButton(me, theText, me.fontSize, me.image, theGroup, 0);
45 void XonoticRadioButton_setChecked(entity me, float val)
53 void XonoticRadioButton_loadCvars(entity me)
58 me.checked = (cvar_string(me.cvarName) == me.cvarValue);
64 me.checked = !!cvar(me.cvarName);
69 // this is the "generic" selection... but at this time, not
70 // everything is constructed yet.
71 // we need to set this later in draw()
76 void XonoticRadioButton_draw(entity me)
81 // this is the "other" option
82 // always select this if none other is
86 for(e = me.parent.firstChild; e; e = e.nextSibling)
87 if(e.group == me.group)
93 SUPER(XonoticRadioButton).draw(me);
95 void XonoticRadioButton_saveCvars(entity me)
103 if(me.getCvarValueFromCvar)
104 cvar_set(me.cvarName, cvar_string(me.cvarValue));
106 cvar_set(me.cvarName, me.cvarValue);
108 else if(me.cvarOffValue)
109 cvar_set(me.cvarName, me.cvarOffValue);
116 cvar_set(me.cvarName, ftos(me.checked));