summaryrefslogtreecommitdiff
path: root/src/gui/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/itemcontainer.cpp44
1 files changed, 41 insertions, 3 deletions
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();