]> 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 134557da7dcd9bd1c12065e89f213d78fea799d1..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)
@@ -31,44 +32,49 @@ 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.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));
+
+       CheckSendCvars(me, me.cvarName);
 }
 #endif