summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-04-16 10:10:50 -0600
committerJared Adams <jaxad0127@gmail.com>2009-04-16 10:10:50 -0600
commit736795a624ae5f04b11fa284cb8a4b14579c1766 (patch)
tree6c7c70926959ff23831002a06ea82c17cadc3188 /src/gui
parente8dd52d8264cd0eec1f5d32c1f809a164e2d2f59 (diff)
downloadmana-client-736795a624ae5f04b11fa284cb8a4b14579c1766.tar.gz
mana-client-736795a624ae5f04b11fa284cb8a4b14579c1766.tar.bz2
mana-client-736795a624ae5f04b11fa284cb8a4b14579c1766.tar.xz
mana-client-736795a624ae5f04b11fa284cb8a4b14579c1766.zip
Rehash CommandHandler a bit, it's now fully merged
Tabs can now interract with CommandHandler and define their own commands in a seemless way. Most channel-related commands have been moved into ChannelTab, the close command is now in the WhisperTab, and eAthena's party tab now shows all standard commands.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/login.cpp2
-rw-r--r--src/gui/widgets/channeltab.cpp87
-rw-r--r--src/gui/widgets/channeltab.h4
-rw-r--r--src/gui/widgets/chattab.h19
-rw-r--r--src/gui/widgets/whispertab.cpp27
-rw-r--r--src/gui/widgets/whispertab.h4
6 files changed, 143 insertions, 0 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/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;