diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-02-15 16:25:30 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-02-15 16:29:54 +0300 |
commit | d8da9ebe28dc38fa9c7e5bd859913faa4460a25d (patch) | |
tree | 4d9387a169ca56b86725fb4165e554ddeb817395 | |
parent | 77a52b24c88dd113a74ff55cecb63a7214193fdf (diff) | |
download | plus-d8da9ebe28dc38fa9c7e5bd859913faa4460a25d.tar.gz plus-d8da9ebe28dc38fa9c7e5bd859913faa4460a25d.tar.bz2 plus-d8da9ebe28dc38fa9c7e5bd859913faa4460a25d.tar.xz plus-d8da9ebe28dc38fa9c7e5bd859913faa4460a25d.zip |
eathena: impliment packet SMSG_BUYINGSTORE_ITEMS_LIST.
-rw-r--r-- | src/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/actions/actions.cpp | 8 | ||||
-rw-r--r-- | src/gui/windows/buyingstoreselldialog.cpp | 48 | ||||
-rw-r--r-- | src/gui/windows/buyingstoreselldialog.h | 55 | ||||
-rw-r--r-- | src/net/eathena/buyingstorehandler.cpp | 35 |
6 files changed, 142 insertions, 8 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 10384a26b..902895b2c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -332,6 +332,8 @@ SET(SRCS gui/popups/createpartypopup.h gui/windows/buydialog.cpp gui/windows/buydialog.h + gui/windows/buyingstoreselldialog.cpp + gui/windows/buyingstoreselldialog.h gui/windows/buyselldialog.cpp gui/windows/buyselldialog.h gui/windows/changeemaildialog.cpp diff --git a/src/Makefile.am b/src/Makefile.am index b14c4f99e..bf8353fb7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -462,6 +462,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/popups/createpartypopup.h \ gui/windows/buydialog.cpp \ gui/windows/buydialog.h \ + gui/windows/buyingstoreselldialog.cpp \ + gui/windows/buyingstoreselldialog.h \ gui/windows/buyselldialog.cpp \ gui/windows/buyselldialog.h \ gui/windows/changeemaildialog.cpp \ diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp index 6290c0d37..1e70a6540 100644 --- a/src/actions/actions.cpp +++ b/src/actions/actions.cpp @@ -71,6 +71,7 @@ #include "net/adminhandler.h" #include "net/beinghandler.h" +#include "net/buyingstorehandler.h" #include "net/buysellhandler.h" #include "net/chathandler.h" #include "net/download.h" @@ -638,7 +639,7 @@ impHandler(sell) { const std::string args = event.args; Being *being = findBeing(args); - if (!being) + if (!being && !serverFeatures->haveVending()) { const std::set<std::string> &players = whoIsOnline->getOnlineNicks(); if (players.find(args) != players.end()) @@ -656,7 +657,10 @@ impHandler(sell) } else if (being->getType() == ActorType::Player) { - buySellHandler->requestBuyList(being->getName()); + if (serverFeatures->haveVending()) + buyingStoreHandler->open(being); + else + buySellHandler->requestBuyList(being->getName()); return true; } return false; diff --git a/src/gui/windows/buyingstoreselldialog.cpp b/src/gui/windows/buyingstoreselldialog.cpp new file mode 100644 index 000000000..e3d6cbf88 --- /dev/null +++ b/src/gui/windows/buyingstoreselldialog.cpp @@ -0,0 +1,48 @@ +/* + * The ManaPlus Client + * Copyright (C) 2004-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2015 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/windows/buyingstoreselldialog.h" + +#include "shopitem.h" + +#include "being/being.h" +#include "being/playerinfo.h" + +#include "gui/models/shopitems.h" + +#include "gui/widgets/shoplistbox.h" + +#include "net/buyingstorehandler.h" + +#include "debug.h" + +BuyingStoreSellDialog::BuyingStoreSellDialog(const int accountId, + const int storeId) : + SellDialog(true), + mAccountId(accountId), + mStoreId(storeId) +{ +} + +void BuyingStoreSellDialog::sellAction(const ActionEvent &event A_UNUSED) +{ +} diff --git a/src/gui/windows/buyingstoreselldialog.h b/src/gui/windows/buyingstoreselldialog.h new file mode 100644 index 000000000..d20c6d9ab --- /dev/null +++ b/src/gui/windows/buyingstoreselldialog.h @@ -0,0 +1,55 @@ +/* + * The ManaPlus Client + * Copyright (C) 2004-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2015 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_WINDOWS_BUYINGSTORESELLDIALOG_H +#define GUI_WINDOWS_BUYINGSTORESELLDIALOG_H + +#include "gui/widgets/selldialog.h" + +class Being; + +/** + * The sell dialog. + * + * \ingroup Interface + */ +class BuyingStoreSellDialog final : public SellDialog +{ + public: + /** + * Constructor. + * + * @see Window::Window + */ + explicit BuyingStoreSellDialog(const int accountId, + const int storeId); + + A_DELETE_COPY(BuyingStoreSellDialog) + + protected: + void sellAction(const ActionEvent &event) override final; + + int mAccountId; + int mStoreId; +}; + +#endif // GUI_WINDOWS_BUYINGSTORESELLDIALOG_H diff --git a/src/net/eathena/buyingstorehandler.cpp b/src/net/eathena/buyingstorehandler.cpp index 33fd8a4ee..7f2627a29 100644 --- a/src/net/eathena/buyingstorehandler.cpp +++ b/src/net/eathena/buyingstorehandler.cpp @@ -21,6 +21,7 @@ #include "net/eathena/buyingstorehandler.h" #include "actormanager.h" +#include "inventory.h" #include "notifymanager.h" #include "shopitem.h" @@ -28,6 +29,10 @@ #include "being/localplayer.h" #include "being/playerinfo.h" +#include "enums/being/attributes.h" + +#include "gui/windows/buyingstoreselldialog.h" + #include "listeners/buyingstoremodelistener.h" #include "listeners/buyingstoreslotslistener.h" @@ -182,15 +187,33 @@ void BuyingStoreHandler::processBuyingStoreHideBoard(Net::MessageIn &msg) void BuyingStoreHandler::processBuyingStoreItemsList(Net::MessageIn &msg) { const int count = (msg.readInt16("len") - 16) / 9; - msg.readInt32("account id"); - msg.readInt32("store id"); + const int id = msg.readInt32("account id"); + const int storeId = msg.readInt32("store id"); + // +++ in future need use it too msg.readInt32("money limit"); + + Being *const dstBeing = actorManager->findBeing(id); + if (!dstBeing) + return; + + SellDialog *const dialog = new BuyingStoreSellDialog( + dstBeing->getId(), + storeId); + dialog->postInit(); + dialog->setMoney(PlayerInfo::getAttribute(Attributes::MONEY)); + Inventory *const inv = PlayerInfo::getInventory(); for (int f = 0; f < count; f ++) { - msg.readInt32("price"); - msg.readInt16("amount"); - msg.readUInt8("item type"); - msg.readInt16("item id"); + const int price = msg.readInt32("price"); + const int amount = msg.readInt16("amount"); + const int itemType = msg.readUInt8("item type"); + const int itemId = msg.readInt16("item id"); + + const Item *const item = inv->findItem(itemId, 1); + if (!item) + continue; + // +++ need add colors support + dialog->addItem(itemId, itemType, 1, amount, price); } } |