diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-08-27 17:17:53 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-08-27 17:28:44 +0300 |
commit | 06300c8a3064a4f58ff7df3bdc8b91c68c25ee77 (patch) | |
tree | df1dea567a635f4a7722408ec10badcbe5528bcc | |
parent | 6f475537cb5e12f7088a401c4fb5b583bbabc580 (diff) | |
download | manaverse-06300c8a3064a4f58ff7df3bdc8b91c68c25ee77.tar.gz manaverse-06300c8a3064a4f58ff7df3bdc8b91c68c25ee77.tar.bz2 manaverse-06300c8a3064a4f58ff7df3bdc8b91c68c25ee77.tar.xz manaverse-06300c8a3064a4f58ff7df3bdc8b91c68c25ee77.zip |
Remove unused commands.cpp and commandhandler.cpp.
-rw-r--r-- | src/CMakeLists.txt | 4 | ||||
-rw-r--r-- | src/Makefile.am | 4 | ||||
-rw-r--r-- | src/client.cpp | 1 | ||||
-rw-r--r-- | src/commandhandler.cpp | 123 | ||||
-rw-r--r-- | src/commandhandler.h | 101 | ||||
-rw-r--r-- | src/commands.cpp | 162 | ||||
-rw-r--r-- | src/commands.h | 55 | ||||
-rw-r--r-- | src/gui/popups/popupmenu.cpp | 6 | ||||
-rw-r--r-- | src/gui/widgets/tabs/chattab.cpp | 8 | ||||
-rw-r--r-- | src/gui/widgets/tabs/whispertab.cpp | 2 | ||||
-rw-r--r-- | src/gui/windowmanager.cpp | 3 | ||||
-rw-r--r-- | src/gui/windows/chatwindow.cpp | 2 | ||||
-rw-r--r-- | src/net/ea/gui/partytab.cpp | 1 |
13 files changed, 4 insertions, 468 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 025e243e4..cef0d364f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -797,10 +797,6 @@ SET(SRCS chatlogger.h client.cpp client.h - commandhandler.cpp - commandhandler.h - commands.cpp - commands.h configmanager.cpp configmanager.h being/compounditem.h diff --git a/src/Makefile.am b/src/Makefile.am index 20326d596..127809a50 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -915,10 +915,6 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ chatlogger.h \ client.cpp \ client.h \ - commandhandler.cpp \ - commandhandler.h \ - commands.cpp \ - commands.h \ configmanager.cpp \ configmanager.h \ being/compounditem.h \ diff --git a/src/client.cpp b/src/client.cpp index 5f9dc74d8..4689c8819 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -26,7 +26,6 @@ #include "auctionmanager.h" #include "chatlogger.h" -#include "commandhandler.h" #include "configmanager.h" #include "configuration.h" #include "dirs.h" diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp deleted file mode 100644 index fb46dd63c..000000000 --- a/src/commandhandler.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2008-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2014 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 "commandhandler.h" - -#include "commands.h" - -#include "input/inputmanager.h" - -#include "gui/widgets/tabs/chattab.h" - -#include "utils/gettext.h" -#include "utils/stringutils.h" - -#include "debug.h" - -CommandHandler *commandHandler = nullptr; - -CommandHandler::CommandHandler() : - mCommands() -{ -} - -void CommandHandler::addChatCommands(std::list<std::string> &arr) -{ -} - -void CommandHandler::handleCommands(const std::string &command, - ChatTab *const tab) const -{ - // here need add splitting commands - handleCommand(command, tab); -} - -void CommandHandler::handleCommand(const std::string &command, - ChatTab *const tab) const -{ - const size_t pos = command.find(' '); - const std::string type(command, 0, pos); - std::string args(command, pos == std::string::npos - ? command.size() : pos + 1); - - args = trim(args); - invokeCommand(type, args, tab, true); -} - -void CommandHandler::invokeCommand(const std::string &type, - const std::string &args, - ChatTab *const tab, - const bool warn) const -{ - const CommandsMapIter it = mCommands.find(type); - if (it != mCommands.end()) - { - callFunc(*(*it).second, args, tab); - } - else if (!tab->handleCommand(type, args)) - { - if (!inputManager.executeChatCommand(type, args, tab)) - { - if (warn) - { - // TRANSLATORS: chat commands handling message - tab->chatLog(_("Unknown command.")); - } - } - } -} - -void CommandHandler::callFunc(const CommandInfo &info, - const std::string &args, - ChatTab *const tab) -{ - const ActionFuncPtr func = info.func; - if (func) - { - InputEvent evt(args, tab, 0); - func(evt); - } - else - { - inputManager.executeAction(info.actionId); - } -} - -void CommandHandler::invokeCommand(const int type) -{ -} - -void CommandHandler::invokeCommand(const int type, - ChatTab *const tab) -{ -} - -void CommandHandler::invokeCommand(const int type, - const std::string &args) -{ -} - -void CommandHandler::invokeCommand(const int type, - const std::string &args, - ChatTab *const tab) -{ -} diff --git a/src/commandhandler.h b/src/commandhandler.h deleted file mode 100644 index 7bcb00fdc..000000000 --- a/src/commandhandler.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2008-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2014 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 COMMANDHANDLER_H -#define COMMANDHANDLER_H - -#include <list> -#include <map> -#include <string> - -#include "localconsts.h" - -class ChatTab; - -struct CommandInfo; - -extern ChatTab *localChatTab; - -typedef std::map<std::string, const CommandInfo*> CommandsMap; -typedef CommandsMap::const_iterator CommandsMapIter; - -/** - * A class to parse and handle user commands - */ -class CommandHandler final -{ - public: - /** - * Constructor - */ - CommandHandler(); - - A_DELETE_COPY(CommandHandler) - - /** - * Destructor - */ - ~CommandHandler() - { } - - static void addChatCommands(std::list<std::string> &arr); - - /** - * Parse and handle the given command. - */ - void handleCommand(const std::string &command, - ChatTab *const tab = localChatTab) const; - - void handleCommands(const std::string &command, - ChatTab *const tab = localChatTab) const; - - void invokeCommand(const std::string &type, - const std::string &args, - ChatTab *const tab, - const bool warn = false) const; - - static void invokeCommand(const int type); - - static void invokeCommand(const int type, - const std::string &args, - ChatTab *const tab); - - static void invokeCommand(const int type, - const std::string &args); - - static void invokeCommand(const int type, - ChatTab *const tab); - - protected: - friend class ChatTab; - friend class WhisperTab; - CommandsMap mCommands; - - private: - static void callFunc(const CommandInfo &info, - const std::string &args, - ChatTab *const tab); -}; - -extern CommandHandler *commandHandler; - -#endif // COMMANDHANDLER_H diff --git a/src/commands.cpp b/src/commands.cpp deleted file mode 100644 index 15f76351d..000000000 --- a/src/commands.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2008-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2014 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 "commands.h" - -#include "auctionmanager.h" -#include "actormanager.h" -#include "client.h" -#include "configuration.h" -#include "game.h" -#include "gamemodifiers.h" -#include "graphicsmanager.h" -#include "guildmanager.h" -#include "main.h" -#include "party.h" -#include "settings.h" - -#include "being/localplayer.h" -#include "being/playerrelations.h" - -#include "gui/chatconsts.h" -#include "gui/gui.h" - -#include "gui/windows/buydialog.h" -#include "gui/windows/chatwindow.h" -#include "gui/windows/helpwindow.h" -#include "gui/windows/okdialog.h" -#include "gui/windows/outfitwindow.h" -#include "gui/windows/shopwindow.h" -#include "gui/windows/socialwindow.h" -#include "gui/windows/tradewindow.h" - -#include "gui/widgets/tabs/whispertab.h" - -#if defined USE_OPENGL -#include "render/normalopenglgraphics.h" -#endif - -#if defined USE_OPENGL && defined DEBUG_SDLFONT -#include "render/nullopenglgraphics.h" -#endif - -#include "net/adminhandler.h" -#include "net/beinghandler.h" -#include "net/chathandler.h" -#include "net/download.h" -#include "net/gamehandler.h" -#include "net/guildhandler.h" -#include "net/ipc.h" -#include "net/net.h" -#include "net/uploadcharinfo.h" -#include "net/partyhandler.h" -#include "net/pethandler.h" -#include "net/tradehandler.h" - -#ifdef DEBUG_DUMP_LEAKS1 -#include "resources/image.h" -#include "resources/resource.h" -#include "resources/subimage.h" -#endif - -#include "resources/iteminfo.h" -#include "resources/resourcemanager.h" - -#include "resources/db/itemdb.h" - -#include "utils/chatutils.h" -#include "utils/delete2.h" -#include "utils/gettext.h" -#include "utils/process.h" -#include "utils/timer.h" - -#include "debug.h" - -#define impHandler(name) bool name(InputEvent &event) -#define impHandler0(name) bool name(InputEvent &event A_UNUSED) - -extern std::string tradePartnerName; -extern char **environ; - -namespace Commands -{ - -static int uploadUpdate(void *ptr, - DownloadStatus::Type status, - size_t total A_UNUSED, - size_t remaining A_UNUSED) -{ - if (status == DownloadStatus::Idle || status == DownloadStatus::Starting) - return 0; - - UploadChatInfo *const info = reinterpret_cast<UploadChatInfo*>(ptr); - if (status == DownloadStatus::Complete) - { - std::string str = Net::Download::getUploadResponse(); - const size_t sz = str.size(); - if (sz > 0) - { - if (str[sz - 1] == '\n') - str = str.substr(0, sz - 1); - str.append(info->addStr); - ChatTab *const tab = info->tab; - if (chatWindow && (!tab || chatWindow->isTabPresent(tab))) - { - str = strprintf("%s [@@%s |%s@@]", - info->text.c_str(), str.c_str(), str.c_str()); - outStringNormal(tab, str, str); - } - else - { - // TRANSLATORS: file uploaded message - new OkDialog(_("File uploaded"), str, - // TRANSLATORS: ok dialog button - _("OK"), - DialogType::OK, - true, false, nullptr, 260); - } - } - } - delete2(info->upload); - delete info; - return 0; -} - -static void uploadFile(const std::string &str, - const std::string &fileName, - const std::string &addStr, - ChatTab *const tab) -{ - UploadChatInfo *const info = new UploadChatInfo(); - Net::Download *const upload = new Net::Download(info, - "http://sprunge.us", - &uploadUpdate, - false, true, false); - info->upload = upload; - info->text = str; - info->addStr = addStr; - info->tab = tab; - upload->setFile(fileName); - upload->start(); -} - -} // namespace Commands diff --git a/src/commands.h b/src/commands.h deleted file mode 100644 index 6c6c481f0..000000000 --- a/src/commands.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2008-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2014 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 COMMANDS_H -#define COMMANDS_H - -#include "actions/actionfuncptr.h" - -#include "input/inputaction.h" - -#include <string> - -#include "localconsts.h" - -class ChatTab; - -extern ChatTab *localChatTab; - -#define decHandler(name) bool name(InputEvent &event) - -struct CommandInfo final -{ - const char *name; - ActionFuncPtr func; - int actionId; - bool useArgs; -}; - -enum -{ - END_COMMANDS = 0 -}; - -#undef decHandler - -#endif // COMMANDS_H diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp index 41135f962..b3569488e 100644 --- a/src/gui/popups/popupmenu.cpp +++ b/src/gui/popups/popupmenu.cpp @@ -23,8 +23,6 @@ #include "gui/popups/popupmenu.h" #include "actormanager.h" -#include "commands.h" -#include "commandhandler.h" #include "configuration.h" #include "dropshortcut.h" #include "game.h" @@ -1333,8 +1331,8 @@ void PopupMenu::handleLink(const std::string &link, } else if (link == "chat close" && mTab) { - if (commandHandler) - commandHandler->invokeCommand("close", "", mTab); + inputManager.executeChatCommand(InputAction::CLOSE_CHAT_TAB, + std::string(), mTab); } else if (link == "leave party" && mTab) { diff --git a/src/gui/widgets/tabs/chattab.cpp b/src/gui/widgets/tabs/chattab.cpp index 44ab6d89c..4b37e2ada 100644 --- a/src/gui/widgets/tabs/chattab.cpp +++ b/src/gui/widgets/tabs/chattab.cpp @@ -23,8 +23,6 @@ #include "gui/widgets/tabs/chattab.h" #include "chatlogger.h" -#include "commands.h" -#include "commandhandler.h" #include "configuration.h" #include "settings.h" #include "soundconsts.h" @@ -438,15 +436,13 @@ void ChatTab::handleInput(const std::string &msg) mChannelName); } -void ChatTab::handleCommand(const std::string &msg) +void ChatTab::handleCommand(const std::string &msg A_UNUSED) { - if (commandHandler) - commandHandler->handleCommands(msg, this); } void ChatTab::handleHelp(const std::string &msg) { - if (commandHandler) + if (helpWindow) helpWindow->search(msg); } diff --git a/src/gui/widgets/tabs/whispertab.cpp b/src/gui/widgets/tabs/whispertab.cpp index ad5ea6564..a67b9450c 100644 --- a/src/gui/widgets/tabs/whispertab.cpp +++ b/src/gui/widgets/tabs/whispertab.cpp @@ -23,8 +23,6 @@ #include "gui/widgets/tabs/whispertab.h" #include "chatlogger.h" -#include "commandhandler.h" -#include "commands.h" #include "being/localplayer.h" diff --git a/src/gui/windowmanager.cpp b/src/gui/windowmanager.cpp index de8f57a62..06bfc8673 100644 --- a/src/gui/windowmanager.cpp +++ b/src/gui/windowmanager.cpp @@ -23,7 +23,6 @@ #include "gui/windowmanager.h" #include "client.h" -#include "commandhandler.h" #include "configuration.h" #include "game.h" #include "settings.h" @@ -98,7 +97,6 @@ void WindowManager::createWindows() helpWindow = new HelpWindow; didYouKnowWindow = new DidYouKnowWindow; didYouKnowWindow->postInit(); - commandHandler = new CommandHandler; popupMenu = new PopupMenu; popupMenu->postInit(); beingPopup = new BeingPopup; @@ -118,7 +116,6 @@ void WindowManager::deleteWindows() delete2(itemPopup); delete2(spellPopup); delete2(popupMenu); - delete2(commandHandler); delete2(didYouKnowWindow); delete2(helpWindow); delete2(setupWindow); diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index 87e6c5b3c..d18f28a9e 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -23,7 +23,6 @@ #include "gui/windows/chatwindow.h" #include "actormanager.h" -#include "commandhandler.h" #include "configuration.h" #include "game.h" #include "guild.h" @@ -239,7 +238,6 @@ void ChatWindow::loadCommandsFile(const std::string &name) void ChatWindow::fillCommands() { loadCommandsFile("chatcommands.txt"); - CommandHandler::addChatCommands(mCommands); inputManager.addChatCommands(mCommands); } diff --git a/src/net/ea/gui/partytab.cpp b/src/net/ea/gui/partytab.cpp index 92c0b5ca2..5e6e1d3eb 100644 --- a/src/net/ea/gui/partytab.cpp +++ b/src/net/ea/gui/partytab.cpp @@ -23,7 +23,6 @@ #include "net/ea/gui/partytab.h" #include "chatlogger.h" -#include "commands.h" #include "configuration.h" #include "party.h" #include "soundconsts.h" |