summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gui/selldialog.cpp22
-rw-r--r--src/resources/itemdb.cpp3
-rw-r--r--src/resources/iteminfo.cpp3
-rw-r--r--src/resources/iteminfo.h7
4 files changed, 31 insertions, 4 deletions
diff --git a/src/gui/selldialog.cpp b/src/gui/selldialog.cpp
index 5963d8dff..82d79104a 100644
--- a/src/gui/selldialog.cpp
+++ b/src/gui/selldialog.cpp
@@ -25,6 +25,7 @@
#include "shopitem.h"
#include "units.h"
+#include "gui/confirmdialog.h"
#include "gui/setup.h"
#include "gui/tradewindow.h"
@@ -99,7 +100,7 @@ void SellDialog::init()
// TRANSLATORS: sell dialog button
mDecreaseButton = new Button(this, _("-"), "dec", this);
// TRANSLATORS: sell dialog button
- mSellButton = new Button(this, _("Sell"), "sell", this);
+ mSellButton = new Button(this, _("Sell"), "presell", this);
// TRANSLATORS: sell dialog button
mQuitButton = new Button(this, _("Quit"), "quit", this);
// TRANSLATORS: sell dialog button
@@ -226,11 +227,26 @@ void SellDialog::action(const gcn::ActionEvent &event)
mSlider->setValue(mAmountItems);
updateButtonsAndLabels();
}
- else if (eventId == "sell" && mAmountItems > 0
- && mAmountItems <= mMaxItems)
+ else if ((eventId == "presell" || eventId == "sell" || eventId == "yes")
+ && mAmountItems > 0 && mAmountItems <= mMaxItems)
{
if (mNpcId != -1)
{
+ if (eventId == "presell")
+ {
+ ShopItem *const item = mShopItems->at(selectedItem);
+ const ItemInfo &info = ItemDB::get(item->getId());
+ if (info.isProtected())
+ {
+ // TRANSLATORS: sell confirmation header
+ ConfirmDialog *dialog = new ConfirmDialog(_("sell item"),
+ // TRANSLATORS: sell confirmation message
+ strprintf(_("Do you really want to sell %s?"),
+ info.getName().c_str()), false, true);
+ dialog->addActionListener(this);
+ return;
+ }
+ }
// Attempt sell
ShopItem *const item = mShopItems->at(selectedItem);
mPlayerMoney +=
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp
index 346ddb9de..b4ae544ba 100644
--- a/src/resources/itemdb.cpp
+++ b/src/resources/itemdb.cpp
@@ -269,6 +269,9 @@ void ItemDB::load()
itemInfo->setType(itemTypeFromString(typeStr));
itemInfo->addTag(mTags["All"]);
itemInfo->setPet(pet);
+ itemInfo->setProtected(XML::getBoolProperty(
+ node, "sellProtected", false));
+
switch (itemInfo->getType())
{
case ITEM_USABLE:
diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp
index 3a2b3e836..e9a550cda 100644
--- a/src/resources/iteminfo.cpp
+++ b/src/resources/iteminfo.cpp
@@ -61,7 +61,8 @@ ItemInfo::ItemInfo() :
mMissEffectId(-1),
maxFloorOffset(32),
mPickupCursor(Cursor::CURSOR_POINTER),
- mPet(0)
+ mPet(0),
+ mProtected(false)
{
for (int f = 0; f < 10; f ++)
{
diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h
index 64855bc0a..c1c9f9d27 100644
--- a/src/resources/iteminfo.h
+++ b/src/resources/iteminfo.h
@@ -286,6 +286,12 @@ class ItemInfo final
Cursor::Cursor getPickupCursor() const A_WARN_UNUSED
{ return mPickupCursor; }
+ void setProtected(bool b)
+ { mProtected = b; }
+
+ bool isProtected() const
+ { return mProtected; }
+
int mDrawBefore[10];
int mDrawAfter[10];
int mDrawPriority[10];
@@ -331,6 +337,7 @@ class ItemInfo final
int maxFloorOffset;
Cursor::Cursor mPickupCursor;
int mPet;
+ bool mProtected;
};
#endif