]> git.localhorst.tv Git - l2e.git/commitdiff
added type description of Sprite
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Sun, 9 Sep 2012 12:45:00 +0000 (14:45 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Sun, 9 Sep 2012 12:45:00 +0000 (14:45 +0200)
src/graphics/Sprite.cpp
src/graphics/Sprite.h

index 67bde8d09ba60f35e9ed85ea1e742d55ed9459e9..e83486e9fe2d4d17baa1b1d53c0f88be322e3d69 100644 (file)
@@ -7,7 +7,11 @@
 
 #include "Sprite.h"
 
+#include "../loader/TypeDescription.h"
+
 using geometry::Vector;
+using loader::FieldDescription;
+using loader::TypeDescription;
 
 namespace graphics {
 
@@ -36,4 +40,19 @@ void Sprite::Draw(SDL_Surface *dest, const Vector<int> &position, int col, int r
        }
 }
 
+
+void Sprite::CreateTypeDescription() {
+       Sprite s;
+       TypeDescription &td(TypeDescription::CreateOrGet("Sprite"));
+
+       td.SetSize(sizeof(Sprite));
+
+       int imageId(TypeDescription::GetTypeId("Image"));
+       int vectorId(TypeDescription::GetTypeId("Vector"));
+
+       td.AddField("image", FieldDescription(((char *)&s.surface) - ((char *)&s), imageId, true));
+       td.AddField("size", FieldDescription(((char *)&s.size) - ((char *)&s), vectorId, false));
+       td.AddField("offset", FieldDescription(((char *)&s.offset) - ((char *)&s), vectorId, false));
+}
+
 }
index 2af95f858d12ac104814fa73ec201e42c39d9c53..257d2dfd6007fba92d2eacd3f2354da2e61ce9d4 100644 (file)
@@ -43,6 +43,8 @@ public:
        void SetSize(const geometry::Vector<int> &s) { size = s; }
        void SetOffset(const geometry::Vector<int> &o) { offset = o; }
 
+       static void CreateTypeDescription();
+
 private:
        SDL_Surface *surface;
        geometry::Vector<int> size;