]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/menu/xonotic/slider.c
Merge branch 'master' into terencehill/music_player
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / slider.c
index e833bb1251379f49535c3edd1599a662b8fc6721..d63fe1c336c8ae2d2577803b67bd12cbfe59b5cb 100644 (file)
@@ -16,6 +16,7 @@ CLASS(XonoticSlider) EXTENDS(Slider)
        ATTRIB(XonoticSlider, cvarName, string, string_null)
        METHOD(XonoticSlider, loadCvars, void(entity))
        METHOD(XonoticSlider, saveCvars, void(entity))
+       ATTRIB(XonoticSlider, sendCvars, float, 0)
 
        ATTRIB(XonoticSlider, alpha, float, SKINALPHA_TEXT)
        ATTRIB(XonoticSlider, disabledAlpha, float, SKINALPHA_DISABLED)
@@ -33,20 +34,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)
 {
@@ -58,16 +63,18 @@ void XonoticSlider_setValue(entity me, float val)
 }
 void XonoticSlider_loadCvars(entity me)
 {
-       if not(me.cvarName)
+       if (!me.cvarName)
                return;
 
        me.setValue( me, cvar(me.cvarName) );
 }
 void XonoticSlider_saveCvars(entity me)
 {
-       if not(me.cvarName)
+       if (!me.cvarName)
                return;
 
        cvar_set(me.cvarName, ftos(me.value));
+
+       CheckSendCvars(me, me.cvarName);
 }
 #endif