diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-08-30 03:26:00 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-08-30 03:26:00 +0300 |
commit | 84941829031cbd707ab28802c7423ce19bfba32e (patch) | |
tree | d1e066e36fa66e9d925cc101acb9fa3e38089113 | |
parent | 9f752d5431364c052b364045015d3574da2c320c (diff) | |
download | manaverse-84941829031cbd707ab28802c7423ce19bfba32e.tar.gz manaverse-84941829031cbd707ab28802c7423ce19bfba32e.tar.bz2 manaverse-84941829031cbd707ab28802c7423ce19bfba32e.tar.xz manaverse-84941829031cbd707ab28802c7423ce19bfba32e.zip |
Add auction bot support switch.
-rw-r--r-- | manaplus.cbp | 2 | ||||
-rw-r--r-- | src/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/auctionmanager.cpp | 89 | ||||
-rw-r--r-- | src/auctionmanager.h | 58 | ||||
-rw-r--r-- | src/client.cpp | 2 | ||||
-rw-r--r-- | src/commandhandler.cpp | 4 | ||||
-rw-r--r-- | src/game.cpp | 11 | ||||
-rw-r--r-- | src/gui/shopwindow.cpp | 18 |
9 files changed, 182 insertions, 6 deletions
diff --git a/manaplus.cbp b/manaplus.cbp index 992915467..1f7308935 100644 --- a/manaplus.cbp +++ b/manaplus.cbp @@ -109,6 +109,8 @@ <Unit filename="src\animatedsprite.h" />
<Unit filename="src\animationparticle.cpp" />
<Unit filename="src\animationparticle.h" />
+ <Unit filename="src\auctionmanager.cpp" />
+ <Unit filename="src\auctionmanager.h" />
<Unit filename="src\avatar.cpp" />
<Unit filename="src\avatar.h" />
<Unit filename="src\being.cpp" />
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 49b41f906..3b9b41371 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -468,6 +468,8 @@ SET(SRCS animatedsprite.h animationparticle.cpp animationparticle.h + auctionmanager.cpp + auctionmanager.h avatar.cpp avatar.h being.cpp diff --git a/src/Makefile.am b/src/Makefile.am index ca6dd6bc2..45d9df7f0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -475,6 +475,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ animatedsprite.h \ animationparticle.cpp \ animationparticle.h \ + auctionmanager.cpp \ + auctionmanager.h \ avatar.cpp \ avatar.h \ being.cpp \ diff --git a/src/auctionmanager.cpp b/src/auctionmanager.cpp new file mode 100644 index 000000000..b360279ba --- /dev/null +++ b/src/auctionmanager.cpp @@ -0,0 +1,89 @@ +/* + * The ManaPlus Client + * 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 "auctionmanager.h" + +#include "actorspritemanager.h" +#include "client.h" +#include "configuration.h" +#include "localplayer.h" + +#include "net/chathandler.h" +#include "net/net.h" + +#include "utils/gettext.h" +#include "utils/stringutils.h" + +#include "debug.h" + +bool AuctionManager::mEnableAuctionBot = false; + +AuctionManager::AuctionManager() +{ +} + +AuctionManager::~AuctionManager() +{ +} + +void AuctionManager::init() +{ + if (auctionManager) + return; + + int val = serverConfig.getValue("enableAuctionBot", -1); + if (val == -1) + { + if (Client::isTmw()) + val = 1; + else + val = 0; + serverConfig.setValue("enableAuctionBot", val); + } + mEnableAuctionBot = val; + if (mEnableAuctionBot) + auctionManager = new AuctionManager(); +} + +void AuctionManager::send(std::string msg) +{ + Net::getChatHandler()->privateMessage("AuctionBot", msg); +} + +bool AuctionManager::processAuctionMessage(std::string msg) +{ + if (msg.size() > 4 && msg[0] == '#' && msg[1] == '#') + msg = msg.substr(3); + + return false; +} + +void AuctionManager::clear() +{ +} + +void AuctionManager::reload() +{ +} + +void AuctionManager::sendMail(std::string mail) +{ + Net::getChatHandler()->privateMessage("AuctionBot", "!mail " + mail); +} diff --git a/src/auctionmanager.h b/src/auctionmanager.h new file mode 100644 index 000000000..bdc0497ae --- /dev/null +++ b/src/auctionmanager.h @@ -0,0 +1,58 @@ +/* + * The ManaPlus Client + * 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 AUCTIONMANAGER_H +#define AUCTIONMANAGER_H + +#include "utils/dtor.h" + +#include <map> +#include <string> +#include <vector> + +class AuctionManager +{ + public: + AuctionManager(); + + ~AuctionManager(); + + static void init(); + + void send(std::string msg); + + bool processAuctionMessage(std::string msg); + + static bool getEnableAuctionBot() + { return mEnableAuctionBot; } + + void clear(); + + void reload(); + + void sendMail(std::string mail); + + private: + static bool mEnableAuctionBot; +}; + +extern AuctionManager *auctionManager; + +#endif // AUCTIONMANAGER_H diff --git a/src/client.cpp b/src/client.cpp index 2e3652188..403dbd7b3 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -23,6 +23,7 @@ #include "client.h" #include "main.h" +#include "auctionmanager.h" #include "chatlogger.h" #include "configuration.h" #include "dropshortcut.h" @@ -795,6 +796,7 @@ int Client::exec() mumbleManager->setServer(mCurrentServer.hostname); GuildManager::init(); + AuctionManager::init(); if (!mConfigAutoSaved) { diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp index 559cfd37e..dc962a17d 100644 --- a/src/commandhandler.cpp +++ b/src/commandhandler.cpp @@ -22,6 +22,7 @@ #include "commandhandler.h" +#include "auctionmanager.h" #include "actorspritemanager.h" #include "channelmanager.h" #include "channel.h" @@ -865,7 +866,8 @@ void CommandHandler::handleHack(const std::string &args, ChatTab *tab A_UNUSED) void CommandHandler::handleMail(const std::string &args, ChatTab *tab A_UNUSED) { - Net::getChatHandler()->privateMessage("AuctionBot", "!mail " + args); + if (auctionManager && auctionManager->getEnableAuctionBot()) + auctionManager->sendMail(args); } void CommandHandler::handlePriceLoad(const std::string &args A_UNUSED, diff --git a/src/game.cpp b/src/game.cpp index 303c59edb..5a372a6bd 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -26,6 +26,7 @@ #include "actorspritemanager.h" #include "actorsprite.h" +#include "auctionmanager.h" #include "being.h" #include "channelmanager.h" #include "client.h" @@ -158,6 +159,7 @@ EffectManager *effectManager = NULL; SpellManager *spellManager = NULL; Viewport *viewport = NULL; /**< Viewport on the map. */ GuildManager *guildManager = NULL; +AuctionManager *auctionManager = NULL; ChatTab *localChatTab = NULL; ChatTab *debugChatTab = NULL; @@ -177,6 +179,7 @@ static void initEngines() commandHandler = new CommandHandler; channelManager = new ChannelManager; effectManager = new EffectManager; + AuctionManager::init(); GuildManager::init(); particleEngine = new Particle(NULL); @@ -298,6 +301,9 @@ static void destroyGuiWindows() if (whoIsOnline) whoIsOnline->setAllowUpdate(false); + if (auctionManager) + auctionManager->clear(); + if (guildManager) guildManager->clear(); @@ -334,6 +340,9 @@ static void destroyGuiWindows() Mana::Event::trigger(CHANNEL_GAME, Mana::Event(EVENT_GUIWINDOWSUNLOADED)); + if (auctionManager && AuctionManager::getEnableAuctionBot()) + auctionManager->reload(); + if (guildManager && GuildManager::getEnableGuildBot()) guildManager->reload(); } @@ -423,7 +432,6 @@ Game::~Game() del_0(actorSpriteManager) if (Client::getState() != STATE_CHANGE_MAP) del_0(player_node) - del_0(guildManager) del_0(channelManager) del_0(commandHandler) del_0(effectManager) @@ -433,6 +441,7 @@ Game::~Game() del_0(mCurrentMap) del_0(spellManager) del_0(spellShortcut) + del_0(auctionManager) del_0(guildManager) del_0(mumbleManager) diff --git a/src/gui/shopwindow.cpp b/src/gui/shopwindow.cpp index 0988ef759..38985a01c 100644 --- a/src/gui/shopwindow.cpp +++ b/src/gui/shopwindow.cpp @@ -40,6 +40,7 @@ #include "gui/widgets/tradetab.h" #include "actorspritemanager.h" +#include "auctionmanager.h" #include "configuration.h" #include "confirmdialog.h" #include "inventory.h" @@ -119,11 +120,9 @@ ShopWindow::ShopWindow(): mBuyAddButton = new Button(_("Add"), "add buy", this); mBuyDeleteButton = new Button(_("Delete"), "delete buy", this); mBuyAnnounceButton = new Button(_("Announce"), "announce buy", this); - mBuyAuctionButton = new Button(_("Auction"), "auction buy", this); mSellAddButton = new Button(_("Add"), "add sell", this); mSellDeleteButton = new Button(_("Delete"), "delete sell", this); mSellAnnounceButton = new Button(_("Announce"), "announce sell", this); - mSellAuctionButton = new Button(_("Auction"), "auction sell", this); mAnnounceLinks = new CheckBox(_("Show links in announce"), false, this, "link announce"); @@ -137,14 +136,25 @@ ShopWindow::ShopWindow(): place(0, 6, mBuyAddButton); place(1, 6, mBuyDeleteButton); place(3, 6, mBuyAnnounceButton); - place(4, 6, mBuyAuctionButton); place(8, 6, mSellAddButton); place(9, 6, mSellDeleteButton); place(11, 6, mSellAnnounceButton); - place(12, 6, mSellAuctionButton); place(0, 7, mAnnounceLinks, 8); place(15, 7, mCloseButton); + if (auctionManager && auctionManager->getEnableAuctionBot()) + { + mBuyAuctionButton = new Button(_("Auction"), "auction buy", this); + mSellAuctionButton = new Button(_("Auction"), "auction sell", this); + place(4, 6, mBuyAuctionButton); + place(12, 6, mSellAuctionButton); + } + else + { + mBuyAuctionButton = 0; + mSellAuctionButton = 0; + } + Layout &layout = getLayout(); layout.setRowHeight(0, Layout::AUTO_SET); |