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 ATTRIB(XonoticSlider, fontSize, float, SKINFONTSIZE_NORMAL)
8 ATTRIB(XonoticSlider, valueSpace, float, SKINWIDTH_SLIDERTEXT)
9 ATTRIB(XonoticSlider, image, string, SKINGFX_SLIDER)
10 ATTRIB(XonoticSlider, tolerance, vector, SKINTOLERANCE_SLIDER)
11 ATTRIB(XonoticSlider, align, float, 0.5)
12 ATTRIB(XonoticSlider, color, vector, SKINCOLOR_SLIDER_N)
13 ATTRIB(XonoticSlider, colorC, vector, SKINCOLOR_SLIDER_C)
14 ATTRIB(XonoticSlider, colorF, vector, SKINCOLOR_SLIDER_F)
15 ATTRIB(XonoticSlider, colorD, vector, SKINCOLOR_SLIDER_D)
16 ATTRIB(XonoticSlider, color2, vector, SKINCOLOR_SLIDER_S)
18 ATTRIB(XonoticSlider, cvarName, string, string_null)
19 METHOD(XonoticSlider, loadCvars, void(entity));
20 METHOD(XonoticSlider, saveCvars, void(entity));
21 ATTRIB(XonoticSlider, sendCvars, float, 0)
23 ATTRIB(XonoticSlider, alpha, float, SKINALPHA_TEXT)
24 ATTRIB(XonoticSlider, disabledAlpha, float, SKINALPHA_DISABLED)
25 ENDCLASS(XonoticSlider)
26 entity makeXonoticSlider_T(float, float, float, string, string theTooltip);
27 entity makeXonoticSlider(float, float, float, string);
31 entity makeXonoticSlider_T(float theValueMin, float theValueMax, float theValueStep, string theCvar, string theTooltip)
34 me = NEW(XonoticSlider);
35 me.configureXonoticSlider(me, theValueMin, theValueMax, theValueStep, theCvar, theTooltip);
38 entity makeXonoticSlider(float theValueMin, float theValueMax, float theValueStep, string theCvar)
40 return makeXonoticSlider_T(theValueMin, theValueMax, theValueStep, theCvar, string_null);
42 void XonoticSlider_configureXonoticSlider(entity me, float theValueMin, float theValueMax, float theValueStep, string theCvar, string theTooltip)
45 vp = theValueStep * 10;
46 while(fabs(vp) < fabs(theValueMax - theValueMin) / 40)
49 me.configureSliderVisuals(me, me.fontSize, me.align, me.valueSpace, me.image);
51 me.cvarName = (theCvar) ? theCvar : string_null;
53 // Prevent flickering of the slider button by initialising the
54 // slider out of bounds to hide the button before loading the cvar
55 me.configureSliderValues(me, theValueMin, theValueMin-theValueStep, theValueMax, theValueStep, theValueStep, vp);
57 me.configureSliderValues(me, theValueMin, theValueMin, theValueMax, theValueStep, theValueStep, vp);
59 setZonedTooltip(me, theTooltip, theCvar);
61 void XonoticSlider_setValue(entity me, float val)
65 SUPER(XonoticSlider).setValue( me, val );
69 void XonoticSlider_loadCvars(entity me)
74 me.setValue( me, cvar(me.cvarName) );
76 void XonoticSlider_saveCvars(entity me)
81 cvar_set(me.cvarName, ftos(me.value));
83 CheckSendCvars(me, me.cvarName);