summaryrefslogtreecommitdiff
path: root/src/gui/widgets
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-11-04 02:03:03 +0300
committerAndrei Karas <akaras@inbox.ru>2015-11-04 02:40:04 +0300
commit5cfc73dc5c0093a96c45f604a028ecca21a01af8 (patch)
tree4916b602dfa9b5caee28252515a45215008b8d71 /src/gui/widgets
parent2288a403ad4377fbb552243e805aaf0b5a4f5a0d (diff)
downloadmv-5cfc73dc5c0093a96c45f604a028ecca21a01af8.tar.gz
mv-5cfc73dc5c0093a96c45f604a028ecca21a01af8.tar.bz2
mv-5cfc73dc5c0093a96c45f604a028ecca21a01af8.tar.xz
mv-5cfc73dc5c0093a96c45f604a028ecca21a01af8.zip
Allow sell to npc many items at one time (hercules).halloween2015
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/selldialog.cpp38
-rw-r--r--src/gui/widgets/selldialog.h5
2 files changed, 36 insertions, 7 deletions
diff --git a/src/gui/widgets/selldialog.cpp b/src/gui/widgets/selldialog.cpp
index 827d1c3ea..3ad8e5e7e 100644
--- a/src/gui/widgets/selldialog.cpp
+++ b/src/gui/widgets/selldialog.cpp
@@ -47,13 +47,15 @@
SellDialog::DialogList SellDialog::instances;
-SellDialog::SellDialog(const bool isSell) :
+SellDialog::SellDialog(const bool isSell,
+ const bool advanced) :
// TRANSLATORS: sell dialog name
Window(_("Sell"), Modal_false, nullptr, "sell.xml"),
ActionListener(),
SelectionListener(),
mSellButton(nullptr),
mQuitButton(nullptr),
+ mConfirmButton(nullptr),
mAddMaxButton(nullptr),
mIncreaseButton(nullptr),
mDecreaseButton(nullptr),
@@ -66,7 +68,8 @@ SellDialog::SellDialog(const bool isSell) :
mPlayerMoney(0),
mMaxItems(0),
mAmountItems(0),
- mIsSell(isSell)
+ mIsSell(isSell),
+ mAdvanced(advanced)
{
}
@@ -86,6 +89,9 @@ void SellDialog::postInit()
// Create a ShopItems instance, that is aware of duplicate entries.
mShopItems = new ShopItems(true);
+ if (mAdvanced)
+ mShopItems->setMergeDuplicates(false);
+
mShopItemList = CREATEWIDGETR(ShopListBox,
this,
mShopItems,
@@ -95,8 +101,11 @@ void SellDialog::postInit()
getOptionBool("showbackground"), "sell_background.xml");
mScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
- // TRANSLATORS: sell dialog button
- mSellButton = new Button(this, _("Sell"), "presell", this);
+ mSellButton = new Button(this,
+ // TRANSLATORS: sell dialog button
+ mAdvanced ? _("Add") : _("Sell"),
+ "presell",
+ this);
// TRANSLATORS: sell dialog button
mQuitButton = new Button(this, _("Quit"), "quit", this);
@@ -129,6 +138,12 @@ void SellDialog::postInit()
// TRANSLATORS: sell dialog label
mMoneyLabel = new Label(this, strprintf(_("Price: %s / Total: %s"),
"", ""));
+ if (mAdvanced)
+ {
+ // TRANSLATORS: sell dialog button
+ mConfirmButton = new Button(this, _("Sell"), "confirm", this);
+ mConfirmButton->setEnabled(false);
+ }
mDecreaseButton->adjustSize();
mDecreaseButton->setWidth(mIncreaseButton->getWidth());
@@ -145,7 +160,15 @@ void SellDialog::postInit()
placer(5, 5, mQuantityLabel, 2);
placer(7, 5, mAddMaxButton);
placer(0, 6, mMoneyLabel, 8);
- placer(6, 7, mSellButton);
+ if (mAdvanced)
+ {
+ placer(5, 7, mSellButton);
+ placer(6, 7, mConfirmButton);
+ }
+ else
+ {
+ placer(6, 7, mSellButton);
+ }
placer(7, 7, mQuitButton);
}
else
@@ -252,7 +275,10 @@ void SellDialog::action(const ActionEvent &event)
mSlider->setValue(mAmountItems);
updateButtonsAndLabels();
}
- else if (eventId == "presell" || eventId == "sell" || eventId == "yes")
+ else if (eventId == "presell" ||
+ eventId == "sell" ||
+ eventId == "yes" ||
+ eventId == "confirm")
{
sellAction(event);
}
diff --git a/src/gui/widgets/selldialog.h b/src/gui/widgets/selldialog.h
index b5e91f67d..92008df38 100644
--- a/src/gui/widgets/selldialog.h
+++ b/src/gui/widgets/selldialog.h
@@ -51,7 +51,8 @@ class SellDialog notfinal : public Window,
/**
* Constructor.
*/
- explicit SellDialog(const bool isSell);
+ SellDialog(const bool isSell,
+ const bool advanced);
A_DELETE_COPY(SellDialog)
@@ -127,6 +128,7 @@ class SellDialog notfinal : public Window,
Button *mSellButton A_NONNULLPOINTER;
Button *mQuitButton A_NONNULLPOINTER;
+ Button *mConfirmButton A_NONNULLPOINTER;
Button *mAddMaxButton;
Button *mIncreaseButton;
Button *mDecreaseButton;
@@ -142,6 +144,7 @@ class SellDialog notfinal : public Window,
int mAmountItems;
bool mIsSell;
+ bool mAdvanced;
};
#endif // GUI_WIDGETS_SELLDIALOG_H