4 #include "../item/slider.qc"
5 CLASS(XonoticSlider, Slider)
6 METHOD(XonoticSlider, configureXonoticSlider, void(entity, float, float, float, string, string));
7 METHOD(XonoticSlider, setValue, void(entity, float));
8 METHOD(XonoticSlider, setValue_noAnim, void(entity, float));
9 ATTRIB(XonoticSlider, fontSize, float, SKINFONTSIZE_NORMAL)
10 ATTRIB(XonoticSlider, valueSpace, float, SKINWIDTH_SLIDERTEXT)
11 ATTRIB(XonoticSlider, image, string, SKINGFX_SLIDER)
12 ATTRIB(XonoticSlider, tolerance, vector, SKINTOLERANCE_SLIDER)
13 ATTRIB(XonoticSlider, align, float, 0.5)
14 ATTRIB(XonoticSlider, color, vector, SKINCOLOR_SLIDER_N)
15 ATTRIB(XonoticSlider, colorC, vector, SKINCOLOR_SLIDER_C)
16 ATTRIB(XonoticSlider, colorF, vector, SKINCOLOR_SLIDER_F)
17 ATTRIB(XonoticSlider, colorD, vector, SKINCOLOR_SLIDER_D)
18 ATTRIB(XonoticSlider, color2, vector, SKINCOLOR_SLIDER_S)
20 ATTRIB(XonoticSlider, cvarName, string, string_null)
21 METHOD(XonoticSlider, loadCvars, void(entity));
22 METHOD(XonoticSlider, saveCvars, void(entity));
23 ATTRIB(XonoticSlider, sendCvars, float, 0)
25 ATTRIB(XonoticSlider, alpha, float, SKINALPHA_TEXT)
26 ATTRIB(XonoticSlider, disabledAlpha, float, SKINALPHA_DISABLED)
27 ENDCLASS(XonoticSlider)
28 entity makeXonoticSlider_T(float, float, float, string, string theTooltip);
29 entity makeXonoticSlider(float, float, float, string);
33 entity makeXonoticSlider_T(float theValueMin, float theValueMax, float theValueStep, string theCvar, string theTooltip)
36 me = NEW(XonoticSlider);
37 me.configureXonoticSlider(me, theValueMin, theValueMax, theValueStep, theCvar, theTooltip);
40 entity makeXonoticSlider(float theValueMin, float theValueMax, float theValueStep, string theCvar)
42 return makeXonoticSlider_T(theValueMin, theValueMax, theValueStep, theCvar, string_null);
44 void XonoticSlider_configureXonoticSlider(entity me, float theValueMin, float theValueMax, float theValueStep, string theCvar, string theTooltip)
47 vp = theValueStep * 10;
48 while(fabs(vp) < fabs(theValueMax - theValueMin) / 40)
51 me.configureSliderVisuals(me, me.fontSize, me.align, me.valueSpace, me.image);
53 me.cvarName = (theCvar) ? theCvar : string_null;
55 // Prevent flickering of the slider button by initialising the
56 // slider out of bounds to hide the button before loading the cvar
57 me.configureSliderValues(me, theValueMin, theValueMin-theValueStep, theValueMax, theValueStep, theValueStep, vp);
59 me.configureSliderValues(me, theValueMin, theValueMin, theValueMax, theValueStep, theValueStep, vp);
61 setZonedTooltip(me, theTooltip, theCvar);
63 void XonoticSlider_setValue(entity me, float val)
67 SUPER(XonoticSlider).setValue( me, val );
71 void XonoticSlider_setValue_noAnim(entity me, float val)
75 SUPER(XonoticSlider).setValue_noAnim(me, val);
79 void XonoticSlider_loadCvars(entity me)
84 me.setValue_noAnim(me, cvar(me.cvarName));
86 void XonoticSlider_saveCvars(entity me)
91 cvar_set(me.cvarName, ftos(me.value));
93 CheckSendCvars(me, me.cvarName);