Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
radiobutton.qc
Go to the documentation of this file.
1#include "radiobutton.qh"
2
3entity makeXonoticRadioButton_T(float theGroup, string theCvar, string theValue, string theText, string theTooltip)
4{
6 me.configureXonoticRadioButton(me, theGroup, theCvar, theValue, theText, theTooltip);
7 return me;
8}
9entity makeXonoticRadioButton(float theGroup, string theCvar, string theValue, string theText)
10{
11 return makeXonoticRadioButton_T(theGroup, theCvar, theValue, theText, string_null);
12}
13void XonoticRadioButton_configureXonoticRadioButton(entity me, float theGroup, string theCvar, string theValue, string theText, string theTooltip)
14{
15 me.controlledCvar = (theCvar) ? theCvar : string_null;
16 me.cvarValue = theValue;
17 me.loadCvars(me);
18 setZonedTooltip(me, theTooltip, theCvar);
19 me.configureRadioButton(me, theText, me.fontSize, me.image, theGroup, 0);
20}
22{
23 if(val != me.checked)
24 {
25 me.checked = val;
26 me.saveCvars(me);
27 }
28}
30{
31 if(me.cvarValue)
32 {
33 if(me.controlledCvar)
34 {
35 if(me.cvarValueIsAnotherCvar)
36 me.checked = (cvar_string(me.controlledCvar) == cvar_string(me.cvarValue));
37 else
38 me.checked = (cvar_string(me.controlledCvar) == me.cvarValue);
39 }
40 }
41 else
42 {
43 if(me.controlledCvar)
44 {
45 me.checked = boolean(cvar(me.controlledCvar));
46 }
47 else
48 {
49 // this is difficult
50 // this is the "generic" selection... but at this time, not
51 // everything is constructed yet.
52 // we need to set this later in draw()
53 me.checked = false;
54 }
55 }
56}
58{
59 if (!me.cvarValue)
60 if (!me.controlledCvar)
61 {
62 // this is the "other" option
63 // always select this if none other is
64 entity e;
65 bool found = false;
66 for(e = me.parent.firstChild; e; e = e.nextSibling)
67 if(e.group == me.group)
68 if(e.checked)
69 found = true;
70 if(!found)
71 me.setChecked(me, true);
72 }
73 SUPER(XonoticRadioButton).draw(me);
74}
76{
77 if(me.cvarValue)
78 {
79 if(me.controlledCvar)
80 {
81 if(me.checked)
82 {
83 if(me.cvarValueIsAnotherCvar)
84 cvar_set(me.controlledCvar, cvar_string(me.cvarValue));
85 else
86 cvar_set(me.controlledCvar, me.cvarValue);
87 }
88 else if(me.cvarOffValue)
89 cvar_set(me.controlledCvar, me.cvarOffValue);
90 }
91 }
92 else
93 {
94 if(me.controlledCvar)
95 {
96 cvar_set(me.controlledCvar, ftos(me.checked));
97 }
98 }
99}
#define boolean(value)
Definition bool.qh:9
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
void setZonedTooltip(entity e, string theTooltip, string theCvar)
Definition util.qc:257
void cvar_set(string name, string value)
float cvar(string name)
const string cvar_string(string name)
string ftos(float f)
string string_null
Definition nil.qh:9
#define NEW(cname,...)
Definition oo.qh:117
#define SUPER(cname)
Definition oo.qh:231
void XonoticRadioButton_configureXonoticRadioButton(entity me, float theGroup, string theCvar, string theValue, string theText, string theTooltip)
void XonoticRadioButton_saveCvars(entity me)
void XonoticRadioButton_loadCvars(entity me)
entity makeXonoticRadioButton(float theGroup, string theCvar, string theValue, string theText)
Definition radiobutton.qc:9
void XonoticRadioButton_draw(entity me)
void XonoticRadioButton_setChecked(entity me, bool val)
entity makeXonoticRadioButton_T(float theGroup, string theCvar, string theValue, string theText, string theTooltip)
Definition radiobutton.qc:3