]> git.localhorst.tv Git - l2e.git/blob - src/graphics/SimpleAnimation.cpp
added textual type/field descriptions and wiki mode
[l2e.git] / src / graphics / SimpleAnimation.cpp
1 /*
2  * SimpleAnimation.cpp
3  *
4  *  Created on: Sep 5, 2012
5  *      Author: holy
6  */
7
8 #include "SimpleAnimation.h"
9
10 #include "../loader/TypeDescription.h"
11
12 using loader::FieldDescription;
13 using loader::TypeDescription;
14
15 namespace graphics {
16
17 void SimpleAnimation::CreateTypeDescription() {
18         SimpleAnimation sa;
19         Animation *a(&sa);
20
21         int animationId(TypeDescription::GetTypeId("Animation"));
22         int boolId(TypeDescription::GetTypeId("Boolean"));
23         int numberId(TypeDescription::GetTypeId("Number"));
24         int spriteId(TypeDescription::GetTypeId("Sprite"));
25
26         TypeDescription &td(TypeDescription::CreateOrGet("SimpleAnimation"));
27         td.SetDescription("An animation that uses a fixed column and increasing row of a sprite based on the frame number.");
28         td.SetConstructor(&Construct);
29         td.SetSize(sizeof(SimpleAnimation));
30         td.AddSupertype(animationId, ((char *)a) - ((char *)&sa));
31
32         Animation::AddFields(td, sa, ((char *)a) - ((char *)&sa), boolId, numberId, spriteId);
33         td.AddField("framecount", FieldDescription(((char *)&sa.numFrames) - ((char *)&sa), numberId).SetDescription("number of frames of a single run"));
34         td.AddField("col", FieldDescription(((char *)&sa.col) - ((char *)&sa), numberId).SetDescription("the column of the sprite to draw from"));
35         td.AddField("row", FieldDescription(((char *)&sa.row) - ((char *)&sa), numberId).SetDescription("the row of the sprite of the first frame"));
36 }
37
38 void SimpleAnimation::Construct(void *data) {
39         new (data) SimpleAnimation;
40 }
41
42 }