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. --- ChangeLog | 7 ++++++- src/gui/item_amount.cpp | 7 +++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 00bd7945..42c8bec1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,9 @@ -2006-05-13 Bjørn Lindeijer +2006-05-15 Björn Steinbrink + + * src/gui/item_amount.cpp: Set slider range to the real values instead + of mapping the amount between [0,1] and [1,max] all the time. + +2006-05-13 Bjørn Lindeijer * src/openglgraphics.cpp: Set color back to current color instead of setting it to white. Fixes white rectangles in equipment window. 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-70-g09d2