From 473dc9b1949ba7c51b59146815969b723a748d6d Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 24 Feb 2011 03:40:23 +0200 Subject: Add to item context menu "add to trade" items. --- src/gui/popupmenu.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'src/gui') diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 8dc392efc..693ee0f70 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -866,6 +866,31 @@ void PopupMenu::handleLink(const std::string &link, mItem->getInvIndex(), mItem->getQuantity(), Inventory::STORAGE); } + else if (link == "addtrade" && mItem) + { + ItemAmountWindow::showWindow(ItemAmountWindow::StoreAdd, + tradeWindow, mItem); + } + else if (link == "addtrade 10" && mItem) + { + if (tradeWindow) + { + int cnt = 10; + if (cnt > mItem->getQuantity()) + cnt = mItem->getQuantity(); + tradeWindow->tradeItem(mItem, cnt); + } + } + else if (link == "addtrade half" && mItem) + { + if (tradeWindow) + tradeWindow->tradeItem(mItem, mItem->getQuantity() / 2); + } + else if (link == "addtrade all" && mItem) + { + if (tradeWindow) + tradeWindow->tradeItem(mItem, mItem->getQuantity()); + } else if (link == "retrieve" && mItem) { ItemAmountWindow::showWindow(ItemAmountWindow::StoreRemove, mWindow, @@ -1092,6 +1117,23 @@ void PopupMenu::showPopup(Window *parent, int x, int y, Item *item, if (isInventory) { + if (tradeWindow) + { + mBrowserBox->addRow(strprintf("@@addtrade|%s@@", _("Add to trade"))); + if (cnt > 1) + { + if (cnt > 10) + { + mBrowserBox->addRow(strprintf("@@addtrade 10|%s@@", + _("Add to trade 10"))); + } + mBrowserBox->addRow(strprintf("@@addtrade half|%s@@", + _("Add to trade half"))); + mBrowserBox->addRow(strprintf("@@addtrade all|%s@@", + _("Add to trade all"))); + } + mBrowserBox->addRow("##3---"); + } if (InventoryWindow::isStorageActive()) { mBrowserBox->addRow(strprintf("@@store|%s@@", _("Store"))); -- cgit v1.2.3-70-g09d2