]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/menu/anim/animhost.qc
Disambiguate translation of team colors (without changing the color code ^TT)
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / anim / animhost.qc
1 #include "../menu.qh"
2
3 #ifndef ANIM_ANIMHOST_H
4         #define ANIM_ANIMHOST_H
5         CLASS(AnimHost, Object)
6                 METHOD(AnimHost, addAnim, void(entity, entity));
7                 METHOD(AnimHost, removeAnim, void(entity, entity));
8                 METHOD(AnimHost, removeAllAnim, void(entity));
9                 METHOD(AnimHost, removeObjAnim, void(entity, entity));
10                 METHOD(AnimHost, stopAllAnim, void(entity));
11                 METHOD(AnimHost, stopObjAnim, void(entity, entity));
12                 METHOD(AnimHost, resumeAllAnim, void(entity));
13                 METHOD(AnimHost, resumeObjAnim, void(entity, entity));
14                 METHOD(AnimHost, finishAllAnim, void(entity));
15                 METHOD(AnimHost, finishObjAnim, void(entity, entity));
16                 METHOD(AnimHost, tickAll, void(entity));
17                 ATTRIB(AnimHost, firstChild, entity, NULL)
18                 ATTRIB(AnimHost, lastChild, entity, NULL)
19         ENDCLASS(AnimHost)
20         .entity nextSibling;
21         .entity prevSibling;
22 #endif
23
24 #ifdef IMPLEMENTATION
25         METHOD(AnimHost, addAnim, void(entity this, entity other))
26         {
27                 if (other.parent) error("Can't add already added anim!");
28
29                 if (other.isFinished(other)) error("Can't add finished anim!");
30
31                 other.parent = this;
32
33                 entity l = this.lastChild;
34
35                 if (l) l.nextSibling = other;
36                 else this.firstChild = other;
37
38                 other.prevSibling = l;
39                 other.nextSibling = NULL;
40                 this.lastChild = other;
41         }
42
43         METHOD(AnimHost, removeAnim, void(entity this, entity other))
44         {
45                 if (other.parent != this) error("Can't remove from wrong AnimHost!");
46
47                 other.parent = NULL;
48
49                 entity n = other.nextSibling;
50                 entity p = other.prevSibling;
51
52                 if (p) p.nextSibling = n;
53                 else this.firstChild = n;
54
55                 if (n) n.prevSibling = p;
56                 else this.lastChild = p;
57                 remove(other);
58         }
59
60         METHOD(AnimHost, removeAllAnim, void(entity this))
61         {
62                 for (entity e = this.firstChild; e; e = e.nextSibling)
63                 {
64                         entity tmp = e;
65                         e = tmp.prevSibling;
66                         this.removeAnim(this, tmp);
67                 }
68         }
69
70         METHOD(AnimHost, removeObjAnim, void(entity this, entity obj))
71         {
72                 for (entity e = this.firstChild; e; e = e.nextSibling)
73                 {
74                         if (e.object == obj)
75                         {
76                                 entity tmp = e;
77                                 e = tmp.prevSibling;
78                                 this.removeAnim(this, tmp);
79                         }
80                 }
81         }
82
83         METHOD(AnimHost, stopAllAnim, void(entity this))
84         {
85                 for (entity e = this.firstChild; e; e = e.nextSibling)
86                         e.stopAnim(e);
87         }
88
89         METHOD(AnimHost, stopObjAnim, void(entity this, entity obj))
90         {
91                 for (entity e = this.firstChild; e; e = e.nextSibling)
92                         if (e.object == obj) e.stopAnim(e);
93         }
94
95         METHOD(AnimHost, resumeAllAnim, void(entity this))
96         {
97                 for (entity e = this.firstChild; e; e = e.nextSibling)
98                         e.resumeAnim(e);
99         }
100
101         METHOD(AnimHost, resumeObjAnim, void(entity this, entity obj))
102         {
103                 for (entity e = this.firstChild; e; e = e.nextSibling)
104                         if (e.object == obj) e.resumeAnim(e);
105         }
106
107         METHOD(AnimHost, finishAllAnim, void(entity this))
108         {
109                 for (entity e = this.firstChild; e; e = e.nextSibling)
110                 {
111                         entity tmp = e;
112                         e = tmp.prevSibling;
113                         tmp.finishAnim(tmp);
114                 }
115         }
116
117         METHOD(AnimHost, finishObjAnim, void(entity this, entity obj))
118         {
119                 for (entity e = this.firstChild; e; e = e.nextSibling)
120                 {
121                         if (e.object == obj)
122                         {
123                                 entity tmp = e;
124                                 e = tmp.prevSibling;
125                                 tmp.finishAnim(tmp);
126                         }
127                 }
128         }
129
130         METHOD(AnimHost, tickAll, void(entity this))
131         {
132                 for (entity e = this.firstChild; e; e = e.nextSibling)
133                 {
134                         e.tick(e, time);
135                         if (e.isFinished(e))
136                         {
137                                 entity tmp = e;
138                                 e = tmp.prevSibling;
139                                 this.removeAnim(this, tmp);
140                         }
141                 }
142         }
143 #endif