diff options
author | Jared Adams <jaxad0127@gmail.com> | 2009-03-27 13:12:24 -0600 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2009-03-27 13:13:03 -0600 |
commit | 74f23fd3d0e1fb3be8e5419193d57d91746c887a (patch) | |
tree | 2715ae060ccd76f1b472dee3b9086e169d0e6926 /src/gui | |
parent | 795cec6e276e7f5df8a25bd8306e6fd87c826502 (diff) | |
download | mana-74f23fd3d0e1fb3be8e5419193d57d91746c887a.tar.gz mana-74f23fd3d0e1fb3be8e5419193d57d91746c887a.tar.bz2 mana-74f23fd3d0e1fb3be8e5419193d57d91746c887a.tar.xz mana-74f23fd3d0e1fb3be8e5419193d57d91746c887a.zip |
Clean up chat and chat tabs some more
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/chat.cpp | 12 | ||||
-rw-r--r-- | src/gui/chat.h | 17 | ||||
-rw-r--r-- | src/gui/guildwindow.cpp | 40 | ||||
-rw-r--r-- | src/gui/npcpostdialog.cpp | 18 | ||||
-rw-r--r-- | src/gui/partywindow.cpp | 11 | ||||
-rw-r--r-- | src/gui/skill.h | 5 | ||||
-rw-r--r-- | src/gui/trade.cpp | 2 | ||||
-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 |
13 files changed, 114 insertions, 150 deletions
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index b0b15dbc..48858bf6 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -27,6 +27,7 @@ #include "gui/scrollarea.h" #include "gui/sdlinput.h" +#include "gui/widgets/chattab.h" #include "gui/widgets/tabbedarea.h" #include "gui/widgets/whispertab.h" @@ -82,7 +83,7 @@ ChatWindow::ChatWindow(Network * network): // run the @assert command for the player again. Convenience for GMs. if (config.getValue(player_node->getName() + "GMassert", 0)) { std::string cmd = "@assert"; - chatSend(cmd); + chatInput(cmd); } #endif mRecorder = new Recorder(this); @@ -180,7 +181,7 @@ void ChatWindow::action(const gcn::ActionEvent &event) mCurHist = mHistory.end(); // Send the message to the server - chatSend(message); + chatInput(message); // Clear the text from the chat input mChatInput->setText(""); @@ -258,10 +259,10 @@ void ChatWindow::removeWhisper(std::string nick) mWhispers.erase(nick); } -void ChatWindow::chatSend(std::string &msg) +void ChatWindow::chatInput(std::string &msg) { ChatTab *tab = getFocused(); - tab->chatSend(msg); + tab->chatInput(msg); } void ChatWindow::doPresent() @@ -377,6 +378,7 @@ void ChatWindow::setRecordingFile(const std::string &msg) void ChatWindow::whisper(std::string nick, std::string mes, bool own) { if (mes.length() == 0) return; + std::string playerName = player_node->getName(); std::string tempNick = nick; @@ -395,7 +397,7 @@ void ChatWindow::whisper(std::string nick, std::string mes, bool own) } if (own) - tab->chatSend(mes); + tab->chatInput(mes); else tab->chatLog(nick, mes); } diff --git a/src/gui/chat.h b/src/gui/chat.h index 177aa38f..ac4e491e 100644 --- a/src/gui/chat.h +++ b/src/gui/chat.h @@ -22,6 +22,8 @@ #ifndef CHAT_H #define CHAT_H +#include "window.h" + #include <list> #include <string> #include <map> @@ -31,10 +33,6 @@ #include <guichan/widget.hpp> #include <guichan/widgetlistener.hpp> -#include "widgets/chattab.h" - -#include "window.h" - class BrowserBox; class Channel; class ChatTab; @@ -45,16 +43,9 @@ class ItemLinkHandler; #ifdef EATHENA_SUPPORT class Network; #endif +class Tab; class WhisperTab; -/** - * gets in between usernick and message text depending on - * message type - */ -#define CAT_NORMAL ": " -#define CAT_IS "" -#define CAT_WHISPER " whispers: " - #define DEFAULT_CHAT_WINDOW_SCROLL 7 // 1 means `1/8th of the window size'. /** One item in the chat log */ @@ -142,7 +133,7 @@ class ChatWindow : public Window, * @param msg The message text which is to be sent. * */ - void chatSend(std::string &msg); + void chatInput(std::string &msg); /** Called when key is pressed */ void keyPressed(gcn::KeyEvent &event); diff --git a/src/gui/guildwindow.cpp b/src/gui/guildwindow.cpp index c8a1872f..fb14235b 100644 --- a/src/gui/guildwindow.cpp +++ b/src/gui/guildwindow.cpp @@ -20,26 +20,26 @@ * $$ */ -#include "guildwindow.h" - -#include "button.h" -#include "chat.h" -#include "confirm_dialog.h" -#include "guildlistbox.h" -#include "scrollarea.h" -#include "textdialog.h" -#include "windowcontainer.h" - -#include "widgets/layout.h" -#include "widgets/tabbedarea.h" - -#include "../guild.h" -#include "../log.h" -#include "../localplayer.h" - -#include "../net/tmwserv/chatserver/guild.h" -#include "../utils/dtor.h" -#include "../utils/gettext.h" +#include "gui/guildwindow.h" + +#include "gui/button.h" +#include "gui/confirm_dialog.h" +#include "gui/guildlistbox.h" +#include "gui/scrollarea.h" +#include "gui/textdialog.h" +#include "gui/windowcontainer.h" + +#include "gui/widgets/chattab.h" +#include "gui/widgets/layout.h" +#include "gui/widgets/tabbedarea.h" + +#include "guild.h" +#include "log.h" +#include "localplayer.h" + +#include "net/tmwserv/chatserver/guild.h" +#include "utils/dtor.h" +#include "utils/gettext.h" #include <algorithm> diff --git a/src/gui/npcpostdialog.cpp b/src/gui/npcpostdialog.cpp index 278bc397..e0133473 100644 --- a/src/gui/npcpostdialog.cpp +++ b/src/gui/npcpostdialog.cpp @@ -19,15 +19,17 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "npcpostdialog.h" -#include "textbox.h" -#include "textfield.h" -#include "button.h" -#include "scrollarea.h" -#include "chat.h" +#include "gui/npcpostdialog.h" -#include "../net/tmwserv/gameserver/player.h" -#include "../utils/gettext.h" +#include "gui/textbox.h" +#include "gui/textfield.h" +#include "gui/button.h" +#include "gui/scrollarea.h" + +#include "gui/widgets/chattab.h" + +#include "net/tmwserv/gameserver/player.h" +#include "utils/gettext.h" #include <guichan/widgets/label.hpp> diff --git a/src/gui/partywindow.cpp b/src/gui/partywindow.cpp index 3f857b5c..1f87b26f 100644 --- a/src/gui/partywindow.cpp +++ b/src/gui/partywindow.cpp @@ -19,13 +19,14 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "partywindow.h" -#include "chat.h" +#include "gui/partywindow.h" -#include "widgets/avatar.h" +#include "gui/widgets/avatar.h" +#include "gui/widgets/chattab.h" -#include "../utils/gettext.h" -#include "../net/tmwserv/chatserver/party.h" +#include "net/tmwserv/chatserver/party.h" + +#include "utils/gettext.h" PartyWindow::PartyWindow() : Window(_("Party")) { diff --git a/src/gui/skill.h b/src/gui/skill.h index 0600d106..0d6336f3 100644 --- a/src/gui/skill.h +++ b/src/gui/skill.h @@ -22,18 +22,19 @@ #ifndef SKILL_H #define SKILL_H +#include "gui/window.h" + #include <vector> #include <guichan/actionlistener.hpp> -#include "window.h" - struct SKILL { short id; /**< Index into "skill_db" array */ short lv, sp; }; class GuiTable; +class ScrollArea; class SkillGuiTableModel; /** diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp index 8aa3c3ea..4ecdede8 100644 --- a/src/gui/trade.cpp +++ b/src/gui/trade.cpp @@ -24,7 +24,7 @@ #include <guichan/font.hpp> #include "button.h" -#include "chat.h" +#include "widgets/chattab.h" #include "inventorywindow.h" #include "item_amount.h" #include "itemcontainer.h" 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; |