summaryrefslogtreecommitdiff
path: root/src/gui/ministatuswindow.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-01-01 15:08:30 +0300
committerAndrei Karas <akaras@inbox.ru>2013-01-01 15:08:30 +0300
commitcdb069409c514a1cec196c2e90ec2f97a5b6753f (patch)
treea12adb49b01dec757e826ffe547fedc8b16bc29a /src/gui/ministatuswindow.cpp
parent020c5e1b6abd52135a3b87fc38238498d7ac6e3d (diff)
downloadmanaplus-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/ministatuswindow.cpp')
-rw-r--r--src/gui/ministatuswindow.cpp20
1 files changed, 12 insertions, 8 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();
}
}
}