From 63e55846d4043f96ee1bdb95f0631b07d5f57c28 Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Wed, 5 Sep 2012 23:20:27 +0200 Subject: [PATCH] added type description of Gauge --- src/graphics/Gauge.cpp | 24 ++++++++++++++++++++++++ src/graphics/Gauge.h | 2 ++ 2 files changed, 26 insertions(+) diff --git a/src/graphics/Gauge.cpp b/src/graphics/Gauge.cpp index 0d72ac0..7407ba7 100644 --- a/src/graphics/Gauge.cpp +++ b/src/graphics/Gauge.cpp @@ -7,7 +7,11 @@ #include "Gauge.h" +#include "../loader/TypeDescription.h" + using geometry::Vector; +using loader::FieldDescription; +using loader::TypeDescription; namespace graphics { @@ -78,4 +82,24 @@ void Gauge::Draw(SDL_Surface *dest, const Vector &position, int width, Uint } + +void Gauge::CreateTypeDescription() { + Gauge g; + TypeDescription &td(TypeDescription::CreateOrGet("Gauge")); + + td.SetSize(sizeof(Gauge)); + + int imageId(TypeDescription::GetTypeId("Image")); + int numberId(TypeDescription::GetTypeId("Number")); + int vectorId(TypeDescription::GetTypeId("Vector")); + + td.AddField("image", FieldDescription(((char *)&g.surface) - ((char *)&g), imageId, true)); + td.AddField("full", FieldDescription(((char *)&g.fullOffset) - ((char *)&g), vectorId, false)); + td.AddField("empty", FieldDescription(((char *)&g.emptyOffset) - ((char *)&g), vectorId, false)); + td.AddField("height", FieldDescription(((char *)&g.height) - ((char *)&g), numberId, false)); + td.AddField("start", FieldDescription(((char *)&g.startWidth) - ((char *)&g), numberId, false)); + td.AddField("repeat", FieldDescription(((char *)&g.repeatWidth) - ((char *)&g), numberId, false)); + td.AddField("end", FieldDescription(((char *)&g.endWidth) - ((char *)&g), numberId, false)); +} + } diff --git a/src/graphics/Gauge.h b/src/graphics/Gauge.h index 3251ec2..82b8952 100644 --- a/src/graphics/Gauge.h +++ b/src/graphics/Gauge.h @@ -34,6 +34,8 @@ public: void SetRepeatWidth(int w) { repeatWidth = w; } void SetEndWidth(int w) { endWidth = w; } + static void CreateTypeDescription(); + private: SDL_Surface *surface; geometry::Vector fullOffset; -- 2.39.2