summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMajin Sniper <majinsniper@gmx.de>2009-03-12 22:42:42 +0100
committerIra Rice <irarice@gmail.com>2009-03-12 21:53:00 -0600
commitf0d5e3da15a308fcc962590330e7d8e39e8874b9 (patch)
treea0e7f61b1f6a2f2aee20549c9ac55a123ba3ccba
parent5207b4cbb462cfa962a6f566897a6affd92eef94 (diff)
downloadmana-f0d5e3da15a308fcc962590330e7d8e39e8874b9.tar.gz
mana-f0d5e3da15a308fcc962590330e7d8e39e8874b9.tar.bz2
mana-f0d5e3da15a308fcc962590330e7d8e39e8874b9.tar.xz
mana-f0d5e3da15a308fcc962590330e7d8e39e8874b9.zip
Make use of the new available colors
This patch lets all being derivatives use the palette to set their name's colors. Text Particle Effects all respect the new settings. Some widgets were updated to use the colors.
-rw-r--r--src/being.cpp41
-rw-r--r--src/being.h2
-rw-r--r--src/gui/listbox.cpp2
-rw-r--r--src/gui/shoplistbox.cpp2
-rw-r--r--src/gui/speechbubble.cpp5
-rw-r--r--src/gui/speechbubble.h4
-rw-r--r--src/gui/textbox.cpp5
-rw-r--r--src/gui/textbox.h15
-rw-r--r--src/gui/widgets/dropdown.cpp16
-rw-r--r--src/localplayer.cpp19
-rw-r--r--src/monster.cpp7
-rw-r--r--src/npc.cpp6
-rw-r--r--src/particle.cpp17
-rw-r--r--src/particle.h14
-rw-r--r--src/player.cpp13
-rw-r--r--src/text.cpp10
-rw-r--r--src/text.h8
-rw-r--r--src/textparticle.cpp11
-rw-r--r--src/textparticle.h7
19 files changed, 105 insertions, 99 deletions
diff --git a/src/being.cpp b/src/being.cpp
index 64972912..3a772fbd 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -47,6 +47,7 @@
#include "resources/resourcemanager.h"
#include "gui/gui.h"
+#include "gui/palette.h"
#include "gui/speechbubble.h"
#include "utils/dtor.h"
@@ -91,7 +92,7 @@ Being::Being(int id, int job, Map *map):
mSpeechBubble = new SpeechBubble();
mSpeech = "";
- mNameColor = 0x202020;
+ mNameColor = &guiPalette->getColor(Palette::CHAT);
mText = 0;
}
@@ -192,17 +193,14 @@ void Being::takeDamage(Being *attacker, int amount, AttackType type)
gcn::Font *font;
std::string damage = amount ? toString(amount) : type == FLEE ?
"dodge" : "miss";
-
- int red, green, blue;
+ const gcn::Color* color;
font = gui->getInfoParticleFont();
// Selecting the right color
if (type == CRITICAL || type == FLEE)
{
- red = 255;
- green = 128;
- blue = 0;
+ color = &guiPalette->getColor(Palette::HIT_CRITICAL);
}
else if (!amount)
{
@@ -210,39 +208,31 @@ void Being::takeDamage(Being *attacker, int amount, AttackType type)
{
// This is intended to be the wrong direction to visually
// differentiate between hits and misses
- red = 0;
- green = 100;
- blue = 255;
+ color = &guiPalette->getColor(Palette::HIT_MONSTER_PLAYER);
}
else
{
- red = 255;
- green = 255;
- blue = 0;
- }
- }
+ color = &guiPalette->getColor(Palette::MISS);
+ }
+ }
else if (getType() == MONSTER)
{
- red = 0;
- green = 100;
- blue = 255;
+ color = &guiPalette->getColor(Palette::HIT_PLAYER_MONSTER);
}
else
{
- red = 255;
- green = 50;
- blue = 50;
+ color = &guiPalette->getColor(Palette::HIT_MONSTER_PLAYER);
}
if (amount > 0 && type == CRITICAL)
{
- particleEngine->addTextSplashEffect("crit!", red, green, blue, font,
- mPx + 16, mPy + 16, true);
+ particleEngine->addTextSplashEffect("crit!", mPx + 16, mPy + 16,
+ color, font, true);
}
// Show damage number
- particleEngine->addTextSplashEffect(damage, red, green, blue, font,
- mPx + 16, mPy + 16, true);
+ particleEngine->addTextSplashEffect(damage, mPx + 16, mPy + 16,
+ color, font, true);
}
void Being::handleAttack(Being *victim, int damage, AttackType type)
@@ -503,7 +493,8 @@ void Being::drawSpeech(int offsetX, int offsetY)
delete mText;
mText = new Text(mSpeech, mPx + X_SPEECH_OFFSET, mPy - Y_SPEECH_OFFSET,
- gcn::Graphics::CENTER, gcn::Color(255, 255, 255));
+ gcn::Graphics::CENTER,
+ &guiPalette->getColor(Palette::PARTICLE));
}
else if (speech == NO_SPEECH)
{
diff --git a/src/being.h b/src/being.h
index 4b30b6c5..689eda02 100644
--- a/src/being.h
+++ b/src/being.h
@@ -428,7 +428,7 @@ class Being : public Sprite
Gender mGender;
int mPx, mPy; /**< Pixel coordinates */
- gcn::Color mNameColor;
+ const gcn::Color* mNameColor;
std::vector<AnimatedSprite*> mSprites;
std::vector<int> mSpriteIDs;
diff --git a/src/gui/listbox.cpp b/src/gui/listbox.cpp
index e53a1652..71e92eaf 100644
--- a/src/gui/listbox.cpp
+++ b/src/gui/listbox.cpp
@@ -57,7 +57,7 @@ void ListBox::draw(gcn::Graphics *graphics)
getWidth(), fontHeight));
// Draw the list elements
- graphics->setColor(gcn::Color(0, 0, 0, 255));
+ graphics->setColor(guiPalette->getColor(Palette::TEXT));
for (int i = 0, y = 0; i < mListModel->getNumberOfElements();
++i, y += fontHeight)
{
diff --git a/src/gui/shoplistbox.cpp b/src/gui/shoplistbox.cpp
index 74209122..5c55069f 100644
--- a/src/gui/shoplistbox.cpp
+++ b/src/gui/shoplistbox.cpp
@@ -79,7 +79,7 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics)
{
gcn::Color temp;
const gcn::Color* backgroundColor =
- &guiPalette->getColor(Palette::BACKGROUND, alpha);
+ &guiPalette->getColor(Palette::BACKGROUND, alpha);
if (mShopItems &&
mPlayerMoney < mShopItems->at(i)->getPrice() && mPriceCheck)
diff --git a/src/gui/speechbubble.cpp b/src/gui/speechbubble.cpp
index d342328e..cb1724c8 100644
--- a/src/gui/speechbubble.cpp
+++ b/src/gui/speechbubble.cpp
@@ -46,6 +46,7 @@ SpeechBubble::SpeechBubble():
mSpeechBox = new TextBox();
mSpeechBox->setEditable(false);
mSpeechBox->setOpaque(false);
+ mSpeechBox->setTextColor(&guiPalette->getColor(Palette::CHAT));
mSpeechArea = new ScrollArea(mSpeechBox);
@@ -61,11 +62,11 @@ SpeechBubble::SpeechBubble():
setLocationRelativeTo(getParent());
}
-void SpeechBubble::setCaption(const std::string &name, const gcn::Color &color)
+void SpeechBubble::setCaption(const std::string &name, const gcn::Color *color)
{
mCaption->setCaption(name);
mCaption->adjustSize();
- mCaption->setForegroundColor(color);
+ mCaption->setForegroundColor(*color);
}
void SpeechBubble::setText(std::string text, bool showName)
diff --git a/src/gui/speechbubble.h b/src/gui/speechbubble.h
index a1a597c1..d356dac1 100644
--- a/src/gui/speechbubble.h
+++ b/src/gui/speechbubble.h
@@ -23,6 +23,7 @@
#ifndef SPEECHBUBBLE_H
#define SPEECHBUBBLE_H
+#include "palette.h"
#include "popup.h"
class ScrollArea;
@@ -34,7 +35,8 @@ class SpeechBubble : public Popup
SpeechBubble();
void setCaption(const std::string &name,
- const gcn::Color &color = 0x000000);
+ const gcn::Color *color =
+ &guiPalette->getColor(Palette::TEXT));
void setText(std::string text, bool showName = true);
void setLocation(int x, int y);
unsigned int getNumRows();
diff --git a/src/gui/textbox.cpp b/src/gui/textbox.cpp
index 589986cd..51a8efc6 100644
--- a/src/gui/textbox.cpp
+++ b/src/gui/textbox.cpp
@@ -24,10 +24,11 @@
#include <guichan/font.hpp>
+#include "palette.h"
#include "textbox.h"
-TextBox::TextBox():
- gcn::TextBox()
+TextBox::TextBox() :
+ gcn::TextBox(), mTextColor(&guiPalette->getColor(Palette::TEXT))
{
setOpaque(false);
setFrameSize(0);
diff --git a/src/gui/textbox.h b/src/gui/textbox.h
index 33ea42f9..20f4ebe2 100644
--- a/src/gui/textbox.h
+++ b/src/gui/textbox.h
@@ -40,6 +40,11 @@ class TextBox : public gcn::TextBox
*/
TextBox();
+ inline void setTextColor(const gcn::Color* color)
+ {
+ mTextColor = color;
+ }
+
/**
* Sets the text after wrapping it to the current width of the widget.
*/
@@ -50,8 +55,18 @@ class TextBox : public gcn::TextBox
*/
int getMinWidth() { return mMinWidth; }
+ /**
+ * Draws the text.
+ */
+ inline void draw(gcn::Graphics *graphics)
+ {
+ setForegroundColor(*mTextColor);
+ gcn::TextBox::draw(graphics);
+ }
+
private:
int mMinWidth;
+ const gcn::Color* mTextColor;
};
#endif
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
index 076a167f..0015beed 100644
--- a/src/gui/widgets/dropdown.cpp
+++ b/src/gui/widgets/dropdown.cpp
@@ -140,24 +140,20 @@ void DropDown::draw(gcn::Graphics* graphics)
}
}
-// bool valid;
const int alpha = (int)(mAlpha * 255.0f);
gcn::Color faceColor = getBaseColor();
faceColor.a = alpha;
- gcn::Color highlightColor = guiPalette->getColor(Palette::HIGHLIGHT, alpha);
+ const gcn::Color* highlightColor = &guiPalette->getColor(Palette::HIGHLIGHT,
+ alpha);
gcn::Color shadowColor = faceColor - 0x303030;
shadowColor.a = alpha;
if (mOpaque)
{
- gcn::Color col = getBackgroundColor();
- col.a = alpha;
- graphics->setColor(col);
+ graphics->setColor(guiPalette->getColor(Palette::BACKGROUND, alpha));
graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), h));
- col = getForegroundColor();
- col.a = alpha;
- graphics->setColor(col);
+ graphics->setColor(guiPalette->getColor(Palette::TEXT, alpha));
}
graphics->setFont(getFont());
@@ -169,7 +165,7 @@ void DropDown::draw(gcn::Graphics* graphics)
if (isFocused())
{
- graphics->setColor(highlightColor);
+ graphics->setColor(*highlightColor);
graphics->drawRectangle(gcn::Rectangle(0, 0, getWidth() - h, h));
}
@@ -181,7 +177,7 @@ void DropDown::draw(gcn::Graphics* graphics)
// Draw two lines separating the ListBox with selected
// element view.
- graphics->setColor(highlightColor);
+ graphics->setColor(*highlightColor);
graphics->drawLine(0, h, getWidth(), h);
graphics->setColor(shadowColor);
graphics->drawLine(0, h + 1, getWidth(), h + 1);
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index d6acc48f..f72aa59a 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -37,6 +37,7 @@
#include "text.h"
#include "gui/gui.h"
+#include "gui/palette.h"
#include "gui/storagewindow.h"
#include "net/messageout.h"
@@ -201,7 +202,9 @@ void LocalPlayer::logic()
void LocalPlayer::setGM()
{
mIsGM = !mIsGM;
- mNameColor = mIsGM ? 0x009000: 0x202020;
+ mNameColor = mIsGM ?
+ &guiPalette->getColor(Palette::GM) :
+ &guiPalette->getColor(Palette::PLAYER);
setName(getName());
config.setValue(getName() + "GMassert", mIsGM);
}
@@ -608,10 +611,9 @@ void LocalPlayer::setXp(int xp)
const std::string text = toString(xp - mXp) + " xp";
// Show XP number
- particleEngine->addTextRiseFadeOutEffect(text,
- gui->getInfoParticleFont(),
- mPx + 16, mPy - 16,
- 255, 255, 0, true);
+ particleEngine->addTextRiseFadeOutEffect(text, mPx + 16, mPy - 16,
+ &guiPalette->getColor(Palette::EXP_INFO),
+ gui->getInfoParticleFont(), true);
}
mXp = xp;
}
@@ -621,10 +623,9 @@ void LocalPlayer::pickedUp(std::string item)
if (mMap)
{
// Show pickup notification
- particleEngine->addTextRiseFadeOutEffect(item,
- gui->getInfoParticleFont (),
- mPx + 16, mPy - 16,
- 40, 220, 40, true);
+ particleEngine->addTextRiseFadeOutEffect(item, mPx + 16, mPy - 16,
+ &guiPalette->getColor(Palette::PICKUP_INFO),
+ gui->getInfoParticleFont (), true);
}
}
diff --git a/src/monster.cpp b/src/monster.cpp
index 45d2fbeb..f71457df 100644
--- a/src/monster.cpp
+++ b/src/monster.cpp
@@ -28,6 +28,8 @@
#include "sound.h"
#include "text.h"
+#include "gui/palette.h"
+
#include "resources/monsterdb.h"
#include "resources/monsterinfo.h"
@@ -72,7 +74,7 @@ Monster::Monster(int id, Uint16 job, Map *map):
}
}
- mNameColor = 0xff2020;
+ mNameColor = &guiPalette->getColor(Palette::MONSTER);
}
Monster::~Monster()
@@ -196,7 +198,8 @@ void Monster::showName(bool show)
{
mText = new Text(getInfo().getName(), mPx + NAME_X_OFFSET,
mPy + NAME_Y_OFFSET - getHeight(),
- gcn::Graphics::CENTER, gcn::Color(255, 32, 32));
+ gcn::Graphics::CENTER,
+ &guiPalette->getColor(Palette::MONSTER));
}
else
{
diff --git a/src/npc.cpp b/src/npc.cpp
index c9250415..a6d60dbb 100644
--- a/src/npc.cpp
+++ b/src/npc.cpp
@@ -27,6 +27,7 @@
#include "text.h"
#include "gui/npc_text.h"
+#include "gui/palette.h"
#include "net/messageout.h"
#include "net/protocol.h"
@@ -72,7 +73,7 @@ NPC::NPC(int id, Uint16 job, Map *map, Network *network):
}
mName = 0;
- mNameColor = 0x21bbbb;
+ mNameColor = &guiPalette->getColor(Palette::NPC);
}
NPC::~NPC()
@@ -86,7 +87,8 @@ void NPC::setName(const std::string &name)
delete mName;
mName = new Text(displayName, mPx + NAME_X_OFFSET, mPy + NAME_Y_OFFSET,
- gcn::Graphics::CENTER, gcn::Color(200, 200, 255));
+ gcn::Graphics::CENTER,
+ &guiPalette->getColor(Palette::NPC));
Being::setName(displayName + " (NPC)");
}
diff --git a/src/particle.cpp b/src/particle.cpp
index 8bc764ba..e56435ed 100644
--- a/src/particle.cpp
+++ b/src/particle.cpp
@@ -325,12 +325,10 @@ Particle* Particle::addEffect(const std::string &particleEffectFile,
return newParticle;
}
-Particle *Particle::addTextSplashEffect(const std::string &text,
- int colorR, int colorG, int colorB,
- gcn::Font *font, int x, int y, bool outline)
+Particle *Particle::addTextSplashEffect(const std::string &text, int x, int y,
+ const gcn::Color *color, gcn::Font *font, bool outline)
{
- Particle *newParticle = new TextParticle(mMap, text, colorR, colorG, colorB,
- font, outline);
+ Particle *newParticle = new TextParticle(mMap, text, color, font, outline);
newParticle->moveTo(x, y);
newParticle->setVelocity(((rand() % 100) - 50) / 200.0f, // X
((rand() % 100) - 50) / 200.0f, // Y
@@ -346,13 +344,8 @@ Particle *Particle::addTextSplashEffect(const std::string &text,
}
Particle *Particle::addTextRiseFadeOutEffect(const std::string &text,
- gcn::Font *font,
- int x, int y,
- int colorR, int colorG,
- int colorB, bool outline)
-{
- Particle *newParticle = new TextParticle(mMap, text, colorR, colorG, colorB,
- font, outline);
+ int x, int y, const gcn::Color *color, gcn::Font *font, bool outline){
+ Particle *newParticle = new TextParticle(mMap, text, color, font, outline);
newParticle->moveTo(x, y);
newParticle->setVelocity(0.0f, 0.0f, 0.5f);
newParticle->setGravity(0.0015f);
diff --git a/src/particle.h b/src/particle.h
index f03f081d..76beb8d1 100644
--- a/src/particle.h
+++ b/src/particle.h
@@ -106,19 +106,17 @@ class Particle : public Sprite
/**
* Creates a standalone text particle.
*/
- Particle *addTextSplashEffect(const std::string &text,
- int colorR, int colorG, int colorB,
- gcn::Font *font, int x, int y,
- bool outline = false);
+ Particle *addTextSplashEffect(const std::string &text, int x, int y,
+ const gcn::Color *color, gcn::Font *font,
+ bool outline = false);
/**
* Creates a standalone text particle.
*/
Particle *addTextRiseFadeOutEffect(const std::string &text,
- gcn::Font *font,
- int x, int y, int colorR = 255,
- int colorG = 255, int colorB = 255,
- bool outline = false);
+ int x, int y, const gcn::Color *color, gcn::Font *font,
+ bool outline = false);
+
/**
* Adds an emitter to the particle.
*/
diff --git a/src/player.cpp b/src/player.cpp
index 61e91613..b289c3e5 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -22,10 +22,13 @@
#include "animatedsprite.h"
#include "game.h"
+#include "localplayer.h"
#include "particle.h"
#include "player.h"
#include "text.h"
+#include "gui/palette.h"
+
#include "resources/colordb.h"
#include "resources/itemdb.h"
@@ -51,17 +54,19 @@ void Player::setName(const std::string &name)
{
if (mIsGM)
{
- mNameColor = 0x009000;
+ mNameColor = &guiPalette->getColor(Palette::GM);
mName = new FlashText("(GM) " + name, mPx + NAME_X_OFFSET, mPy +
NAME_Y_OFFSET, gcn::Graphics::CENTER,
- gcn::Color(0, 255, 0));
+ &guiPalette->getColor(Palette::GM));
}
else
{
- mNameColor = 0x202020;
+ mNameColor = &guiPalette->getColor(Palette::PLAYER);
mName = new FlashText(name, mPx + NAME_X_OFFSET, mPy + NAME_Y_OFFSET,
gcn::Graphics::CENTER,
- gcn::Color(255, 255, 255));
+ (this == player_node) ?
+ &guiPalette->getColor(Palette::SELF) :
+ &guiPalette->getColor(Palette::PC));
}
Being::setName(name);
}
diff --git a/src/text.cpp b/src/text.cpp
index 2d96152b..420eeb8b 100644
--- a/src/text.cpp
+++ b/src/text.cpp
@@ -32,8 +32,9 @@
int Text::mInstances = 0;
Text::Text(const std::string &text, int x, int y,
- gcn::Graphics::Alignment alignment, gcn::Color color) :
- mText(text), mColor(color)
+ gcn::Graphics::Alignment alignment, const gcn::Color* color) :
+ mText(text),
+ mColor(color)
{
if (textManager == 0)
{
@@ -80,11 +81,12 @@ void Text::draw(gcn::Graphics *graphics, int xOff, int yOff)
TextRenderer::renderText(graphics, mText,
mX - xOff, mY - yOff, gcn::Graphics::LEFT,
- &mColor, boldFont, true, true);
+ mColor, boldFont, true);
}
FlashText::FlashText(const std::string &text, int x, int y,
- gcn::Graphics::Alignment alignment, gcn::Color color) :
+ gcn::Graphics::Alignment alignment,
+ const gcn::Color *color) :
Text(text, x, y, alignment, color),
mTime(0)
{
diff --git a/src/text.h b/src/text.h
index 0b53dd48..cf0aac48 100644
--- a/src/text.h
+++ b/src/text.h
@@ -39,7 +39,8 @@ class Text
* Constructor creates a text object to display on the screen.
*/
Text(const std::string &text, int x, int y,
- gcn::Graphics::Alignment alignment, gcn::Color color);
+ gcn::Graphics::Alignment alignment,
+ const gcn::Color *color);
/**
* Destructor. The text is removed from the screen.
@@ -64,14 +65,15 @@ class Text
int mXOffset; /**< The offset of mX from the desired x. */
static int mInstances; /**< Instances of text. */
std::string mText; /**< The text to display. */
- gcn::Color mColor; /**< The color of the text. */
+ const gcn::Color *mColor; /**< The color of the text. */
};
class FlashText : public Text
{
public:
FlashText(const std::string &text, int x, int y,
- gcn::Graphics::Alignment alignment, gcn::Color color);
+ gcn::Graphics::Alignment alignment,
+ const gcn::Color* color);
/**
* Remove the text from the screen
diff --git a/src/textparticle.cpp b/src/textparticle.cpp
index a065eadd..865c6764 100644
--- a/src/textparticle.cpp
+++ b/src/textparticle.cpp
@@ -22,21 +22,17 @@
#include <guichan/color.hpp>
-#include <SDL/SDL_ttf.h>
-
#include "textparticle.h"
#include "gui/textrenderer.h"
TextParticle::TextParticle(Map *map, const std::string &text,
- int colorR, int colorG, int colorB,
+ const gcn::Color* color,
gcn::Font *font, bool outline):
Particle(map),
mText(text),
mTextFont(font),
- mColorR(colorR),
- mColorG(colorG),
- mColorB(colorB),
+ mColor(color),
mOutline(outline)
{
}
@@ -65,6 +61,5 @@ void TextParticle::draw(Graphics *graphics, int offsetX, int offsetY) const
TextRenderer::renderText(graphics, mText,
screenX, screenY, gcn::Graphics::CENTER,
- &gcn::Color(mColorR, mColorG, mColorB), mTextFont, mOutline, false,
- (int) alpha);
+ mColor, mTextFont, mOutline, false, (int) alpha);
}
diff --git a/src/textparticle.h b/src/textparticle.h
index 26b92a50..1a49b5ef 100644
--- a/src/textparticle.h
+++ b/src/textparticle.h
@@ -33,7 +33,7 @@ class TextParticle : public Particle
* Constructor.
*/
TextParticle(Map *map, const std::string &text,
- int colorR, int colorG, int colorB,
+ const gcn::Color* color,
gcn::Font *font, bool outline = false);
/**
@@ -48,9 +48,8 @@ class TextParticle : public Particle
private:
std::string mText; /**< Text of the particle. */
gcn::Font *mTextFont; /**< Font used for drawing the text. */
- int mColorR, mColorG, mColorB; /**< Color used for drawing the text. */
- bool mOutline; /**< Make the text readable - draw it the way
- a Text is usually drawn: with outline */
+ const gcn::Color* mColor; /**< Color used for drawing the text. */
+ bool mOutline; /**< Make the text better readable */
};
#endif