From: Stephan Stahl Date: Tue, 18 May 2010 21:58:06 +0000 (+0000) Subject: more stuff for the animation framework and use that to make sliders behave better... X-Git-Tag: xonotic-v0.1.0preview~578^2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=8a019118c4f94b3728669b31765fcc4004098797;p=xonotic%2Fxonotic-data.pk3dir.git more stuff for the animation framework and use that to make sliders behave better when mixing clicking and dragging --- diff --git a/qcsrc/menu/anim/animation.c b/qcsrc/menu/anim/animation.c index 1019fdacb..d6fb114c2 100644 --- a/qcsrc/menu/anim/animation.c +++ b/qcsrc/menu/anim/animation.c @@ -106,6 +106,7 @@ void finishAnimAnimation(entity me) { me.value = me.delta + me.startValue; me.finished = TRUE; + me.setter(me.object, me.value); } void setterDummy(entity obj, float objValue) diff --git a/qcsrc/menu/anim/animhost.c b/qcsrc/menu/anim/animhost.c index 38c9894ea..41a26d5e0 100644 --- a/qcsrc/menu/anim/animhost.c +++ b/qcsrc/menu/anim/animhost.c @@ -2,8 +2,12 @@ CLASS(AnimHost) EXTENDS(Object) METHOD(AnimHost, addAnim, void(entity, entity)) METHOD(AnimHost, removeAnim, void(entity, entity)) + METHOD(AnimHost, removeAllAnim, void(entity)) + METHOD(AnimHost, removeObjAnim, void(entity, entity)) METHOD(AnimHost, stopAllAnim, void(entity)) METHOD(AnimHost, stopObjAnim, void(entity, entity)) + METHOD(AnimHost, resumeAllAnim, void(entity)) + METHOD(AnimHost, resumeObjAnim, void(entity, entity)) METHOD(AnimHost, finishAllAnim, void(entity)) METHOD(AnimHost, finishObjAnim, void(entity, entity)) METHOD(AnimHost, tickAll, void(entity)) @@ -63,6 +67,31 @@ void removeAnimAnimHost(entity me, entity other) me.lastChild = p; } +void removeAllAnimAnimHost(entity me) +{ + entity e, tmp; + for(e = me.firstChild; e; e = e.nextSibling) + { + tmp = e; + e = tmp.prevSibling; + me.removeAnim(me, tmp); + } +} + +void removeObjAnimAnimHost(entity me, entity obj) +{ + entity e, tmp; + for(e = me.firstChild; e; e = e.nextSibling) + { + if (e.object == obj) + { + tmp = e; + e = tmp.prevSibling; + me.removeAnim(me, tmp); + } + } +} + void stopAllAnimAnimHost(entity me) { entity e; @@ -84,6 +113,27 @@ void stopObjAnimAnimHost(entity me, entity obj) } } +void resumeAllAnimAnimHost(entity me) +{ + entity e; + for(e = me.firstChild; e; e = e.nextSibling) + { + e.resumeAnim(e); + } +} + +void resumeObjAnimAnimHost(entity me, entity obj) +{ + entity e; + for(e = me.firstChild; e; e = e.nextSibling) + { + if (e.object == obj) + { + e.resumeAnim(e); + } + } +} + void finishAllAnimAnimHost(entity me) { entity e, tmp; diff --git a/qcsrc/menu/item/slider.c b/qcsrc/menu/item/slider.c index c5605affe..eeac0edd8 100644 --- a/qcsrc/menu/item/slider.c +++ b/qcsrc/menu/item/slider.c @@ -47,7 +47,8 @@ ENDCLASS(Slider) void setValueSlider(entity me, float val) { if (me.animated) { - anim.finishObjAnim(anim, me); + anim.stopObjAnim(anim, me); + anim.removeObjAnim(anim, me); makeHostedEasing(me, setSliderValueSlider, easingQuadInOut, 1, me.sliderValue, val); } else { me.setSliderValue(me, val); @@ -154,8 +155,11 @@ float mouseDragSlider(entity me, vector pos) float v, animed; if(me.disabled) return 0; + + anim.finishObjAnim(anim, me); animed = me.animated; me.animated = false; + if(me.pressed) { hit = 1; @@ -173,7 +177,9 @@ float mouseDragSlider(entity me, vector pos) else me.setValue(me, me.previousValue); } + me.animated = animed; + return 1; } float mousePressSlider(entity me, vector pos)