From: Daniel Karbach Date: Wed, 5 Sep 2012 21:01:26 +0000 (+0200) Subject: added type description of Font X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=679b9e39c7680fd46482589f37f0a225032103b7;p=l2e.git added type description of Font --- diff --git a/src/graphics/Font.cpp b/src/graphics/Font.cpp index ca06a07..c680310 100644 --- a/src/graphics/Font.cpp +++ b/src/graphics/Font.cpp @@ -7,10 +7,14 @@ #include "Font.h" +#include "../loader/TypeDescription.h" + #include #include using geometry::Vector; +using loader::FieldDescription; +using loader::TypeDescription; using std::pow; namespace graphics { @@ -70,4 +74,19 @@ void Font::DrawNumber(int numberIn, SDL_Surface *dest, const Vector &positi } } + +void Font::CreateTypeDescription() { + Font f; + TypeDescription &td(TypeDescription::CreateOrGet("Font")); + + td.SetSize(sizeof(Font)); + + int numberId(TypeDescription::GetTypeId("Number")); + int spriteId(TypeDescription::GetTypeId("Sprite")); + + td.AddField("sprite", FieldDescription(((char *)&f.sprite) - ((char *)&f), spriteId, true)); + td.AddField("columnoffset", FieldDescription(((char *)&f.colOffset) - ((char *)&f), numberId, false)); + td.AddField("rowoffset", FieldDescription(((char *)&f.rowOffset) - ((char *)&f), numberId, false)); +} + } diff --git a/src/graphics/Font.h b/src/graphics/Font.h index 571431d..8b36525 100644 --- a/src/graphics/Font.h +++ b/src/graphics/Font.h @@ -36,6 +36,8 @@ public: void SetColOffset(int n) { colOffset = n; } void SetRowOffset(int n) { rowOffset = n; } + static void CreateTypeDescription(); + private: const Sprite *sprite; int colOffset;