summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChuck Miller <shadowmil@gmail.com>2010-01-15 23:35:30 -0500
committerChuck Miller <shadowmil@gmail.com>2010-01-15 23:38:07 -0500
commitb278542da029c629736be8605a9b4d85a6f2b902 (patch)
treee935cf888be4e88d5f471654a27fbdf512ab537b /src
parentc5e241b276bcbf725309360edc2bdf033f49e98e (diff)
downloadmana-b278542da029c629736be8605a9b4d85a6f2b902.tar.gz
mana-b278542da029c629736be8605a9b4d85a6f2b902.tar.bz2
mana-b278542da029c629736be8605a9b4d85a6f2b902.tar.xz
mana-b278542da029c629736be8605a9b4d85a6f2b902.zip
Fixes drawing sprite in the playerbox widget.
Diffstat (limited to 'src')
-rw-r--r--src/being.cpp14
-rw-r--r--src/being.h8
-rw-r--r--src/gui/widgets/playerbox.cpp2
3 files changed, 23 insertions, 1 deletions
diff --git a/src/being.cpp b/src/being.cpp
index 613e692a..45a621e4 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -664,6 +664,20 @@ void Being::draw(Graphics *graphics, int offsetX, int offsetY) const
}
}
+void Being::drawSpriteAt(Graphics *graphics, int x, int y) const
+{
+ const int px = x - 16;
+ const int py = y - 32;
+
+ for (SpriteConstIterator it = mSprites.begin(); it != mSprites.end(); it++)
+ if (*it)
+ {
+ if ((*it)->getAlpha() != mAlpha)
+ (*it)->setAlpha(mAlpha);
+ (*it)->draw(graphics, px, py);
+ }
+}
+
void Being::drawEmotion(Graphics *graphics, int offsetX, int offsetY)
{
if (!mEmotion)
diff --git a/src/being.h b/src/being.h
index 02abf898..f670722c 100644
--- a/src/being.h
+++ b/src/being.h
@@ -321,9 +321,17 @@ class Being : public Sprite, public ConfigListener
* Draws this being to the given graphics context.
*
* @see Sprite::draw(Graphics, int, int)
+ *
+ * TODO: The following two functions should be combined.
+ * at some point draw(), was changed to use mPx and mPy, with arugements
+ * only for the offset, drawSpriteAt() takes x, and y and draws the sprite
+ * exactly at those coords (though it does do some computing to work how the
+ * old draw() worked).
*/
virtual void draw(Graphics *graphics, int offsetX, int offsetY) const;
+ virtual void drawSpriteAt(Graphics *graphics, int x, int y) const;
+
/**
* Set the alpha opacity used to draw the being.
*/
diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp
index 4c499c36..9419616e 100644
--- a/src/gui/widgets/playerbox.cpp
+++ b/src/gui/widgets/playerbox.cpp
@@ -86,7 +86,7 @@ void PlayerBox::draw(gcn::Graphics *graphics)
const int bs = getFrameSize();
const int x = getWidth() / 2 + bs;
const int y = getHeight() - bs;
- mPlayer->draw(static_cast<Graphics*>(graphics), x, y);
+ mPlayer->drawSpriteAt(static_cast<Graphics*>(graphics), x, y);
}
if (config.getValue("guialpha", 0.8) != mAlpha)