summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/graphics/gui/CMakeLists.txt1
-rw-r--r--data/graphics/gui/Makefile.am1
-rw-r--r--data/graphics/gui/progressbar.xml2
-rw-r--r--data/graphics/gui/progressbar_fill.xml19
-rw-r--r--src/gui/widgets/progressbar.cpp49
-rw-r--r--src/gui/widgets/progressbar.h5
-rw-r--r--src/gui/windows/inventorywindow.cpp4
-rw-r--r--src/gui/windows/ministatuswindow.cpp29
-rw-r--r--src/gui/windows/ministatuswindow.h1
-rw-r--r--src/gui/windows/statuswindow.cpp13
-rw-r--r--src/gui/windows/updaterwindow.cpp2
11 files changed, 104 insertions, 22 deletions
diff --git a/data/graphics/gui/CMakeLists.txt b/data/graphics/gui/CMakeLists.txt
index 870b86b60..61acadfa0 100644
--- a/data/graphics/gui/CMakeLists.txt
+++ b/data/graphics/gui/CMakeLists.txt
@@ -51,6 +51,7 @@ SET (FILES
popupbrowserbox.xml
progress-indicator.png
progressbar.xml
+ progressbar_fill.xml
quests.xml
radio.xml
resize.xml
diff --git a/data/graphics/gui/Makefile.am b/data/graphics/gui/Makefile.am
index 50ea62178..740f81613 100644
--- a/data/graphics/gui/Makefile.am
+++ b/data/graphics/gui/Makefile.am
@@ -54,6 +54,7 @@ gui_DATA = \
popupbrowserbox.xml \
progress-indicator.png \
progressbar.xml \
+ progressbar_fill.xml \
quests.xml \
radio.xml \
resize.xml \
diff --git a/data/graphics/gui/progressbar.xml b/data/graphics/gui/progressbar.xml
index 1be7e4100..c2b1f46e9 100644
--- a/data/graphics/gui/progressbar.xml
+++ b/data/graphics/gui/progressbar.xml
@@ -3,6 +3,8 @@
<widget type="Window" xpos="73" ypos="164">
<option name="padding" value="2" />
<option name="fillPadding" value="3" />
+ <option name="fillImage" value="0" />
+
<!-- Top Row -->
<part type="top-left-corner" xpos="0" ypos="0" width="4" height="4" />
<part type="top-edge" xpos="4" ypos="0" width="3" height="4" />
diff --git a/data/graphics/gui/progressbar_fill.xml b/data/graphics/gui/progressbar_fill.xml
new file mode 100644
index 000000000..c674c7c7b
--- /dev/null
+++ b/data/graphics/gui/progressbar_fill.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<skinset name="Default" image="window.png">
+ <widget type="Window" xpos="73" ypos="164">
+ <!-- Top Row -->
+ <part type="top-left-corner" xpos="0" ypos="0" width="4" height="4" />
+ <part type="top-edge" xpos="4" ypos="0" width="3" height="4" />
+ <part type="top-right-corner" xpos="7" ypos="0" width="4" height="4" />
+
+ <!-- Middle Row -->
+ <part type="left-edge" xpos="0" ypos="4" width="4" height="10" />
+ <part type="bg-quad" xpos="4" ypos="4" width="3" height="10" />
+ <part type="right-edge" xpos="7" ypos="4" width="4" height="10" />
+
+ <!-- Bottom Row -->
+ <part type="bottom-left-corner" xpos="0" ypos="15" width="4" height="4" />
+ <part type="bottom-edge" xpos="4" ypos="15" width="3" height="4" />
+ <part type="bottom-right-corner" xpos="7" ypos="15" width="4" height="4" />
+ </widget>
+</skinset>
diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp
index e8f3b5947..5d776fa1a 100644
--- a/src/gui/widgets/progressbar.cpp
+++ b/src/gui/widgets/progressbar.cpp
@@ -37,11 +37,14 @@ float ProgressBar::mAlpha = 1.0;
ProgressBar::ProgressBar(const Widget2 *const widget, float progress,
const int width, const int height,
- const int backColor, const std::string &skin):
+ const int backColor,
+ const std::string &skin, const std::string &skinFill):
gcn::Widget(),
Widget2(widget),
gcn::WidgetListener(),
+ mFillRect(),
mSkin(nullptr),
+ mSkinFill(nullptr),
mProgress(progress),
mProgressToGo(progress),
mBackgroundColor(Theme::getProgressColor(backColor >= 0
@@ -53,6 +56,7 @@ ProgressBar::ProgressBar(const Widget2 *const widget, float progress,
mProgressPalette(backColor),
mPadding(2),
mFillPadding(3),
+ mFillImage(false),
mSmoothProgress(true),
mSmoothColorChange(true),
mRedraw(true)
@@ -73,6 +77,9 @@ ProgressBar::ProgressBar(const Widget2 *const widget, float progress,
{
setPadding(mSkin->getPadding());
mFillPadding = mSkin->getOption("fillPadding");
+ mFillImage = mSkin->getOption("fillImage") != 0;
+ if (mFillImage)
+ theme->loadRect(mFillRect, skinFill, "progressbar_fill.xml");
}
setHeight(2 * mPadding + getFont()->getHeight() + 2);
}
@@ -86,13 +93,15 @@ ProgressBar::~ProgressBar()
gui->removeDragged(this);
mInstances--;
+ Theme *const theme = Theme::instance();
if (mSkin)
{
- Theme *const theme = Theme::instance();
if (theme)
theme->unload(mSkin);
mSkin = nullptr;
}
+ if (theme)
+ theme->unloadRect(mFillRect);
delete mVertexes;
mVertexes = nullptr;
}
@@ -115,6 +124,7 @@ void ProgressBar::logic()
mBackgroundColor.g--;
if (mBackgroundColorToGo.b < mBackgroundColor.b)
mBackgroundColor.b--;
+ mRedraw = true;
}
if (mSmoothProgress && mProgressToGo != mProgress)
@@ -124,6 +134,7 @@ void ProgressBar::logic()
mProgress = std::min(1.0F, mProgress + 0.005F);
if (mProgressToGo < mProgress)
mProgress = std::max(0.0F, mProgress - 0.005F);
+ mRedraw = true;
}
BLOCK_END("ProgressBar::logic")
}
@@ -148,6 +159,7 @@ void ProgressBar::setProgress(const float progress)
{
const float p = std::min(1.0F, std::max(0.0F, progress));
mProgressToGo = p;
+ mRedraw = true;
if (!mSmoothProgress)
mProgress = p;
@@ -163,6 +175,7 @@ void ProgressBar::setProgressPalette(const int progressPalette)
{
const int oldPalette = mProgressPalette;
mProgressPalette = progressPalette;
+ mRedraw = true;
if (mProgressPalette != oldPalette && mProgressPalette >= 0)
{
@@ -173,6 +186,7 @@ void ProgressBar::setProgressPalette(const int progressPalette)
void ProgressBar::setBackgroundColor(const gcn::Color &color)
{
+ mRedraw = true;
mBackgroundColorToGo = color;
if (!mSmoothColorChange)
@@ -198,6 +212,21 @@ void ProgressBar::render(Graphics *graphics)
mVertexes->clear();
graphics->calcWindow(mVertexes, 0, 0,
mDimension.width, mDimension.height, mSkin->getBorder());
+ if (mFillImage)
+ {
+ const unsigned int pad = 2 * mFillPadding;
+ const int maxWidth = mDimension.width - pad;
+ int width = static_cast<int>(mProgress
+ * static_cast<float>(maxWidth));
+ if (width > 0)
+ {
+ if (width > maxWidth)
+ width = maxWidth;
+ logger->log("calc fill: %d, %d", mFillPadding, width);
+ graphics->calcWindow(mVertexes, mFillPadding, mFillPadding,
+ width, mDimension.height - pad, mFillRect);
+ }
+ }
}
graphics->drawTileCollection(mVertexes);
@@ -206,10 +235,24 @@ void ProgressBar::render(Graphics *graphics)
{
graphics->drawImageRect(0, 0, mDimension.width, mDimension.height,
mSkin->getBorder());
+ if (mFillImage)
+ {
+ const unsigned int pad = 2 * mFillPadding;
+ const int maxWidth = mDimension.width - pad;
+ int width = static_cast<int>(mProgress
+ * static_cast<float>(maxWidth));
+ if (width > 0)
+ {
+ if (width > maxWidth)
+ width = maxWidth;
+ graphics->drawImageRect(mFillPadding, mFillPadding,
+ width, mDimension.height - pad, mFillRect);
+ }
+ }
}
// The bar
- if (mProgress > 0)
+ if (!mFillImage && mProgress > 0)
{
graphics->setColor(mBackgroundColor);
const unsigned int pad = 2 * mFillPadding;
diff --git a/src/gui/widgets/progressbar.h b/src/gui/widgets/progressbar.h
index 3bfceab18..9b2ab353a 100644
--- a/src/gui/widgets/progressbar.h
+++ b/src/gui/widgets/progressbar.h
@@ -52,7 +52,7 @@ class ProgressBar final : public gcn::Widget,
ProgressBar(const Widget2 *const widget, float progress,
const int width, const int height,
const int backColor,
- const std::string &skin);
+ const std::string &skin, const std::string &skinFill);
A_DELETE_COPY(ProgressBar)
@@ -140,7 +140,9 @@ class ProgressBar final : public gcn::Widget,
{ mPadding = padding; }
private:
+ ImageRect mFillRect;
Skin *mSkin;
+ Skin *mSkinFill;
float mProgress;
float mProgressToGo;
@@ -157,6 +159,7 @@ class ProgressBar final : public gcn::Widget,
static int mInstances;
static float mAlpha;
+ bool mFillImage;
bool mSmoothProgress;
bool mSmoothColorChange;
bool mRedraw;
diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp
index b477e2b5a..3f447e443 100644
--- a/src/gui/windows/inventorywindow.cpp
+++ b/src/gui/windows/inventorywindow.cpp
@@ -118,7 +118,7 @@ InventoryWindow::InventoryWindow(Inventory *const inventory):
mInvCloseButton(nullptr),
mWeightBar(nullptr),
mSlotsBar(new ProgressBar(this, 0.0F, 100, 0, Theme::PROG_INVY_SLOTS,
- "slotsprogressbar.xml")),
+ "slotsprogressbar.xml", "slotsprogressbar_fill.xml")),
mFilter(nullptr),
mSortModel(new SortListModelInv),
mSortDropDown(new DropDown(this, mSortModel, false, false, this, "sort")),
@@ -227,7 +227,7 @@ InventoryWindow::InventoryWindow(Inventory *const inventory):
// TRANSLATORS: inventory button
mEquipmentButton = new Button(this, _("Equipment"), "equipment", this);
mWeightBar = new ProgressBar(this, 0.0F, 100, 0, Theme::PROG_WEIGHT,
- "weightprogressbar.xml");
+ "weightprogressbar.xml", "weightprogressbar_fill.xml");
mWeightBar->setColor(Theme::getThemeColor(Theme::WEIGHT_BAR),
Theme::getThemeColor(Theme::WEIGHT_BAR_OUTLINE));
diff --git a/src/gui/windows/ministatuswindow.cpp b/src/gui/windows/ministatuswindow.cpp
index cd3f3701d..4559c1af4 100644
--- a/src/gui/windows/ministatuswindow.cpp
+++ b/src/gui/windows/ministatuswindow.cpp
@@ -63,7 +63,8 @@ MiniStatusWindow::MiniStatusWindow() :
mMaxX(0),
// TRANSLATORS: status bar name
mHpBar(createBar(0, 100, 0, Theme::HP_BAR, Theme::PROG_HP,
- "hpprogressbar.xml", "hp bar", _("health bar"))),
+ "hpprogressbar.xml", "hpprogressbar_fill.xml",
+ "hp bar", _("health bar"))),
mMpBar(Net::getGameHandler()->canUseMagicBar()
? createBar(0, 100, 0, Net::getPlayerHandler()->canUseMagic()
? Theme::MP_BAR : Theme::NO_MP_BAR,
@@ -71,30 +72,38 @@ MiniStatusWindow::MiniStatusWindow() :
? Theme::PROG_MP : Theme::PROG_NO_MP,
Net::getPlayerHandler()->canUseMagic()
? "mpprogressbar.xml" : "nompprogressbar.xml",
+ Net::getPlayerHandler()->canUseMagic()
+ ? "mpprogressbar_fill.xml" : "nompprogressbar_fill.xml",
// TRANSLATORS: status bar name
"mp bar", _("mana bar")) : nullptr),
mXpBar(createBar(0, 100, 0, Theme::XP_BAR, Theme::PROG_EXP,
+ "xpprogressbar.xml", "xpprogressbar_fill.xml",
// TRANSLATORS: status bar name
- "xpprogressbar.xml", "xp bar", _("experience bar"))),
+ "xp bar", _("experience bar"))),
mJobBar(nullptr),
mWeightBar(createBar(0, 140, 0, Theme::WEIGHT_BAR, Theme::PROG_WEIGHT,
+ "weightprogressbar.xml", "weightprogressbar_fill.xml",
// TRANSLATORS: status bar name
- "weightprogressbar.xml", "weight bar", _("weight bar"))),
+ "weight bar", _("weight bar"))),
mInvSlotsBar(createBar(0, 45, 0,
Theme::SLOTS_BAR, Theme::PROG_INVY_SLOTS,
- "slotsprogressbar.xml", "inventory slots bar",
+ "slotsprogressbar.xml", "slotsprogressbar_fill.xml",
+ "inventory slots bar",
// TRANSLATORS: status bar name
_("inventory slots bar"))),
mMoneyBar(createBar(0, 130, 0, Theme::MONEY_BAR, Theme::PROG_MONEY,
+ "moneyprogressbar.xml", "moneyprogressbar_fill.xml",
// TRANSLATORS: status bar name
- "moneyprogressbar.xml", "money bar", _("money bar"))),
+ "money bar", _("money bar"))),
mArrowsBar(createBar(0, 50, 0, Theme::ARROWS_BAR, Theme::PROG_ARROWS,
+ "arrowsprogressbar.xml", "arrowsprogressbar_fill.xml",
// TRANSLATORS: status bar name
- "arrowsprogressbar.xml", "arrows bar", _("arrows bar"))),
+ "arrows bar", _("arrows bar"))),
mStatusBar(createBar(100, (config.getIntValue("fontSize") > 16
? 250 : 165), 0, Theme::STATUS_BAR, Theme::PROG_STATUS,
+ "statusprogressbar.xml", "statusprogressbar_fill.xml",
// TRANSLATORS: status bar name
- "statusprogressbar.xml", "status bar", _("status bar"))),
+ "status bar", _("status bar"))),
mTextPopup(new TextPopup),
mStatusPopup(new StatusPopup)
{
@@ -117,7 +126,8 @@ MiniStatusWindow::MiniStatusWindow() :
{
mJobBar = createBar(0, 100, 0, Theme::JOB_BAR, Theme::PROG_JOB,
// TRANSLATORS: status bar name
- "jobprogressbar.xml", "job bar", _("job bar"));
+ "jobprogressbar.xml", "jobprogressbar_fill.xml",
+ "job bar", _("job bar"));
StatusWindow::updateJobBar(mJobBar);
}
@@ -164,12 +174,13 @@ ProgressBar *MiniStatusWindow::createBar(const float progress,
const int textColor,
const int backColor,
const std::string &restrict skin,
+ const std::string &restrict skinFill,
const std::string &restrict name,
const std::string &restrict
description)
{
ProgressBar *const bar = new ProgressBar(this,
- progress, width, height, backColor, skin);
+ progress, width, height, backColor, skin, skinFill);
bar->setActionEventId(name);
bar->setId(description);
bar->setColor(Theme::getThemeColor(textColor),
diff --git a/src/gui/windows/ministatuswindow.h b/src/gui/windows/ministatuswindow.h
index e2bae8a49..e73913683 100644
--- a/src/gui/windows/ministatuswindow.h
+++ b/src/gui/windows/ministatuswindow.h
@@ -100,6 +100,7 @@ class MiniStatusWindow final : public Popup,
const int width, const int height,
const int textColor, const int backColor,
const std::string &restrict skin,
+ const std::string &restrict skinFill,
const std::string &restrict name,
const std::string &restrict description)
A_WARN_UNUSED;
diff --git a/src/gui/windows/statuswindow.cpp b/src/gui/windows/statuswindow.cpp
index 1f0fb4d91..2fb2e48e4 100644
--- a/src/gui/windows/statuswindow.cpp
+++ b/src/gui/windows/statuswindow.cpp
@@ -191,16 +191,16 @@ StatusWindow::StatusWindow() :
max = 1;
mHpBar = new ProgressBar(this, static_cast<float>(PlayerInfo::getAttribute(
- PlayerInfo::HP)) / static_cast<float>(max), 80, 0,
- Theme::PROG_HP, "hpprogressbar.xml");
+ PlayerInfo::HP)) / static_cast<float>(max), 80, 0, Theme::PROG_HP,
+ "hpprogressbar.xml", "hpprogressbar_fill.xml");
mHpBar->setColor(Theme::getThemeColor(Theme::HP_BAR),
Theme::getThemeColor(Theme::HP_BAR_OUTLINE));
max = PlayerInfo::getAttribute(PlayerInfo::EXP_NEEDED);
mXpBar = new ProgressBar(this, max ?
static_cast<float>(PlayerInfo::getAttribute(PlayerInfo::EXP))
- / static_cast<float>(max) : static_cast<float>(0),
- 80, 0, Theme::PROG_EXP, "xpprogressbar.xml");
+ / static_cast<float>(max) : static_cast<float>(0), 80, 0,
+ Theme::PROG_EXP, "xpprogressbar.xml", "xpprogressbar_fill.xml");
mXpBar->setColor(Theme::getThemeColor(Theme::XP_BAR),
Theme::getThemeColor(Theme::XP_BAR_OUTLINE));
@@ -218,7 +218,8 @@ StatusWindow::StatusWindow() :
PlayerInfo::getAttribute(PlayerInfo::MAX_MP))
/ static_cast<float>(max) : static_cast<float>(0),
80, 0, useMagic ? Theme::PROG_MP : Theme::PROG_NO_MP,
- useMagic ? "mpprogressbar.xml" : "nompprogressbar.xml");
+ useMagic ? "mpprogressbar.xml" : "nompprogressbar.xml",
+ useMagic ? "mpprogressbar_fill.xml" : "nompprogressbar_fill.xml");
if (useMagic)
{
mMpBar->setColor(Theme::getThemeColor(Theme::MP_BAR),
@@ -258,7 +259,7 @@ StatusWindow::StatusWindow() :
// TRANSLATORS: status window label
mJobLabel = new Label(this, _("Job:"));
mJobBar = new ProgressBar(this, 0.0F, 80, 0, Theme::PROG_JOB,
- "jobprogressbar.xml");
+ "jobprogressbar.xml", "jobprogressbar_fill.xml");
mJobBar->setColor(Theme::getThemeColor(Theme::JOB_BAR),
Theme::getThemeColor(Theme::JOB_BAR_OUTLINE));
diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp
index e219ab0b7..d33d58374 100644
--- a/src/gui/windows/updaterwindow.cpp
+++ b/src/gui/windows/updaterwindow.cpp
@@ -180,7 +180,7 @@ UpdaterWindow::UpdaterWindow(const std::string &restrict updateHost,
// TRANSLATORS: updater window button
mPlayButton(new Button(this, _("Play"), "play", this)),
mProgressBar(new ProgressBar(this, 0.0, 310, 0, Theme::PROG_UPDATE,
- "updateprogressbar.xml")),
+ "updateprogressbar.xml", "updateprogressbar_fill.xml")),
mBrowserBox(new BrowserBox(this, BrowserBox::AUTO_SIZE, true,
"browserbox.xml")),
mScrollArea(new ScrollArea(mBrowserBox, true, "update_background.xml")),