diff options
author | Lloyd Bryant <lloyd_bryant@netzero.net> | 2008-08-13 15:02:59 +0000 |
---|---|---|
committer | Lloyd Bryant <lloyd_bryant@netzero.net> | 2008-08-13 15:02:59 +0000 |
commit | 94024e2b57b31ee92bb81fc48ce236283330b60c (patch) | |
tree | a526015cfcdd33c3482b710dc4fa22bbec4e0090 /src | |
parent | c9175a4d140f4c852aa5195b72ad9bd1ae8d5cee (diff) | |
download | mana-94024e2b57b31ee92bb81fc48ce236283330b60c.tar.gz mana-94024e2b57b31ee92bb81fc48ce236283330b60c.tar.bz2 mana-94024e2b57b31ee92bb81fc48ce236283330b60c.tar.xz mana-94024e2b57b31ee92bb81fc48ce236283330b60c.zip |
Added support for different colored fonts for different being types
Diffstat (limited to 'src')
-rw-r--r-- | src/being.cpp | 1 | ||||
-rw-r--r-- | src/being.h | 4 | ||||
-rw-r--r-- | src/gui/gui.cpp | 47 | ||||
-rw-r--r-- | src/gui/gui.h | 8 | ||||
-rw-r--r-- | src/monster.cpp | 2 | ||||
-rw-r--r-- | src/net/beinghandler.cpp | 6 | ||||
-rw-r--r-- | src/npc.cpp | 2 | ||||
-rw-r--r-- | src/player.cpp | 13 |
8 files changed, 76 insertions, 7 deletions
diff --git a/src/being.cpp b/src/being.cpp index 14f7ce20..822bc647 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -82,6 +82,7 @@ Being::Being(int id, int job, Map *map): instances++; mSpeech = 0; + mIsGM = false; } Being::~Being() diff --git a/src/being.h b/src/being.h index 90bab9ac..7f68c8c3 100644 --- a/src/being.h +++ b/src/being.h @@ -233,6 +233,9 @@ class Being : public Sprite virtual void nextStep(); + virtual void + setGM() { mIsGM = true; } + /** * Performs being logic. */ @@ -382,6 +385,7 @@ class Being : public Sprite Map *mMap; /**< Map on which this being resides */ std::string mName; /**< Name of character */ SpriteIterator mSpriteIterator; + bool mIsGM; /** Engine-related infos about weapon. */ const ItemInfo* mEquippedWeapon; diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index e56afc76..edc25152 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -56,6 +56,13 @@ gcn::Font *hitYellowFont; // Font used to display speech and player names gcn::Font *speechFont; +// Font for displaying NPC names +gcn::Font *npcNameFont; +// Font for displaying mob names +gcn::Font *mobNameFont; +// Font for displaying GM names +gcn::Font *gmNameFont; + class GuiConfigListener : public ConfigListener { public: @@ -128,6 +135,46 @@ Gui::Gui(Graphics *graphics): logger->error("Unable to load rpgfont_wider.png!"); } + // Set npc name font + try { + npcNameFont = new gcn::ImageFont("graphics/gui/rpgfont_wider-blue.png", + " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" + "0123456789.,!?-+/():;%&`'*#=[]\"<>{}^~|_@$\\" + "áÁéÉíÍóÓúÚç륣¢¡¿àãõêñÑöüäÖÜÄßøèÈåÅ" + ); + } + catch (gcn::Exception e) + { + logger->error("Unable to load rpgfont_wider-blue.png!"); + } + + // Set monster name font + try { + mobNameFont = new gcn::ImageFont("graphics/gui/rpgfont_wider-orange.png", + " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" + "0123456789.,!?-+/():;%&`'*#=[]\"<>{}^~|_@$\\" + "áÁéÉíÍóÓúÚç륣¢¡¿àãõêñÑöüäÖÜÄßøèÈåÅ" + ); + } + catch (gcn::Exception e) + { + logger->error("Unable to load rpgfont_wider-orange.png!"); + } + + // Set GM name font + try { + gmNameFont = new gcn::ImageFont("graphics/gui/rpgfont_wider-green.png", + " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" + "0123456789.,!?-+/():;%&`'*#=[]\"<>{}^~|_@$\\" + "áÁéÉíÍóÓúÚç륣¢¡¿àãõêñÑöüäÖÜÄßøèÈåÅ" + ); + } + catch (gcn::Exception e) + { + logger->error("Unable to load rpgfont_wider-green.png!"); + } + + gcn::Widget::setGlobalFont(mGuiFont); // Load hits' colourful fonts diff --git a/src/gui/gui.h b/src/gui/gui.h index d2a832c7..f250a8e3 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -119,4 +119,12 @@ extern gcn::Font *hitYellowFont; */ extern gcn::Font *speechFont; +/** + * being name fonts + */ +extern gcn::Font *npcNameFont; +extern gcn::Font *mobNameFont; +extern gcn::Font *gmNameFont; + + #endif diff --git a/src/monster.cpp b/src/monster.cpp index 1a7f6c4e..5d62a9cc 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -168,7 +168,7 @@ void Monster::showName(bool show) mText = new Text(getInfo().getName(), mPx + NAME_X_OFFSET, mPy + NAME_Y_OFFSET - getHeight(), gcn::Graphics::CENTER, - speechFont, gcn::Color(255, 32, 32)); + mobNameFont, gcn::Color(255, 32, 32)); } else { diff --git a/src/net/beinghandler.cpp b/src/net/beinghandler.cpp index a8591fce..34c65d1c 100644 --- a/src/net/beinghandler.cpp +++ b/src/net/beinghandler.cpp @@ -71,6 +71,7 @@ void BeingHandler::handleMessage(MessageIn *msg) Uint16 headTop, headMid, headBottom; Uint16 shoes, gloves, cape, misc1, misc2; Uint16 weapon, shield; + Uint16 gmstatus; Sint16 param1; Sint8 type; Being *srcBeing, *dstBeing; @@ -443,8 +444,9 @@ void BeingHandler::handleMessage(MessageIn *msg) dstBeing->setDirection(dir); } - msg->readInt8(); // unknown - msg->readInt8(); // unknown + gmstatus = msg->readInt16(); + if (gmstatus & 0x01) + dstBeing->setGM(); if (msg->getId() == SMSG_PLAYER_UPDATE_1) { diff --git a/src/npc.cpp b/src/npc.cpp index ec7088ab..1615ecd6 100644 --- a/src/npc.cpp +++ b/src/npc.cpp @@ -84,7 +84,7 @@ void NPC::setName(const std::string &name) delete mName; } mName = new Text(name, mPx + NAME_X_OFFSET, mPy + NAME_Y_OFFSET, - gcn::Graphics::CENTER, speechFont, + gcn::Graphics::CENTER, npcNameFont, gcn::Color(200, 200, 255)); } diff --git a/src/player.cpp b/src/player.cpp index 5db009ba..0740c7db 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -43,6 +43,7 @@ Player::Player(int id, int job, Map *map): Being(id, job, map) { mName = 0; + mIsGM = false; } Player::~Player() @@ -57,9 +58,15 @@ void Player::setName(const std::string &name) { if (mName == 0) { - mName = new FlashText(name, mPx + NAME_X_OFFSET, mPy + NAME_Y_OFFSET, - gcn::Graphics::CENTER, - speechFont, gcn::Color(255, 255, 255)); + if (mIsGM) { + mName = new FlashText("(GM) " + name, mPx + NAME_X_OFFSET, mPy + NAME_Y_OFFSET, + gcn::Graphics::CENTER, + gmNameFont, gcn::Color(255, 255, 255)); + } else { + mName = new FlashText(name, mPx + NAME_X_OFFSET, mPy + NAME_Y_OFFSET, + gcn::Graphics::CENTER, + speechFont, gcn::Color(255, 255, 255)); + } Being::setName(name); } } |