3 #include "../item/slider.qc"
4 CLASS(XonoticSlider, Slider)
5 METHOD(XonoticSlider, configureXonoticSlider, void(entity, float, float, float, 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(float, float, float, string);
30 entity makeXonoticSlider(float theValueMin, float theValueMax, float theValueStep, string theCvar)
33 me = NEW(XonoticSlider);
34 me.configureXonoticSlider(me, theValueMin, theValueMax, theValueStep, theCvar);
37 void XonoticSlider_configureXonoticSlider(entity me, float theValueMin, float theValueMax, float theValueStep, string theCvar)
40 vp = theValueStep * 10;
41 while(fabs(vp) < fabs(theValueMax - theValueMin) / 40)
44 me.configureSliderVisuals(me, me.fontSize, me.align, me.valueSpace, me.image);
48 // Prevent flickering of the slider button by initialising the
49 // slider out of bounds to hide the button before loading the cvar
50 me.configureSliderValues(me, theValueMin, theValueMin-theValueStep, theValueMax, theValueStep, theValueStep, vp);
51 me.cvarName = theCvar;
53 me.tooltip = getZonedTooltipForIdentifier(theCvar);
56 me.configureSliderValues(me, theValueMin, theValueMin, theValueMax, theValueStep, theValueStep, vp);
58 void XonoticSlider_setValue(entity me, float val)
62 SUPER(XonoticSlider).setValue( me, val );
66 void XonoticSlider_loadCvars(entity me)
71 me.setValue( me, cvar(me.cvarName) );
73 void XonoticSlider_saveCvars(entity me)
78 cvar_set(me.cvarName, ftos(me.value));
80 CheckSendCvars(me, me.cvarName);