From bbf4d657e77fd39887b9941af1fe75a5ec27d988 Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Sun, 29 Mar 2009 20:35:19 -0600 Subject: Fix up eAthena party handling some more --- src/gui/widgets/avatar.cpp | 48 +++++++++++++++++++++++++++++++++------------ src/gui/widgets/avatar.h | 16 +++++++-------- src/gui/widgets/chattab.cpp | 27 +------------------------ src/gui/widgets/chattab.h | 5 +---- 4 files changed, 46 insertions(+), 50 deletions(-) (limited to 'src/gui/widgets') diff --git a/src/gui/widgets/avatar.cpp b/src/gui/widgets/avatar.cpp index a36c0302..2603e3ae 100644 --- a/src/gui/widgets/avatar.cpp +++ b/src/gui/widgets/avatar.cpp @@ -28,28 +28,52 @@ #include +namespace { + Image *avatarStatusOffline; + Image *avatarStatusOnline; + int avatarCount = 0; +} + Avatar::Avatar(const std::string &name): mName(name) { + setOpaque(false); setSize(110, 12); + + if (avatarCount == 0) + { + ResourceManager *resman = ResourceManager::getInstance(); + avatarStatusOffline = resman->getImage("graphics/gui/circle-gray.png"); + avatarStatusOnline = resman->getImage("graphics/gui/circle-green.png"); + } + avatarCount++; + avatarStatusOffline->incRef(); + avatarStatusOnline->incRef(); + + mStatus = new Icon(avatarStatusOffline); + mStatus->setSize(12, 12); + add(mStatus, 1, 0); + mLabel = new gcn::Label(name); mLabel->setSize(85, 12); - mLabel->setPosition(25, 0); - ResourceManager *resman = ResourceManager::getInstance(); - mStatusOffline = resman->getImage("graphics/gui/circle-gray.png"); - mStatusOnline = resman->getImage("graphics/gui/circle-green.png"); - mStatus = new Icon(mStatusOffline); - mStatus->setSize(25, 12); - mStatus->setPosition(0, 0); + add(mLabel, 14, 0); } -void Avatar::setOnline(bool online) +Avatar::~Avatar() { - mStatus->setImage(online ? mStatusOnline : mStatusOffline); + avatarCount--; + + avatarStatusOffline->decRef(); + avatarStatusOnline->decRef(); } -void Avatar::draw(gcn::Graphics *g) +void Avatar::setName(const std::string &name) +{ + mName = name; + mLabel->setCaption(name); +} + +void Avatar::setOnline(bool online) { - mLabel->draw(g); - mStatus->draw(g); + mStatus->setImage(online ? avatarStatusOnline : avatarStatusOffline); } diff --git a/src/gui/widgets/avatar.h b/src/gui/widgets/avatar.h index 16972104..026a3581 100644 --- a/src/gui/widgets/avatar.h +++ b/src/gui/widgets/avatar.h @@ -24,14 +24,14 @@ #include "guichanfwd.h" -#include +#include "gui/gccontainer.h" #include class Image; class Icon; -class Avatar : public gcn::Widget +class Avatar : public GCContainer { public: /** @@ -40,21 +40,21 @@ public: */ Avatar(const std::string &name); + ~Avatar(); + /** - * Set the avatar online status. + * Set the avatar's name. */ - void setOnline(bool online); + void setName(const std::string &name); /** - * Draws the avatar. + * Set the avatar's online status. */ - void draw(gcn::Graphics *g); + void setOnline(bool online); private: std::string mName; Icon *mStatus; - Image *mStatusOnline; - Image *mStatusOffline; gcn::Label *mLabel; }; diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index c4563cc9..4a63bbcd 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -150,12 +150,6 @@ void ChatTab::chatLog(std::string line, int own, bool ignoreRecord) // TODO: Use a predefined color lineColor = "##2"; // Equiv. to BrowserBox::GREEN break; -#ifdef EATHENA_SUPPORT - case BY_PARTY: - tmp.nick += CAT_NORMAL; - lineColor = "##P"; - break; -#endif case ACT_WHISPER: // Resend whisper through normal mechanism chatWindow->whisper(tmp.nick, tmp.text); @@ -215,7 +209,7 @@ void ChatTab::chatLog(std::string line, int own, bool ignoreRecord) chatWindow->mRecorder->record(line.substr(3)); } -void ChatTab::chatLog(std::string &nick, std::string &msg) +void ChatTab::chatLog(const std::string &nick, const std::string &msg) { chatLog(nick + CAT_NORMAL + msg, nick == player_node->getName() ? BY_PLAYER : BY_OTHER, false); @@ -227,25 +221,6 @@ void ChatTab::chatInput(std::string &msg) if (msg.empty()) return; -#ifdef EATHENA_SUPPORT - // Send party message - if (msg.at(0) == chatWindow->mPartyPrefix) - { - msg.erase(0, 1); - std::size_t length = msg.length() + 1; - - if (length == 0) - { - chatLog(_("Trying to send a blank party message."), BY_SERVER, true); - return; - } - MessageOut outMsg(CMSG_PARTY_MESSAGE); - outMsg.writeInt16(length + 4); - outMsg.writeString(msg, length); - return; - } -#endif - // Check for item link std::string::size_type start = msg.find('['); while (start != std::string::npos && msg[start+1] != '@') diff --git a/src/gui/widgets/chattab.h b/src/gui/widgets/chattab.h index 52449f6f..76b33011 100644 --- a/src/gui/widgets/chattab.h +++ b/src/gui/widgets/chattab.h @@ -34,9 +34,6 @@ class ScrollArea; enum { BY_GM, -#ifdef EATHENA_SUPPORT - BY_PARTY, -#endif BY_PLAYER, BY_OTHER, BY_SERVER, @@ -86,7 +83,7 @@ class ChatTab : public Tab * @param msg The message text which is to be sent. * */ - void chatLog(std::string &nick, std::string &msg); + void chatLog(const std::string &nick, const std::string &msg); /** * Determines whether the message is a command or message, then -- cgit v1.2.3-70-g09d2