summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-06-06 23:44:23 +0300
committerAndrei Karas <akaras@inbox.ru>2011-06-06 23:44:23 +0300
commit0c3770d8aec1b56ad704e88d6e6d510ddc4af9a1 (patch)
tree4a54dc866fa7b0479e6a187ffcc60761d98abddb /src/gui
parenta89170d63eabaec5f2b63ecb9df95c982ac044a1 (diff)
downloadmv-0c3770d8aec1b56ad704e88d6e6d510ddc4af9a1.tar.gz
mv-0c3770d8aec1b56ad704e88d6e6d510ddc4af9a1.tar.bz2
mv-0c3770d8aec1b56ad704e88d6e6d510ddc4af9a1.tar.xz
mv-0c3770d8aec1b56ad704e88d6e6d510ddc4af9a1.zip
Extend quick move items from inventory to storage and back.
Add new key for quick actions "modifier key".
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/inventorywindow.cpp54
-rw-r--r--src/gui/popupmenu.cpp19
2 files changed, 57 insertions, 16 deletions
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index 056afee92..132f9cb87 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -307,19 +307,22 @@ void InventoryWindow::action(const gcn::ActionEvent &event)
{
if (isStorageActive())
{
- Item *item = mItems->getSelectedItem();
-
- if (!item)
- return;
-
Net::getInventoryHandler()->moveItem(Inventory::INVENTORY,
item->getInvIndex(), item->getQuantity(),
Inventory::STORAGE);
}
else
{
- ItemAmountWindow::showWindow(ItemAmountWindow::ItemDrop,
- this, item);
+ if (keyboard.isKeyActive(keyboard.KEY_MOD))
+ {
+ Net::getInventoryHandler()->dropItem(
+ item, item->getQuantity());
+ }
+ else
+ {
+ ItemAmountWindow::showWindow(ItemAmountWindow::ItemDrop,
+ this, item);
+ }
}
}
else if (event.getId() == "split")
@@ -348,7 +351,9 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event)
{
Window::mouseClicked(event);
- if (event.getButton() == gcn::MouseEvent::RIGHT)
+ bool mod = (isStorageActive() && keyboard.isKeyActive(keyboard.KEY_MOD));
+
+ if (!mod && event.getButton() == gcn::MouseEvent::RIGHT)
{
Item *item = mItems->getSelectedItem();
@@ -365,9 +370,10 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event)
viewport->showPopup(this, mx, my, item, isMainInventory());
}
- if (event.getButton() == gcn::MouseEvent::LEFT)
+ if (event.getButton() == gcn::MouseEvent::LEFT
+ || event.getButton() == gcn::MouseEvent::RIGHT)
{
- if (isStorageActive() && keyboard.isKeyActive(keyboard.KEY_EMOTE))
+ if (mod)
{
Item *item = mItems->getSelectedItem();
@@ -376,15 +382,31 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event)
if (mInventory->isMainInventory())
{
- Net::getInventoryHandler()->moveItem(Inventory::INVENTORY,
- item->getInvIndex(), item->getQuantity(),
- Inventory::STORAGE);
+ if (event.getButton() == gcn::MouseEvent::RIGHT)
+ {
+ ItemAmountWindow::showWindow(ItemAmountWindow::StoreAdd,
+ inventoryWindow, item);
+ }
+ else
+ {
+ Net::getInventoryHandler()->moveItem(Inventory::INVENTORY,
+ item->getInvIndex(), item->getQuantity(),
+ Inventory::STORAGE);
+ }
}
else
{
- Net::getInventoryHandler()->moveItem(Inventory::STORAGE,
- item->getInvIndex(), item->getQuantity(),
- Inventory::INVENTORY);
+ if (event.getButton() == gcn::MouseEvent::RIGHT)
+ {
+ ItemAmountWindow::showWindow(ItemAmountWindow::StoreRemove,
+ inventoryWindow, item);
+ }
+ else
+ {
+ Net::getInventoryHandler()->moveItem(Inventory::STORAGE,
+ item->getInvIndex(), item->getQuantity(),
+ Inventory::INVENTORY);
+ }
}
}
}
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index 8497b2924..766e968ad 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -967,6 +967,10 @@ void PopupMenu::handleLink(const std::string &link,
ItemAmountWindow::showWindow(ItemAmountWindow::ItemDrop,
inventoryWindow, mItem);
}
+ else if (link == "drop all" && mItem)
+ {
+ Net::getInventoryHandler()->dropItem(mItem, mItem->getQuantity());
+ }
else if (link == "store" && mItem)
{
ItemAmountWindow::showWindow(ItemAmountWindow::StoreAdd,
@@ -1539,9 +1543,14 @@ void PopupMenu::showPopup(Window *parent, int x, int y, Item *item,
mBrowserBox->addRow(strprintf("@@use|%s@@", _("Use")));
if (cnt > 1)
+ {
mBrowserBox->addRow(strprintf("@@drop|%s@@", _("Drop...")));
+ mBrowserBox->addRow(strprintf("@@drop all|%s@@", _("Drop all")));
+ }
else
+ {
mBrowserBox->addRow(strprintf("@@drop|%s@@", _("Drop")));
+ }
if (Net::getInventoryHandler()->canSplit(item))
mBrowserBox->addRow(strprintf("@@split|%s@@", _("Split")));
@@ -1631,9 +1640,14 @@ void PopupMenu::showItemPopup(int x, int y, Item *item)
}
if (item->getQuantity() > 1)
+ {
mBrowserBox->addRow(strprintf("@@drop|%s@@", _("Drop...")));
+ mBrowserBox->addRow(strprintf("@@drop all|%s@@", _("Drop all")));
+ }
else
+ {
mBrowserBox->addRow(strprintf("@@drop|%s@@", _("Drop")));
+ }
if (Net::getInventoryHandler()->canSplit(item))
mBrowserBox->addRow(strprintf("@@split|%s@@", _("Split")));
@@ -1669,9 +1683,14 @@ void PopupMenu::showDropPopup(int x, int y, Item *item)
mBrowserBox->addRow(strprintf("@@use|%s@@", _("Use")));
if (item->getQuantity() > 1)
+ {
mBrowserBox->addRow(strprintf("@@drop|%s@@", _("Drop...")));
+ mBrowserBox->addRow(strprintf("@@drop all|%s@@", _("Drop all")));
+ }
else
+ {
mBrowserBox->addRow(strprintf("@@drop|%s@@", _("Drop")));
+ }
if (Net::getInventoryHandler()->canSplit(item))
mBrowserBox->addRow(strprintf("@@split|%s@@", _("Split")));