From 679b9e39c7680fd46482589f37f0a225032103b7 Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Wed, 5 Sep 2012 23:01:26 +0200 Subject: [PATCH] added type description of Font --- src/graphics/Font.cpp | 19 +++++++++++++++++++ src/graphics/Font.h | 2 ++ 2 files changed, 21 insertions(+) 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; -- 2.39.2