X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fgraphics%2FFrame.cpp;h=46fa1b59db7c799255c282f90e9fe92c654a509d;hb=3a86cc937e9fce68384efc08edb6d6ba101d12eb;hp=34767f53f0cd170185723e2a0806f4cd87ab14bf;hpb=76ebf3fdefce0655ecd2404e735e8fd96347d934;p=l2e.git diff --git a/src/graphics/Frame.cpp b/src/graphics/Frame.cpp index 34767f5..46fa1b5 100644 --- a/src/graphics/Frame.cpp +++ b/src/graphics/Frame.cpp @@ -7,10 +7,12 @@ #include "Frame.h" +#include "../loader/Interpreter.h" #include "../loader/TypeDescription.h" using geometry::Vector; using loader::FieldDescription; +using loader::Interpreter; using loader::TypeDescription; namespace graphics { @@ -121,17 +123,22 @@ void Frame::Draw(SDL_Surface *dest, const Vector &position, int width, int void Frame::CreateTypeDescription() { Frame f; - TypeDescription &td(TypeDescription::CreateOrGet("Frame")); + TypeDescription &td(TypeDescription::Create(TYPE_ID, "Frame")); + td.SetDescription( + "A frame is basically a border + a background texture.\n" + "It splits an image into 3*3 parts where the edges are kept as is and the sides and the middle part are repeated as needed."); + td.SetConstructor(&Construct); td.SetSize(sizeof(Frame)); - int imageId(TypeDescription::GetTypeId("Image")); - int vectorId(TypeDescription::GetTypeId("Vector")); + td.AddField("image", FieldDescription(((char *)&f.surface) - ((char *)&f), Interpreter::IMAGE_ID).SetReferenced().SetDescription("the underlying graphic from which the frame parts are cut")); + td.AddField("border", FieldDescription(((char *)&f.borderSize) - ((char *)&f), Interpreter::VECTOR_ID).SetDescription("size of the border part, dimensions of top-left corner")); + td.AddField("repeat", FieldDescription(((char *)&f.repeatSize) - ((char *)&f), Interpreter::VECTOR_ID).SetDescription("size of the repeat part, dimensions of a single tile of the background texture")); + td.AddField("offset", FieldDescription(((char *)&f.offset) - ((char *)&f), Interpreter::VECTOR_ID).SetDescription("offset into the image where to start cutting, coordinates of the top-left corner on the image")); +} - td.AddField("surface", FieldDescription(((char *)&f.surface) - ((char *)&f), imageId, true)); - td.AddField("borderSize", FieldDescription(((char *)&f.borderSize) - ((char *)&f), vectorId, false)); - td.AddField("repeatSize", FieldDescription(((char *)&f.repeatSize) - ((char *)&f), vectorId, false)); - td.AddField("offset", FieldDescription(((char *)&f.offset) - ((char *)&f), vectorId, false)); +void Frame::Construct(void *data) { + new (data) Frame; } }