diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2025-03-05 16:10:36 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2025-03-07 22:27:48 +0100 |
commit | f5b0403c9d6231ea324932ba76b0cda77d9fcd8f (patch) | |
tree | 857d8caae2db6ae9ad173972717298fcb1c32dc5 /src | |
parent | e9f8e94c67283057feac75128962fd5fd3a4daa0 (diff) | |
download | mana-f5b0403c9d6231ea324932ba76b0cda77d9fcd8f.tar.gz mana-f5b0403c9d6231ea324932ba76b0cda77d9fcd8f.tar.bz2 mana-f5b0403c9d6231ea324932ba76b0cda77d9fcd8f.tar.xz mana-f5b0403c9d6231ea324932ba76b0cda77d9fcd8f.zip |
Fixed CompoundSprite::getWidth/getHeight
The getWidth and getHeight functions need to make sure the mWidth and
mHeight members have been initialized, by calling redraw() when still
necessary.
Removed the unused getOffsetX/Y getters.
Diffstat (limited to 'src')
-rw-r--r-- | src/compoundsprite.cpp | 9 | ||||
-rw-r--r-- | src/compoundsprite.h | 15 |
2 files changed, 10 insertions, 14 deletions
diff --git a/src/compoundsprite.cpp b/src/compoundsprite.cpp index 0ca55098..8193d8c0 100644 --- a/src/compoundsprite.cpp +++ b/src/compoundsprite.cpp @@ -74,8 +74,7 @@ bool CompoundSprite::update(int time) bool CompoundSprite::draw(Graphics *graphics, int posX, int posY) const { - if (mNeedsRedraw) - redraw(); + doRedraw(); if (mSprites.empty()) // Nothing to draw return false; @@ -163,12 +162,6 @@ void CompoundSprite::ensureSize(size_t layerCount) mSprites.resize(layerCount); } -void CompoundSprite::doRedraw() -{ - if (mNeedsRedraw) - redraw(); -} - int CompoundSprite::getMaxDuration() const { int duration = 0; diff --git a/src/compoundsprite.h b/src/compoundsprite.h index cea0b11f..5aa11686 100644 --- a/src/compoundsprite.h +++ b/src/compoundsprite.h @@ -38,15 +38,12 @@ public: /** * Gets the width in pixels of the first sprite in the list. */ - int getWidth() const { return mWidth; } + int getWidth() const { doRedraw(); return mWidth; } /** * Gets the height in pixels of the first sprite in the list. */ - int getHeight() const { return mHeight; } - - int getOffsetX() const { return mOffsetX; } - int getOffsetY() const { return mOffsetY; } + int getHeight() const { doRedraw(); return mHeight; } float getAlpha() const { return mAlpha; } void setAlpha(float alpha) { mAlpha = alpha; } @@ -64,7 +61,7 @@ public: void clear(); void ensureSize(size_t layerCount); - void doRedraw(); + void doRedraw() const; private: void redraw() const; @@ -80,3 +77,9 @@ private: float mAlpha = 1.0f; std::vector<Sprite*> mSprites; }; + +inline void CompoundSprite::doRedraw() const +{ + if (mNeedsRedraw) + redraw(); +} |