summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
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())));