summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-08-23 18:42:30 +0300
committerAndrei Karas <akaras@inbox.ru>2017-08-23 20:55:58 +0300
commitbfdee54a34531631a021f9f112186504cebde4c7 (patch)
treee49dfa982d7724497c8a7a433285e833410a0bb1 /src
parent79864826790a33a3583819fe02893eed010381d9 (diff)
downloadmanaverse-bfdee54a34531631a021f9f112186504cebde4c7.tar.gz
manaverse-bfdee54a34531631a021f9f112186504cebde4c7.tar.bz2
manaverse-bfdee54a34531631a021f9f112186504cebde4c7.tar.xz
manaverse-bfdee54a34531631a021f9f112186504cebde4c7.zip
Add partial adding items into new mail message.
Diffstat (limited to 'src')
-rw-r--r--src/gui/widgets/itemcontainer.cpp44
-rw-r--r--src/gui/windows/itemamountwindow.cpp11
-rw-r--r--src/gui/windows/maileditwindow.cpp8
-rw-r--r--src/gui/windows/maileditwindow.h1
-rw-r--r--src/net/ea/inventoryhandler.cpp2
5 files changed, 59 insertions, 7 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();
diff --git a/src/gui/windows/itemamountwindow.cpp b/src/gui/windows/itemamountwindow.cpp
index d31e263c4..100ad748a 100644
--- a/src/gui/windows/itemamountwindow.cpp
+++ b/src/gui/windows/itemamountwindow.cpp
@@ -22,6 +22,8 @@
#include "gui/windows/itemamountwindow.h"
+#include "settings.h"
+
#include "being/playerinfo.h"
#include "input/keyboardconfig.h"
@@ -47,6 +49,7 @@
#include "gui/widgets/slider.h"
#include "net/inventoryhandler.h"
+#include "net/mail2handler.h"
#include "net/npchandler.h"
#include "resources/item/item.h"
@@ -104,8 +107,14 @@ void ItemAmountWindow::finish(Item *const item,
item->getInvIndex(), amount, InventoryType::Inventory);
break;
case ItemAmountWindowUsage::MailAdd:
- if (mailEditWindow != nullptr)
+ if (settings.enableNewMailSystem)
+ {
+ mail2Handler->addItem(item, amount);
+ }
+ else if (mailEditWindow != nullptr)
+ {
mailEditWindow->addItem(item, amount);
+ }
break;
case ItemAmountWindowUsage::CraftAdd:
{
diff --git a/src/gui/windows/maileditwindow.cpp b/src/gui/windows/maileditwindow.cpp
index a2f7fe6c8..5f7426a76 100644
--- a/src/gui/windows/maileditwindow.cpp
+++ b/src/gui/windows/maileditwindow.cpp
@@ -20,6 +20,8 @@
#include "gui/windows/maileditwindow.h"
+#include "settings.h"
+
#include "being/playerinfo.h"
#include "gui/windows/inventorywindow.h"
@@ -67,11 +69,13 @@ MailEditWindow::MailEditWindow() :
mSubjectField(new TextField(this)),
mMoneyField(new IntTextField(this, 0, 0, 10000000)),
mMessageField(new TextField(this)),
- mInventory(new Inventory(InventoryType::Mail, 1)),
+ mInventory(new Inventory(InventoryType::Mail,
+ settings.enableNewMailSystem ? -1 : 1)),
mItemContainer(new ItemContainer(this, mInventory)),
mItemScrollArea(new ScrollArea(this, mItemContainer,
fromBool(getOptionBool("showitemsbackground"), Opaque),
- "mailedit_listbackground.xml"))
+ "mailedit_listbackground.xml")),
+ mUseMail2(settings.enableNewMailSystem)
{
setWindowName("MailEdit");
setCloseButton(true);
diff --git a/src/gui/windows/maileditwindow.h b/src/gui/windows/maileditwindow.h
index a4184fdd6..e25fb8f4f 100644
--- a/src/gui/windows/maileditwindow.h
+++ b/src/gui/windows/maileditwindow.h
@@ -72,6 +72,7 @@ class MailEditWindow final : public Window,
Inventory *mInventory;
ItemContainer *mItemContainer;
ScrollArea *mItemScrollArea;
+ bool mUseMail2;
};
extern MailEditWindow *mailEditWindow;
diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp
index fcee70676..b16e6db49 100644
--- a/src/net/ea/inventoryhandler.cpp
+++ b/src/net/ea/inventoryhandler.cpp
@@ -82,6 +82,7 @@ size_t InventoryHandler::getSize(const InventoryTypeT type) const
switch (type)
{
case InventoryType::Inventory:
+ case InventoryType::Mail:
return 100;
case InventoryType::Storage:
return 0; // Comes from server after items
@@ -90,7 +91,6 @@ size_t InventoryHandler::getSize(const InventoryTypeT type) const
case InventoryType::Npc:
case InventoryType::Cart:
case InventoryType::Vending:
- case InventoryType::Mail:
case InventoryType::Craft:
case InventoryType::TypeEnd:
default: