]> git.localhorst.tv Git - l2e.git/commitdiff
added type description of simple animation
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Wed, 5 Sep 2012 20:06:35 +0000 (22:06 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Wed, 5 Sep 2012 20:26:48 +0000 (22:26 +0200)
src/graphics/Animation.cpp [new file with mode: 0644]
src/graphics/Animation.h
src/graphics/SimpleAnimation.cpp [new file with mode: 0644]
src/graphics/SimpleAnimation.h

diff --git a/src/graphics/Animation.cpp b/src/graphics/Animation.cpp
new file mode 100644 (file)
index 0000000..caffb50
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Animation.cpp
+ *
+ *  Created on: Sep 5, 2012
+ *      Author: holy
+ */
+
+#include "Animation.h"
+
+#include "../loader/TypeDescription.h"
+
+using loader::FieldDescription;
+using loader::TypeDescription;
+
+namespace graphics {
+
+void AddFields(TypeDescription &td, const Animation &a, std::ptrdiff_t offset) {
+       int boolId(TypeDescription::GetTypeId("Boolean"));
+       int numberId(TypeDescription::GetTypeId("Number"));
+       int spriteId(TypeDescription::GetTypeId("Sprite"));
+
+       td.AddField("sprite", FieldDescription(((char *)&a.sprite) - ((char *)&a) - offset, spriteId, true));
+       td.AddField("frametime", FieldDescription(((char *)&a.frameTime) - ((char *)&a) - offset, numberId, false));
+       td.AddField("repeat", FieldDescription(((char *)&a.repeat) - ((char *)&a) - offset, boolId, false));
+}
+
+}
index 2696694a4f4235cc9454af5b2528ad1a80788567..ee62493b18f54c623c729d52c450ec046b027993 100644 (file)
 #include "../app/Timer.h"
 #include "../geometry/Vector.h"
 
+#include <memory>
 #include <SDL.h>
 
+namespace loader {
+       class TypeDescription;
+}
+
 namespace graphics {
 
 class Animation {
@@ -43,6 +48,9 @@ public:
        virtual int Row(int frame) const = 0;
        virtual geometry::Vector<int> Offset(int frame) const { return geometry::Vector<int>(); }
 
+protected:
+       static void AddFields(loader::TypeDescription &, const Animation &, std::ptrdiff_t offset);
+
 private:
        const Sprite *sprite;
        int frameTime;
diff --git a/src/graphics/SimpleAnimation.cpp b/src/graphics/SimpleAnimation.cpp
new file mode 100644 (file)
index 0000000..4e16b81
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * SimpleAnimation.cpp
+ *
+ *  Created on: Sep 5, 2012
+ *      Author: holy
+ */
+
+#include "SimpleAnimation.h"
+
+#include "../loader/TypeDescription.h"
+
+using loader::FieldDescription;
+using loader::TypeDescription;
+
+namespace graphics {
+
+void SimpleAnimation::CreateTypeDescription() {
+       SimpleAnimation sa;
+       Animation *a(&sa);
+       TypeDescription &td(TypeDescription::CreateOrGet("SimpleAnimation"));
+
+       td.SetSize(sizeof(SimpleAnimation));
+       td.AddSupertype(TypeDescription::GetTypeId("Animation"), ((char *)a) - ((char *)&sa));
+
+       int numberId(TypeDescription::GetTypeId("Number"));
+
+       td.AddField("framecount", FieldDescription(((char *)&sa.numFrames) - ((char *)&sa), numberId, false));
+       td.AddField("col", FieldDescription(((char *)&sa.col) - ((char *)&sa), numberId, false));
+       td.AddField("row", FieldDescription(((char *)&sa.row) - ((char *)&sa), numberId, false));
+}
+
+}
index 003a03120c5b451908e3f72443e55251d2c15cb1..81d62443f699fbc144de9c720722eb2cac7c4631 100644 (file)
@@ -26,6 +26,8 @@ public:
        void SetCol(int c) { col = c; }
        void SetRow(int r) { row = r; }
 
+       static void CreateTypeDescription();
+
 protected:
        virtual int NumFrames() const { return numFrames; };
        virtual int Col(int frame) const { return col; }