diff options
author | Freeyorp <Freeyorp101@NOSPAM@hotmail.com> | 2009-05-07 16:30:50 +1200 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2009-05-07 22:58:19 -0600 |
commit | 02401cfae13ea9d2c836e707f21164729f8ee364 (patch) | |
tree | 6d77076dd18de5894a3176b5061f5a826e492600 | |
parent | af09f9d13118eaf17fb6cebcf86ee8100003d834 (diff) | |
download | mana-02401cfae13ea9d2c836e707f21164729f8ee364.tar.gz mana-02401cfae13ea9d2c836e707f21164729f8ee364.tar.bz2 mana-02401cfae13ea9d2c836e707f21164729f8ee364.tar.xz mana-02401cfae13ea9d2c836e707f21164729f8ee364.zip |
Put an input field back into the itemamount window.
-rw-r--r-- | src/gui/itemamount.cpp | 26 | ||||
-rw-r--r-- | src/gui/itemamount.h | 3 |
2 files changed, 14 insertions, 15 deletions
diff --git a/src/gui/itemamount.cpp b/src/gui/itemamount.cpp index 190290e3..03f1ae5f 100644 --- a/src/gui/itemamount.cpp +++ b/src/gui/itemamount.cpp @@ -25,7 +25,7 @@ #include "gui/trade.h" #include "gui/widgets/button.h" -#include "gui/widgets/label.h" +#include "gui/widgets/inttextfield.h" #include "gui/widgets/layout.h" #include "gui/widgets/slider.h" @@ -33,7 +33,6 @@ #include "localplayer.h" #include "utils/gettext.h" -#include "utils/stringutils.h" void ItemAmountWindow::finish(Item *item, int amount, Usage usage) { @@ -72,9 +71,9 @@ ItemAmountWindow::ItemAmountWindow(Usage usage, Window *parent, Item *item, setCloseButton(true); // Integer field - - mItemAmountLabel = new Label(strprintf("%d / %d", 1, mMax)); - mItemAmountLabel->setAlignment(gcn::Graphics::CENTER); + mItemAmountTextField = new IntTextField(1); + mItemAmountTextField->setRange(1, mMax); + mItemAmountTextField->setWidth(35); // Slider mItemAmountSlide = new Slider(1.0, mMax); @@ -95,13 +94,13 @@ ItemAmountWindow::ItemAmountWindow(Usage usage, Window *parent, Item *item, // Set positions ContainerPlacer place; place = getPlacer(0, 0); - place(0, 0, minusButton); - place(1, 0, mItemAmountSlide, 3); - place(4, 0, plusButton); - place(5, 0, mItemAmountLabel, 2); - place(7, 0, addAllButton); + place(1, 0, mItemAmountTextField); + place(2, 0, plusButton); + place(3, 0, addAllButton); place = getPlacer(0, 1); + place(0, 0, mItemAmountSlide, 6); + place = getPlacer(0, 2); place(4, 0, cancelButton); place(5, 0, okButton); reflowLayout(225, 0); @@ -133,12 +132,12 @@ ItemAmountWindow::ItemAmountWindow(Usage usage, Window *parent, Item *item, void ItemAmountWindow::resetAmount() { - mItemAmountLabel->setCaption(strprintf("%d / %d", 1, mMax)); + mItemAmountTextField->setValue(1); } void ItemAmountWindow::action(const gcn::ActionEvent &event) { - int amount = mItemAmountSlide->getValue(); + int amount = mItemAmountTextField->getValue(); if (event.getId() == "Cancel") { @@ -166,8 +165,7 @@ void ItemAmountWindow::action(const gcn::ActionEvent &event) scheduleDelete(); return; } - - mItemAmountLabel->setCaption(strprintf("%d / %d", amount, mMax)); + mItemAmountTextField->setValue(amount); mItemAmountSlide->setValue(amount); } diff --git a/src/gui/itemamount.h b/src/gui/itemamount.h index 33d6d816..1ae3f0d5 100644 --- a/src/gui/itemamount.h +++ b/src/gui/itemamount.h @@ -26,6 +26,7 @@ #include <guichan/actionlistener.hpp> +class IntTextField; class Item; /** @@ -71,7 +72,7 @@ class ItemAmountWindow : public Window, public gcn::ActionListener ItemAmountWindow(Usage usage, Window *parent, Item *item, int maxRange = 0); - gcn::Label *mItemAmountLabel; /**< Item amount caption. */ + IntTextField *mItemAmountTextField; /**< Item amount caption. */ Item *mItem; int mMax; |