summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorIra Rice <irarice@gmail.com>2009-03-14 20:20:04 -0600
committerIra Rice <irarice@gmail.com>2009-03-14 20:20:04 -0600
commit8fb5276dcc5c527a3daf99c18826d6d9bf9802be (patch)
treef1a18874fc863d78c992b63f0ce1521607251ac8 /src/gui
parent79fa5a629426888f51241914d90ca8599373f2d0 (diff)
downloadmana-client-8fb5276dcc5c527a3daf99c18826d6d9bf9802be.tar.gz
mana-client-8fb5276dcc5c527a3daf99c18826d6d9bf9802be.tar.bz2
mana-client-8fb5276dcc5c527a3daf99c18826d6d9bf9802be.tar.xz
mana-client-8fb5276dcc5c527a3daf99c18826d6d9bf9802be.zip
Added a pulse effect into the palette class, which uses the set color
and pulsates back and forth between it and black. Added directly after the spectrum effect. Also modified the gradient delay to be a lot farther out, so that we don't end up with a Pokemon seizure causing disaster (the speed was the same, as well as the colors. The new speed should be a lot more considerate of people who are prone to having issues from that speed of color changing). TODO: Modify the palette class to allow for updating the color for the pulse gradient without needing to have it applied first. Signed-off-by: Ira Rice <irarice@gmail.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/palette.cpp55
-rw-r--r--src/gui/palette.h22
-rw-r--r--src/gui/setup_colors.cpp3
3 files changed, 39 insertions, 41 deletions
diff --git a/src/gui/palette.cpp b/src/gui/palette.cpp
index a3d654be..412550c7 100644
--- a/src/gui/palette.cpp
+++ b/src/gui/palette.cpp
@@ -33,7 +33,7 @@
const gcn::Color Palette::BLACK = gcn::Color(0, 0, 0);
-const gcn::Color Palette::RAINBOW_COLORS[8] = {
+const gcn::Color Palette::RAINBOW_COLORS[7] = {
gcn::Color(255, 0, 0),
gcn::Color(255, 153, 0),
gcn::Color(255, 255, 0),
@@ -73,7 +73,7 @@ std::string Palette::getConfigName(const std::string& typeName)
DEFENUMNAMES(ColorType, COLOR_TYPE);
-const int Palette::GRADIENT_DELAY = 20;
+const int Palette::GRADIENT_DELAY = 40;
Palette::Palette() :
mRainbowTime(tick_time),
@@ -89,7 +89,7 @@ Palette::Palette() :
addColor(BACKGROUND, 0xffffff, STATIC, _("Background"));
addColor(HIGHLIGHT, 0xebc873, STATIC, _("Highlight"), 'H');
- addColor(TAB_HIGHLIGHT, 0xff0000, STATIC, indent + _("Tab Highlight"));
+ addColor(TAB_HIGHLIGHT, 0xff0000, PULSE, indent + _("Tab Highlight"));
addColor(SHOP_WARNING, 0x910000, STATIC, indent +
_("Item too expensive"));
@@ -222,7 +222,7 @@ void Palette::commit(bool commitNonStatic)
i != iEnd; ++i)
{
i->committedGrad = i->grad;
- if (commitNonStatic || i->grad == STATIC)
+ if (commitNonStatic || i->grad == STATIC || i->grad == PULSE)
{
i->committedColor = i->color;
}
@@ -245,8 +245,8 @@ void Palette::rollback()
}
void Palette::addColor(Palette::ColorType type, int rgb,
- Palette::GradientType grad,
- const std::string &text, char c)
+ Palette::GradientType grad,
+ const std::string &text, char c)
{
const std::string *configName = &ColorTypeNames[type];
gcn::Color trueCol = (int)config.getValue(*configName, rgb);
@@ -263,7 +263,7 @@ void Palette::advanceGradient ()
if (get_elapsed_time(mRainbowTime) > 5)
{
int pos, colIndex, colVal;
- // For slower systems, advance can be greater than one (adcanve > 1
+ // For slower systems, advance can be greater than one (advance > 1
// skips advance-1 steps). Should make gradient look the same
// independent of the framerate.
int advance = get_elapsed_time(mRainbowTime) / 5;
@@ -273,25 +273,32 @@ void Palette::advanceGradient ()
{
mGradVector[i]->gradientIndex =
(mGradVector[i]->gradientIndex + advance) %
- (GRADIENT_DELAY *
- ((mGradVector[i]->grad == SPECTRUM) ? 6 :
- RAINBOW_COLOR_COUNT));
+ (GRADIENT_DELAY * ((mGradVector[i]->grad == SPECTRUM) ?
+ (mGradVector[i]->grad == PULSE) ? 255 : 6 :
+ RAINBOW_COLOR_COUNT));
pos = mGradVector[i]->gradientIndex % GRADIENT_DELAY;
colIndex = mGradVector[i]->gradientIndex / GRADIENT_DELAY;
+ if (mGradVector[i]->grad == PULSE)
+ {
+ colVal = (int) (255.0 * (sin(M_PI * (mGradVector[i]->gradientIndex) / 255) + 1) / 2);
+
+ const gcn::Color* col = &mGradVector[i]->committedColor;
+
+ mGradVector[i]->color.r = (colVal) % (col->r + 1);
+ mGradVector[i]->color.g = (colVal) % (col->g + 1);
+ mGradVector[i]->color.b = (colVal) % (col->b + 1);
+ }
if (mGradVector[i]->grad == SPECTRUM)
{
if (colIndex % 2)
{ // falling curve
- colVal = (int)(255.0 *
- (cos(M_PI * pos / GRADIENT_DELAY) + 1) / 2);
+ colVal = (int)(255.0 * (cos(M_PI * pos / GRADIENT_DELAY) + 1) / 2);
}
else
{ // ascending curve
- colVal = (int)(255.0 *
- (cos(M_PI * (GRADIENT_DELAY-pos) / GRADIENT_DELAY) +
- 1) / 2);
+ colVal = (int)(255.0 * (cos(M_PI * (GRADIENT_DELAY-pos) / GRADIENT_DELAY) + 1) / 2);
}
mGradVector[i]->color.r =
@@ -304,7 +311,7 @@ void Palette::advanceGradient ()
(colIndex == 3 || colIndex == 4) ? 255 :
(colIndex == 2 || colIndex == 5) ? colVal : 0;
}
- else
+ else if (mGradVector[i]->grad == RAINBOW)
{
const gcn::Color* startCol = &RAINBOW_COLORS[colIndex];
const gcn::Color* destCol =
@@ -313,20 +320,18 @@ void Palette::advanceGradient ()
startColVal = (cos(M_PI * pos / GRADIENT_DELAY) + 1) / 2;
destColVal = 1 - startColVal;
- mGradVector[i]->color.r =(int)(
- startColVal * startCol->r +
- destColVal * destCol->r);
+ mGradVector[i]->color.r =(int)(startColVal * startCol->r +
+ destColVal * destCol->r);
- mGradVector[i]->color.g =(int)(
- startColVal * startCol->g +
- destColVal * destCol->g);
+ mGradVector[i]->color.g =(int)(startColVal * startCol->g +
+ destColVal * destCol->g);
- mGradVector[i]->color.b =(int)(
- startColVal * startCol->b +
- destColVal * destCol->b);
+ mGradVector[i]->color.b =(int)(startColVal * startCol->b +
+ destColVal * destCol->b);
}
}
mRainbowTime = tick_time;
}
}
+
diff --git a/src/gui/palette.h b/src/gui/palette.h
index f0a3d541..0947aa58 100644
--- a/src/gui/palette.h
+++ b/src/gui/palette.h
@@ -98,6 +98,7 @@ class Palette : public gcn::ListModel
/** Colors can be static or can alter over time. */
enum GradientType {
STATIC,
+ PULSE,
SPECTRUM,
RAINBOW
};
@@ -147,9 +148,7 @@ class Palette : public gcn::ListModel
* @return the requested committed color
*/
inline const gcn::Color& getCommittedColor(ColorType type)
- {
- return mColVector[type].committedColor;
- }
+ { return mColVector[type].committedColor; }
/**
* Gets the GradientType associated with the specified type.
@@ -159,9 +158,7 @@ class Palette : public gcn::ListModel
* @return the gradient type of the color with the given index
*/
inline GradientType getGradientType(ColorType type)
- {
- return mColVector[type].grad;
- }
+ { return mColVector[type].grad; }
/**
* Get the character used by the specified color.
@@ -170,10 +167,7 @@ class Palette : public gcn::ListModel
*
* @return the color char of the color with the given index
*/
- inline char getColorChar(ColorType type)
- {
- return mColVector[type].ch;
- }
+ inline char getColorChar(ColorType type) { return mColVector[type].ch; }
/**
* Sets the color for the specified type.
@@ -221,10 +215,7 @@ class Palette : public gcn::ListModel
/**
* Commit the colors
*/
- inline void commit()
- {
- commit(false);
- }
+ inline void commit() { commit(false); }
/**
* Rollback the colors
@@ -286,7 +277,8 @@ class Palette : public gcn::ListModel
ColorElem::gradientIndex = rand();
}
- inline int getRGB() {
+ inline int getRGB()
+ {
return (committedColor.r << 16) | (committedColor.g << 8) |
committedColor.b;
}
diff --git a/src/gui/setup_colors.cpp b/src/gui/setup_colors.cpp
index b7c408d1..79c4fcb5 100644
--- a/src/gui/setup_colors.cpp
+++ b/src/gui/setup_colors.cpp
@@ -73,7 +73,7 @@ Setup_Colors::Setup_Colors() :
mGradTypeLabel = new Label(_("Type: "));
- mGradTypeSlider = new Slider(0, 2);
+ mGradTypeSlider = new Slider(0, 3);
mGradTypeSlider->setWidth(160);
mGradTypeSlider->setActionEventId("slider_grad");
mGradTypeSlider->setValue(0);
@@ -378,6 +378,7 @@ void Setup_Colors::updateGradType()
mGradTypeText->setCaption(
(grad == Palette::STATIC) ? _("Static") :
+ (grad == Palette::PULSE) ? _("Pulse") :
(grad == Palette::RAINBOW) ? _("Rainbow") : _("Spectrum"));
bool enable = (grad == Palette::STATIC);