summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-08-26 16:57:05 +0300
committerAndrei Karas <akaras@inbox.ru>2011-08-27 05:37:27 +0300
commit12bf548533867a2eb3a1c354b778ef7f9157322a (patch)
tree3cb6f61396f00a5d3fa280ecd9d99f309f06f4ca /src/gui
parent2e7bfc350d38e16b3d340f8e4ea69e6ff6748f5c (diff)
downloadManaVerse-12bf548533867a2eb3a1c354b778ef7f9157322a.tar.gz
ManaVerse-12bf548533867a2eb3a1c354b778ef7f9157322a.tar.bz2
ManaVerse-12bf548533867a2eb3a1c354b778ef7f9157322a.tar.xz
ManaVerse-12bf548533867a2eb3a1c354b778ef7f9157322a.zip
Basic support for guild bot integration.
Not working context menu actions, chat commands, auto complete.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/chatwindow.cpp6
-rw-r--r--src/gui/popupmenu.cpp77
-rw-r--r--src/gui/setup_other.cpp6
-rw-r--r--src/gui/socialwindow.cpp111
-rw-r--r--src/gui/widgets/guildtab.cpp127
-rw-r--r--src/gui/widgets/guildtab.h52
6 files changed, 354 insertions, 25 deletions
diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp
index 8896ca028..9c75320a6 100644
--- a/src/gui/chatwindow.cpp
+++ b/src/gui/chatwindow.cpp
@@ -1459,12 +1459,8 @@ void ChatWindow::saveState()
std::string ChatWindow::doReplace(const std::string &msg)
{
- if (Client::getServerName() == "server.themanaworld.org"
- || Client::getServerName() == "themanaworld.org"
- || Client::getServerName() == "81.161.192.4")
- {
+ if (Client::isTmw())
return msg;
- }
std::string str = msg;
replaceSpecialChars(str);
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index 61769bc7e..a3041fcf7 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -27,6 +27,7 @@
#include "being.h"
#include "dropshortcut.h"
#include "guild.h"
+#include "guildmanager.h"
#include "flooritem.h"
#include "graphics.h"
#include "item.h"
@@ -224,14 +225,22 @@ void PopupMenu::showPopup(int x, int y, Being *being)
{
mBrowserBox->addRow(strprintf(
"@@guild-kick|%s@@", _("Kick from guild")));
- mBrowserBox->addRow(strprintf("@@guild-pos|%s >@@",
- _("Change pos in guild")));
+ if (guild2->getServerGuild())
+ {
+ mBrowserBox->addRow(strprintf(
+ "@@guild-pos|%s >@@",
+ _("Change pos in guild")));
+ }
}
}
else
{
- mBrowserBox->addRow(strprintf(
- "@@guild|%s@@", _("Invite to guild")));
+ if (guild2->getServerGuild()
+ || (guildManager && guildManager->havePower()))
+ {
+ mBrowserBox->addRow(strprintf(
+ "@@guild|%s@@", _("Invite to guild")));
+ }
}
}
@@ -435,15 +444,26 @@ void PopupMenu::showPlayerPopup(int x, int y, std::string nick)
{
if (guild2->getMember(mNick))
{
- mBrowserBox->addRow(strprintf(
- "@@guild-kick|%s@@", _("Kick from guild")));
- mBrowserBox->addRow(strprintf(
- "@@guild-pos|%s >@@", _("Change pos in guild")));
+ if (guild2->getServerGuild() || (guildManager
+ && guildManager->havePower()))
+ {
+ mBrowserBox->addRow(strprintf(
+ "@@guild-kick|%s@@", _("Kick from guild")));
+ }
+ if (guild2->getServerGuild())
+ {
+ mBrowserBox->addRow(strprintf(
+ "@@guild-pos|%s >@@", _("Change pos in guild")));
+ }
}
else
{
- mBrowserBox->addRow(strprintf(
- "@@guild|%s@@", _("Invite to guild")));
+ if (guild2->getServerGuild() || (guildManager
+ && guildManager->havePower()))
+ {
+ mBrowserBox->addRow(strprintf(
+ "@@guild|%s@@", _("Invite to guild")));
+ }
}
}
@@ -725,16 +745,27 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab)
{
if (guild1->getId() == guild2->getId())
{
- mBrowserBox->addRow(strprintf(
- "@@guild-kick|%s@@", _("Kick from guild")));
- mBrowserBox->addRow(strprintf(
- "@@guild-pos|%s >@@", _("Change pos in guild")));
+ if (guild2->getServerGuild() || (guildManager
+ && guildManager->havePower()))
+ {
+ mBrowserBox->addRow(strprintf(
+ "@@guild-kick|%s@@", _("Kick from guild")));
+ }
+ if (guild2->getServerGuild())
+ {
+ mBrowserBox->addRow(strprintf("@@guild-pos|%s >@@",
+ _("Change pos in guild")));
+ }
}
}
else
{
- mBrowserBox->addRow(strprintf(
- "@@guild|%s@@", _("Invite to guild")));
+ if (guild2->getServerGuild() || (guildManager
+ && guildManager->havePower()))
+ {
+ mBrowserBox->addRow(strprintf(
+ "@@guild|%s@@", _("Invite to guild")));
+ }
}
}
}
@@ -897,7 +928,12 @@ void PopupMenu::handleLink(const std::string &link,
{
const Guild *guild = player_node->getGuild();
if (guild)
- Net::getGuildHandler()->invite(guild->getId(), mNick);
+ {
+ if (guild->getServerGuild())
+ Net::getGuildHandler()->invite(guild->getId(), mNick);
+ else if (guildManager)
+ guildManager->invite(mNick);
+ }
}
}
else if (link == "nuke" && being)
@@ -1263,7 +1299,12 @@ void PopupMenu::handleLink(const std::string &link,
{
const Guild *guild = player_node->getGuild();
if (guild)
- Net::getGuildHandler()->kick(guild->getMember(mNick));
+ {
+ if (guild->getServerGuild())
+ Net::getGuildHandler()->kick(guild->getMember(mNick));
+ else if (guildManager)
+ guildManager->kick(mNick);
+ }
}
}
else if (link == "enable highlight" && mTab)
diff --git a/src/gui/setup_other.cpp b/src/gui/setup_other.cpp
index b405f5045..05ec9d672 100644
--- a/src/gui/setup_other.cpp
+++ b/src/gui/setup_other.cpp
@@ -145,6 +145,12 @@ Setup_Other::Setup_Other()
this, "logNpcInGuiEvent");
+ new SetupItemLabel(_("Bots support"), "", this);
+
+ new SetupItemCheckBox(_("Enable guild bot support and disable native "
+ "guild support"), "", "enableGuildBot", this,
+ "enableGuildBotEvent", false);
+
new SetupItemLabel(_("Other"), "", this);
new SetupItemCheckBox(_("Enable server side attack"), "",
diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp
index e3aa69b30..aa26fa051 100644
--- a/src/gui/socialwindow.cpp
+++ b/src/gui/socialwindow.cpp
@@ -206,6 +206,109 @@ private:
Guild *mGuild;
};
+class GuildTab2 : public SocialTab, public gcn::ActionListener
+{
+public:
+ GuildTab2(Guild *guild):
+ mGuild(guild)
+ {
+ setCaption(_("Guild"));
+
+ setTabColor(&Theme::getThemeColor(Theme::GUILD_SOCIAL_TAB));
+
+ mList = new AvatarListBox(guild);
+ mScroll = new ScrollArea(mList);
+
+ mScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_AUTO);
+ mScroll->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_ALWAYS);
+ }
+
+ ~GuildTab2()
+ {
+ delete mList;
+ mList = 0;
+ delete mScroll;
+ mScroll = 0;
+ }
+
+ void action(const gcn::ActionEvent &event)
+ {
+/*
+ if (event.getId() == "do invite")
+ {
+ std::string name = mInviteDialog->getText();
+ Net::getGuildHandler()->invite(mGuild->getId(), name);
+
+ if (localChatTab)
+ {
+ localChatTab->chatLog(strprintf(
+ _("Invited user %s to guild %s."),
+ name.c_str(), mGuild->getName().c_str()), BY_SERVER);
+ }
+ mInviteDialog = 0;
+ }
+ else if (event.getId() == "~do invite")
+ {
+ mInviteDialog = 0;
+ }
+ else if (event.getId() == "yes")
+ {
+ Net::getGuildHandler()->leave(mGuild->getId());
+ if (localChatTab)
+ {
+ localChatTab->chatLog(strprintf(_("Guild %s quit requested."),
+ mGuild->getName().c_str()), BY_SERVER);
+ }
+ mConfirmDialog = 0;
+ }
+ else if (event.getId() == "~yes")
+ {
+ mConfirmDialog = 0;
+ }
+*/
+ }
+
+ void updateList()
+ {
+ }
+
+ void updateAvatar(std::string name A_UNUSED)
+ {
+ }
+
+ void resetDamage(std::string name A_UNUSED)
+ {
+ }
+
+protected:
+ void invite()
+ {
+/*
+ mInviteDialog = new TextDialog(_("Member Invite to Guild"),
+ strprintf(_("Who would you like to invite to guild %s?"),
+ mGuild->getName().c_str()),
+ socialWindow);
+ mInviteDialog->setActionEventId("do invite");
+ mInviteDialog->addActionListener(this);
+*/
+ }
+
+ void leave()
+ {
+/*
+ mConfirmDialog = new ConfirmDialog(_("Leave Guild?"),
+ strprintf(_("Are you sure you want to leave guild %s?"),
+ mGuild->getName().c_str()),
+ socialWindow);
+
+ mConfirmDialog->addActionListener(this);
+*/
+ }
+
+private:
+ Guild *mGuild;
+};
+
class PartyTab : public SocialTab, public gcn::ActionListener
{
public:
@@ -1106,9 +1209,13 @@ bool SocialWindow::addTab(Guild *guild)
if (mGuilds.find(guild) != mGuilds.end())
return false;
- GuildTab *tab = new GuildTab(guild);
- mGuilds[guild] = tab;
+ SocialTab *tab = 0;
+ if (guild->getServerGuild())
+ tab = new GuildTab(guild);
+ else
+ tab = new GuildTab2(guild);
+ mGuilds[guild] = tab;
mTabs->addTab(tab, tab->mScroll);
updateButtons();
diff --git a/src/gui/widgets/guildtab.cpp b/src/gui/widgets/guildtab.cpp
new file mode 100644
index 000000000..d9f61cb43
--- /dev/null
+++ b/src/gui/widgets/guildtab.cpp
@@ -0,0 +1,127 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2008-2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "gui/widgets/guildtab.h"
+
+#include "chatlogger.h"
+#include "commandhandler.h"
+#include "guild.h"
+#include "guildmanager.h"
+#include "localplayer.h"
+
+#include "gui/theme.h"
+
+#include "resources/iteminfo.h"
+#include "resources/itemdb.h"
+
+#include "utils/dtor.h"
+#include "utils/gettext.h"
+#include "utils/stringutils.h"
+
+#include "debug.h"
+
+GuildTab::GuildTab() :
+ ChatTab(_("Guild"))
+{
+ setTabColor(&Theme::getThemeColor(Theme::GUILD_CHAT_TAB));
+}
+
+GuildTab::~GuildTab()
+{
+}
+
+bool GuildTab::handleCommand(const std::string &type, const std::string &args)
+{
+ if (type == "help")
+ {
+ if (args == "invite")
+ {
+ chatLog(_("Command: /invite <nick>"));
+ chatLog(_("This command invites <nick> to the guild you're in."));
+ chatLog(_("If the <nick> has spaces in it, enclose it in "
+ "double quotes (\")."));
+ }
+ else if (args == "leave")
+ {
+ chatLog(_("Command: /leave"));
+ chatLog(_("This command causes the player to leave the guild."));
+ }
+ else
+ return false;
+ }
+ else if (type == "invite" && guildManager)
+ {
+ guildManager->invite(args);
+ }
+ else if (type == "leave" && guildManager)
+ {
+ guildManager->leave();
+ }
+ else if (type == "kick" && guildManager)
+ {
+ guildManager->kick(args);
+ }
+ else if (type == "notice" && guildManager)
+ {
+ guildManager->notice(args);
+ }
+ else
+ {
+ return false;
+ }
+
+ return false;
+}
+
+void GuildTab::handleInput(const std::string &msg)
+{
+ if (!guildManager)
+ return;
+
+ if (chatWindow)
+ guildManager->chat(chatWindow->doReplace(msg));
+ else
+ guildManager->chat(msg);
+}
+
+void GuildTab::showHelp()
+{
+ chatLog(_("/help > Display this help."));
+ chatLog(_("/invite > Invite a player to your guild"));
+ chatLog(_("/leave > Leave the guild you are in"));
+ chatLog(_("/kick > Kick some one from the guild you are in"));
+}
+
+void GuildTab::getAutoCompleteList(std::vector<std::string> &names) const
+{
+ if (!guildManager)
+ return;
+
+ guildManager->getNames(names);
+ names.push_back("/notice ");
+}
+
+void GuildTab::saveToLogFile(std::string &msg)
+{
+ if (chatLogger)
+ chatLogger->log("#Guild", msg);
+}
diff --git a/src/gui/widgets/guildtab.h b/src/gui/widgets/guildtab.h
new file mode 100644
index 000000000..a7f0aa766
--- /dev/null
+++ b/src/gui/widgets/guildtab.h
@@ -0,0 +1,52 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GUI_GUILDTAB_H
+#define GUI_GUILDTAB_H
+
+#include "gui/widgets/chattab.h"
+
+/**
+ * A tab for a guild chat channel.
+ */
+class GuildTab : public ChatTab
+{
+ public:
+ GuildTab();
+
+ ~GuildTab();
+
+ bool handleCommand(const std::string &type, const std::string &args);
+
+ void showHelp();
+
+ void saveToLogFile(std::string &msg);
+
+ int getType() const { return ChatTab::TAB_GUILD; }
+
+ protected:
+ void handleInput(const std::string &msg);
+
+ void getAutoCompleteList(std::vector<std::string> &names) const;
+};
+
+#endif