Xonotic
radiobutton.qc File Reference
#include "radiobutton.qh"
+ Include dependency graph for radiobutton.qc:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

entity makeXonoticRadioButton (float theGroup, string theCvar, string theValue, string theText)
 
entity makeXonoticRadioButton_T (float theGroup, string theCvar, string theValue, string theText, string theTooltip)
 
void XonoticRadioButton_configureXonoticRadioButton (entity me, float theGroup, string theCvar, string theValue, string theText, string theTooltip)
 
void XonoticRadioButton_draw (entity me)
 
void XonoticRadioButton_loadCvars (entity me)
 
void XonoticRadioButton_saveCvars (entity me)
 
void XonoticRadioButton_setChecked (entity me, float val)
 

Function Documentation

◆ makeXonoticRadioButton()

entity makeXonoticRadioButton ( float  theGroup,
string  theCvar,
string  theValue,
string  theText 
)

Definition at line 10 of file radiobutton.qc.

References makeXonoticRadioButton_T(), and string_null.

Referenced by XonoticGameCrosshairSettingsTab_fill(), and XonoticGameViewSettingsTab_fill().

11 {
12  return makeXonoticRadioButton_T(theGroup, theCvar, theValue, theText, string_null);
13 }
string string_null
Definition: nil.qh:9
entity makeXonoticRadioButton_T(float theGroup, string theCvar, string theValue, string theText, string theTooltip)
Definition: radiobutton.qc:3
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ makeXonoticRadioButton_T()

entity makeXonoticRadioButton_T ( float  theGroup,
string  theCvar,
string  theValue,
string  theText,
string  theTooltip 
)

Definition at line 3 of file radiobutton.qc.

References entity(), and NEW.

Referenced by makeXonoticRadioButton().

4 {
5  entity me;
7  me.configureXonoticRadioButton(me, theGroup, theCvar, theValue, theText, theTooltip);
8  return me;
9 }
#define NEW(cname,...)
Definition: oo.qh:105
entity() spawn
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ XonoticRadioButton_configureXonoticRadioButton()

void XonoticRadioButton_configureXonoticRadioButton ( entity  me,
float  theGroup,
string  theCvar,
string  theValue,
string  theText,
string  theTooltip 
)

Definition at line 14 of file radiobutton.qc.

References setZonedTooltip(), and string_null.

15 {
16  me.controlledCvar = (theCvar) ? theCvar : string_null;
17  me.cvarValue = theValue;
18  me.loadCvars(me);
19  setZonedTooltip(me, theTooltip, theCvar);
20  me.configureRadioButton(me, theText, me.fontSize, me.image, theGroup, 0);
21 }
string string_null
Definition: nil.qh:9
+ Here is the call graph for this function:

◆ XonoticRadioButton_draw()

void XonoticRadioButton_draw ( entity  me)

Definition at line 58 of file radiobutton.qc.

References entity(), and SUPER.

59 {
60  if (!me.cvarValue)
61  if (!me.controlledCvar)
62  {
63  // this is the "other" option
64  // always select this if none other is
65  entity e;
66  float found;
67  found = 0;
68  for(e = me.parent.firstChild; e; e = e.nextSibling)
69  if(e.group == me.group)
70  if(e.checked)
71  found = 1;
72  if(!found)
73  me.setChecked(me, 1);
74  }
75  SUPER(XonoticRadioButton).draw(me);
76 }
entity() spawn
#define SUPER(cname)
Definition: oo.qh:219
+ Here is the call graph for this function:

◆ XonoticRadioButton_loadCvars()

void XonoticRadioButton_loadCvars ( entity  me)

Definition at line 30 of file radiobutton.qc.

References boolean, cvar(), and cvar_string().

31 {
32  if(me.cvarValue)
33  {
34  if(me.controlledCvar)
35  {
36  if(me.cvarValueIsAnotherCvar)
37  me.checked = (cvar_string(me.controlledCvar) == cvar_string(me.cvarValue));
38  else
39  me.checked = (cvar_string(me.controlledCvar) == me.cvarValue);
40  }
41  }
42  else
43  {
44  if(me.controlledCvar)
45  {
46  me.checked = boolean(cvar(me.controlledCvar));
47  }
48  else
49  {
50  // this is difficult
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()
54  me.checked = 0;
55  }
56  }
57 }
#define boolean(value)
Definition: bool.qh:9
+ Here is the call graph for this function:

◆ XonoticRadioButton_saveCvars()

void XonoticRadioButton_saveCvars ( entity  me)

Definition at line 77 of file radiobutton.qc.

References cvar_set(), cvar_string(), and ftos().

78 {
79  if(me.cvarValue)
80  {
81  if(me.controlledCvar)
82  {
83  if(me.checked)
84  {
85  if(me.cvarValueIsAnotherCvar)
86  cvar_set(me.controlledCvar, cvar_string(me.cvarValue));
87  else
88  cvar_set(me.controlledCvar, me.cvarValue);
89  }
90  else if(me.cvarOffValue)
91  cvar_set(me.controlledCvar, me.cvarOffValue);
92  }
93  }
94  else
95  {
96  if(me.controlledCvar)
97  {
98  cvar_set(me.controlledCvar, ftos(me.checked));
99  }
100  }
101 }
+ Here is the call graph for this function:

◆ XonoticRadioButton_setChecked()

void XonoticRadioButton_setChecked ( entity  me,
float  val 
)

Definition at line 22 of file radiobutton.qc.

23 {
24  if(val != me.checked)
25  {
26  me.checked = val;
27  me.saveCvars(me);
28  }
29 }