diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-05-31 14:23:11 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-05-31 14:23:11 +0300 |
commit | d7c67fa2b6faa3e81269244224da4b72f045d659 (patch) | |
tree | 596010d034e44ff46eabccca3c77d995626fca88 /src/gui/widgets | |
parent | b072723595e729eed79199f246439ffed62cdbb5 (diff) | |
download | plus-d7c67fa2b6faa3e81269244224da4b72f045d659.tar.gz plus-d7c67fa2b6faa3e81269244224da4b72f045d659.tar.bz2 plus-d7c67fa2b6faa3e81269244224da4b72f045d659.tar.xz plus-d7c67fa2b6faa3e81269244224da4b72f045d659.zip |
Convert ProgressColorId enum into strong typed enum.
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/avatarlistbox.cpp | 8 | ||||
-rw-r--r-- | src/gui/widgets/progressbar.cpp | 17 | ||||
-rw-r--r-- | src/gui/widgets/progressbar.h | 8 |
3 files changed, 19 insertions, 14 deletions
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index 5c2f0a65d..d5b6cbaf8 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -179,7 +179,7 @@ void AvatarListBox::draw(Graphics *graphics) const bool isPoison = a->getPoison(); if (a->getMaxHp()) { - const int themeColor = (isPoison + const ProgressColorIdT themeColor = (isPoison ? ProgressColorId::PROG_HP_POISON : ProgressColorId::PROG_HP); Color color = Theme::getProgressColor( themeColor, static_cast<float>(a->getHp()) @@ -204,7 +204,7 @@ void AvatarListBox::draw(Graphics *graphics) a->getDamageHp()); } - const int themeColor = (a->getPoison() + const ProgressColorIdT themeColor = (a->getPoison() ? ProgressColorId::PROG_HP_POISON : ProgressColorId::PROG_HP); Color color = Theme::getProgressColor(themeColor, 1); color.a = 80; @@ -416,7 +416,7 @@ void AvatarListBox::safeDraw(Graphics *graphics) const bool isPoison = a->getPoison(); if (a->getMaxHp()) { - const int themeColor = (isPoison + const ProgressColorIdT themeColor = (isPoison ? ProgressColorId::PROG_HP_POISON : ProgressColorId::PROG_HP); Color color = Theme::getProgressColor( themeColor, static_cast<float>(a->getHp()) @@ -441,7 +441,7 @@ void AvatarListBox::safeDraw(Graphics *graphics) a->getDamageHp()); } - const int themeColor = (a->getPoison() + const ProgressColorIdT themeColor = (a->getPoison() ? ProgressColorId::PROG_HP_POISON : ProgressColorId::PROG_HP); Color color = Theme::getProgressColor(themeColor, 1); color.a = 80; diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp index dfba99892..2965fc410 100644 --- a/src/gui/widgets/progressbar.cpp +++ b/src/gui/widgets/progressbar.cpp @@ -43,7 +43,7 @@ ProgressBar::ProgressBar(const Widget2 *const widget, float progress, const int width, const int height, - const int backColor, + const ProgressColorIdT backColor, const std::string &skin, const std::string &skinFill) : Widget(widget), @@ -62,8 +62,10 @@ ProgressBar::ProgressBar(const Widget2 *const widget, mSmoothProgress(true), mSmoothColorChange(true) { - mBackgroundColor = Theme::getProgressColor(backColor >= 0 - ? backColor : 0, mProgress); + mBackgroundColor = Theme::getProgressColor( + backColor >= ProgressColorId::PROG_HP + ? backColor : ProgressColorId::PROG_HP, + mProgress); mBackgroundColorToGo = mBackgroundColor; mForegroundColor2 = getThemeColor(ThemeColorId::PROGRESS_BAR_OUTLINE); @@ -297,20 +299,21 @@ void ProgressBar::setProgress(const float progress) if (!mSmoothProgress) mProgress = p; - if (mProgressPalette >= 0) + if (mProgressPalette >= ProgressColorId::PROG_HP) { mBackgroundColorToGo = Theme::getProgressColor( mProgressPalette, progress); } } -void ProgressBar::setProgressPalette(const int progressPalette) +void ProgressBar::setProgressPalette(const ProgressColorIdT progressPalette) { - const int oldPalette = mProgressPalette; + const ProgressColorIdT oldPalette = mProgressPalette; mProgressPalette = progressPalette; mRedraw = true; - if (mProgressPalette != oldPalette && mProgressPalette >= 0) + if (mProgressPalette != oldPalette && + mProgressPalette >= ProgressColorId::PROG_HP) { mBackgroundColorToGo = Theme::getProgressColor( mProgressPalette, mProgressToGo); diff --git a/src/gui/widgets/progressbar.h b/src/gui/widgets/progressbar.h index 053710ae8..571568e6c 100644 --- a/src/gui/widgets/progressbar.h +++ b/src/gui/widgets/progressbar.h @@ -23,6 +23,8 @@ #ifndef GUI_WIDGETS_PROGRESSBAR_H #define GUI_WIDGETS_PROGRESSBAR_H +#include "enums/gui/progresscolorid.h" + #include "gui/widgets/widget.h" #include "listeners/widgetlistener.h" @@ -50,7 +52,7 @@ class ProgressBar final : public Widget, float progress, const int width, const int height, - const int backColor, + const ProgressColorIdT backColor, const std::string &skin, const std::string &skinFill); @@ -90,7 +92,7 @@ class ProgressBar final : public Widget, * Change the ProgressPalette for this ProgressBar to follow or -1 to * disable this and manage color manually. */ - void setProgressPalette(const int progressPalette); + void setProgressPalette(const ProgressColorIdT progressPalette); /** * Change the color of the progress bar. @@ -146,7 +148,7 @@ class ProgressBar final : public Widget, std::string mText; ImageCollection *mVertexes; - int mProgressPalette; /** < Entry in ProgressPalette or -1 for none. */ + ProgressColorIdT mProgressPalette; unsigned int mPadding; unsigned int mFillPadding; |