diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-01-01 15:08:30 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-01-01 15:08:30 +0300 |
commit | cdb069409c514a1cec196c2e90ec2f97a5b6753f (patch) | |
tree | a12adb49b01dec757e826ffe547fedc8b16bc29a /src/gui | |
parent | 020c5e1b6abd52135a3b87fc38238498d7ac6e3d (diff) | |
download | manaplus-cdb069409c514a1cec196c2e90ec2f97a5b6753f.tar.gz manaplus-cdb069409c514a1cec196c2e90ec2f97a5b6753f.tar.bz2 manaplus-cdb069409c514a1cec196c2e90ec2f97a5b6753f.tar.xz manaplus-cdb069409c514a1cec196c2e90ec2f97a5b6753f.zip |
Add support for theming in bars in top left corner.
New theme options in ministatus.xml:
padding - border padding
spacing - space between buttons
iconPadding - padding for icons
iconSpacing - space between icons
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/ministatuswindow.cpp | 20 | ||||
-rw-r--r-- | src/gui/ministatuswindow.h | 4 | ||||
-rw-r--r-- | src/gui/widgets/popup.h | 2 |
3 files changed, 17 insertions, 9 deletions
diff --git a/src/gui/ministatuswindow.cpp b/src/gui/ministatuswindow.cpp index 835c0b250..64da94389 100644 --- a/src/gui/ministatuswindow.cpp +++ b/src/gui/ministatuswindow.cpp @@ -51,6 +51,9 @@ extern volatile int tick_time; MiniStatusWindow::MiniStatusWindow() : Popup("MiniStatus", "ministatus.xml"), InventoryListener(), + mSpacing(mSkin ? mSkin->getOption("spacing", 3) : 3), + mIconPadding(mSkin ? mSkin->getOption("iconPadding", 3) : 3), + mIconSpacing(mSkin ? mSkin->getOption("iconSpacing", 2) : 2), mHpBar(createBar(0, 100, 0, Theme::PROG_HP, "hp bar", _("health bar"))), mMpBar(Net::getGameHandler()->canUseMagicBar() ? createBar(0, 100, 0, Net::getPlayerHandler()->canUseMagic() @@ -149,7 +152,7 @@ ProgressBar *MiniStatusWindow::createBar(const float progress, void MiniStatusWindow::updateBars() { - int x = 0; + int x = mPadding; const ProgressBar *lastBar = nullptr; for (std::vector <ProgressBar*>::const_iterator it = mBars.begin(), it_end = mBars.end(); it != it_end; ++it) @@ -164,17 +167,18 @@ void MiniStatusWindow::updateBars() continue; if (bar->isVisible()) { - bar->setPosition(x, 3); + bar->setPosition(x, mPadding); add(bar); - x += bar->getWidth() + 3; + x += bar->getWidth() + mSpacing; lastBar = bar; } } if (lastBar) { - setContentSize(lastBar->getX() + lastBar->getWidth(), - lastBar->getY() + lastBar->getHeight()); + const int pad2 = 2 * mPadding; + setContentSize(lastBar->getX() + lastBar->getWidth() + pad2, + lastBar->getY() + lastBar->getHeight() + pad2); } } @@ -200,13 +204,13 @@ void MiniStatusWindow::eraseIcon(const int index) void MiniStatusWindow::drawIcons(Graphics *const graphics) { // Draw icons - int icon_x = mStatusBar->getX() + mStatusBar->getWidth() + 4; + int icon_x = mStatusBar->getX() + mStatusBar->getWidth() + mIconPadding; for (size_t i = 0, sz = mIcons.size(); i < sz; i ++) { if (mIcons[i]) { - mIcons[i]->draw(graphics, icon_x, 3); - icon_x += 2 + mIcons[i]->getWidth(); + mIcons[i]->draw(graphics, icon_x, mIconPadding); + icon_x += mIconSpacing + mIcons[i]->getWidth(); } } } diff --git a/src/gui/ministatuswindow.h b/src/gui/ministatuswindow.h index 16d010669..feae1e1df 100644 --- a/src/gui/ministatuswindow.h +++ b/src/gui/ministatuswindow.h @@ -105,6 +105,10 @@ class MiniStatusWindow final : public Popup, std::map <std::string, ProgressBar*> mBarNames; std::vector<AnimatedSprite *> mIcons; + int mSpacing; + int mIconPadding; + int mIconSpacing; + /* * Mini Status Bars */ diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h index 410e14059..e4ff5ed4b 100644 --- a/src/gui/widgets/popup.h +++ b/src/gui/widgets/popup.h @@ -170,6 +170,7 @@ class Popup : public Container, public gcn::MouseListener, protected: int mPadding; /**< Holds the padding of the popup. */ + Skin *mSkin; /**< Skin in use by this popup */ private: std::string mPopupName; /**< Name of the popup */ @@ -178,7 +179,6 @@ class Popup : public Container, public gcn::MouseListener, int mMaxWidth; /**< Maximum popup width */ int mMaxHeight; /**< Maximum popup height */ - Skin *mSkin; /**< Skin in use by this popup */ ImageCollection *mVertexes; bool mRedraw; }; |