summaryrefslogtreecommitdiff
path: root/src/gui/widgets/playerbox.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-04-22 12:16:20 +0300
committerAndrei Karas <akaras@inbox.ru>2013-04-29 00:49:56 +0300
commit76c98ce0c8e78778f73d6a5728441897e134fb9e (patch)
tree63753c9b80004c2f66314d8ea883a9b378656a12 /src/gui/widgets/playerbox.cpp
parentecf7284930fc6b67db33146819bedf6ec0ed7e7b (diff)
downloadplus-76c98ce0c8e78778f73d6a5728441897e134fb9e.tar.gz
plus-76c98ce0c8e78778f73d6a5728441897e134fb9e.tar.bz2
plus-76c98ce0c8e78778f73d6a5728441897e134fb9e.tar.xz
plus-76c98ce0c8e78778f73d6a5728441897e134fb9e.zip
Improve a bit look in character selection window.
Add selection skin for playerbox. New theme file: playerboxselected.xml
Diffstat (limited to 'src/gui/widgets/playerbox.cpp')
-rw-r--r--src/gui/widgets/playerbox.cpp52
1 files changed, 37 insertions, 15 deletions
diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp
index 98c0adc42..38e7f1f57 100644
--- a/src/gui/widgets/playerbox.cpp
+++ b/src/gui/widgets/playerbox.cpp
@@ -33,31 +33,39 @@
#include "debug.h"
-PlayerBox::PlayerBox(Being *const being, const std::string &skin) :
+PlayerBox::PlayerBox(Being *const being, const std::string &skin,
+ const std::string &selectedSkin) :
Widget2(),
ScrollArea(),
mBeing(being),
mAlpha(1.0),
mBackground(),
+ mSelectedBackground(),
mSkin(nullptr),
- mDrawBackground(false),
+ mSelectedSkin(nullptr),
mOffsetX(-16),
- mOffsetY(-32)
+ mOffsetY(-32),
+ mDrawBackground(false),
+ mSelected(false)
{
- init(skin);
+ init(skin, selectedSkin);
}
-PlayerBox::PlayerBox(std::string skin) :
+PlayerBox::PlayerBox(const std::string &skin,
+ const std::string &selectedSkin) :
ScrollArea(),
mBeing(nullptr),
mAlpha(1.0),
mBackground(),
+ mSelectedBackground(),
mSkin(nullptr),
- mDrawBackground(false),
+ mSelectedSkin(nullptr),
mOffsetX(-16),
- mOffsetY(-32)
+ mOffsetY(-32),
+ mDrawBackground(false),
+ mSelected(false)
{
- init(skin);
+ init(skin, selectedSkin);
}
PlayerBox::~PlayerBox()
@@ -68,23 +76,23 @@ PlayerBox::~PlayerBox()
Theme *const theme = Theme::instance();
if (theme)
{
- theme->unload(mSkin);
theme->unloadRect(mBackground);
+ theme->unloadRect(mSelectedBackground);
}
mBeing = nullptr;
}
-void PlayerBox::init(std::string skin)
+void PlayerBox::init(std::string name, std::string selectedName)
{
setFrameSize(2);
if (Theme::instance())
{
- if (skin.empty())
- skin = "playerbox.xml";
+ if (name.empty())
+ name = "playerbox.xml";
mSkin = Theme::instance()->loadSkinRect(mBackground,
- skin, "playerbox_background.xml");
+ name, "playerbox_background.xml");
if (mSkin)
{
mDrawBackground = (mSkin->getOption("drawbackground") != 0);
@@ -92,11 +100,17 @@ void PlayerBox::init(std::string skin)
mOffsetY = mSkin->getOption("offsetY", -32);
mFrameSize = mSkin->getOption("frameSize", 2);
}
+ if (selectedName.empty())
+ selectedName = "playerboxselected.xml";
+ mSelectedSkin = Theme::instance()->loadSkinRect(mSelectedBackground,
+ selectedName, "playerbox_background.xml");
}
else
{
for (int f = 0; f < 9; f ++)
mBackground.grid[f] = nullptr;
+ for (int f = 0; f < 9; f ++)
+ mSelectedBackground.grid[f] = nullptr;
}
}
@@ -133,8 +147,16 @@ void PlayerBox::drawFrame(gcn::Graphics *graphics)
w = getWidth() + bs * 2;
h = getHeight() + bs * 2;
- static_cast<Graphics*>(graphics)->drawImageRect(
- 0, 0, w, h, mBackground);
+ if (!mSelected)
+ {
+ static_cast<Graphics*>(graphics)->drawImageRect(
+ 0, 0, w, h, mBackground);
+ }
+ else
+ {
+ static_cast<Graphics*>(graphics)->drawImageRect(
+ 0, 0, w, h, mSelectedBackground);
+ }
}
BLOCK_END("PlayerBox::drawFrame")
}