]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Prevent the slider button from flickering when changing gametype
authorSeverin Meyer <sev.ch@web.de>
Fri, 14 Nov 2014 14:04:08 +0000 (15:04 +0100)
committerSeverin Meyer <sev.ch@web.de>
Fri, 14 Nov 2014 14:04:08 +0000 (15:04 +0100)
qcsrc/menu/xonotic/slider.c

index 0577207ca284bb56baf90ef001c83abb6c48975a..aba15ecae625d244fda71f4eb60f9c623a61787b 100644 (file)
@@ -33,20 +33,24 @@ entity makeXonoticSlider(float theValueMin, float theValueMax, float theValueSte
 }
 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);
                me.tooltip = getZonedTooltipForIdentifier(theCvar);
        }
+       else
+               me.configureSliderValues(me, theValueMin, theValueMin, theValueMax, theValueStep, theValueStep, vp);
 }
 void XonoticSlider_setValue(entity me, float val)
 {