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

Go to the source code of this file.

Functions

entity makeXonoticTextSlider (string theCvar)
 
entity makeXonoticTextSlider_T (string theCvar, string theTooltip)
 
void XonoticTextSlider_configureXonoticTextSlider (entity me, string theCvar, string theTooltip)
 
void XonoticTextSlider_configureXonoticTextSliderValues (entity me)
 
void XonoticTextSlider_loadCvars (entity me)
 
void XonoticTextSlider_saveCvars (entity me)
 
void XonoticTextSlider_setValue (entity me, float val)
 
void XonoticTextSlider_setValue_noAnim (entity me, float val)
 

Function Documentation

◆ makeXonoticTextSlider()

entity makeXonoticTextSlider ( string  theCvar)

Definition at line 10 of file textslider.qc.

References makeXonoticTextSlider_T(), and string_null.

Referenced by GameType_GetIcon(), XonoticHUDItemsTimeDialog_fill(), XonoticHUDPhysicsDialog_fill(), XonoticHUDPressedKeysDialog_fill(), XonoticHUDRadarDialog_fill(), and XonoticHUDStrafeHUDDialog_fill().

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

◆ makeXonoticTextSlider_T()

entity makeXonoticTextSlider_T ( string  theCvar,
string  theTooltip 
)

Definition at line 3 of file textslider.qc.

References entity(), and NEW.

Referenced by makeXonoticTextSlider().

4 {
5  entity me;
7  me.configureXonoticTextSlider(me, theCvar, 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:

◆ XonoticTextSlider_configureXonoticTextSlider()

void XonoticTextSlider_configureXonoticTextSlider ( entity  me,
string  theCvar,
string  theTooltip 
)

Definition at line 14 of file textslider.qc.

References setZonedTooltip(), and string_null.

15 {
16  me.configureSliderVisuals(me, me.fontSize, me.align, me.valueSpace, me.image);
17  me.controlledCvar = (theCvar) ? theCvar : string_null;
18  // me.loadCvars(me); // don't load it yet
19  setZonedTooltip(me, theTooltip, theCvar);
20 }
string string_null
Definition: nil.qh:9
+ Here is the call graph for this function:

◆ XonoticTextSlider_configureXonoticTextSliderValues()

void XonoticTextSlider_configureXonoticTextSliderValues ( entity  me)

Definition at line 98 of file textslider.qc.

References string_null.

99 {
100  me.configureTextSliderValues(me, string_null);
101  me.loadCvars(me);
102 }
string string_null
Definition: nil.qh:9

◆ XonoticTextSlider_loadCvars()

void XonoticTextSlider_loadCvars ( entity  me)

Definition at line 37 of file textslider.qc.

References argv(), cvar_string(), strcat(), and tokenize_console.

38 {
39  if (!me.controlledCvar)
40  return;
41 
42  float n = tokenize_console(me.controlledCvar);
43  string s = cvar_string(argv(0));
44  float i;
45  for(i = 1; i < n; ++i)
46  s = strcat(s, " ", cvar_string(argv(i)));
47  me.setValueFromIdentifier_noAnim(me, s);
48  if(me.value < 0 && n > 1)
49  {
50  // if it failed: check if all cvars have the same value
51  // if yes, try its value as 1-word identifier
52  for(i = 1; i < n; ++i)
53  if(cvar_string(argv(i)) != cvar_string(argv(i-1)))
54  break;
55  if(i >= n)
56  me.setValueFromIdentifier_noAnim(me, cvar_string(argv(0)));
57  }
58 }
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
#define tokenize_console
Definition: dpextensions.qh:24
+ Here is the call graph for this function:

◆ XonoticTextSlider_saveCvars()

void XonoticTextSlider_saveCvars ( entity  me)

Definition at line 59 of file textslider.qc.

References argv(), CheckSendCvars(), cvar_set(), error(), strcat(), and tokenize_console.

60 {
61  if (!me.controlledCvar)
62  return;
63 
64  if(me.value >= 0 && me.value < me.nValues)
65  {
66  float n = tokenize_console(me.controlledCvar);
67  if(n == 1)
68  {
69  // this is a special case to allow spaces in the identifiers
70  cvar_set(argv(0), me.getIdentifier(me));
71  CheckSendCvars(me, argv(0));
72  }
73  else
74  {
75  float i;
76  float m = tokenize_console(strcat(me.controlledCvar, " ", me.getIdentifier(me)));
77  if(m == n + 1)
78  {
79  for(i = 0; i < n; ++i)
80  {
81  cvar_set(argv(i), argv(n));
82  CheckSendCvars(me, argv(i));
83  }
84  }
85  else if(m == n * 2)
86  {
87  for(i = 0; i < n; ++i)
88  {
89  cvar_set(argv(i), argv(i + n));
90  CheckSendCvars(me, argv(i));
91  }
92  }
93  else
94  error("XonoticTextSlider: invalid identifier ", me.getIdentifier(me), " does not match cvar list ", me.controlledCvar);
95  }
96  }
97 }
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
#define tokenize_console
Definition: dpextensions.qh:24
+ Here is the call graph for this function:

◆ XonoticTextSlider_setValue()

void XonoticTextSlider_setValue ( entity  me,
float  val 
)

Definition at line 21 of file textslider.qc.

References SUPER.

22 {
23  if(val != me.value)
24  {
25  SUPER(XonoticTextSlider).setValue( me, val );
26  me.saveCvars(me);
27  }
28 }
#define SUPER(cname)
Definition: oo.qh:219

◆ XonoticTextSlider_setValue_noAnim()

void XonoticTextSlider_setValue_noAnim ( entity  me,
float  val 
)

Definition at line 29 of file textslider.qc.

References SUPER.

30 {
31  if(val != me.value)
32  {
33  SUPER(XonoticTextSlider).setValue_noAnim(me, val);
34  me.saveCvars(me);
35  }
36 }
#define SUPER(cname)
Definition: oo.qh:219