X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fgraphics%2FGauge.cpp;h=7e20567eceab33dd606421012de24f1a8920550e;hb=7f0a586b8238c7093a8942ff5b5c4122edd386fc;hp=6925c2ff2482ae1a302d60a8d9f3bc77add64a7c;hpb=46d158b25b842d2ec4b9734af09ca6006c934498;p=l2e.git diff --git a/src/graphics/Gauge.cpp b/src/graphics/Gauge.cpp index 6925c2f..7e20567 100644 --- a/src/graphics/Gauge.cpp +++ b/src/graphics/Gauge.cpp @@ -1,16 +1,11 @@ -/* - * Gauge.cpp - * - * Created on: Aug 7, 2012 - * Author: holy - */ - #include "Gauge.h" +#include "../loader/Interpreter.h" #include "../loader/TypeDescription.h" using geometry::Vector; using loader::FieldDescription; +using loader::Interpreter; using loader::TypeDescription; namespace graphics { @@ -86,20 +81,25 @@ void Gauge::Draw(SDL_Surface *dest, const Vector &position, int width, Uint void Gauge::CreateTypeDescription() { Gauge g; - int imageId(TypeDescription::GetTypeId("Image")); - int numberId(TypeDescription::GetTypeId("Number")); - int vectorId(TypeDescription::GetTypeId("Vector")); - - TypeDescription &td(TypeDescription::CreateOrGet("Gauge")); + TypeDescription &td(TypeDescription::Create(TYPE_ID, "Gauge")); + td.SetDescription( + "Gauges display a percentage by filling the left part different than the right.\n" + "The fill level is only mapped with repeat.\n" + "Start is filled if the level in greater than zero, end is filled if the level is at its maximum."); + td.SetConstructor(&Construct); td.SetSize(sizeof(Gauge)); - 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)); + td.AddField("image", FieldDescription(((char *)&g.surface) - ((char *)&g), Interpreter::IMAGE_ID).SetReferenced().SetDescription("the underlying graphic from which the gauge parts are cut")); + td.AddField("full", FieldDescription(((char *)&g.fullOffset) - ((char *)&g), Interpreter::VECTOR_ID).SetDescription("top-left corner of the filled gauge")); + td.AddField("empty", FieldDescription(((char *)&g.emptyOffset) - ((char *)&g), Interpreter::VECTOR_ID).SetDescription("top-left corner of the empty gauge")); + td.AddField("height", FieldDescription(((char *)&g.height) - ((char *)&g), Interpreter::NUMBER_ID).SetDescription("height of the gauges")); + td.AddField("start", FieldDescription(((char *)&g.startWidth) - ((char *)&g), Interpreter::NUMBER_ID).SetDescription("width of the start part")); + td.AddField("repeat", FieldDescription(((char *)&g.repeatWidth) - ((char *)&g), Interpreter::NUMBER_ID).SetDescription("width of the repeat part")); + td.AddField("end", FieldDescription(((char *)&g.endWidth) - ((char *)&g), Interpreter::NUMBER_ID).SetDescription("width of the end part")); +} + +void Gauge::Construct(void *data) { + new (data) Gauge; } }