Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
slider.qc
Go to the documentation of this file.
1#include "slider.qh"
2
3entity makeXonoticSlider_T(float theValueMin, float theValueMax, float theValueStep, string theCvar, string theTooltip)
4{
5 entity me;
6 me = NEW(XonoticSlider);
7 me.configureXonoticSlider(me, theValueMin, theValueMax, theValueStep, theCvar, theTooltip);
8 return me;
9}
10entity makeXonoticSlider(float theValueMin, float theValueMax, float theValueStep, string theCvar)
11{
12 return makeXonoticSlider_T(theValueMin, theValueMax, theValueStep, theCvar, string_null);
13}
14void XonoticSlider_configureXonoticSlider(entity me, float theValueMin, float theValueMax, float theValueStep, string theCvar, string theTooltip)
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}
33void XonoticSlider_setValue(entity me, float val, bool allowAnim)
34{
35 if(val != me.value)
36 {
37 SUPER(XonoticSlider).setValue(me, val, allowAnim);
38 me.saveCvars(me);
39
40 if(me.onChange)
41 me.onChange(me, me.onChangeEntity);
42 }
43}
45{
46 me.valueSpace = val;
47 me.configureSliderVisuals(me, me.fontSize, me.align, me.valueSpace, me.image);
48}
50{
51 if (!me.controlledCvar)
52 return;
53
54 SUPER(XonoticSlider).setValue(me, cvar(me.controlledCvar), false);
55}
57{
58 if (!me.controlledCvar)
59 return;
60
61 cvar_set(me.controlledCvar, ftos_mindecimals(me.value));
62
63 CheckSendCvars(me, me.controlledCvar);
64}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
void CheckSendCvars(entity me, string cvarnamestring)
Definition util.qc:825
void setZonedTooltip(entity e, string theTooltip, string theCvar)
Definition util.qc:257
void cvar_set(string name, string value)
float cvar(string name)
float fabs(float f)
string string_null
Definition nil.qh:9
#define NEW(cname,...)
Definition oo.qh:117
#define SUPER(cname)
Definition oo.qh:231
ERASEABLE string ftos_mindecimals(float number)
Converts a number to a string with the minimum number of decimals It assumes that an extreme accuracy...
Definition string.qh:497
void XonoticSlider_setValue(entity me, float val, bool allowAnim)
Definition slider.qc:33
void XonoticSlider_setValueSpace(entity me, float val)
Definition slider.qc:44
void XonoticSlider_saveCvars(entity me)
Definition slider.qc:56
entity makeXonoticSlider_T(float theValueMin, float theValueMax, float theValueStep, string theCvar, string theTooltip)
Definition slider.qc:3
entity makeXonoticSlider(float theValueMin, float theValueMax, float theValueStep, string theCvar)
Definition slider.qc:10
void XonoticSlider_configureXonoticSlider(entity me, float theValueMin, float theValueMax, float theValueStep, string theCvar, string theTooltip)
Definition slider.qc:14
void XonoticSlider_loadCvars(entity me)
Definition slider.qc:49