X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fmenu%2Fxonotic%2Fslider.c;h=d63fe1c336c8ae2d2577803b67bd12cbfe59b5cb;hb=5e3a7beca384caa6f3da36fe07b29aff942e7b3e;hp=0577207ca284bb56baf90ef001c83abb6c48975a;hpb=451c0fbf5473c6acc88bafaa0e9c14e5afd3764e;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/menu/xonotic/slider.c b/qcsrc/menu/xonotic/slider.c index 0577207ca..d63fe1c33 100644 --- a/qcsrc/menu/xonotic/slider.c +++ b/qcsrc/menu/xonotic/slider.c @@ -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) { @@ -69,5 +74,7 @@ void XonoticSlider_saveCvars(entity me) return; cvar_set(me.cvarName, ftos(me.value)); + + CheckSendCvars(me, me.cvarName); } #endif