summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-06-12 21:01:40 +0300
committerAndrei Karas <akaras@inbox.ru>2013-06-12 21:01:40 +0300
commitf08efa8a84347e2d734b4a2580a4faa8613a469b (patch)
treee7fec0f40343146939b4d64a56ca02a09987c05d
parent7faf2a34326d54a0c750a38680de942fb9e5f717 (diff)
downloadmv-f08efa8a84347e2d734b4a2580a4faa8613a469b.tar.gz
mv-f08efa8a84347e2d734b4a2580a4faa8613a469b.tar.bz2
mv-f08efa8a84347e2d734b4a2580a4faa8613a469b.tar.xz
mv-f08efa8a84347e2d734b4a2580a4faa8613a469b.zip
improve playerbox.
-rw-r--r--src/gui/widgets/playerbox.cpp24
-rw-r--r--src/gui/widgets/playerbox.h5
2 files changed, 14 insertions, 15 deletions
diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp
index 38e7f1f57..20260b9ac 100644
--- a/src/gui/widgets/playerbox.cpp
+++ b/src/gui/widgets/playerbox.cpp
@@ -87,11 +87,12 @@ void PlayerBox::init(std::string name, std::string selectedName)
{
setFrameSize(2);
- if (Theme::instance())
+ Theme *const theme = Theme::instance();
+ if (theme)
{
if (name.empty())
name = "playerbox.xml";
- mSkin = Theme::instance()->loadSkinRect(mBackground,
+ mSkin = theme->loadSkinRect(mBackground,
name, "playerbox_background.xml");
if (mSkin)
{
@@ -102,7 +103,7 @@ void PlayerBox::init(std::string name, std::string selectedName)
}
if (selectedName.empty())
selectedName = "playerboxselected.xml";
- mSelectedSkin = Theme::instance()->loadSkinRect(mSelectedBackground,
+ mSelectedSkin = theme->loadSkinRect(mSelectedBackground,
selectedName, "playerbox_background.xml");
}
else
@@ -119,19 +120,19 @@ void PlayerBox::draw(gcn::Graphics *graphics)
BLOCK_START("PlayerBox::draw")
if (mBeing)
{
- // Draw character
- const int bs = getFrameSize();
- const int x = getWidth() / 2 + bs + mOffsetX;
- const int y = getHeight() - bs + mOffsetY;
+ const int bs = mFrameSize;
+ const int x = mDimension.width / 2 + bs + mOffsetX;
+ const int y = mDimension.height - bs + mOffsetY;
mBeing->drawSpriteAt(static_cast<Graphics*>(graphics), x, y);
}
if (Client::getGuiAlpha() != mAlpha)
{
+ const float alpha = Client::getGuiAlpha();
for (int a = 0; a < 9; a++)
{
if (mBackground.grid[a])
- mBackground.grid[a]->setAlpha(Client::getGuiAlpha());
+ mBackground.grid[a]->setAlpha(alpha);
}
}
BLOCK_END("PlayerBox::draw")
@@ -142,10 +143,9 @@ void PlayerBox::drawFrame(gcn::Graphics *graphics)
BLOCK_START("PlayerBox::drawFrame")
if (mDrawBackground)
{
- int w, h, bs;
- bs = getFrameSize();
- w = getWidth() + bs * 2;
- h = getHeight() + bs * 2;
+ const int bs = mFrameSize * 2;
+ const int w = mDimension.width + bs;
+ const int h = mDimension.height + bs;
if (!mSelected)
{
diff --git a/src/gui/widgets/playerbox.h b/src/gui/widgets/playerbox.h
index 7368bb2d7..eeb179625 100644
--- a/src/gui/widgets/playerbox.h
+++ b/src/gui/widgets/playerbox.h
@@ -85,11 +85,10 @@ class PlayerBox final : public Widget2,
void setSelected(bool b)
{ mSelected = b; }
- void mouseReleased(gcn::MouseEvent& event);
+ void mouseReleased(gcn::MouseEvent& event) override;
private:
- Being *mBeing; /**< The character used for display */
-
+ Being *mBeing;
float mAlpha;
ImageRect mBackground;
ImageRect mSelectedBackground;