3 #include "../item/radiobutton.qc"
4 CLASS(XonoticRadioButton, RadioButton)
5 METHOD(XonoticRadioButton, configureXonoticRadioButton, void(entity, float, string, string, string, string));
6 METHOD(XonoticRadioButton, draw, void(entity));
7 METHOD(XonoticRadioButton, setChecked, void(entity, float));
8 ATTRIB(XonoticRadioButton, fontSize, float, SKINFONTSIZE_NORMAL)
9 ATTRIB(XonoticRadioButton, image, string, SKINGFX_RADIOBUTTON)
10 ATTRIB(XonoticRadioButton, color, vector, SKINCOLOR_RADIOBUTTON_N)
11 ATTRIB(XonoticRadioButton, colorC, vector, SKINCOLOR_RADIOBUTTON_C)
12 ATTRIB(XonoticRadioButton, colorF, vector, SKINCOLOR_RADIOBUTTON_F)
13 ATTRIB(XonoticRadioButton, colorD, vector, SKINCOLOR_RADIOBUTTON_D)
15 ATTRIB(XonoticRadioButton, cvarName, string, string_null)
16 ATTRIB(XonoticRadioButton, cvarValue, string, string_null)
17 ATTRIB(XonoticRadioButton, cvarOffValue, string, string_null)
18 ATTRIB(XonoticRadioButton, cvarValueIsAnotherCvar, float, 0)
19 METHOD(XonoticRadioButton, loadCvars, void(entity));
20 METHOD(XonoticRadioButton, saveCvars, void(entity));
22 ATTRIB(XonoticRadioButton, alpha, float, SKINALPHA_TEXT)
23 ATTRIB(XonoticRadioButton, disabledAlpha, float, SKINALPHA_DISABLED)
24 ENDCLASS(XonoticRadioButton)
25 entity makeXonoticRadioButton_T(float, string, string, string, string theTooltip);
26 entity makeXonoticRadioButton(float, string, string, string);
30 entity makeXonoticRadioButton_T(float theGroup, string theCvar, string theValue, string theText, string theTooltip)
33 me = NEW(XonoticRadioButton);
34 me.configureXonoticRadioButton(me, theGroup, theCvar, theValue, theText, theTooltip);
37 entity makeXonoticRadioButton(float theGroup, string theCvar, string theValue, string theText)
39 return makeXonoticRadioButton_T(theGroup, theCvar, theValue, theText, string_null);
41 void XonoticRadioButton_configureXonoticRadioButton(entity me, float theGroup, string theCvar, string theValue, string theText, string theTooltip)
45 me.cvarName = theCvar;
46 me.tooltip = getZonedTooltip(theTooltip, theCvar);
49 me.configureRadioButton(me, theText, me.fontSize, me.image, theGroup, 0);
51 void XonoticRadioButton_setChecked(entity me, float val)
59 void XonoticRadioButton_loadCvars(entity me)
65 if(me.cvarValueIsAnotherCvar)
66 me.checked = (cvar_string(me.cvarName) == cvar_string(me.cvarValue));
68 me.checked = (cvar_string(me.cvarName) == me.cvarValue);
75 me.checked = !!cvar(me.cvarName);
80 // this is the "generic" selection... but at this time, not
81 // everything is constructed yet.
82 // we need to set this later in draw()
87 void XonoticRadioButton_draw(entity me)
92 // this is the "other" option
93 // always select this if none other is
97 for(e = me.parent.firstChild; e; e = e.nextSibling)
98 if(e.group == me.group)
102 me.setChecked(me, 1);
104 SUPER(XonoticRadioButton).draw(me);
106 void XonoticRadioButton_saveCvars(entity me)
114 if(me.cvarValueIsAnotherCvar)
115 cvar_set(me.cvarName, cvar_string(me.cvarValue));
117 cvar_set(me.cvarName, me.cvarValue);
119 else if(me.cvarOffValue)
120 cvar_set(me.cvarName, me.cvarOffValue);
127 cvar_set(me.cvarName, ftos(me.checked));