From bfdee54a34531631a021f9f112186504cebde4c7 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 23 Aug 2017 18:42:30 +0300 Subject: Add partial adding items into new mail message. --- src/gui/widgets/itemcontainer.cpp | 44 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) (limited to 'src/gui/widgets/itemcontainer.cpp') diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index 8dd0f1210..f701ab6af 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -23,6 +23,7 @@ #include "gui/widgets/itemcontainer.h" #include "dragdrop.h" +#include "settings.h" #include "being/playerinfo.h" @@ -41,12 +42,14 @@ #include "gui/windows/shopwindow.h" #include "gui/windows/shortcutwindow.h" #include "gui/windows/itemamountwindow.h" +#include "gui/windows/maileditwindow.h" #include "gui/windows/npcdialog.h" #include "input/inputmanager.h" #include "net/inventoryhandler.h" #include "net/net.h" +#include "net/mail2handler.h" #include "net/npchandler.h" #include "net/tradehandler.h" @@ -845,9 +848,8 @@ void ItemContainer::mouseReleased(MouseEvent &event) checkProtection = true; inventory = PlayerInfo::getInventory(); } - else if (src == DragDropSource::Inventory - && (dst == DragDropSource::Npc - || dst == DragDropSource::Mail)) + else if (src == DragDropSource::Inventory && + dst == DragDropSource::Npc) { inventory = PlayerInfo::getInventory(); if (inventory != nullptr) @@ -863,6 +865,42 @@ void ItemContainer::mouseReleased(MouseEvent &event) } return; } + else if (src == DragDropSource::Inventory && + dst == DragDropSource::Mail) + { + inventory = PlayerInfo::getInventory(); + if (inventory == nullptr) + return; + Item *const item = inventory->getItem(dragDrop.getTag()); + if (item == nullptr) + return; + if (settings.enableNewMailSystem) + { + if (item->getQuantity() > 1 + && !inputManager.isActionActive(InputAction::STOP_ATTACK)) + { + ItemAmountWindow::showWindow( + ItemAmountWindowUsage::MailAdd, + mailEditWindow, + item); + } + else + { + mail2Handler->addItem(item, 1); + } + } + else + { + if (mInventory->addVirtualItem( + item, + getSlotByXY(event.getX(), event.getY()), + 1)) + { + inventory->virtualRemove(item, 1); + } + } + return; + } else if (src == DragDropSource::Npc) { inventory = PlayerInfo::getInventory(); -- cgit v1.2.3-70-g09d2