From: Daniel Karbach Date: Fri, 31 Aug 2012 19:20:46 +0000 (+0200) Subject: made Frame default constructible X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=4bc4ae3e73ea6c7cc43464470204801e7721a2e8;p=l2e.git made Frame default constructible --- diff --git a/src/graphics/Frame.cpp b/src/graphics/Frame.cpp index a152ee7..1485607 100644 --- a/src/graphics/Frame.cpp +++ b/src/graphics/Frame.cpp @@ -13,6 +13,15 @@ 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(); diff --git a/src/graphics/Frame.h b/src/graphics/Frame.h index 09674cc..59aa1fb 100644 --- a/src/graphics/Frame.h +++ b/src/graphics/Frame.h @@ -17,7 +17,7 @@ namespace graphics { class Frame { public: - Frame(SDL_Surface *s, int borderWidth, int borderHeight, int repeatWidth = 1, int repeatHeight = 1, int xOffset = 0, int yOffset = 0) + explicit Frame(SDL_Surface *s = 0, int borderWidth = 1, int borderHeight = 1, int repeatWidth = 1, int repeatHeight = 1, int xOffset = 0, int yOffset = 0) : surface(s), borderSize(borderWidth, borderHeight), repeatSize(repeatWidth, repeatHeight), offset(xOffset, yOffset) { } public: @@ -31,6 +31,12 @@ public: const geometry::Vector RepeatSize() const { return repeatSize; } void Draw(SDL_Surface *dest, const geometry::Vector &position, int width, int height) const; +public: + void SetSurface(SDL_Surface *s) { surface = s; } + void SetBorderSize(const geometry::Vector &s) { borderSize = s; } + void SetRepeatSize(const geometry::Vector &s) { repeatSize = s; } + void SetOffset(const geometry::Vector &o) { offset = o; } + private: SDL_Surface *surface; geometry::Vector borderSize;