summaryrefslogtreecommitdiff
path: root/src/gui/widgets/playerbox.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-07-28 01:55:56 +0300
committerAndrei Karas <akaras@inbox.ru>2012-07-28 01:55:56 +0300
commitf60d54307c20d4150e630620dbe0be62b2a1b8a5 (patch)
treedc5661a9f75cf495bbea050b6566b1fa0240781e /src/gui/widgets/playerbox.cpp
parent3574afc2818a5401d825fe649d49a0b9fbccdf00 (diff)
downloadplus-f60d54307c20d4150e630620dbe0be62b2a1b8a5.tar.gz
plus-f60d54307c20d4150e630620dbe0be62b2a1b8a5.tar.bz2
plus-f60d54307c20d4150e630620dbe0be62b2a1b8a5.tar.xz
plus-f60d54307c20d4150e630620dbe0be62b2a1b8a5.zip
Extend playerbox theming.
Diffstat (limited to 'src/gui/widgets/playerbox.cpp')
-rw-r--r--src/gui/widgets/playerbox.cpp55
1 files changed, 32 insertions, 23 deletions
diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp
index bf17793f5..f0a6a5e89 100644
--- a/src/gui/widgets/playerbox.cpp
+++ b/src/gui/widgets/playerbox.cpp
@@ -36,36 +36,45 @@
#include "debug.h"
-int PlayerBox::instances = 0;
-float PlayerBox::mAlpha = 1.0;
-ImageRect PlayerBox::background;
-
-PlayerBox::PlayerBox(Being *being):
- mBeing(being)
+PlayerBox::PlayerBox(Being *being, std::string skin):
+ mBeing(being),
+ mAlpha(1.0)
{
- setFrameSize(2);
-
- if (instances == 0)
- {
- if (Theme::instance())
- {
- Theme::instance()->loadRect(background,
- "playerbox_background.xml");
- }
- }
+ init(skin);
+}
- instances++;
+PlayerBox::PlayerBox(std::string skin):
+ mBeing(nullptr),
+ mAlpha(1.0)
+{
+ init(skin);
}
PlayerBox::~PlayerBox()
{
- instances--;
- if (instances == 0 && Theme::instance())
- Theme::instance()->unloadRect(background);
+ if (Theme::instance())
+ Theme::instance()->unloadRect(mBackground);
mBeing = nullptr;
}
+void PlayerBox::init(std::string skin)
+{
+ setFrameSize(2);
+
+ if (Theme::instance())
+ {
+ if (skin.empty())
+ skin = "playerbox_background.xml";
+ Theme::instance()->loadRect(mBackground, skin);
+ }
+ else
+ {
+ for (int f = 0; f < 9; f ++)
+ mBackground.grid[f] = nullptr;
+ }
+}
+
void PlayerBox::draw(gcn::Graphics *graphics)
{
if (mBeing)
@@ -81,8 +90,8 @@ void PlayerBox::draw(gcn::Graphics *graphics)
{
for (int a = 0; a < 9; a++)
{
- if (background.grid[a])
- background.grid[a]->setAlpha(Client::getGuiAlpha());
+ if (mBackground.grid[a])
+ mBackground.grid[a]->setAlpha(Client::getGuiAlpha());
}
}
}
@@ -94,5 +103,5 @@ void PlayerBox::drawFrame(gcn::Graphics *graphics)
w = getWidth() + bs * 2;
h = getHeight() + bs * 2;
- static_cast<Graphics*>(graphics)->drawImageRect(0, 0, w, h, background);
+ static_cast<Graphics*>(graphics)->drawImageRect(0, 0, w, h, mBackground);
}