X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fmenu%2Fxonotic%2Fslider.c;h=aba15ecae625d244fda71f4eb60f9c623a61787b;hb=dc891780036706390bcaa27975dcb71e499deeae;hp=c76ed08a84f5d2ab98c148ebc4f735cfd518a6a2;hpb=8a3497931f1e38e84b55d895c01a518a79b49251;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/menu/xonotic/slider.c b/qcsrc/menu/xonotic/slider.c index c76ed08a8..aba15ecae 100644 --- a/qcsrc/menu/xonotic/slider.c +++ b/qcsrc/menu/xonotic/slider.c @@ -31,42 +31,45 @@ entity makeXonoticSlider(float theValueMin, float theValueMax, float theValueSte me.configureXonoticSlider(me, theValueMin, theValueMax, theValueStep, theCvar); return me; } -void configureXonoticSliderXonoticSlider(entity me, float theValueMin, float theValueMax, float theValueStep, string theCvar) +void XonoticSlider_configureXonoticSlider(entity me, float theValueMin, float theValueMax, float theValueStep, string theCvar) { - float v, vk, vp; - v = theValueMin; - vk = theValueStep; + float vp; vp = theValueStep * 10; while(fabs(vp) < fabs(theValueMax - theValueMin) / 40) vp *= 10; + me.configureSliderVisuals(me, me.fontSize, me.align, me.valueSpace, me.image); - me.configureSliderValues(me, theValueMin, v, theValueMax, theValueStep, vk, vp); + if(theCvar) { + // Prevent flickering of the slider button by initialising the + // slider out of bounds to hide the button before loading the cvar + me.configureSliderValues(me, theValueMin, theValueMin-theValueStep, theValueMax, theValueStep, theValueStep, vp); me.cvarName = theCvar; me.loadCvars(me); - if(tooltipdb >= 0) - me.tooltip = getZonedTooltipForIdentifier(theCvar); + me.tooltip = getZonedTooltipForIdentifier(theCvar); } + else + me.configureSliderValues(me, theValueMin, theValueMin, theValueMax, theValueStep, theValueStep, vp); } -void setValueXonoticSlider(entity me, float val) +void XonoticSlider_setValue(entity me, float val) { if(val != me.value) { - setValueSlider( me, val ); + SUPER(XonoticSlider).setValue( me, val ); me.saveCvars(me); } } -void loadCvarsXonoticSlider(entity me) +void XonoticSlider_loadCvars(entity me) { - if not(me.cvarName) + if (!me.cvarName) return; - me.value = cvar(me.cvarName); + me.setValue( me, cvar(me.cvarName) ); } -void saveCvarsXonoticSlider(entity me) +void XonoticSlider_saveCvars(entity me) { - if not(me.cvarName) + if (!me.cvarName) return; cvar_set(me.cvarName, ftos(me.value));