summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-05-30 16:04:27 +0300
committerAndrei Karas <akaras@inbox.ru>2015-05-30 16:04:27 +0300
commitdc8422dbac2c45a082153240138d699c1bfc3b88 (patch)
treed073286b567fe45179440e678be779c8eb8c0f0e /src/gui
parentaa86dbe6a7c966a4bfa7aa6c81218fe58f0bf92d (diff)
downloadplus-dc8422dbac2c45a082153240138d699c1bfc3b88.tar.gz
plus-dc8422dbac2c45a082153240138d699c1bfc3b88.tar.bz2
plus-dc8422dbac2c45a082153240138d699c1bfc3b88.tar.xz
plus-dc8422dbac2c45a082153240138d699c1bfc3b88.zip
Move gradient type into separate file.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/palette.cpp14
-rw-r--r--src/gui/palette.h23
-rw-r--r--src/gui/theme.cpp10
-rw-r--r--src/gui/userpalette.cpp113
-rw-r--r--src/gui/userpalette.h4
-rw-r--r--src/gui/widgets/tabs/setup_colors.cpp24
6 files changed, 92 insertions, 96 deletions
diff --git a/src/gui/palette.cpp b/src/gui/palette.cpp
index 4935ce60d..88de9d5d0 100644
--- a/src/gui/palette.cpp
+++ b/src/gui/palette.cpp
@@ -108,13 +108,13 @@ void Palette::advanceGradient()
continue;
int delay = elem->delay;
- const GradientType &grad = elem->grad;
+ const GradientTypeT &grad = elem->grad;
- if (grad == PULSE)
+ if (grad == GradientType::PULSE)
delay = delay / 20;
- const int numOfColors = (elem->grad == SPECTRUM ? 6 :
- grad == PULSE ? 127 :
+ const int numOfColors = (elem->grad == GradientType::SPECTRUM ? 6 :
+ grad == GradientType::PULSE ? 127 :
RAINBOW_COLOR_COUNT);
elem->gradientIndex = (elem->gradientIndex + advance)
@@ -131,7 +131,7 @@ void Palette::advanceGradient()
Color &color = elem->color;
int colVal;
- if (grad == PULSE)
+ if (grad == GradientType::PULSE)
{
colVal = static_cast<int>(255.0 *
sin(M_PI * colIndex / numOfColors));
@@ -142,7 +142,7 @@ void Palette::advanceGradient()
color.g = ((colVal * col.g) / 255) % (col.g + 1);
color.b = ((colVal * col.b) / 255) % (col.b + 1);
}
- else if (grad == SPECTRUM)
+ else if (grad == GradientType::SPECTRUM)
{
if (colIndex % 2)
{ // falling curve
@@ -178,7 +178,7 @@ void Palette::advanceGradient()
color.b = (colIndex == 3 || colIndex == 4) ? 255 :
(colIndex == 2 || colIndex == 5) ? colVal : 0;
}
- else if (elem->grad == RAINBOW)
+ else if (elem->grad == GradientType::RAINBOW)
{
const Color &startCol = RAINBOW_COLORS[colIndex];
const Color &destCol
diff --git a/src/gui/palette.h b/src/gui/palette.h
index c8bf5de47..b42ada438 100644
--- a/src/gui/palette.h
+++ b/src/gui/palette.h
@@ -26,6 +26,8 @@
#include "logger.h"
+#include "enums/gui/gradienttype.h"
+
#include "gui/color.h"
#if defined __native_client__
@@ -49,15 +51,6 @@ class Palette notfinal
/** Black Color Constant */
static const Color BLACK;
- /** Colors can be static or can alter over time. */
- enum GradientType
- {
- STATIC = 0,
- PULSE,
- SPECTRUM,
- RAINBOW
- };
-
A_DELETE_COPY(Palette)
/**
@@ -111,7 +104,7 @@ class Palette notfinal
*
* @return the gradient type of the color with the given index
*/
- inline GradientType getGradientType(const int type) const A_WARN_UNUSED
+ inline GradientTypeT getGradientType(const int type) const A_WARN_UNUSED
{ return mColors[type].grad; }
/**
@@ -171,8 +164,8 @@ class Palette notfinal
committedColor(0),
text(),
ch(0),
- grad(STATIC),
- committedGrad(STATIC),
+ grad(GradientType::STATIC),
+ committedGrad(GradientType::STATIC),
gradientIndex(0),
delay(0),
committedDelay(0)
@@ -185,14 +178,14 @@ class Palette notfinal
Color committedColor;
std::string text;
signed char ch;
- GradientType grad;
- GradientType committedGrad;
+ GradientTypeT grad;
+ GradientTypeT committedGrad;
int gradientIndex;
int delay;
int committedDelay;
void set(const int type0, const Color &color0,
- const GradientType grad0, const int delay0)
+ const GradientTypeT grad0, const int delay0)
{
type = type0;
color = color0;
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp
index 477da5fb0..d9740de3b 100644
--- a/src/gui/theme.cpp
+++ b/src/gui/theme.cpp
@@ -913,7 +913,7 @@ static Color readColor(const std::string &description)
return Color(v);
}
-static Palette::GradientType readColorGradient(const std::string &grad)
+static GradientTypeT readColorGradient(const std::string &grad)
{
static const std::string grads[] =
{
@@ -924,15 +924,15 @@ static Palette::GradientType readColorGradient(const std::string &grad)
};
if (grad.empty())
- return Palette::STATIC;
+ return GradientType::STATIC;
for (int i = 0; i < 4; i++)
{
if (compareStrI(grad, grads[i]))
- return static_cast<Palette::GradientType>(i);
+ return static_cast<GradientTypeT>(i);
}
- return Palette::STATIC;
+ return GradientType::STATIC;
}
static int readProgressType(const std::string &type)
@@ -1018,7 +1018,7 @@ void Theme::loadColors(std::string file)
continue;
const Color color = readColor(temp);
- const GradientType grad = readColorGradient(
+ const GradientTypeT grad = readColorGradient(
XML::getProperty(node, "effect", ""));
mColors[paletteId * ThemeColorId::THEME_COLORS_END + type].set(
type, color, grad, 10);
diff --git a/src/gui/userpalette.cpp b/src/gui/userpalette.cpp
index 7163cb396..38cf4cfe1 100644
--- a/src/gui/userpalette.cpp
+++ b/src/gui/userpalette.cpp
@@ -113,116 +113,116 @@ UserPalette::UserPalette() :
mColors[MONSTER] = ColorElem();
// TRANSLATORS: palette color
- addColor(BEING, 0xffffff, STATIC, _("Being"));
+ addColor(BEING, 0xffffff, GradientType::STATIC, _("Being"));
// TRANSLATORS: palette color
- addColor(FRIEND, 0xb0ffb0, STATIC, _("Friend names"));
+ addColor(FRIEND, 0xb0ffb0, GradientType::STATIC, _("Friend names"));
// TRANSLATORS: palette color
- addColor(DISREGARDED, 0xa00000, STATIC, _("Disregarded names"));
+ addColor(DISREGARDED, 0xa00000, GradientType::STATIC, _("Disregarded names"));
// TRANSLATORS: palette color
- addColor(IGNORED, 0xff0000, STATIC, _("Ignored names"));
+ addColor(IGNORED, 0xff0000, GradientType::STATIC, _("Ignored names"));
// TRANSLATORS: palette color
- addColor(ERASED, 0xff0000, STATIC, _("Erased names"));
+ addColor(ERASED, 0xff0000, GradientType::STATIC, _("Erased names"));
// TRANSLATORS: palette color
- addColor(PC, 0xffffff, STATIC, _("Other players names"));
+ addColor(PC, 0xffffff, GradientType::STATIC, _("Other players names"));
// TRANSLATORS: palette color
- addColor(SELF, 0xff8040, STATIC, _("Own name"));
+ addColor(SELF, 0xff8040, GradientType::STATIC, _("Own name"));
// TRANSLATORS: palette color
- addColor(GM, 0x00ff00, STATIC, _("GM names"));
+ addColor(GM, 0x00ff00, GradientType::STATIC, _("GM names"));
// TRANSLATORS: palette color
- addColor(NPC, 0xc8c8ff, STATIC, _("NPCs"));
+ addColor(NPC, 0xc8c8ff, GradientType::STATIC, _("NPCs"));
// TRANSLATORS: palette color
- addColor(MONSTER, 0xff4040, STATIC, _("Monsters"));
+ addColor(MONSTER, 0xff4040, GradientType::STATIC, _("Monsters"));
// TRANSLATORS: palette color
- addColor(MONSTER_HP, 0x00ff00, STATIC, _("Monster HP bar"), 50);
- addColor(MONSTER_HP2, 0xff0000, STATIC,
+ addColor(MONSTER_HP, 0x00ff00, GradientType::STATIC, _("Monster HP bar"), 50);
+ addColor(MONSTER_HP2, 0xff0000, GradientType::STATIC,
// TRANSLATORS: palette color
_("Monster HP bar (second color)"), 50);
// TRANSLATORS: palette color
- addColor(PARTY, 0xff00d8, STATIC, _("Party members"));
+ addColor(PARTY, 0xff00d8, GradientType::STATIC, _("Party members"));
// TRANSLATORS: palette color
- addColor(GUILD, 0xff00d8, STATIC, _("Guild members"));
+ addColor(GUILD, 0xff00d8, GradientType::STATIC, _("Guild members"));
// TRANSLATORS: palette color
- addColor(PARTICLE, 0xffffff, STATIC, _("Particle effects"));
+ addColor(PARTICLE, 0xffffff, GradientType::STATIC, _("Particle effects"));
// TRANSLATORS: palette color
- addColor(PICKUP_INFO, 0x28dc28, STATIC, _("Pickup notification"));
+ addColor(PICKUP_INFO, 0x28dc28, GradientType::STATIC, _("Pickup notification"));
// TRANSLATORS: palette color
- addColor(EXP_INFO, 0xffff00, STATIC, _("Exp notification"));
+ addColor(EXP_INFO, 0xffff00, GradientType::STATIC, _("Exp notification"));
// TRANSLATORS: palette color
- addColor(PLAYER_HP, 0x00ff00, STATIC, _("Player HP bar"), 50);
+ addColor(PLAYER_HP, 0x00ff00, GradientType::STATIC, _("Player HP bar"), 50);
// TRANSLATORS: palette color
- addColor(PLAYER_HP2, 0xff0000, STATIC,
+ addColor(PLAYER_HP2, 0xff0000, GradientType::STATIC,
// TRANSLATORS: palette color
_("Player HP bar (second color)"), 50);
// TRANSLATORS: palette color
- addColor(HIT_PLAYER_MONSTER, 0x0064ff, STATIC, _("Player hits monster"));
+ addColor(HIT_PLAYER_MONSTER, 0x0064ff, GradientType::STATIC, _("Player hits monster"));
// TRANSLATORS: palette color
- addColor(HIT_MONSTER_PLAYER, 0xff3232, STATIC, _("Monster hits player"));
+ addColor(HIT_MONSTER_PLAYER, 0xff3232, GradientType::STATIC, _("Monster hits player"));
// TRANSLATORS: palette color
- addColor(HIT_PLAYER_PLAYER, 0xff5050, STATIC,
+ addColor(HIT_PLAYER_PLAYER, 0xff5050, GradientType::STATIC,
// TRANSLATORS: palette color
_("Other player hits local player"));
// TRANSLATORS: palette color
- addColor(HIT_CRITICAL, 0xff0000, RAINBOW, _("Critical Hit"));
+ addColor(HIT_CRITICAL, 0xff0000, GradientType::RAINBOW, _("Critical Hit"));
// TRANSLATORS: palette color
- addColor(HIT_LOCAL_PLAYER_MONSTER, 0x00ff00, STATIC,
+ addColor(HIT_LOCAL_PLAYER_MONSTER, 0x00ff00, GradientType::STATIC,
// TRANSLATORS: palette color
_("Local player hits monster"));
- addColor(HIT_LOCAL_PLAYER_CRITICAL, 0xff0000, RAINBOW,
+ addColor(HIT_LOCAL_PLAYER_CRITICAL, 0xff0000, GradientType::RAINBOW,
// TRANSLATORS: palette color
_("Local player critical hit"));
- addColor(HIT_LOCAL_PLAYER_MISS, 0x00ffa6, STATIC,
+ addColor(HIT_LOCAL_PLAYER_MISS, 0x00ffa6, GradientType::STATIC,
// TRANSLATORS: palette color
_("Local player miss"));
// TRANSLATORS: palette color
- addColor(MISS, 0xffff00, STATIC, _("Misses"));
+ addColor(MISS, 0xffff00, GradientType::STATIC, _("Misses"));
// TRANSLATORS: palette color
- addColor(PORTAL_HIGHLIGHT, 0xC80000, STATIC, _("Portal highlight"));
- addColor(COLLISION_HIGHLIGHT, 0x0000C8, STATIC,
+ addColor(PORTAL_HIGHLIGHT, 0xC80000, GradientType::STATIC, _("Portal highlight"));
+ addColor(COLLISION_HIGHLIGHT, 0x0000C8, GradientType::STATIC,
// TRANSLATORS: palette color
_("Default collision highlight"), 64);
- addColor(AIR_COLLISION_HIGHLIGHT, 0xe0e0ff, STATIC,
+ addColor(AIR_COLLISION_HIGHLIGHT, 0xe0e0ff, GradientType::STATIC,
// TRANSLATORS: palette color
_("Air collision highlight"), 64);
- addColor(WATER_COLLISION_HIGHLIGHT, 0x2050e0, STATIC,
+ addColor(WATER_COLLISION_HIGHLIGHT, 0x2050e0, GradientType::STATIC,
// TRANSLATORS: palette color
_("Water collision highlight"), 64);
- addColor(GROUNDTOP_COLLISION_HIGHLIGHT, 0xffff00, STATIC,
+ addColor(GROUNDTOP_COLLISION_HIGHLIGHT, 0xffff00, GradientType::STATIC,
// TRANSLATORS: palette color
_("Special ground collision highlight"), 20);
- addColor(WALKABLE_HIGHLIGHT, 0x00D000, STATIC,
+ addColor(WALKABLE_HIGHLIGHT, 0x00D000, GradientType::STATIC,
// TRANSLATORS: palette color
_("Walkable highlight"), 255);
- addColor(ATTACK_RANGE, 0xffffff, STATIC,
+ addColor(ATTACK_RANGE, 0xffffff, GradientType::STATIC,
// TRANSLATORS: palette color
_("Local player attack range"), 5);
- addColor(ATTACK_RANGE_BORDER, 0x0, STATIC,
+ addColor(ATTACK_RANGE_BORDER, 0x0, GradientType::STATIC,
// TRANSLATORS: palette color
_("Local player attack range border"), 76);
- addColor(MONSTER_ATTACK_RANGE, 0xff0000, STATIC,
+ addColor(MONSTER_ATTACK_RANGE, 0xff0000, GradientType::STATIC,
// TRANSLATORS: palette color
_("Monster attack range"), 20);
- addColor(FLOOR_ITEM_TEXT, 0xffffff, STATIC,
+ addColor(FLOOR_ITEM_TEXT, 0xffffff, GradientType::STATIC,
// TRANSLATORS: palette color
_("Floor item amount color"), 100);
- addColor(HOME_PLACE, 0xffffff, STATIC,
+ addColor(HOME_PLACE, 0xffffff, GradientType::STATIC,
// TRANSLATORS: palette color
_("Home place"), 20);
- addColor(HOME_PLACE_BORDER, 0xffff00, STATIC,
+ addColor(HOME_PLACE_BORDER, 0xffff00, GradientType::STATIC,
// TRANSLATORS: palette color
_("Home place border"), 200);
- addColor(ROAD_POINT, 0x000000, STATIC,
+ addColor(ROAD_POINT, 0x000000, GradientType::STATIC,
// TRANSLATORS: palette color
_("Road point"), 100);
- addColor(NET, 0x000000, STATIC,
+ addColor(NET, 0x000000, GradientType::STATIC,
// TRANSLATORS: palette color
_("Tiles border"), 64);
// TRANSLATORS: palette color
- addColor(PET, 0xffffff, STATIC, _("Pets"));
+ addColor(PET, 0xffffff, GradientType::STATIC, _("Pets"));
// TRANSLATORS: palette color
- addColor(MERCENARY, 0xffffff, STATIC, _("Mercenary"));
+ addColor(MERCENARY, 0xffffff, GradientType::STATIC, _("Mercenary"));
// TRANSLATORS: palette color
- addColor(HOMUNCULUS, 0xffffff, STATIC, _("Homunculus"));
+ addColor(HOMUNCULUS, 0xffffff, GradientType::STATIC, _("Homunculus"));
commit(true);
}
@@ -235,7 +235,8 @@ UserPalette::~UserPalette()
static_cast<int>(col->committedGrad));
config.setValue(configName + "Delay", col->delay);
- if (col->grad == STATIC || col->grad == PULSE)
+ if (col->grad == GradientType::STATIC ||
+ col->grad == GradientType::PULSE)
{
char buffer[20];
snprintf(buffer, sizeof(buffer), "0x%06x", col->getRGB());
@@ -256,11 +257,11 @@ void UserPalette::setColor(const int type,
color.b = b;
}
-void UserPalette::setGradient(const int type, const GradientType grad)
+void UserPalette::setGradient(const int type, const GradientTypeT grad)
{
ColorElem *const elem = &mColors[type];
- if (elem->grad != STATIC && grad == STATIC)
+ if (elem->grad != GradientType::STATIC && grad == GradientType::STATIC)
{
const size_t sz = mGradVector.size();
for (size_t i = 0; i < sz; i++)
@@ -272,7 +273,8 @@ void UserPalette::setGradient(const int type, const GradientType grad)
}
}
}
- else if (elem->grad == STATIC && grad != STATIC)
+ else if (elem->grad == GradientType::STATIC &&
+ grad != GradientType::STATIC)
{
mGradVector.push_back(elem);
}
@@ -295,9 +297,9 @@ void UserPalette::commit(const bool commitNonStatic)
{
i->committedGrad = i->grad;
i->committedDelay = i->delay;
- if (commitNonStatic || i->grad == STATIC)
+ if (commitNonStatic || i->grad == GradientType::STATIC)
i->committedColor = i->color;
- else if (i->grad == PULSE)
+ else if (i->grad == GradientType::PULSE)
i->committedColor = i->testColor;
}
}
@@ -314,7 +316,7 @@ void UserPalette::rollback()
setColor(i->type, committedColor.r,
committedColor.g, committedColor.b);
- if (i->grad == PULSE)
+ if (i->grad == GradientType::PULSE)
{
Color &testColor = i->testColor;
testColor.r = committedColor.r;
@@ -334,7 +336,7 @@ int UserPalette::getColorTypeAt(const int i)
void UserPalette::addColor(const unsigned type,
const unsigned rgb,
- Palette::GradientType grad,
+ GradientTypeT grad,
const std::string &text,
int delay)
{
@@ -357,12 +359,13 @@ void UserPalette::addColor(const unsigned type,
else
rgbValue = atoi(rgbString.c_str());
const Color &trueCol = Color(rgbValue);
- grad = static_cast<GradientType>(config.getValue(configName + "Gradient",
- static_cast<int>(grad)));
+ grad = static_cast<GradientTypeT>(config.getValue(
+ configName + "Gradient",
+ static_cast<int>(grad)));
delay = config.getValueInt(configName + "Delay", delay);
mColors[type].set(type, trueCol, grad, delay);
mColors[type].text = text;
- if (grad != STATIC)
+ if (grad != GradientType::STATIC)
mGradVector.push_back(&mColors[type]);
}
diff --git a/src/gui/userpalette.h b/src/gui/userpalette.h
index 249b48a0a..61f4a1799 100644
--- a/src/gui/userpalette.h
+++ b/src/gui/userpalette.h
@@ -143,7 +143,7 @@ class UserPalette final : public Palette, public ListModel
*
* @param grad gradient type to set
*/
- void setGradient(const int type, const Palette::GradientType grad);
+ void setGradient(const int type, const GradientTypeT grad);
/**
* Sets the gradient delay for the specified color.
@@ -229,7 +229,7 @@ class UserPalette final : public Palette, public ListModel
* @param text identifier of color
*/
void addColor(const unsigned type, const unsigned rgb,
- GradientType grad, const std::string &text,
+ GradientTypeT grad, const std::string &text,
int delay = GRADIENT_DELAY);
};
diff --git a/src/gui/widgets/tabs/setup_colors.cpp b/src/gui/widgets/tabs/setup_colors.cpp
index 28d52db0b..b511a1446 100644
--- a/src/gui/widgets/tabs/setup_colors.cpp
+++ b/src/gui/widgets/tabs/setup_colors.cpp
@@ -250,7 +250,7 @@ void Setup_Colors::valueChanged(const SelectionEvent &event A_UNUSED)
mSelected = mColorBox->getSelected();
const int type = userPalette->getColorTypeAt(mSelected);
const Color *col = &userPalette->getColor(type);
- const Palette::GradientType grad = userPalette->getGradientType(type);
+ const GradientTypeT grad = userPalette->getGradientType(type);
const int delay = userPalette->getGradientDelay(type);
mPreview->clearRows();
@@ -337,12 +337,12 @@ void Setup_Colors::valueChanged(const SelectionEvent &event A_UNUSED)
mGradDelaySlider->setScale(20, 100);
break;
}
- if (grad != Palette::STATIC && grad != Palette::PULSE)
+ if (grad != GradientType::STATIC && grad != GradientType::PULSE)
{ // If nonstatic color, don't display the current, but the committed
// color at the sliders
col = &userPalette->getCommittedColor(type);
}
- else if (grad == Palette::PULSE)
+ else if (grad == GradientType::PULSE)
{
col = &userPalette->getTestColor(type);
}
@@ -395,17 +395,17 @@ void Setup_Colors::updateGradType()
mSelected = mColorBox->getSelected();
const int type = userPalette->getColorTypeAt(mSelected);
- const Palette::GradientType grad = userPalette->getGradientType(type);
+ const GradientTypeT grad = userPalette->getGradientType(type);
mGradTypeText->setCaption(
// TRANSLATORS: color type
- (grad == Palette::STATIC) ? _("Static") :
+ (grad == GradientType::STATIC) ? _("Static") :
// TRANSLATORS: color type
- (grad == Palette::PULSE) ? _("Pulse") :
+ (grad == GradientType::PULSE) ? _("Pulse") :
// TRANSLATORS: color type
- (grad == Palette::RAINBOW) ? _("Rainbow") : _("Spectrum"));
+ (grad == GradientType::RAINBOW) ? _("Rainbow") : _("Spectrum"));
- const bool enable = (grad == Palette::STATIC || grad == Palette::PULSE);
+ const bool enable = (grad == GradientType::STATIC || grad == GradientType::PULSE);
const bool delayEnable = true;
mGradDelayText->setEnabled(delayEnable);
@@ -425,20 +425,20 @@ void Setup_Colors::updateColor()
return;
const int type = userPalette->getColorTypeAt(mSelected);
- const Palette::GradientType grad = static_cast<Palette::GradientType>(
- static_cast<int>(mGradTypeSlider->getValue()));
+ const GradientTypeT grad = static_cast<GradientTypeT>(
+ static_cast<int>(mGradTypeSlider->getValue()));
const int delay = static_cast<int>(mGradDelaySlider->getValue());
userPalette->setGradient(type, grad);
userPalette->setGradientDelay(type, delay);
- if (grad == Palette::STATIC)
+ if (grad == GradientType::STATIC)
{
userPalette->setColor(type,
static_cast<int>(mRedSlider->getValue()),
static_cast<int>(mGreenSlider->getValue()),
static_cast<int>(mBlueSlider->getValue()));
}
- else if (grad == Palette::PULSE)
+ else if (grad == GradientType::PULSE)
{
userPalette->setTestColor(type, Color(
static_cast<int>(mRedSlider->getValue()),