]> git.localhorst.tv Git - l2e.git/blob - src/graphics/ComplexAnimation.cpp
b3784dd667c0017ac1d2339e18d63795836930f0
[l2e.git] / src / graphics / ComplexAnimation.cpp
1 /*
2  * ComplexAnimation.cpp
3  *
4  *  Created on: Sep 5, 2012
5  *      Author: holy
6  */
7
8 #include "ComplexAnimation.h"
9
10 #include "../loader/Interpreter.h"
11 #include "../loader/TypeDescription.h"
12
13 using loader::FieldDescription;
14 using loader::Interpreter;
15 using loader::TypeDescription;
16
17 namespace graphics {
18
19 void ComplexAnimation::CreateTypeDescription() {
20         ComplexAnimation ca;
21         Animation *a(&ca);
22
23         TypeDescription &td(TypeDescription::Create(TYPE_ID, "ComplexAnimation"));
24         td.SetDescription("Complex animation type that supports per-frame disposition and non-linear sprite offset selection.");
25         td.SetConstructor(&Construct);
26         td.SetSize(sizeof(ComplexAnimation));
27         td.AddSupertype(Animation::TYPE_ID, ((char *)a) - ((char *)&ca));
28
29         Animation::AddFields(td, ca, ((char *)a) - ((char *)&ca));
30         td.AddField("frames", FieldDescription(((char *)&ca.frames) - ((char *)&ca), FrameProp::TYPE_ID).SetReferenced().SetAggregate().SetDescription("a variable number of frames"));
31
32
33         FrameProp fp;
34
35         TypeDescription &ftd(TypeDescription::Create(FrameProp::TYPE_ID, "ComplexAnimationFrame"));
36         ftd.SetDescription("Information about how a frame of a complex animation should be rendered.");
37         ftd.SetSize(sizeof(FrameProp));
38
39         ftd.AddField("column", FieldDescription(((char *)&fp.col) - ((char *)&fp), Interpreter::NUMBER_ID).SetDescription("the column of the sprite that will be drawn"));
40         ftd.AddField("row", FieldDescription(((char *)&fp.row) - ((char *)&fp), Interpreter::NUMBER_ID).SetDescription("the row of the sprite that will be drawn"));
41         ftd.AddField("disposition", FieldDescription(((char *)&fp.disposition) - ((char *)&fp), Interpreter::VECTOR_ID).SetDescription("offset from the original drawing position"));
42 }
43
44 void ComplexAnimation::Construct(void *data) {
45         new (data) ComplexAnimation;
46 }
47
48 }