From 2b528cc71c56a01fefe95e48373d3c101ce6307a Mon Sep 17 00:00:00 2001 From: Björn Steinbrink Date: Mon, 15 May 2006 21:03:22 +0000 Subject: Set slider range to the real values instead of mapping the amount between [0,1] and [1,max] all the time. --- src/gui/item_amount.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/gui/item_amount.cpp b/src/gui/item_amount.cpp index 8c66144b..b1b01c3f 100644 --- a/src/gui/item_amount.cpp +++ b/src/gui/item_amount.cpp @@ -43,7 +43,7 @@ ItemAmountWindow::ItemAmountWindow(int usage, Window *parent, Item *item): Button *plusButton = new Button("+", "Plus", this); Button *okButton = new Button("Okay", "Drop", this); Button *cancelButton = new Button("Cancel", "Cancel", this); - mItemAmountSlide = new Slider(1.0); + mItemAmountSlide = new Slider(1.0, mItem->getQuantity()); mItemAmountTextBox->setRange(1, mItem->getQuantity()); mItemAmountSlide->setDimension(gcn::Rectangle(5, 120, 180, 10)); @@ -122,10 +122,9 @@ void ItemAmountWindow::action(const std::string& eventId) } else if (eventId == "Slide") { - amount = (int)(mItemAmountSlide->getValue()*(mItem->getQuantity()+1)); + amount = static_cast(mItemAmountSlide->getValue()); } mItemAmountTextBox->setInt(amount); - amount = mItemAmountTextBox->getInt(); // The textbox cares about bounds - mItemAmountSlide->setValue((amount-1)*1.0f/(mItem->getQuantity()-1)); + mItemAmountSlide->setValue(amount); } -- cgit v1.2.3-60-g2f50