summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-12-04 16:24:17 +0300
committerAndrei Karas <akaras@inbox.ru>2013-12-04 16:24:17 +0300
commitcdca37e368923c0298691847eba1c394a287e52f (patch)
tree77a3b0190aae27cb8095e8817bd022cd8c9c8fb4 /src
parentbbc361c48389875a8a67d138bc05aad30070b916 (diff)
downloadmanaverse-cdca37e368923c0298691847eba1c394a287e52f.tar.gz
manaverse-cdca37e368923c0298691847eba1c394a287e52f.tar.bz2
manaverse-cdca37e368923c0298691847eba1c394a287e52f.tar.xz
manaverse-cdca37e368923c0298691847eba1c394a287e52f.zip
Add new color for slots progress bar in inventory.
New colors: SLOTS_BAR, SLOTS_BAR_OUTLINE.
Diffstat (limited to 'src')
-rw-r--r--src/gui/theme.cpp6
-rw-r--r--src/gui/theme.h2
-rw-r--r--src/gui/widgets/progressbar.cpp61
-rw-r--r--src/gui/widgets/progressbar.h14
-rw-r--r--src/gui/windows/inventorywindow.cpp2
-rw-r--r--src/gui/windows/statuswindow.cpp4
6 files changed, 55 insertions, 34 deletions
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp
index fa5ec0e04..8f5d49bfa 100644
--- a/src/gui/theme.cpp
+++ b/src/gui/theme.cpp
@@ -768,7 +768,7 @@ ImageSet *Theme::getImageSetFromTheme(const std::string &path,
static int readColorType(const std::string &type)
{
- static const std::string colors[] =
+ static const std::string colors[Theme::THEME_COLORS_END] =
{
"BROWSERBOX",
"BROWSERBOX_OUTLINE",
@@ -949,7 +949,9 @@ static int readColorType(const std::string &type)
"BROWN_OUTLINE",
"STATUSBAR_ON",
"STATUSBAR_OFF",
- "TABLE_BACKGROUND"
+ "TABLE_BACKGROUND",
+ "SLOTS_BAR",
+ "SLOTS_BAR_OUTLINE"
};
if (type.empty())
diff --git a/src/gui/theme.h b/src/gui/theme.h
index 31dc0ee60..0ed7c2fb1 100644
--- a/src/gui/theme.h
+++ b/src/gui/theme.h
@@ -393,6 +393,8 @@ class Theme final : public Palette, public ConfigListener
STATUSBAR_ON,
STATUSBAR_OFF,
TABLE_BACKGROUND,
+ SLOTS_BAR,
+ SLOTS_BAR_OUTLINE,
THEME_COLORS_END
};
diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp
index 51faed2ae..dd44a3b9c 100644
--- a/src/gui/widgets/progressbar.cpp
+++ b/src/gui/widgets/progressbar.cpp
@@ -44,9 +44,10 @@ ProgressBar::ProgressBar(const Widget2 *const widget, float progress,
mSkin(nullptr),
mProgress(progress),
mProgressToGo(progress),
- mColor(Theme::getProgressColor(backColor >= 0 ? backColor : 0, mProgress)),
- mColorToGo(mColor),
- mOutlineColor(getThemeColor(Theme::OUTLINE)),
+ mBackgroundColor(Theme::getProgressColor(backColor >= 0
+ ? backColor : 0, mProgress)),
+ mBackgroundColorToGo(mBackgroundColor),
+ mForegroundColor2(getThemeColor(Theme::OUTLINE)),
mText(),
mVertexes(new ImageCollection),
mProgressPalette(backColor),
@@ -99,21 +100,21 @@ ProgressBar::~ProgressBar()
void ProgressBar::logic()
{
BLOCK_START("ProgressBar::logic")
- if (mSmoothColorChange && mColorToGo != mColor)
+ if (mSmoothColorChange && mBackgroundColorToGo != mBackgroundColor)
{
// Smoothly changing the color for a nicer effect.
- if (mColorToGo.r > mColor.r)
- mColor.r++;
- if (mColorToGo.g > mColor.g)
- mColor.g++;
- if (mColorToGo.b > mColor.b)
- mColor.b++;
- if (mColorToGo.r < mColor.r)
- mColor.r--;
- if (mColorToGo.g < mColor.g)
- mColor.g--;
- if (mColorToGo.b < mColor.b)
- mColor.b--;
+ if (mBackgroundColorToGo.r > mBackgroundColor.r)
+ mBackgroundColor.r++;
+ if (mBackgroundColorToGo.g > mBackgroundColor.g)
+ mBackgroundColor.g++;
+ if (mBackgroundColorToGo.b > mBackgroundColor.b)
+ mBackgroundColor.b++;
+ if (mBackgroundColorToGo.r < mBackgroundColor.r)
+ mBackgroundColor.r--;
+ if (mBackgroundColorToGo.g < mBackgroundColor.g)
+ mBackgroundColor.g--;
+ if (mBackgroundColorToGo.b < mBackgroundColor.b)
+ mBackgroundColor.b--;
}
if (mSmoothProgress && mProgressToGo != mProgress)
@@ -138,7 +139,7 @@ void ProgressBar::draw(gcn::Graphics *graphics)
{
BLOCK_START("ProgressBar::draw")
updateAlpha();
- mColor.a = static_cast<int>(mAlpha * 255);
+ mBackgroundColor.a = static_cast<int>(mAlpha * 255);
render(static_cast<Graphics*>(graphics));
BLOCK_END("ProgressBar::draw")
}
@@ -152,7 +153,10 @@ void ProgressBar::setProgress(const float progress)
mProgress = p;
if (mProgressPalette >= 0)
- mColorToGo = Theme::getProgressColor(mProgressPalette, progress);
+ {
+ mBackgroundColorToGo = Theme::getProgressColor(
+ mProgressPalette, progress);
+ }
}
void ProgressBar::setProgressPalette(const int progressPalette)
@@ -161,15 +165,24 @@ void ProgressBar::setProgressPalette(const int progressPalette)
mProgressPalette = progressPalette;
if (mProgressPalette != oldPalette && mProgressPalette >= 0)
- mColorToGo = Theme::getProgressColor(mProgressPalette, mProgressToGo);
+ {
+ mBackgroundColorToGo = Theme::getProgressColor(
+ mProgressPalette, mProgressToGo);
+ }
}
-void ProgressBar::setColor(const gcn::Color &color)
+void ProgressBar::setBackgroundColor(const gcn::Color &color)
{
- mColorToGo = color;
+ mBackgroundColorToGo = color;
if (!mSmoothColorChange)
- mColor = color;
+ mBackgroundColor = color;
+}
+
+void ProgressBar::setColor(const gcn::Color &color1, const gcn::Color &color2)
+{
+ mForegroundColor = color1;
+ mForegroundColor2 = color2;
}
void ProgressBar::render(Graphics *graphics)
@@ -198,7 +211,7 @@ void ProgressBar::render(Graphics *graphics)
// The bar
if (mProgress > 0)
{
- graphics->setColor(mColor);
+ graphics->setColor(mBackgroundColor);
const unsigned int pad = 2 * mFillPadding;
const int maxWidth = mDimension.width - pad;
int width = static_cast<int>(mProgress * static_cast<float>(maxWidth));
@@ -220,7 +233,7 @@ void ProgressBar::render(Graphics *graphics)
const int textX = mDimension.width / 2;
const int textY = (mDimension.height - font->getHeight()) / 2;
- graphics->setColorAll(mForegroundColor, mOutlineColor);
+ graphics->setColorAll(mForegroundColor, mForegroundColor2);
font->drawString(graphics, mText, textX
- font->getWidth(mText) / 2, textY);
diff --git a/src/gui/widgets/progressbar.h b/src/gui/widgets/progressbar.h
index 160d3f4a2..954d9f7d2 100644
--- a/src/gui/widgets/progressbar.h
+++ b/src/gui/widgets/progressbar.h
@@ -92,13 +92,15 @@ class ProgressBar final : public gcn::Widget,
/**
* Change the color of the progress bar.
*/
- void setColor(const gcn::Color &color);
+ void setBackgroundColor(const gcn::Color &color);
+
+ void setColor(const gcn::Color &color1, const gcn::Color &color2);
/**
* Returns the color of the progress bar.
*/
- const gcn::Color &getColor() const A_WARN_UNUSED
- { return mColor; }
+ const gcn::Color &getBackgroundColor() const A_WARN_UNUSED
+ { return mBackgroundColor; }
/**
* Sets the text shown on the progress bar.
@@ -141,9 +143,9 @@ class ProgressBar final : public gcn::Widget,
float mProgress;
float mProgressToGo;
- gcn::Color mColor;
- gcn::Color mColorToGo;
- gcn::Color mOutlineColor;
+ gcn::Color mBackgroundColor;
+ gcn::Color mBackgroundColorToGo;
+ gcn::Color mForegroundColor2;
std::string mText;
ImageCollection *mVertexes;
diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp
index 825c3d934..b9c89ad96 100644
--- a/src/gui/windows/inventorywindow.cpp
+++ b/src/gui/windows/inventorywindow.cpp
@@ -131,6 +131,8 @@ InventoryWindow::InventoryWindow(Inventory *const inventory):
mCompactMode(false)
{
mTextPopup->postInit();
+ mSlotsBar->setColor(Theme::getThemeColor(Theme::SLOTS_BAR),
+ Theme::getThemeColor(Theme::SLOTS_BAR_OUTLINE));
if (inventory)
{
diff --git a/src/gui/windows/statuswindow.cpp b/src/gui/windows/statuswindow.cpp
index e574c7230..5d90ad078 100644
--- a/src/gui/windows/statuswindow.cpp
+++ b/src/gui/windows/statuswindow.cpp
@@ -713,9 +713,9 @@ void StatusWindow::updateStatusBar(ProgressBar *const bar,
bar->setProgress(50);
if (player_node->getDisableGameModifiers())
- bar->setColor(Theme::getThemeColor(Theme::STATUSBAR_ON));
+ bar->setBackgroundColor(Theme::getThemeColor(Theme::STATUSBAR_ON));
else
- bar->setColor(Theme::getThemeColor(Theme::STATUSBAR_OFF));
+ bar->setBackgroundColor(Theme::getThemeColor(Theme::STATUSBAR_OFF));
}
void StatusWindow::action(const gcn::ActionEvent &event)