From: Daniel Karbach Date: Sun, 9 Sep 2012 12:45:00 +0000 (+0200) Subject: added type description of Sprite X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=edfc8aae94284af20df348a23b48afeb5971a230;p=l2e.git added type description of Sprite --- diff --git a/src/graphics/Sprite.cpp b/src/graphics/Sprite.cpp index 67bde8d..e83486e 100644 --- a/src/graphics/Sprite.cpp +++ b/src/graphics/Sprite.cpp @@ -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 &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)); +} + } diff --git a/src/graphics/Sprite.h b/src/graphics/Sprite.h index 2af95f8..257d2df 100644 --- a/src/graphics/Sprite.h +++ b/src/graphics/Sprite.h @@ -43,6 +43,8 @@ public: void SetSize(const geometry::Vector &s) { size = s; } void SetOffset(const geometry::Vector &o) { offset = o; } + static void CreateTypeDescription(); + private: SDL_Surface *surface; geometry::Vector size;