diff options
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/channeltab.cpp | 34 | ||||
-rw-r--r-- | src/gui/widgets/channeltab.h | 2 | ||||
-rw-r--r-- | src/gui/widgets/chattab.cpp | 64 | ||||
-rw-r--r-- | src/gui/widgets/chattab.h | 21 | ||||
-rw-r--r-- | src/gui/widgets/whispertab.cpp | 34 | ||||
-rw-r--r-- | src/gui/widgets/whispertab.h | 4 |
6 files changed, 63 insertions, 96 deletions
diff --git a/src/gui/widgets/channeltab.cpp b/src/gui/widgets/channeltab.cpp index c17aec0a..375ead26 100644 --- a/src/gui/widgets/channeltab.cpp +++ b/src/gui/widgets/channeltab.cpp @@ -19,40 +19,18 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <guichan/widgets/label.hpp> - #include "channeltab.h" -#include "../browserbox.h" -#include "../chatinput.h" -#include "../itemlinkhandler.h" -#include "../recorder.h" -#include "../scrollarea.h" - -#include "../../beingmanager.h" -#include "../../commandhandler.h" -#include "../../channel.h" -#include "../../configuration.h" -#include "../../game.h" -#include "../../localplayer.h" +#include "channel.h" #ifdef TMWSERV_SUPPORT -#include "../../net/tmwserv/chatserver/chatserver.h" -#include "../../net/tmwserv/gameserver/player.h" +#include "net/tmwserv/chatserver/chatserver.h" +#include "net/tmwserv/gameserver/player.h" #else -#include "../../party.h" -#include "../../net/messageout.h" -#include "../../net/ea/protocol.h" +#include "net/messageout.h" +#include "net/ea/protocol.h" #endif -#include "../../resources/iteminfo.h" -#include "../../resources/itemdb.h" - -#include "../../utils/dtor.h" -#include "../../utils/gettext.h" -#include "../../utils/strprintf.h" -#include "../../utils/stringutils.h" - ChannelTab::ChannelTab(Channel *channel) : ChatTab(channel->getName()), mChannel(channel) { @@ -63,7 +41,7 @@ ChannelTab::~ChannelTab() { } -void ChannelTab::sendChat(const std::string &msg) { +void ChannelTab::handleInput(const std::string &msg) { #ifdef TMSERV_SUPPORT Net::ChatServer::chat(getId(), msg); #endif diff --git a/src/gui/widgets/channeltab.h b/src/gui/widgets/channeltab.h index 04a11e29..8c98189b 100644 --- a/src/gui/widgets/channeltab.h +++ b/src/gui/widgets/channeltab.h @@ -48,7 +48,7 @@ class ChannelTab : public ChatTab */ ~ChannelTab(); - void sendChat(const std::string &msg); + void handleInput(const std::string &msg); private: Channel *mChannel; diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index 0594761d..715aaf20 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -19,34 +19,31 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <guichan/widgets/label.hpp> - #include "chattab.h" -#include "layouthelper.h" -#include "../browserbox.h" -#include "../chatinput.h" -#include "../itemlinkhandler.h" -#include "../recorder.h" -#include "../scrollarea.h" +#include "commandhandler.h" +#include "configuration.h" +#include "localplayer.h" -#include "../../commandhandler.h" -#include "../../configuration.h" -#include "../../localplayer.h" +#include "gui/browserbox.h" +#include "gui/itemlinkhandler.h" +#include "gui/recorder.h" +#include "gui/scrollarea.h" #ifdef TMWSERV_SUPPORT -#include "../../net/tmwserv/chatserver/chatserver.h" -#include "../../net/tmwserv/gameserver/player.h" +#include "net/tmwserv/chatserver/chatserver.h" +#include "net/tmwserv/gameserver/player.h" #else -#include "../../net/messageout.h" -#include "../../net/ea/protocol.h" +#include "net/messageout.h" +#include "net/ea/protocol.h" #endif -#include "../../resources/iteminfo.h" -#include "../../resources/itemdb.h" +#include "resources/iteminfo.h" +#include "resources/itemdb.h" -#include "../../utils/strprintf.h" -#include "../../utils/stringutils.h" +#include "utils/gettext.h" +#include "utils/strprintf.h" +#include "utils/stringutils.h" ChatTab::ChatTab(const std::string &name) : Tab() { @@ -160,10 +157,9 @@ void ChatTab::chatLog(std::string line, int own, bool ignoreRecord) break; #endif case ACT_WHISPER: - tmp.nick = strprintf(_("%s whispers:"), tmp.nick.c_str()); - tmp.nick += " "; - lineColor = "##W"; - break; + // Resend whisper through normal mechanism + chatWindow->whisper(tmp.nick, tmp.text); + return; case ACT_IS: tmp.nick += CAT_IS; lineColor = "##I"; @@ -221,10 +217,11 @@ void ChatTab::chatLog(std::string line, int own, bool ignoreRecord) void ChatTab::chatLog(std::string &nick, std::string &msg) { - chatLog(nick + ": " + msg, nick == player_node->getName() ? BY_PLAYER : BY_OTHER, false); + chatLog(nick + CAT_NORMAL + msg, nick == player_node->getName() ? + BY_PLAYER : BY_OTHER, false); } -void ChatTab::chatSend(std::string &msg) +void ChatTab::chatInput(std::string &msg) { trim(msg); @@ -282,16 +279,11 @@ void ChatTab::chatSend(std::string &msg) start = msg.find('[', start + 1); } - // Prepare ordinary message if (msg[0] != '/') - { - sendChat(msg); - } + handleInput(msg); else - { handleCommand(std::string(msg, 1)); - } } void ChatTab::scroll(int amount) @@ -308,22 +300,22 @@ void ChatTab::clearText() mTextOutput->clearRows(); } -void ChatTab::sendChat(std::string &msg) { +void ChatTab::handleInput(const std::string &msg) { #ifdef TMWSERV_SUPPORT Net::GameServer::Player::say(msg); #else - msg = player_node->getName() + " : " + msg; + std::string mes = player_node->getName() + " : " + msg; MessageOut outMsg(chatWindow->mNetwork); outMsg.writeInt16(CMSG_CHAT_MESSAGE); // Added + 1 in order to let eAthena parse admin commands correctly - outMsg.writeInt16(msg.length() + 4 + 1); - outMsg.writeString(msg, msg.length() + 1); + outMsg.writeInt16(mes.length() + 4 + 1); + outMsg.writeString(mes, mes.length() + 1); return; #endif } -void ChatTab::handleCommand(const std::string msg) +void ChatTab::handleCommand(std::string msg) { commandHandler->handleCommand(msg); } diff --git a/src/gui/widgets/chattab.h b/src/gui/widgets/chattab.h index 3e64242c..52449f6f 100644 --- a/src/gui/widgets/chattab.h +++ b/src/gui/widgets/chattab.h @@ -22,11 +22,10 @@ #ifndef CHATTAB_H #define CHATTAB_H -#include <guichan/widgets/container.hpp> - -#include "tab.h" +#include "gui/widgets/tab.h" +#include "gui/chat.h" -#include "../chat.h" +#include <guichan/widgets/container.hpp> class BrowserBox; class Recorder; @@ -48,6 +47,13 @@ enum }; /** + * gets in between usernick and message text depending on + * message type + */ +#define CAT_NORMAL ": " +#define CAT_IS "" + +/** * A tab for the chat window. This is special to ease chat handling. */ class ChatTab : public Tab @@ -90,7 +96,7 @@ class ChatTab : public Tab * @param msg The message text which is to be sent. * */ - void chatSend(std::string &msg); + void chatInput(std::string &msg); /** * Scrolls the chat window @@ -105,10 +111,11 @@ class ChatTab : public Tab protected: friend class ChatWindow; + friend class WhisperWindow; - virtual void sendChat(std::string &msg); + virtual void handleInput(const std::string &msg); - virtual void handleCommand(const std::string msg); + virtual void handleCommand(std::string msg); ScrollArea *mScrollArea; BrowserBox *mTextOutput; diff --git a/src/gui/widgets/whispertab.cpp b/src/gui/widgets/whispertab.cpp index 1c63d1c9..0ae042df 100644 --- a/src/gui/widgets/whispertab.cpp +++ b/src/gui/widgets/whispertab.cpp @@ -19,38 +19,28 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <guichan/widgets/label.hpp> - #include "whispertab.h" -#include "../../beingmanager.h" -#include "../../commandhandler.h" -#include "../../channel.h" -#include "../../configuration.h" -#include "../../game.h" -#include "../../localplayer.h" +#include "localplayer.h" + +#include "gui/palette.h" #ifdef TMWSERV_SUPPORT -#include "../../net/tmwserv/chatserver/chatserver.h" -#include "../../net/tmwserv/gameserver/player.h" +#include "net/tmwserv/chatserver/chatserver.h" #else -#include "../../party.h" -#include "../../net/messageout.h" -#include "../../net/ea/protocol.h" +#include "party.h" +#include "net/messageout.h" +#include "net/ea/protocol.h" #endif -#include "../../resources/iteminfo.h" -#include "../../resources/itemdb.h" - -#include "../../utils/dtor.h" -#include "../../utils/gettext.h" -#include "../../utils/strprintf.h" -#include "../../utils/stringutils.h" +#include "utils/gettext.h" +#include "utils/strprintf.h" WhisperTab::WhisperTab(const std::string &nick) : ChatTab(nick), mNick(nick) { + setForegroundColor(guiPalette->getColor(Palette::WHISPER)); } WhisperTab::~WhisperTab() @@ -58,7 +48,7 @@ WhisperTab::~WhisperTab() chatWindow->removeWhisper(mNick); } -void WhisperTab::sendChat(const std::string &msg) { +void WhisperTab::handleInput(const std::string &msg) { if (msg.length() == 0) { chatLog(_("Cannot send empty chat!"), BY_SERVER, false); return; @@ -78,7 +68,7 @@ void WhisperTab::sendChat(const std::string &msg) { msg.c_str()), BY_PLAYER, false); } -void WhisperTab::handleCommand(const std::string msg) +void WhisperTab::handleCommand(std::string msg) { if (msg == "close") delete this; diff --git a/src/gui/widgets/whispertab.h b/src/gui/widgets/whispertab.h index 1d2f968d..739ae159 100644 --- a/src/gui/widgets/whispertab.h +++ b/src/gui/widgets/whispertab.h @@ -46,9 +46,9 @@ class WhisperTab : public ChatTab ~WhisperTab(); - void sendChat(const std::string &msg); + void handleInput(const std::string &msg); - void handleCommand(const std::string msg); + void handleCommand(std::string msg); private: std::string mNick; |