summaryrefslogtreecommitdiff
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
parent020c5e1b6abd52135a3b87fc38238498d7ac6e3d (diff)
downloadmanaverse-cdb069409c514a1cec196c2e90ec2f97a5b6753f.tar.gz
manaverse-cdb069409c514a1cec196c2e90ec2f97a5b6753f.tar.bz2
manaverse-cdb069409c514a1cec196c2e90ec2f97a5b6753f.tar.xz
manaverse-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
-rw-r--r--data/graphics/gui/CMakeLists.txt1
-rw-r--r--data/graphics/gui/Makefile.am1
-rw-r--r--data/graphics/gui/ministatus.xml9
-rw-r--r--src/gui/ministatuswindow.cpp20
-rw-r--r--src/gui/ministatuswindow.h4
-rw-r--r--src/gui/widgets/popup.h2
6 files changed, 28 insertions, 9 deletions
diff --git a/data/graphics/gui/CMakeLists.txt b/data/graphics/gui/CMakeLists.txt
index f0244d697..f8559824a 100644
--- a/data/graphics/gui/CMakeLists.txt
+++ b/data/graphics/gui/CMakeLists.txt
@@ -35,6 +35,7 @@ SET (FILES
keyboard_icon.xml
label.xml
listbox.xml
+ ministatus.xml
mouse.png
ok.xml
playerbox.xml
diff --git a/data/graphics/gui/Makefile.am b/data/graphics/gui/Makefile.am
index c691404e9..6aedbc32d 100644
--- a/data/graphics/gui/Makefile.am
+++ b/data/graphics/gui/Makefile.am
@@ -38,6 +38,7 @@ gui_DATA = \
keyboard_icon.xml \
label.xml \
listbox.xml \
+ ministatus.xml \
mouse.png \
ok.xml \
playerbox.xml \
diff --git a/data/graphics/gui/ministatus.xml b/data/graphics/gui/ministatus.xml
new file mode 100644
index 000000000..1e585d844
--- /dev/null
+++ b/data/graphics/gui/ministatus.xml
@@ -0,0 +1,9 @@
+<skinset name="Default" image="window.png">
+ <widget type="Window">
+ <option name="padding" value="1" />
+ <option name="spacing" value="1" />
+
+ <option name="iconPadding" value="3" />
+ <option name="iconSpacing" value="2" />
+ </widget>
+</skinset>
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;
};