summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-09-15 21:17:23 +0300
committerAndrei Karas <akaras@inbox.ru>2016-09-15 21:17:23 +0300
commitec7d24a8f2d7d528bc200a62f7242e6817b9e1ed (patch)
tree78c1fb26ed2e198677a0ff75e07eec4765cee3fa /src/gui
parent413637151f0eb471ff6b28feddc028c374f96401 (diff)
downloadmanaplus-ec7d24a8f2d7d528bc200a62f7242e6817b9e1ed.tar.gz
manaplus-ec7d24a8f2d7d528bc200a62f7242e6817b9e1ed.tar.bz2
manaplus-ec7d24a8f2d7d528bc200a62f7242e6817b9e1ed.tar.xz
manaplus-ec7d24a8f2d7d528bc200a62f7242e6817b9e1ed.zip
Add support for drag and drop into shops.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/widgets/shoplistbox.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp
index 3ce06ba0d..ce8ce78e1 100644
--- a/src/gui/widgets/shoplistbox.cpp
+++ b/src/gui/widgets/shoplistbox.cpp
@@ -22,6 +22,7 @@
#include "gui/widgets/shoplistbox.h"
+#include "dragdrop.h"
#include "settings.h"
#include "being/playerinfo.h"
@@ -35,10 +36,16 @@
#include "gui/models/shopitems.h"
+#include "gui/windows/itemamountwindow.h"
+
+#include "net/serverfeatures.h"
+
#include "render/graphics.h"
#include "resources/image/image.h"
+#include "resources/inventory/inventory.h"
+
#include "resources/item/shopitem.h"
#include "debug.h"
@@ -239,6 +246,48 @@ void ShopListBox::mouseMoved(MouseEvent &event)
void ShopListBox::mouseReleased(MouseEvent& event)
{
ListBox::mouseReleased(event);
+ if (event.getType() == MouseEventType::RELEASED2)
+ {
+ if (dragDrop.isEmpty())
+ return;
+ const DragDropSourceT src = dragDrop.getSource();
+ if (mType != ShopListBoxType::SellShop &&
+ mType != ShopListBoxType::BuyShop)
+ {
+ return;
+ }
+ if (mType == ShopListBoxType::SellShop &&
+ serverFeatures->haveCart() &&
+ src != DragDropSource::Cart)
+ {
+ return;
+ }
+ Inventory *inventory;
+ if (src == DragDropSource::Inventory)
+ inventory = PlayerInfo::getInventory();
+ else if (src == DragDropSource::Cart)
+ inventory = PlayerInfo::getCartInventory();
+ else
+ return;
+ if (!inventory)
+ return;
+ Item *const item = inventory->getItem(dragDrop.getTag());
+ if (mType == ShopListBoxType::BuyShop)
+ {
+ ItemAmountWindow::showWindow(
+ ItemAmountWindowUsage::ShopBuyAdd,
+ nullptr,
+ item);
+ }
+ else
+ {
+ ItemAmountWindow::showWindow(
+ ItemAmountWindowUsage::ShopSellAdd,
+ nullptr,
+ item);
+ }
+ }
+
if (event.getButton() == MouseButton::RIGHT)
{
setSelected(std::max(0, getSelectionByMouse(event.getY())));