3 #include "../item/slider.qc"
4 CLASS(XonoticSlider, Slider)
5 METHOD(XonoticSlider, configureXonoticSlider, void(entity, float, float, float, string, string));
6 METHOD(XonoticSlider, setValue, void(entity, float));
7 METHOD(XonoticSlider, setValue_noAnim, void(entity, float));
8 ATTRIB(XonoticSlider, fontSize, float, SKINFONTSIZE_NORMAL)
9 ATTRIB(XonoticSlider, valueSpace, float, SKINWIDTH_SLIDERTEXT)
10 ATTRIB(XonoticSlider, image, string, SKINGFX_SLIDER)
11 ATTRIB(XonoticSlider, tolerance, vector, SKINTOLERANCE_SLIDER)
12 ATTRIB(XonoticSlider, align, float, 0.5)
13 ATTRIB(XonoticSlider, color, vector, SKINCOLOR_SLIDER_N)
14 ATTRIB(XonoticSlider, colorC, vector, SKINCOLOR_SLIDER_C)
15 ATTRIB(XonoticSlider, colorF, vector, SKINCOLOR_SLIDER_F)
16 ATTRIB(XonoticSlider, colorD, vector, SKINCOLOR_SLIDER_D)
17 ATTRIB(XonoticSlider, color2, vector, SKINCOLOR_SLIDER_S)
19 ATTRIB(XonoticSlider, cvarName, string, string_null)
20 METHOD(XonoticSlider, loadCvars, void(entity));
21 METHOD(XonoticSlider, saveCvars, void(entity));
22 ATTRIB(XonoticSlider, sendCvars, float, 0)
24 ATTRIB(XonoticSlider, alpha, float, SKINALPHA_TEXT)
25 ATTRIB(XonoticSlider, disabledAlpha, float, SKINALPHA_DISABLED)
26 ENDCLASS(XonoticSlider)
27 entity makeXonoticSlider_T(float, float, float, string, string theTooltip);
28 entity makeXonoticSlider(float, float, float, string);
32 entity makeXonoticSlider_T(float theValueMin, float theValueMax, float theValueStep, string theCvar, string theTooltip)
35 me = NEW(XonoticSlider);
36 me.configureXonoticSlider(me, theValueMin, theValueMax, theValueStep, theCvar, theTooltip);
39 entity makeXonoticSlider(float theValueMin, float theValueMax, float theValueStep, string theCvar)
41 return makeXonoticSlider_T(theValueMin, theValueMax, theValueStep, theCvar, string_null);
43 void XonoticSlider_configureXonoticSlider(entity me, float theValueMin, float theValueMax, float theValueStep, string theCvar, string theTooltip)
46 vp = theValueStep * 10;
47 while(fabs(vp) < fabs(theValueMax - theValueMin) / 40)
50 me.configureSliderVisuals(me, me.fontSize, me.align, me.valueSpace, me.image);
52 me.cvarName = (theCvar) ? theCvar : string_null;
54 // Prevent flickering of the slider button by initialising the
55 // slider out of bounds to hide the button before loading the cvar
56 me.configureSliderValues(me, theValueMin, theValueMin-theValueStep, theValueMax, theValueStep, theValueStep, vp);
58 me.configureSliderValues(me, theValueMin, theValueMin, theValueMax, theValueStep, theValueStep, vp);
60 setZonedTooltip(me, theTooltip, theCvar);
62 void XonoticSlider_setValue(entity me, float val)
66 SUPER(XonoticSlider).setValue( me, val );
70 void XonoticSlider_setValue_noAnim(entity me, float val)
74 SUPER(XonoticSlider).setValue_noAnim(me, val);
78 void XonoticSlider_loadCvars(entity me)
83 me.setValue_noAnim(me, cvar(me.cvarName));
85 void XonoticSlider_saveCvars(entity me)
90 cvar_set(me.cvarName, ftos(me.value));
92 CheckSendCvars(me, me.cvarName);