summaryrefslogtreecommitdiff
path: root/src/being
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-03-13 22:06:58 +0300
committerAndrei Karas <akaras@inbox.ru>2016-03-13 22:06:58 +0300
commit9e77738e7c8a01e343c060a12f0d9d44a96874ed (patch)
treea233f74e925958cd991019d1c35671433b1adf9a /src/being
parentd2c64cb6995486136be2cd511ff7ad835d57c319 (diff)
downloadplus-9e77738e7c8a01e343c060a12f0d9d44a96874ed.tar.gz
plus-9e77738e7c8a01e343c060a12f0d9d44a96874ed.tar.bz2
plus-9e77738e7c8a01e343c060a12f0d9d44a96874ed.tar.xz
plus-9e77738e7c8a01e343c060a12f0d9d44a96874ed.zip
Split CompoundSprite::draw into draw and drawSimple.
Diffstat (limited to 'src/being')
-rw-r--r--src/being/being.cpp10
-rw-r--r--src/being/compoundsprite.cpp30
-rw-r--r--src/being/compoundsprite.h4
3 files changed, 38 insertions, 6 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp
index c3e63d41c..f31e45447 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -3050,7 +3050,7 @@ void Being::drawOtherSpriteAt(Graphics *restrict const graphics,
const int x,
const int y) const restrict2
{
- CompoundSprite::draw(graphics, x, y);
+ CompoundSprite::drawSimple(graphics, x, y);
}
void Being::drawMonsterSpriteAt(Graphics *restrict const graphics,
@@ -3063,7 +3063,7 @@ void Being::drawMonsterSpriteAt(Graphics *restrict const graphics,
{
if (!userPalette)
{
- CompoundSprite::draw(graphics, x, y);
+ CompoundSprite::drawSimple(graphics, x, y);
return;
}
@@ -3081,7 +3081,7 @@ void Being::drawMonsterSpriteAt(Graphics *restrict const graphics,
2 * attackRange + mapTileSize, 2 * attackRange + mapTileSize));
}
- CompoundSprite::draw(graphics, x, y);
+ CompoundSprite::drawSimple(graphics, x, y);
if (mShowMobHP &&
mInfo &&
@@ -3118,7 +3118,7 @@ void Being::drawPortalSpriteAt(Graphics *restrict const graphics,
{
if (!userPalette)
{
- CompoundSprite::draw(graphics, x, y);
+ CompoundSprite::drawSimple(graphics, x, y);
return;
}
@@ -3135,7 +3135,7 @@ void Being::drawPortalSpriteAt(Graphics *restrict const graphics,
}
}
- CompoundSprite::draw(graphics, x, y);
+ CompoundSprite::drawSimple(graphics, x, y);
}
void Being::drawHpBar(Graphics *restrict const graphics,
diff --git a/src/being/compoundsprite.cpp b/src/being/compoundsprite.cpp
index f19b479a6..2af54f247 100644
--- a/src/being/compoundsprite.cpp
+++ b/src/being/compoundsprite.cpp
@@ -137,7 +137,8 @@ bool CompoundSprite::update(const int time)
}
void CompoundSprite::draw(Graphics *const graphics,
- const int posX, const int posY) const
+ const int posX,
+ const int posY) const
{
FUNC_BLOCK("CompoundSprite::draw", 1)
if (mNeedsRedraw)
@@ -162,6 +163,33 @@ void CompoundSprite::draw(Graphics *const graphics,
}
}
+void CompoundSprite::drawSimple(Graphics *const graphics,
+ const int posX,
+ const int posY) const
+{
+ FUNC_BLOCK("CompoundSprite::draw", 1)
+ if (mNeedsRedraw)
+ updateImages();
+
+ if (mSprites.empty()) // Nothing to draw
+ return;
+
+ if (mAlpha == 1.0F && mImage)
+ {
+ graphics->drawImage(mImage, posX + mOffsetX, posY + mOffsetY);
+ }
+ else if (mAlpha && mAlphaImage)
+ {
+ mAlphaImage->setAlpha(mAlpha);
+ graphics->drawImage(mAlphaImage,
+ posX + mOffsetX, posY + mOffsetY);
+ }
+ else
+ {
+ CompoundSprite::drawSprites(graphics, posX, posY);
+ }
+}
+
void CompoundSprite::drawSprites(Graphics *const graphics,
const int posX,
const int posY) const
diff --git a/src/being/compoundsprite.h b/src/being/compoundsprite.h
index d50f20b2d..a1a0e9742 100644
--- a/src/being/compoundsprite.h
+++ b/src/being/compoundsprite.h
@@ -54,6 +54,10 @@ class CompoundSprite notfinal : public Sprite
const int posX,
const int posY) const override A_NONNULL(2);
+ void drawSimple(Graphics *const graphics,
+ const int posX,
+ const int posY) const A_NONNULL(2);
+
/**
* Gets the width in pixels of the first sprite in the list.
*/