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

Go to the source code of this file.

Functions

entity makeXonoticCheckBox (float isInverted, string theCvar, string theText)
 
entity makeXonoticCheckBox_T (float isInverted, string theCvar, string theText, string theTooltip)
 
entity makeXonoticCheckBoxEx (float theYesValue, float theNoValue, string theCvar, string theText)
 
entity makeXonoticCheckBoxEx_T (float theYesValue, float theNoValue, string theCvar, string theText, string theTooltip)
 
void XonoticCheckBox_configureXonoticCheckBox (entity me, float theYesValue, float theNoValue, string theCvar, string theText, string theTooltip)
 
void XonoticCheckBox_loadCvars (entity me)
 
void XonoticCheckBox_saveCvars (entity me)
 
void XonoticCheckBox_setChecked (entity me, float val)
 

Function Documentation

◆ makeXonoticCheckBox()

entity makeXonoticCheckBox ( float  isInverted,
string  theCvar,
string  theText 
)

Definition at line 28 of file checkbox.qc.

References makeXonoticCheckBox_T(), and string_null.

Referenced by dialog_hudpanel_main_checkbox(), GameType_GetIcon(), XonoticDamageTextSettings::XonoticDamageTextSettings ::fill(), XonoticHUDHealthArmorDialog_fill(), XonoticHUDPowerupsDialog_fill(), and XonoticServerListTab_fill().

29 {
30  return makeXonoticCheckBox_T(isInverted, theCvar, theText, string_null);
31 }
string string_null
Definition: nil.qh:9
entity makeXonoticCheckBox_T(float isInverted, string theCvar, string theText, string theTooltip)
Definition: checkbox.qc:3
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ makeXonoticCheckBox_T()

entity makeXonoticCheckBox_T ( float  isInverted,
string  theCvar,
string  theText,
string  theTooltip 
)

Definition at line 3 of file checkbox.qc.

References makeXonoticCheckBoxEx_T().

Referenced by makeXonoticCheckBox().

4 {
5  float m, n;
6  if(isInverted > 1)
7  {
8  n = isInverted - 1;
9  m = -n;
10  }
11  else if(isInverted < -1)
12  {
13  n = isInverted + 1;
14  m = -n;
15  }
16  else if(isInverted == 1)
17  {
18  n = 1;
19  m = 0;
20  }
21  else
22  {
23  n = 0;
24  m = 1;
25  }
26  return makeXonoticCheckBoxEx_T(m, n, theCvar, theText, theTooltip);
27 }
entity makeXonoticCheckBoxEx_T(float theYesValue, float theNoValue, string theCvar, string theText, string theTooltip)
Definition: checkbox.qc:33
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ makeXonoticCheckBoxEx()

entity makeXonoticCheckBoxEx ( float  theYesValue,
float  theNoValue,
string  theCvar,
string  theText 
)

Definition at line 40 of file checkbox.qc.

References makeXonoticCheckBoxEx_T(), and string_null.

41 {
42  return makeXonoticCheckBoxEx_T(theYesValue, theNoValue, theCvar, theText, string_null);
43 }
string string_null
Definition: nil.qh:9
entity makeXonoticCheckBoxEx_T(float theYesValue, float theNoValue, string theCvar, string theText, string theTooltip)
Definition: checkbox.qc:33
+ Here is the call graph for this function:

◆ makeXonoticCheckBoxEx_T()

entity makeXonoticCheckBoxEx_T ( float  theYesValue,
float  theNoValue,
string  theCvar,
string  theText,
string  theTooltip 
)

Definition at line 33 of file checkbox.qc.

References entity(), and NEW.

Referenced by makeXonoticCheckBox_T(), and makeXonoticCheckBoxEx().

34 {
35  entity me;
36  me = NEW(XonoticCheckBox);
37  me.configureXonoticCheckBox(me, theYesValue, theNoValue, theCvar, theText, theTooltip);
38  return me;
39 }
#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:

◆ XonoticCheckBox_configureXonoticCheckBox()

void XonoticCheckBox_configureXonoticCheckBox ( entity  me,
float  theYesValue,
float  theNoValue,
string  theCvar,
string  theText,
string  theTooltip 
)

Definition at line 45 of file checkbox.qc.

References setZonedTooltip(), and string_null.

46 {
47  me.yesValue = theYesValue;
48  me.noValue = theNoValue;
49  me.checked = 0;
50  me.controlledCvar = (theCvar) ? theCvar : string_null;
51  me.loadCvars(me);
52  setZonedTooltip(me, theTooltip, theCvar);
53  me.configureCheckBox(me, theText, me.fontSize, me.image);
54 }
string string_null
Definition: nil.qh:9
+ Here is the call graph for this function:

◆ XonoticCheckBox_loadCvars()

void XonoticCheckBox_loadCvars ( entity  me)

Definition at line 65 of file checkbox.qc.

References cvar().

66 {
67  float m, d;
68 
69  if (!me.controlledCvar)
70  return;
71 
72  m = (me.yesValue + me.noValue) * 0.5;
73  d = (cvar(me.controlledCvar) - m) / (me.yesValue - m);
74  me.checked = (d > 0);
75 }
+ Here is the call graph for this function:

◆ XonoticCheckBox_saveCvars()

void XonoticCheckBox_saveCvars ( entity  me)

Definition at line 76 of file checkbox.qc.

References CheckSendCvars(), cvar_set(), and ftos_mindecimals().

77 {
78  if (!me.controlledCvar)
79  return;
80 
81  if(me.checked)
82  cvar_set(me.controlledCvar, ftos_mindecimals(me.yesValue));
83  else
84  cvar_set(me.controlledCvar, ftos_mindecimals(me.noValue));
85 
86  CheckSendCvars(me, me.controlledCvar);
87 }
ERASEABLE string ftos_mindecimals(float number)
converts a number to a string with the minimum number of decimals
Definition: string.qh:461
+ Here is the call graph for this function:

◆ XonoticCheckBox_setChecked()

void XonoticCheckBox_setChecked ( entity  me,
float  val 
)

Definition at line 55 of file checkbox.qc.

56 {
57  if(val != me.checked)
58  {
59  me.checked = val;
60  me.saveCvars(me);
61  if(me.linkedCheckBox)
62  me.linkedCheckBox.loadCvars(me.linkedCheckBox);
63  }
64 }