diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-07-28 01:55:56 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-07-28 01:55:56 +0300 |
commit | f60d54307c20d4150e630620dbe0be62b2a1b8a5 (patch) | |
tree | dc5661a9f75cf495bbea050b6566b1fa0240781e /src | |
parent | 3574afc2818a5401d825fe649d49a0b9fbccdf00 (diff) | |
download | plus-f60d54307c20d4150e630620dbe0be62b2a1b8a5.tar.gz plus-f60d54307c20d4150e630620dbe0be62b2a1b8a5.tar.bz2 plus-f60d54307c20d4150e630620dbe0be62b2a1b8a5.tar.xz plus-f60d54307c20d4150e630620dbe0be62b2a1b8a5.zip |
Extend playerbox theming.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/charcreatedialog.cpp | 2 | ||||
-rw-r--r-- | src/gui/charselectdialog.cpp | 2 | ||||
-rw-r--r-- | src/gui/equipmentwindow.cpp | 2 | ||||
-rw-r--r-- | src/gui/npcdialog.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/playerbox.cpp | 55 | ||||
-rw-r--r-- | src/gui/widgets/playerbox.h | 13 |
6 files changed, 45 insertions, 31 deletions
diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp index ad766091c..693002789 100644 --- a/src/gui/charcreatedialog.cpp +++ b/src/gui/charcreatedialog.cpp @@ -147,7 +147,7 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot): mFemale->addActionListener(this); mOther->addActionListener(this); - mPlayerBox = new PlayerBox(mPlayer); + mPlayerBox = new PlayerBox(mPlayer, "charcreate_playerbox.xml"); mPlayerBox->setWidth(74); mNameField->setActionEventId("create"); diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp index 9004c52f9..a212d08c4 100644 --- a/src/gui/charselectdialog.cpp +++ b/src/gui/charselectdialog.cpp @@ -550,7 +550,7 @@ bool CharSelectDialog::selectByName(const std::string &name, CharacterDisplay::CharacterDisplay(CharSelectDialog *charSelectDialog): mCharacter(nullptr), - mPlayerBox(new PlayerBox), + mPlayerBox(new PlayerBox(nullptr)), mName(new Label("wwwwwwwwwwwwwwwwwwwwwwww")), mLevel(new Label("(888)")), mMoney(new Label("wwwwwwwww")), diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp index c3610ea0b..6a0397a7e 100644 --- a/src/gui/equipmentwindow.cpp +++ b/src/gui/equipmentwindow.cpp @@ -74,7 +74,7 @@ EquipmentWindow::EquipmentWindow(Equipment *equipment, Being *being, setupWindow->registerWindowForReset(this); // Control that shows the Player - mPlayerBox = new PlayerBox; + mPlayerBox = new PlayerBox("equipment_playerbox.xml"); mPlayerBox->setDimension(gcn::Rectangle(50, 80, 74, 168)); mPlayerBox->setPlayer(being); diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp index 04e0aa9fb..116935afd 100644 --- a/src/gui/npcdialog.cpp +++ b/src/gui/npcdialog.cpp @@ -73,7 +73,7 @@ NpcDialog::NpcDialog(int npcId) : mCameraMode(-1), mCameraX(0), mCameraY(0), - mPlayerBox(new PlayerBox), + mPlayerBox(new PlayerBox(nullptr)), mAvatarBeing(nullptr), mShowAvatar(false) { 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); } diff --git a/src/gui/widgets/playerbox.h b/src/gui/widgets/playerbox.h index 9e5a761b4..6498e69ec 100644 --- a/src/gui/widgets/playerbox.h +++ b/src/gui/widgets/playerbox.h @@ -25,6 +25,8 @@ #include <guichan/widgets/scrollarea.hpp> +#include "graphics.h" + #include "localconsts.h" class Being; @@ -42,13 +44,17 @@ class PlayerBox : public gcn::ScrollArea * Constructor. Takes the initial player character that this box should * display, which defaults to <code>NULL</code>. */ - PlayerBox(Being *being = nullptr); + PlayerBox(Being *being, std::string skin = ""); + + PlayerBox(std::string skin = ""); /** * Destructor. */ ~PlayerBox(); + void init(std::string skin); + /** * Sets a new player character to be displayed by this box. Setting the * player to <code>NULL</code> causes the box not to draw any @@ -73,9 +79,8 @@ class PlayerBox : public gcn::ScrollArea private: Being *mBeing; /**< The character used for display */ - static float mAlpha; - static int instances; - static ImageRect background; + float mAlpha; + ImageRect mBackground; }; #endif |