]> git.localhorst.tv Git - l2e.git/blobdiff - src/graphics/ComplexAnimation.cpp
new language, new compiler
[l2e.git] / src / graphics / ComplexAnimation.cpp
index f999c4af18f748d7129e71056074aa40b49e586b..942db777e0f72eeaec4e5b0e52777dc8db5a8fc6 100644 (file)
@@ -3,12 +3,52 @@
 #include "../loader/Interpreter.h"
 #include "../loader/TypeDescription.h"
 
+using math::Vector;
 using loader::FieldDescription;
 using loader::Interpreter;
 using loader::TypeDescription;
 
 namespace graphics {
 
+ComplexAnimation::ComplexAnimation()
+: frames(0)
+, numFrames(0) {
+
+}
+
+ComplexAnimation::ComplexAnimation(
+               const Sprite *sprite,
+               int frameTime,
+               bool repeat)
+: Animation(sprite, frameTime, repeat)
+, frames(0)
+, numFrames(0) {
+
+}
+
+ComplexAnimation::ComplexAnimation(loader::noinit_t n)
+: Animation(n) {
+
+}
+
+
+int ComplexAnimation::NumFrames() const {
+       return numFrames;
+}
+
+int ComplexAnimation::Col(int frame) const {
+       return frames[frame].col;
+}
+
+int ComplexAnimation::Row(int frame) const {
+       return frames[frame].row;
+}
+
+Vector<int> ComplexAnimation::Offset(int frame) const {
+       return frames[frame].disposition;
+}
+
+
 void ComplexAnimation::CreateTypeDescription() {
        ComplexAnimation ca;
        Animation *a(&ca);
@@ -16,11 +56,12 @@ void ComplexAnimation::CreateTypeDescription() {
        TypeDescription &td(TypeDescription::Create(TYPE_ID, "ComplexAnimation"));
        td.SetDescription("Complex animation type that supports per-frame disposition and non-linear sprite offset selection.");
        td.SetConstructor(&Construct);
+       td.SetInitializer(&Initialize);
        td.SetSize(sizeof(ComplexAnimation));
        td.AddSupertype(Animation::TYPE_ID, ((char *)a) - ((char *)&ca));
 
        Animation::AddFields(td, ca, ((char *)a) - ((char *)&ca));
-       td.AddField("frames", FieldDescription(((char *)&ca.frames) - ((char *)&ca), FrameProp::TYPE_ID).SetReferenced().SetAggregate().SetDescription("a variable number of frames"));
+       td.AddField("frames", FieldDescription(((char *)&ca.frames) - ((char *)&ca), FrameProp::TYPE_ID).SetAggregate().SetDescription("a variable number of frames"));
 
 
        FrameProp fp;
@@ -38,4 +79,8 @@ void ComplexAnimation::Construct(void *data) {
        new (data) ComplexAnimation;
 }
 
+void ComplexAnimation::Initialize(void *data) {
+       new (data) ComplexAnimation(loader::noinit);
+}
+
 }