summaryrefslogtreecommitdiff
path: root/src/gui/sell.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/sell.cpp')
-rw-r--r--src/gui/sell.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp
index 4ab41cd2..d4bd1d8a 100644
--- a/src/gui/sell.cpp
+++ b/src/gui/sell.cpp
@@ -42,6 +42,7 @@ SellDialog::SellDialog():
quantityLabel = new gcn::Label("0");
okButton = new Button("OK");
cancelButton = new Button("Cancel");
+ okButton->setEnabled(false);
setContentSize(260, 175);
scrollArea->setDimension(gcn::Rectangle(5, 5, 250, 110));
@@ -114,11 +115,17 @@ void SellDialog::action(const std::string& eventId)
if (eventId == "slider" || eventId == "item") {
if (selectedItem > -1) {
int maxItems = shopInventory[selectedItem].quantity;
+ int numItems = (int)(slider->getValue() * maxItems);
std::stringstream ss;
- ss << (int)(slider->getValue() * maxItems);
+ ss << numItems;
quantityLabel->setCaption(ss.str());
quantityLabel->adjustSize();
+
+ okButton->setEnabled(numItems > 0);
+ }
+ else {
+ okButton->setEnabled(false);
}
}
else if (eventId == "ok") {