summaryrefslogtreecommitdiff
path: root/src/gui/windows/selldialog.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-09-22 14:04:40 +0300
committerAndrei Karas <akaras@inbox.ru>2014-09-22 14:04:40 +0300
commitd34decaf8b2b4cbffca970e9059e1a2b4f463055 (patch)
tree047edf620410b2a85ea54ba0f2c5670290317e52 /src/gui/windows/selldialog.cpp
parentf7e32db400bcfdd1b5f3c30d817ceeae5e1dc573 (diff)
downloadmanaverse-d34decaf8b2b4cbffca970e9059e1a2b4f463055.tar.gz
manaverse-d34decaf8b2b4cbffca970e9059e1a2b4f463055.tar.bz2
manaverse-d34decaf8b2b4cbffca970e9059e1a2b4f463055.tar.xz
manaverse-d34decaf8b2b4cbffca970e9059e1a2b4f463055.zip
Move npc sell code from SellDialog into NpcSellDialog.
Diffstat (limited to 'src/gui/windows/selldialog.cpp')
-rw-r--r--src/gui/windows/selldialog.cpp59
1 files changed, 3 insertions, 56 deletions
diff --git a/src/gui/windows/selldialog.cpp b/src/gui/windows/selldialog.cpp
index fc9ec4b66..cd8c03bdc 100644
--- a/src/gui/windows/selldialog.cpp
+++ b/src/gui/windows/selldialog.cpp
@@ -247,60 +247,7 @@ void SellDialog::action(const ActionEvent &event)
{
if (mNpcId != -1)
{
- ShopItem *const item = mShopItems->at(selectedItem);
- if (PlayerInfo::isItemProtected(item->getId()))
- return;
- if (eventId == "presell")
- {
- const ItemInfo &info = ItemDB::get(item->getId());
- if (info.isProtected())
- {
- ConfirmDialog *const dialog = new ConfirmDialog(
- // TRANSLATORS: sell confirmation header
- _("sell item"),
- // TRANSLATORS: sell confirmation message
- strprintf(_("Do you really want to sell %s?"),
- info.getName().c_str()), SOUND_REQUEST, false, true);
- dialog->postInit();
- dialog->addActionListener(this);
- return;
- }
- }
- // Attempt sell
- mPlayerMoney +=
- mAmountItems * mShopItems->at(selectedItem)->getPrice();
- mMaxItems -= mAmountItems;
- while (mAmountItems > 0)
- {
- // This order is important, item->getCurrentInvIndex() would
- // return the inventory index of the next Duplicate otherwise.
- const int itemIndex = item->getCurrentInvIndex();
- const int sellCount = item->sellCurrentDuplicate(mAmountItems);
- npcHandler->sellItem(mNpcId, itemIndex, sellCount);
- mAmountItems -= sellCount;
- }
-
- mPlayerMoney +=
- mAmountItems * mShopItems->at(selectedItem)->getPrice();
- mAmountItems = 1;
- mSlider->setValue(0);
-
- if (mMaxItems)
- {
- updateButtonsAndLabels();
- }
- else
- {
- // All were sold
- mShopItemList->setSelected(-1);
- delete mShopItems->at(selectedItem);
- mShopItems->erase(selectedItem);
-
- Rect scroll;
- scroll.y = mShopItemList->getRowHeight() * (selectedItem + 1);
- scroll.height = mShopItemList->getRowHeight();
- mShopItemList->showPart(scroll);
- }
+ sellAction(event);
}
else
{
@@ -368,8 +315,8 @@ void SellDialog::updateButtonsAndLabels()
mQuantityLabel->setCaption(strprintf("%d / %d", mAmountItems, mMaxItems));
// TRANSLATORS: sell dialog label
mMoneyLabel->setCaption(strprintf(_("Price: %s / Total: %s"),
- Units::formatCurrency(income).c_str(),
- Units::formatCurrency(mPlayerMoney + income).c_str()));
+ Units::formatCurrency(income).c_str(),
+ Units::formatCurrency(mPlayerMoney + income).c_str()));
if (item)
item->update();
}