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

Go to the source code of this file.

Functions

entity makeXonoticSlider (float theValueMin, float theValueMax, float theValueStep, string theCvar)
 
entity makeXonoticSlider_T (float theValueMin, float theValueMax, float theValueStep, string theCvar, string theTooltip)
 
void XonoticSlider_configureXonoticSlider (entity me, float theValueMin, float theValueMax, float theValueStep, string theCvar, string theTooltip)
 
void XonoticSlider_loadCvars (entity me)
 
void XonoticSlider_saveCvars (entity me)
 
void XonoticSlider_setValue (entity me, float val)
 
void XonoticSlider_setValue_noAnim (entity me, float val)
 

Function Documentation

◆ makeXonoticSlider()

entity makeXonoticSlider ( float  theValueMin,
float  theValueMax,
float  theValueStep,
string  theCvar 
)

Definition at line 10 of file slider.qc.

References makeXonoticSlider_T(), and string_null.

11 {
12  return makeXonoticSlider_T(theValueMin, theValueMax, theValueStep, theCvar, string_null);
13 }
string string_null
Definition: nil.qh:9
entity makeXonoticSlider_T(float theValueMin, float theValueMax, float theValueStep, string theCvar, string theTooltip)
Definition: slider.qc:3
+ Here is the call graph for this function:

◆ makeXonoticSlider_T()

entity makeXonoticSlider_T ( float  theValueMin,
float  theValueMax,
float  theValueStep,
string  theCvar,
string  theTooltip 
)

Definition at line 3 of file slider.qc.

References entity(), and NEW.

Referenced by makeXonoticSlider().

4 {
5  entity me;
6  me = NEW(XonoticSlider);
7  me.configureXonoticSlider(me, theValueMin, theValueMax, theValueStep, 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:

◆ XonoticSlider_configureXonoticSlider()

void XonoticSlider_configureXonoticSlider ( entity  me,
float  theValueMin,
float  theValueMax,
float  theValueStep,
string  theCvar,
string  theTooltip 
)

Definition at line 14 of file slider.qc.

References fabs(), setZonedTooltip(), and string_null.

15 {
16  float vp;
17  vp = theValueStep * 10;
18  while(fabs(vp) < fabs(theValueMax - theValueMin) / 40)
19  vp *= 10;
20 
21  me.configureSliderVisuals(me, me.fontSize, me.align, me.valueSpace, me.image);
22 
23  me.controlledCvar = (theCvar) ? theCvar : string_null;
24  if(theCvar)
25  // Prevent flickering of the slider button by initialising the
26  // slider out of bounds to hide the button before loading the cvar
27  me.configureSliderValues(me, theValueMin, theValueMin-theValueStep, theValueMax, theValueStep, theValueStep, vp);
28  else
29  me.configureSliderValues(me, theValueMin, theValueMin, theValueMax, theValueStep, theValueStep, vp);
30  me.loadCvars(me);
31  setZonedTooltip(me, theTooltip, theCvar);
32 }
string string_null
Definition: nil.qh:9
+ Here is the call graph for this function:

◆ XonoticSlider_loadCvars()

void XonoticSlider_loadCvars ( entity  me)

Definition at line 49 of file slider.qc.

References cvar().

50 {
51  if (!me.controlledCvar)
52  return;
53 
54  me.setValue_noAnim(me, cvar(me.controlledCvar));
55 }
+ Here is the call graph for this function:

◆ XonoticSlider_saveCvars()

void XonoticSlider_saveCvars ( entity  me)

Definition at line 56 of file slider.qc.

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

57 {
58  if (!me.controlledCvar)
59  return;
60 
61  cvar_set(me.controlledCvar, ftos_mindecimals(me.value));
62 
63  CheckSendCvars(me, me.controlledCvar);
64 }
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:

◆ XonoticSlider_setValue()

void XonoticSlider_setValue ( entity  me,
float  val 
)

Definition at line 33 of file slider.qc.

References SUPER.

34 {
35  if(val != me.value)
36  {
37  SUPER(XonoticSlider).setValue( me, val );
38  me.saveCvars(me);
39  }
40 }
#define SUPER(cname)
Definition: oo.qh:219

◆ XonoticSlider_setValue_noAnim()

void XonoticSlider_setValue_noAnim ( entity  me,
float  val 
)

Definition at line 41 of file slider.qc.

References SUPER.

42 {
43  if(val != me.value)
44  {
45  SUPER(XonoticSlider).setValue_noAnim(me, val);
46  me.saveCvars(me);
47  }
48 }
#define SUPER(cname)
Definition: oo.qh:219