X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fgraphics%2FFrame.cpp;h=34767f53f0cd170185723e2a0806f4cd87ab14bf;hb=76ebf3fdefce0655ecd2404e735e8fd96347d934;hp=a152ee76c8efa152825dc514938e100df97c3736;hpb=d20fa78a0dcbc95a69bb6077d2081d42b74a2d1a;p=l2e.git diff --git a/src/graphics/Frame.cpp b/src/graphics/Frame.cpp index a152ee7..34767f5 100644 --- a/src/graphics/Frame.cpp +++ b/src/graphics/Frame.cpp @@ -7,12 +7,25 @@ #include "Frame.h" +#include "../loader/TypeDescription.h" + using geometry::Vector; +using loader::FieldDescription; +using loader::TypeDescription; namespace graphics { // TODO: maybe create a cache for frames? void Frame::Draw(SDL_Surface *dest, const Vector &position, int width, int height) const { + if (!surface) { + SDL_Rect rect; + rect.x = position.X(); + rect.y = position.Y(); + rect.w = width; + rect.h = height; + SDL_FillRect(dest, &rect, SDL_MapRGB(dest->format, 0xFF, 0x00, 0x00)); + return; + } // top-left corner SDL_Rect srcRect; srcRect.x = offset.X(); @@ -105,4 +118,20 @@ void Frame::Draw(SDL_Surface *dest, const Vector &position, int width, int SDL_BlitSurface(surface, &srcRect, dest, &destRect); } + +void Frame::CreateTypeDescription() { + Frame f; + TypeDescription &td(TypeDescription::CreateOrGet("Frame")); + + td.SetSize(sizeof(Frame)); + + int imageId(TypeDescription::GetTypeId("Image")); + int vectorId(TypeDescription::GetTypeId("Vector")); + + 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)); +} + }