From cdca37e368923c0298691847eba1c394a287e52f Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 4 Dec 2013 16:24:17 +0300 Subject: Add new color for slots progress bar in inventory. New colors: SLOTS_BAR, SLOTS_BAR_OUTLINE. --- data/graphics/gui/colors.xml | 2 ++ data/themes/blacknblack/colors.xml | 2 ++ data/themes/blackwood/colors.xml | 2 ++ data/themes/enchilado/colors.xml | 2 ++ data/themes/jewelry/colors.xml | 6 ++++ data/themes/mana/colors.xml | 2 ++ data/themes/pink/colors.xml | 2 ++ data/themes/unity/colors.xml | 2 ++ data/themes/wood/colors.xml | 2 ++ src/gui/theme.cpp | 6 ++-- src/gui/theme.h | 2 ++ src/gui/widgets/progressbar.cpp | 61 ++++++++++++++++++++++--------------- src/gui/widgets/progressbar.h | 14 +++++---- src/gui/windows/inventorywindow.cpp | 2 ++ src/gui/windows/statuswindow.cpp | 4 +-- 15 files changed, 77 insertions(+), 34 deletions(-) diff --git a/data/graphics/gui/colors.xml b/data/graphics/gui/colors.xml index a5a8faa0e..d751f2046 100644 --- a/data/graphics/gui/colors.xml +++ b/data/graphics/gui/colors.xml @@ -98,6 +98,8 @@ + + diff --git a/data/themes/blacknblack/colors.xml b/data/themes/blacknblack/colors.xml index b89548679..63c14a9a3 100644 --- a/data/themes/blacknblack/colors.xml +++ b/data/themes/blacknblack/colors.xml @@ -88,6 +88,8 @@ + + diff --git a/data/themes/blackwood/colors.xml b/data/themes/blackwood/colors.xml index b96472dac..d7a813658 100644 --- a/data/themes/blackwood/colors.xml +++ b/data/themes/blackwood/colors.xml @@ -87,6 +87,8 @@ + + diff --git a/data/themes/enchilado/colors.xml b/data/themes/enchilado/colors.xml index 38d2df416..7f871030f 100644 --- a/data/themes/enchilado/colors.xml +++ b/data/themes/enchilado/colors.xml @@ -88,6 +88,8 @@ + + diff --git a/data/themes/jewelry/colors.xml b/data/themes/jewelry/colors.xml index 50a297a55..f66625b8f 100644 --- a/data/themes/jewelry/colors.xml +++ b/data/themes/jewelry/colors.xml @@ -85,6 +85,8 @@ + + @@ -247,6 +249,8 @@ + + @@ -333,6 +337,8 @@ + + diff --git a/data/themes/mana/colors.xml b/data/themes/mana/colors.xml index 8a21f9f34..e7ef15f09 100644 --- a/data/themes/mana/colors.xml +++ b/data/themes/mana/colors.xml @@ -88,6 +88,8 @@ + + diff --git a/data/themes/pink/colors.xml b/data/themes/pink/colors.xml index 72b355317..423e05e44 100644 --- a/data/themes/pink/colors.xml +++ b/data/themes/pink/colors.xml @@ -88,6 +88,8 @@ + + diff --git a/data/themes/unity/colors.xml b/data/themes/unity/colors.xml index 8f86df563..58bab3eab 100644 --- a/data/themes/unity/colors.xml +++ b/data/themes/unity/colors.xml @@ -87,6 +87,8 @@ + + diff --git a/data/themes/wood/colors.xml b/data/themes/wood/colors.xml index 54a19172e..1566ab5e6 100644 --- a/data/themes/wood/colors.xml +++ b/data/themes/wood/colors.xml @@ -88,6 +88,8 @@ + + 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(mAlpha * 255); + mBackgroundColor.a = static_cast(mAlpha * 255); render(static_cast(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(mProgress * static_cast(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) -- cgit v1.2.3-60-g2f50