diff options
author | Philipp Sehmisch <crush@themanaworld.org> | 2009-04-16 18:55:35 +0200 |
---|---|---|
committer | Philipp Sehmisch <crush@themanaworld.org> | 2009-04-16 18:55:35 +0200 |
commit | 2fb36c5f27e2891bbd9968bdf9bbc7142ff28983 (patch) | |
tree | 56dc005cf1fa552f13be2668d8e4547bfaf68815 /src/gui | |
parent | 126c19c7acd63fcd039ab9449a5d96790ce3cfac (diff) | |
parent | 736795a624ae5f04b11fa284cb8a4b14579c1766 (diff) | |
download | mana-2fb36c5f27e2891bbd9968bdf9bbc7142ff28983.tar.gz mana-2fb36c5f27e2891bbd9968bdf9bbc7142ff28983.tar.bz2 mana-2fb36c5f27e2891bbd9968bdf9bbc7142ff28983.tar.xz mana-2fb36c5f27e2891bbd9968bdf9bbc7142ff28983.zip |
Merge branch 'master' of git@gitorious.org:tmw/mainline
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/login.cpp | 2 | ||||
-rw-r--r-- | src/gui/partywindow.cpp | 10 | ||||
-rw-r--r-- | src/gui/partywindow.h | 6 | ||||
-rw-r--r-- | src/gui/widgets/channeltab.cpp | 87 | ||||
-rw-r--r-- | src/gui/widgets/channeltab.h | 4 | ||||
-rw-r--r-- | src/gui/widgets/chattab.h | 19 | ||||
-rw-r--r-- | src/gui/widgets/whispertab.cpp | 27 | ||||
-rw-r--r-- | src/gui/widgets/whispertab.h | 4 |
8 files changed, 156 insertions, 3 deletions
diff --git a/src/gui/login.cpp b/src/gui/login.cpp index c1ffb658..021f8d4b 100644 --- a/src/gui/login.cpp +++ b/src/gui/login.cpp @@ -131,7 +131,9 @@ LoginDialog::LoginDialog(LoginData *loginData): LoginDialog::~LoginDialog() { +#ifdef EATHENA_SUPPORT delete mServerList; +#endif } void LoginDialog::action(const gcn::ActionEvent &event) diff --git a/src/gui/partywindow.cpp b/src/gui/partywindow.cpp index 9c2d3161..08698dab 100644 --- a/src/gui/partywindow.cpp +++ b/src/gui/partywindow.cpp @@ -54,6 +54,16 @@ void PartyWindow::draw(gcn::Graphics *graphics) Window::draw(graphics); } +PartyMember *PartyWindow::findMember(int id) +{ + PartyList::iterator it = mMembers.find(id); + + if (it == mMembers.end()) + return NULL; + else + return it->second; +} + PartyMember *PartyWindow::findMember2(int id) { PartyMember *member = findMember(id); diff --git a/src/gui/partywindow.h b/src/gui/partywindow.h index b1967b0e..60c4da29 100644 --- a/src/gui/partywindow.h +++ b/src/gui/partywindow.h @@ -72,12 +72,12 @@ class PartyWindow : public Window, gcn::ActionListener void draw(gcn::Graphics *graphics); /** - * Find a party member based on ID + * Find a party member based on ID. Returns NULL if not found. */ - PartyMember *findMember(int id) { return mMembers[id]; } + PartyMember *findMember(int id); /** - * Find a party member based on ID. Creates if it doesn't already exist. + * Find a party member based on ID. Creates if not found. */ PartyMember *findMember2(int id); diff --git a/src/gui/widgets/channeltab.cpp b/src/gui/widgets/channeltab.cpp index edc0473c..0bafc10f 100644 --- a/src/gui/widgets/channeltab.cpp +++ b/src/gui/widgets/channeltab.cpp @@ -26,6 +26,8 @@ #include "net/chathandler.h" #include "net/net.h" +#include "utils/gettext.h" + ChannelTab::ChannelTab(Channel *channel) : ChatTab(channel->getName()), mChannel(channel) { @@ -39,3 +41,88 @@ ChannelTab::~ChannelTab() void ChannelTab::handleInput(const std::string &msg) { Net::getChatHandler()->sendToChannel(getChannel()->getId(), msg); } + +void ChannelTab::showHelp() +{ + chatLog(_("/users > Lists the users in the current channel")); + chatLog(_("/topic > Set the topic of the current channel")); + chatLog(_("/quit > Leave a channel")); + chatLog(_("/op > Make a user a channel operator")); + chatLog(_("/kick > Kick a user from the channel")); +} + +bool ChannelTab::handleCommand(std::string type, std::string args) +{ + if (type == "help") + { + if (args == "users") + { + chatLog(_("Command: /users")); + chatLog(_("This command shows the users in this channel.")); + } + else if (args == "topic") + { + chatLog(_("Command: /topic <message>")); + chatLog(_("This command sets the topic to <message>.")); + } + else if (args == "quit") + { + chatLog(_("Command: /quit")); + chatLog(_("This command leaves the current channel.")); + chatLog(_("If you're the last person in the channel, it will be deleted.")); + } + else if (args == "op") + { + chatLog(_("Command: /op <nick>")); + chatLog(_("This command makes <nick> a channel operator.")); + chatLog(_("If the <nick> has spaces in it, enclose it in " + "double quotes (\").")); + chatLog(_("Channel operators can kick and op other users " + "from the channel.")); + } + else if (args == "kick") + { + chatLog(_("Command: /kick <nick>")); + chatLog(_("This command makes <nick> leave the channel.")); + chatLog(_("If the <nick> has spaces in it, enclose it in " + "double quotes (\").")); + } + else + return false; + } + else if (type == "users") + { + Net::getChatHandler()->userList(mChannel->getName()); + } + else if (type == "topic") + { + Net::getChatHandler()->setChannelTopic(mChannel->getId(), args); + } + else if (type == "topic") + { + Net::getChatHandler()->setChannelTopic(mChannel->getId(), args); + } + else if (type == "quit") + { + Net::getChatHandler()->quitChannel(mChannel->getId()); + } + else if (type == "op") + { + // set the user mode 'o' to op a user + if (args != "") + Net::getChatHandler()->setUserMode(mChannel->getId(), args, 'o'); + else + chatLog(_("Need a user to op!"), BY_CHANNEL); + } + else if (type == "kick") + { + if (args != "") + Net::getChatHandler()->kickUser(mChannel->getId(), args); + else + chatLog(_("Need a user to kick!"), BY_CHANNEL); + } + else + return false; + + return true; +} diff --git a/src/gui/widgets/channeltab.h b/src/gui/widgets/channeltab.h index 8c98189b..886ae28e 100644 --- a/src/gui/widgets/channeltab.h +++ b/src/gui/widgets/channeltab.h @@ -35,6 +35,10 @@ class ChannelTab : public ChatTab Channel *getChannel() { return mChannel; } + void showHelp(); + + bool handleCommand(std::string type, std::string args); + protected: friend class Channel; diff --git a/src/gui/widgets/chattab.h b/src/gui/widgets/chattab.h index 3d92e57f..ccb85d2a 100644 --- a/src/gui/widgets/chattab.h +++ b/src/gui/widgets/chattab.h @@ -95,8 +95,27 @@ class ChatTab : public Tab */ void scroll(int amount); + /** + * Clears the text from the tab + */ void clearText(); + /** + * Add any extra help text to the output. Allows tabs to define help + * for commands defined by the tab itself. + */ + virtual void showHelp() {} + + /** + * Handle special commands. Allows a tab to handle commands it + * defines itself. + * + * @returns true if the command was handled + * false if the command was not handled + */ + virtual bool handleCommand(std::string type, std::string args) + { return false; } + protected: friend class ChatWindow; friend class WhisperWindow; diff --git a/src/gui/widgets/whispertab.cpp b/src/gui/widgets/whispertab.cpp index d69a495c..975cac94 100644 --- a/src/gui/widgets/whispertab.cpp +++ b/src/gui/widgets/whispertab.cpp @@ -62,3 +62,30 @@ void WhisperTab::handleCommand(std::string msg) else ChatTab::handleCommand(msg); } + +void WhisperTab::showHelp() +{ + chatLog(_("/close > Close the whisper tab")); +} + +bool WhisperTab::handleCommand(std::string type, std::string args) +{ + if (type == "help") + { + if (args == "close") + { + chatLog(_("Command: /close")); + chatLog(_("This command closes the current whisper tab.")); + } + else + return false; + } + else if (type == "close") + { + delete this; + } + else + return false; + + return true; +} diff --git a/src/gui/widgets/whispertab.h b/src/gui/widgets/whispertab.h index 739ae159..0d39b6ec 100644 --- a/src/gui/widgets/whispertab.h +++ b/src/gui/widgets/whispertab.h @@ -34,6 +34,10 @@ class WhisperTab : public ChatTab public: const std::string &getNick() const { return mNick; } + void showHelp(); + + bool handleCommand(std::string type, std::string args); + protected: friend class ChatWindow; |