diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-08-23 18:42:30 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-08-23 20:55:58 +0300 |
commit | bfdee54a34531631a021f9f112186504cebde4c7 (patch) | |
tree | e49dfa982d7724497c8a7a433285e833410a0bb1 /src/gui/widgets/itemcontainer.cpp | |
parent | 79864826790a33a3583819fe02893eed010381d9 (diff) | |
download | plus-bfdee54a34531631a021f9f112186504cebde4c7.tar.gz plus-bfdee54a34531631a021f9f112186504cebde4c7.tar.bz2 plus-bfdee54a34531631a021f9f112186504cebde4c7.tar.xz plus-bfdee54a34531631a021f9f112186504cebde4c7.zip |
Add partial adding items into new mail message.
Diffstat (limited to 'src/gui/widgets/itemcontainer.cpp')
-rw-r--r-- | src/gui/widgets/itemcontainer.cpp | 44 |
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(); |