]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/menu/anim/animhost.c
Merge branch 'master' into TimePath/issue-1170
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / anim / animhost.c
index 38c9894eaf6a76437a33057706cdc37650f7334e..ae84e0957da7be5efaff03271861b81b5810d6c4 100644 (file)
@@ -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))
@@ -15,7 +19,7 @@ ENDCLASS(AnimHost)
 #endif
 
 #ifdef IMPLEMENTATION
-void addAnimAnimHost(entity me, entity other)
+void AnimHost_addAnim(entity me, entity other)
 {
        if(other.parent)
                error("Can't add already added anim!");
@@ -25,8 +29,7 @@ void addAnimAnimHost(entity me, entity other)
 
        other.parent = me;
 
-       entity f, l;
-       f = me.firstChild;
+       entity l;
        l = me.lastChild;
 
        if(l)
@@ -39,16 +42,14 @@ void addAnimAnimHost(entity me, entity other)
        me.lastChild = other;
 }
 
-void removeAnimAnimHost(entity me, entity other)
+void AnimHost_removeAnim(entity me, entity other)
 {
        if(other.parent != me)
                error("Can't remove from wrong AnimHost!");
 
        other.parent = NULL;
 
-       entity n, p, f, l;
-       f = me.firstChild;
-       l = me.lastChild;
+       entity n, p;
        n = other.nextSibling;
        p = other.prevSibling;
 
@@ -61,9 +62,35 @@ void removeAnimAnimHost(entity me, entity other)
                n.prevSibling = p;
        else
                me.lastChild = p;
+       remove(other);
+}
+
+void AnimHost_removeAllAnim(entity me)
+{
+       entity e, tmp;
+       for(e = me.firstChild; e; e = e.nextSibling)
+       {
+               tmp = e;
+               e = tmp.prevSibling;
+               me.removeAnim(me, tmp);
+       }
+}
+
+void AnimHost_removeObjAnim(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)
+void AnimHost_stopAllAnim(entity me)
 {
        entity e;
        for(e = me.firstChild; e; e = e.nextSibling)
@@ -72,7 +99,7 @@ void stopAllAnimAnimHost(entity me)
        }
 }
 
-void stopObjAnimAnimHost(entity me, entity obj)
+void AnimHost_stopObjAnim(entity me, entity obj)
 {
        entity e;
        for(e = me.firstChild; e; e = e.nextSibling)
@@ -84,19 +111,39 @@ void stopObjAnimAnimHost(entity me, entity obj)
        }
 }
 
-void finishAllAnimAnimHost(entity me)
+void AnimHost_resumeAllAnim(entity me)
+{
+       entity e;
+       for(e = me.firstChild; e; e = e.nextSibling)
+       {
+               e.resumeAnim(e);
+       }
+}
+
+void AnimHost_resumeObjAnim(entity me, entity obj)
+{
+       entity e;
+       for(e = me.firstChild; e; e = e.nextSibling)
+       {
+               if (e.object == obj)
+               {
+                       e.resumeAnim(e);
+               }
+       }
+}
+
+void AnimHost_finishAllAnim(entity me)
 {
        entity e, tmp;
        for(e = me.firstChild; e; e = e.nextSibling)
        {
                tmp = e;
                e = tmp.prevSibling;
-               me.removeAnim(me, tmp);
                tmp.finishAnim(tmp);
        }
 }
 
-void finishObjAnimAnimHost(entity me, entity obj)
+void AnimHost_finishObjAnim(entity me, entity obj)
 {
        entity e, tmp;
        for(e = me.firstChild; e; e = e.nextSibling)
@@ -105,27 +152,22 @@ void finishObjAnimAnimHost(entity me, entity obj)
                {
                        tmp = e;
                        e = tmp.prevSibling;
-                       me.removeAnim(me, tmp);
                        tmp.finishAnim(tmp);
                }
        }
 }
 
-void tickAllAnimHost(entity me)
+void AnimHost_tickAll(entity me)
 {
        entity e, tmp;
        for(e = me.firstChild; e; e = e.nextSibling)
        {
                e.tick(e, time);
-       }
-       for(e = me.firstChild; e; e = e.nextSibling)
-       {
                if (e.isFinished(e))
                {
                        tmp = e;
                        e = tmp.prevSibling;
                        me.removeAnim(me, tmp);
-                       remove(tmp);
                }
        }
 }