summaryrefslogtreecommitdiff
path: root/src/gui/windows/itemamountwindow.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-01-08 23:07:23 +0300
committerAndrei Karas <akaras@inbox.ru>2016-01-08 23:07:23 +0300
commitc74a91d49f6afea0b23acc4d5b4543dfee5e64db (patch)
treef851e96a451605b244e7fe77b7ad2c57b54a29b5 /src/gui/windows/itemamountwindow.cpp
parent52865ff4b24e3ea85967e76099b73f2e581a856d (diff)
downloadmanaverse-c74a91d49f6afea0b23acc4d5b4543dfee5e64db.tar.gz
manaverse-c74a91d49f6afea0b23acc4d5b4543dfee5e64db.tar.bz2
manaverse-c74a91d49f6afea0b23acc4d5b4543dfee5e64db.tar.xz
manaverse-c74a91d49f6afea0b23acc4d5b4543dfee5e64db.zip
Allow drag & drop more than one amount at time in craft inventory.
Diffstat (limited to 'src/gui/windows/itemamountwindow.cpp')
-rw-r--r--src/gui/windows/itemamountwindow.cpp60
1 files changed, 50 insertions, 10 deletions
diff --git a/src/gui/windows/itemamountwindow.cpp b/src/gui/windows/itemamountwindow.cpp
index 35d7a629f..103fb619b 100644
--- a/src/gui/windows/itemamountwindow.cpp
+++ b/src/gui/windows/itemamountwindow.cpp
@@ -26,7 +26,6 @@
#include "input/keyboardconfig.h"
-#include "net/inventoryhandler.h"
#include "gui/viewport.h"
#include "gui/models/itemsmodel.h"
@@ -34,6 +33,9 @@
#include "gui/popups/itempopup.h"
#include "gui/windows/maileditwindow.h"
+#ifdef EATHENA_SUPPORT
+#include "gui/windows/npcdialog.h"
+#endif
#include "gui/windows/shopwindow.h"
#include "gui/windows/tradewindow.h"
@@ -46,6 +48,11 @@
#include "gui/widgets/label.h"
#include "gui/widgets/slider.h"
+#include "net/inventoryhandler.h"
+#ifdef EATHENA_SUPPORT
+#include "net/npchandler.h"
+#endif
+
#include "resources/item/item.h"
#include "utils/gettext.h"
@@ -54,7 +61,7 @@
#include "debug.h"
-void ItemAmountWindow::finish(const Item *const item,
+void ItemAmountWindow::finish(Item *const item,
const int amount,
const int price,
const Usage usage)
@@ -102,6 +109,12 @@ void ItemAmountWindow::finish(const Item *const item,
if (mailEditWindow)
mailEditWindow->addItem(item, amount);
break;
+ case CraftAdd:
+ {
+ NpcDialog *const dialog = npcHandler->getCurrentNpcDialog();
+ if (dialog)
+ dialog->addCraftItem(item, amount, price); // price as slot
+ }
#endif
default:
break;
@@ -336,13 +349,27 @@ void ItemAmountWindow::action(const ActionEvent &event)
{
if (mItemPriceTextField)
{
- finish(mItem, mItemAmountTextField->getValue(),
- mItemPriceTextField->getValue(), mUsage);
+ finish(mItem,
+ mItemAmountTextField->getValue(),
+ mItemPriceTextField->getValue(),
+ mUsage);
}
else
{
- finish(mItem, mItemAmountTextField->getValue(),
- 0, mUsage);
+ if (mUsage == CraftAdd)
+ {
+ finish(mItem,
+ mItemAmountTextField->getValue(),
+ mPrice,
+ mUsage);
+ }
+ else
+ {
+ finish(mItem,
+ mItemAmountTextField->getValue(),
+ 0,
+ mUsage);
+ }
}
close();
return;
@@ -431,8 +458,11 @@ void ItemAmountWindow::keyReleased(KeyEvent &event A_UNUSED)
mItemAmountSlide->setValue(mItemAmountTextField->getValue());
}
-void ItemAmountWindow::showWindow(const Usage usage, Window *const parent,
- Item *const item, int maxRange)
+void ItemAmountWindow::showWindow(const Usage usage,
+ Window *const parent,
+ Item *const item,
+ int maxRange,
+ int tag)
{
if (!item)
return;
@@ -441,7 +471,17 @@ void ItemAmountWindow::showWindow(const Usage usage, Window *const parent,
maxRange = item->getQuantity();
if (usage != ShopBuyAdd && usage != ShopSellAdd && maxRange <= 1)
- finish(item, maxRange, 0, usage);
+ {
+ if (usage == CraftAdd)
+ finish(item, maxRange, tag, usage);
+ else
+ finish(item, maxRange, 0, usage);
+ }
else
- CREATEWIDGET(ItemAmountWindow, usage, parent, item, maxRange);
+ {
+ ItemAmountWindow *const window = CREATEWIDGETR(ItemAmountWindow,
+ usage, parent, item, maxRange);
+ if (usage == CraftAdd)
+ window->mPrice = tag;
+ }
}