From: terencehill Date: Fri, 4 Sep 2015 22:30:33 +0000 (+0200) Subject: Don't play any animation when loading the initial value of a slider since the animati... X-Git-Tag: xonotic-v0.8.2~1890^2~2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=b41b1b47e0f20ed2d30358311ba111d82da56f54;p=xonotic%2Fxonotic-data.pk3dir.git Don't play any animation when loading the initial value of a slider since the animation can't be seen anyway (the menu takes 2-3 seconds to load); also the high number (200) of animations played at once on menu start caused a bug where slider's handles couldn't be moved for a while (up to 12 seconds with 30 fps) --- diff --git a/qcsrc/menu/item/slider.qc b/qcsrc/menu/item/slider.qc index cdc8e2b95..daad34a16 100644 --- a/qcsrc/menu/item/slider.qc +++ b/qcsrc/menu/item/slider.qc @@ -15,6 +15,8 @@ CLASS(Slider, Label) METHOD(Slider, mouseRelease, float(entity, vector)); METHOD(Slider, valueToText, string(entity, float)); METHOD(Slider, toString, string(entity)); + METHOD(Slider, setValue_allowAnim, void(entity, float, bool)); + METHOD(Slider, setValue_noAnim, void(entity, float)); METHOD(Slider, setValue, void(entity, float)); METHOD(Slider, setSliderValue, void(entity, float)); METHOD(Slider, showNotify, void(entity)); @@ -49,9 +51,9 @@ ENDCLASS(Slider) #endif #ifdef IMPLEMENTATION -void Slider_setValue(entity me, float val) +void Slider_setValue_allowAnim(entity me, float val, bool allowAnim) { - if (me.animated) { + if(allowAnim && me.animated) { float t = 0.5; if(me.pressed == 2) t = 0.3; // slightly more responsive while dragging the handle @@ -64,6 +66,14 @@ void Slider_setValue(entity me, float val) } me.value = val; } +void Slider_setValue_noAnim(entity me, float val) +{ + Slider_setValue_allowAnim(me, val, false); +} +void Slider_setValue(entity me, float val) +{ + Slider_setValue_allowAnim(me, val, true); +} void Slider_setSliderValue(entity me, float val) { me.sliderValue = val; diff --git a/qcsrc/menu/item/textslider.qc b/qcsrc/menu/item/textslider.qc index 733b1d612..30b80c196 100644 --- a/qcsrc/menu/item/textslider.qc +++ b/qcsrc/menu/item/textslider.qc @@ -6,6 +6,8 @@ CLASS(TextSlider, Slider) METHOD(TextSlider, valueToText, string(entity, float)); METHOD(TextSlider, valueToIdentifier, string(entity, float)); + METHOD(TextSlider, setValueFromIdentifier_allowAnim, void(entity, string, bool)); + METHOD(TextSlider, setValueFromIdentifier_noAnim, void(entity, string)); METHOD(TextSlider, setValueFromIdentifier, void(entity, string)); METHOD(TextSlider, getIdentifier, string(entity)); METHOD(TextSlider, clearValues, void(entity)); @@ -35,16 +37,24 @@ string TextSlider_valueToText(entity me, int val) return _("Custom"); return me.(valueStrings[val]); } -void TextSlider_setValueFromIdentifier(entity me, string id) +void TextSlider_setValueFromIdentifier_allowAnim(entity me, string id, bool allowAnim) { int i; for(i = 0; i < me.nValues; ++i) if(me.valueToIdentifier(me, i) == id) { - SUPER(TextSlider).setValue( me, i ); + SUPER(TextSlider).setValue_allowAnim(me, i, allowAnim); return; } - SUPER(TextSlider).setValue( me, -1 ); + SUPER(TextSlider).setValue_allowAnim(me, -1, allowAnim); +} +void TextSlider_setValueFromIdentifier_noAnim(entity me, string id) +{ + TextSlider_setValueFromIdentifier_allowAnim(me, id, false); +} +void TextSlider_setValueFromIdentifier(entity me, string id) +{ + TextSlider_setValueFromIdentifier_allowAnim(me, id, true); } string TextSlider_getIdentifier(entity me) { @@ -75,6 +85,6 @@ void TextSlider_insertValue(entity me, int pos, string theString, string theIden void TextSlider_configureTextSliderValues(entity me, string theDefault) { me.configureSliderValues(me, 0, 0, me.nValues - 1, 1, 1, 1); - me.setValueFromIdentifier(me, theDefault); + me.setValueFromIdentifier_noAnim(me, theDefault); } #endif diff --git a/qcsrc/menu/xonotic/slider.qc b/qcsrc/menu/xonotic/slider.qc index 46379d5a3..d1e4f7e07 100644 --- a/qcsrc/menu/xonotic/slider.qc +++ b/qcsrc/menu/xonotic/slider.qc @@ -68,7 +68,7 @@ void XonoticSlider_loadCvars(entity me) if (!me.cvarName) return; - me.setValue( me, cvar(me.cvarName) ); + me.setValue_noAnim(me, cvar(me.cvarName)); } void XonoticSlider_saveCvars(entity me) { diff --git a/qcsrc/menu/xonotic/slider_decibels.qc b/qcsrc/menu/xonotic/slider_decibels.qc index eabbaf16d..2878b5056 100644 --- a/qcsrc/menu/xonotic/slider_decibels.qc +++ b/qcsrc/menu/xonotic/slider_decibels.qc @@ -57,9 +57,9 @@ void XonoticDecibelsSlider_loadCvars(entity me) // snapping if(v > fromDecibelOfSquare(me.valueMax - 0.5 * me.valueStep, me.valueMin)) - Slider_setValue(me, me.valueMax); + Slider_setValue_noAnim(me, me.valueMax); else - Slider_setValue(me, me.valueStep * floor(0.5 + toDecibelOfSquare(v, me.valueMin) / me.valueStep) ); + Slider_setValue_noAnim(me, me.valueStep * floor(0.5 + toDecibelOfSquare(v, me.valueMin) / me.valueStep)); } void XonoticDecibelsSlider_saveCvars(entity me) { diff --git a/qcsrc/menu/xonotic/slider_particles.qc b/qcsrc/menu/xonotic/slider_particles.qc index f7acdfeca..a0d5225c5 100644 --- a/qcsrc/menu/xonotic/slider_particles.qc +++ b/qcsrc/menu/xonotic/slider_particles.qc @@ -31,7 +31,7 @@ void XonoticParticlesSlider_configureXonoticParticlesSlider(entity me) } void XonoticParticlesSlider_loadCvars(entity me) { - me.setValueFromIdentifier(me, sprintf("%s %s %s", + me.setValueFromIdentifier_noAnim(me, sprintf("%s %s %s", cvar_string("cl_particles_quality"), cvar_string("r_drawparticles_drawdistance"), cvar_string("cl_damageeffect") diff --git a/qcsrc/menu/xonotic/slider_resolution.qc b/qcsrc/menu/xonotic/slider_resolution.qc index 93291ea1d..954d97532 100644 --- a/qcsrc/menu/xonotic/slider_resolution.qc +++ b/qcsrc/menu/xonotic/slider_resolution.qc @@ -211,7 +211,7 @@ void XonoticResolutionSlider_loadResolutions(entity me, float fullscreen) } void XonoticResolutionSlider_loadCvars(entity me) { - me.setValueFromIdentifier(me, strcat(cvar_string("_menu_vid_width"), " ", cvar_string("_menu_vid_height"), " ", cvar_string("_menu_vid_pixelheight"))); + me.setValueFromIdentifier_noAnim(me, strcat(cvar_string("_menu_vid_width"), " ", cvar_string("_menu_vid_height"), " ", cvar_string("_menu_vid_pixelheight"))); } void XonoticResolutionSlider_saveCvars(entity me) { diff --git a/qcsrc/menu/xonotic/slider_sbfadetime.qc b/qcsrc/menu/xonotic/slider_sbfadetime.qc index d64a990d2..a66d2d145 100644 --- a/qcsrc/menu/xonotic/slider_sbfadetime.qc +++ b/qcsrc/menu/xonotic/slider_sbfadetime.qc @@ -28,7 +28,7 @@ void XonoticScoreboardFadeTimeSlider_configureXonoticScoreboardFadeTimeSlider(en } void XonoticScoreboardFadeTimeSlider_loadCvars(entity me) { - me.setValueFromIdentifier(me, sprintf("%s %s", + me.setValueFromIdentifier_noAnim(me, sprintf("%s %s", cvar_string("scoreboard_fadeinspeed"), cvar_string("scoreboard_fadeoutspeed") )); diff --git a/qcsrc/menu/xonotic/textslider.qc b/qcsrc/menu/xonotic/textslider.qc index 886465404..1b1968751 100644 --- a/qcsrc/menu/xonotic/textslider.qc +++ b/qcsrc/menu/xonotic/textslider.qc @@ -63,7 +63,7 @@ void XonoticTextSlider_loadCvars(entity me) float i; for(i = 1; i < n; ++i) s = strcat(s, " ", cvar_string(argv(i))); - me.setValueFromIdentifier(me, s); + me.setValueFromIdentifier_noAnim(me, s); if(me.value < 0 && n > 1) { // if it failed: check if all cvars have the same value @@ -72,7 +72,7 @@ void XonoticTextSlider_loadCvars(entity me) if(cvar_string(argv(i)) != cvar_string(argv(i-1))) break; if(i >= n) - me.setValueFromIdentifier(me, cvar_string(argv(0))); + me.setValueFromIdentifier_noAnim(me, cvar_string(argv(0))); } } void XonoticTextSlider_saveCvars(entity me)