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{
6 me.configureXonoticSlider(me, theValueMin, theValueMax, theValueStep, theCvar, theTooltip);
7 return me;
8}
9entity makeXonoticSlider(float theValueMin, float theValueMax, float theValueStep, string theCvar)
10{
11 return makeXonoticSlider_T(theValueMin, theValueMax, theValueStep, theCvar, string_null);
12}
13void XonoticSlider_configureXonoticSlider(entity me, float theValueMin, float theValueMax, float theValueStep, string theCvar, string theTooltip)
14{
15 float vp = theValueStep * 10;
16 while(fabs(vp) < fabs(theValueMax - theValueMin) / 40)
17 vp *= 10;
18
19 me.configureSliderVisuals(me, me.fontSize, me.align, me.valueSpace, me.image);
20
21 me.controlledCvar = (theCvar) ? theCvar : string_null;
22 if(theCvar)
23 // Prevent flickering of the slider button by initialising the
24 // slider out of bounds to hide the button before loading the cvar
25 me.configureSliderValues(me, theValueMin, theValueMin-theValueStep, theValueMax, theValueStep, theValueStep, vp);
26 else
27 me.configureSliderValues(me, theValueMin, theValueMin, theValueMax, theValueStep, theValueStep, vp);
28 me.loadCvars(me);
29 setZonedTooltip(me, theTooltip, theCvar);
30}
31void XonoticSlider_setValue(entity me, float val, bool allowAnim)
32{
33 if(val != me.value)
34 {
35 SUPER(XonoticSlider).setValue(me, val, allowAnim);
36 me.saveCvars(me);
37
38 if(me.onChange)
39 me.onChange(me, me.onChangeEntity);
40 }
41}
43{
44 me.valueSpace = val;
45 me.configureSliderVisuals(me, me.fontSize, me.align, me.valueSpace, me.image);
46}
48{
49 if (!me.controlledCvar)
50 return;
51
52 SUPER(XonoticSlider).setValue(me, cvar(me.controlledCvar), false);
53}
55{
56 if (!me.controlledCvar)
57 return;
58
59 cvar_set(me.controlledCvar, ftos_mindecimals(me.value));
60
61 CheckSendCvars(me, me.controlledCvar);
62}
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:31
void XonoticSlider_setValueSpace(entity me, float val)
Definition slider.qc:42
void XonoticSlider_saveCvars(entity me)
Definition slider.qc:54
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:9
void XonoticSlider_configureXonoticSlider(entity me, float theValueMin, float theValueMax, float theValueStep, string theCvar, string theTooltip)
Definition slider.qc:13
void XonoticSlider_loadCvars(entity me)
Definition slider.qc:47