diff options
-rw-r--r-- | src/being.cpp | 4 | ||||
-rw-r--r-- | src/being.h | 2 | ||||
-rw-r--r-- | src/gui/speechbubble.cpp | 52 | ||||
-rw-r--r-- | src/gui/speechbubble.h | 4 | ||||
-rw-r--r-- | src/localplayer.cpp | 1 | ||||
-rw-r--r-- | src/monster.cpp | 2 | ||||
-rw-r--r-- | src/npc.cpp | 2 | ||||
-rw-r--r-- | src/player.cpp | 9 |
8 files changed, 50 insertions, 26 deletions
diff --git a/src/being.cpp b/src/being.cpp index e30ccee4..3fc679da 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -109,6 +109,7 @@ Being::Being(int id, int job, Map *map): instances++; mSpeech = ""; + mNameColor = 0x202020; mText = 0; } @@ -510,8 +511,7 @@ void Being::drawSpeech(Graphics *graphics, int offsetX, int offsetY) mText = 0; } - if (mName != mSpeechBubble->getCaption()) - mSpeechBubble->setName(mName); + mSpeechBubble->setCaption(mName, mNameColor); // Not quite centered, but close enough. However, it's not too important to get // it right right now, as it doesn't take bubble collision into account yet. diff --git a/src/being.h b/src/being.h index 1e9954c5..c47864e8 100644 --- a/src/being.h +++ b/src/being.h @@ -416,6 +416,8 @@ class Being : public Sprite Uint16 mStunMode; /**< Stun mode; zero if not stunned */ StatusEffects mStatusEffects; /**< Bitset of active status effects */ + gcn::Color mNameColor; + std::vector<AnimatedSprite*> mSprites; std::vector<int> mSpriteIDs; std::vector<std::string> mSpriteColors; diff --git a/src/gui/speechbubble.cpp b/src/gui/speechbubble.cpp index eb3232ea..97e3fd73 100644 --- a/src/gui/speechbubble.cpp +++ b/src/gui/speechbubble.cpp @@ -22,6 +22,8 @@ #include <guichan/font.hpp> +#include <guichan/widgets/label.hpp> + #include "gui.h" #include "speechbubble.h" @@ -33,23 +35,30 @@ // TODO: Fix windows so that they can each load their own skins without the // other windows overriding another window's skin. SpeechBubble::SpeechBubble(): - Window(_(""), false, NULL, "graphics/gui/speechbubble.xml") + Window(_("Speech"), false, NULL, "graphics/gui/speechbubble.xml") { + // Height == Top Graphic (14px) + 1 Row of Text (15px) + Bottom Graphic (17px) + setContentSize(140, 46); + setShowTitle(false); + setTitleBarHeight(0); + + mCaption = new gcn::Label(""); + mCaption->setFont(boldFont); + mCaption->setPosition(5, 3); + mSpeechBox = new TextBox(); mSpeechBox->setEditable(false); mSpeechBox->setOpaque(false); mSpeechArea = new ScrollArea(mSpeechBox); - // Height == Top Graphic (14px) + 1 Row of Text (15px) + Bottom Graphic (17px) - setContentSize(140, 46); - setTitleBarHeight(5); - mSpeechArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mSpeechArea->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); - mSpeechArea->setDimension(gcn::Rectangle(4, 15, 130, 28)); + mSpeechArea->setDimension(gcn::Rectangle(4, boldFont->getHeight() + 3, + 130, 28)); mSpeechArea->setOpaque(false); + add(mCaption); add(mSpeechArea); setLocationRelativeTo(getParent()); @@ -60,38 +69,39 @@ SpeechBubble::SpeechBubble(): mSpeechBox->setTextWrapped( "" ); } -void SpeechBubble::setName(const std::string &name) +void SpeechBubble::setCaption(const std::string &name, const gcn::Color &color) { - setWindowName(name); - setCaption(name); + mCaption->setCaption(name); + mCaption->adjustSize(); + mCaption->setForegroundColor(color); } void SpeechBubble::setText(std::string mText) { mSpeechBox->setMinWidth(140); - mSpeechBox->setTextWrapped( mText ); + mSpeechBox->setTextWrapped(mText); const int fontHeight = getFont()->getHeight(); - int numRows = mSpeechBox->getNumberOfRows(); + const int numRows = mSpeechBox->getNumberOfRows() + 1; - if (numRows > 1) + if (numRows > 2) { // 15 == height of each line of text (based on font heights) // 14 == speechbubble Top + Bottom graphic pixel heights - setContentSize(mSpeechBox->getMinWidth() + fontHeight, fontHeight + - (numRows * fontHeight)); - mSpeechArea->setDimension(gcn::Rectangle(4, fontHeight, - mSpeechBox->getMinWidth() + 5, - 3 + (numRows * fontHeight))); + setContentSize(mSpeechBox->getMinWidth() + fontHeight, + (numRows * fontHeight) + 6); + mSpeechArea->setDimension(gcn::Rectangle(4, fontHeight + 3, + mSpeechBox->getMinWidth() + 5, + (numRows * fontHeight))); } else { - int width = boldFont->getWidth(this->getCaption()); + int width = mCaption->getWidth() + 8; if (width < getFont()->getWidth(mText)) width = getFont()->getWidth(mText); - setContentSize(width + fontHeight, fontHeight * 2); - mSpeechArea->setDimension(gcn::Rectangle(4, fontHeight, - width + 5, fontHeight + 2)); + setContentSize(width + fontHeight, (fontHeight * 2) + 6); + mSpeechArea->setDimension(gcn::Rectangle(4, fontHeight + 3, + width + 5, fontHeight)); } } diff --git a/src/gui/speechbubble.h b/src/gui/speechbubble.h index 6d8a94d4..23733813 100644 --- a/src/gui/speechbubble.h +++ b/src/gui/speechbubble.h @@ -33,12 +33,14 @@ class SpeechBubble : public Window SpeechBubble(); - void setName(const std::string &name); + void setCaption(const std::string &name, + const gcn::Color &color = 0x000000); void setText(std::string mText); void setLocation(int x, int y); unsigned int getNumRows(); private: + gcn::Label *mCaption; TextBox *mSpeechBox; ScrollArea *mSpeechArea; }; diff --git a/src/localplayer.cpp b/src/localplayer.cpp index db7a25f8..c6fde7a8 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -173,6 +173,7 @@ void LocalPlayer::logic() void LocalPlayer::setGM() { mIsGM = !mIsGM; + mNameColor = mIsGM ? 0x009000: 0x202020; setName(getName()); config.setValue(getName() + "GMassert", mIsGM); } diff --git a/src/monster.cpp b/src/monster.cpp index 814a5904..4f2c97e7 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -71,6 +71,8 @@ Monster::Monster(Uint32 id, Uint16 job, Map *map): controlParticle(particleEngine->addEffect((*i), 0, 0)); } } + + mNameColor = 0xff2020; } Monster::~Monster() diff --git a/src/npc.cpp b/src/npc.cpp index 27388880..cef98e45 100644 --- a/src/npc.cpp +++ b/src/npc.cpp @@ -67,6 +67,8 @@ NPC::NPC(Uint32 id, Uint16 job, Map *map, Network *network): } } mName = 0; + + mNameColor = 0x21bbbb; } NPC::~NPC() diff --git a/src/player.cpp b/src/player.cpp index d62018f2..ad5b568b 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -50,10 +50,15 @@ void Player::setName(const std::string &name) { if (mName == 0) { - if (mIsGM) { + if (mIsGM) + { + mNameColor = 0x009000; mName = new FlashText("(GM) " + name, mPx + NAME_X_OFFSET, mPy + NAME_Y_OFFSET, gcn::Graphics::CENTER, gcn::Color(0, 255, 0)); - } else { + } + else + { + mNameColor = 0x202020; mName = new FlashText(name, mPx + NAME_X_OFFSET, mPy + NAME_Y_OFFSET, gcn::Graphics::CENTER, gcn::Color(255, 255, 255)); } |