diff options
author | Jared Adams <jaxad0127@gmail.com> | 2009-03-18 18:06:21 -0600 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2009-03-18 18:06:21 -0600 |
commit | 87a5e7ff9aab0073a0658b543376622febabc630 (patch) | |
tree | 4a6fe05078f4a706ff5a6639900282d7a5fccc71 /src | |
parent | f64903f3f139ba83e94c6260c39f88b8d31b793b (diff) | |
download | mana-client-87a5e7ff9aab0073a0658b543376622febabc630.tar.gz mana-client-87a5e7ff9aab0073a0658b543376622febabc630.tar.bz2 mana-client-87a5e7ff9aab0073a0658b543376622febabc630.tar.xz mana-client-87a5e7ff9aab0073a0658b543376622febabc630.zip |
Clean up TtemAmount dialog and add an All button
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/item_amount.cpp | 58 | ||||
-rw-r--r-- | src/gui/item_amount.h | 2 |
2 files changed, 33 insertions, 27 deletions
diff --git a/src/gui/item_amount.cpp b/src/gui/item_amount.cpp index 280f063e..aca7ff52 100644 --- a/src/gui/item_amount.cpp +++ b/src/gui/item_amount.cpp @@ -35,19 +35,17 @@ ItemAmountWindow::ItemAmountWindow(int usage, Window *parent, Item *item): Window("", true, parent), - mItem(item) + mItem(item), mUsage(usage), mMax(mItem->getQuantity()) { - const int maxRange = mItem->getQuantity(); - // Integer field mItemAmountTextField = new IntTextField(1); - mItemAmountTextField->setRange(1, maxRange); + mItemAmountTextField->setRange(1, mMax); mItemAmountTextField->setWidth(30); mItemAmountTextField->setActionEventId("Dummy"); mItemAmountTextField->addActionListener(this); // Slider - mItemAmountSlide = new Slider(1.0, maxRange); + mItemAmountSlide = new Slider(1.0, mMax); mItemAmountSlide->setHeight(10); mItemAmountSlide->setActionEventId("Slide"); mItemAmountSlide->addActionListener(this); @@ -59,11 +57,13 @@ ItemAmountWindow::ItemAmountWindow(int usage, Window *parent, Item *item): plusButton->setSize(20, 20); Button *okButton = new Button(_("Ok"), "Drop", this); Button *cancelButton = new Button(_("Cancel"), "Cancel", this); + Button *addAllButton = new Button(_("All"), "All", this); // Set positions place(0, 0, minusButton); place(1, 0, mItemAmountTextField).setPadding(2); place(2, 0, plusButton); + place(4, 0, addAllButton, 2); place(0, 1, mItemAmountSlide, 6); place(4, 2, okButton); place(5, 2, cancelButton); @@ -75,19 +75,15 @@ ItemAmountWindow::ItemAmountWindow(int usage, Window *parent, Item *item): { case AMOUNT_TRADE_ADD: setCaption(_("Select amount of items to trade.")); - okButton->setActionEventId("AddTrade"); break; case AMOUNT_ITEM_DROP: setCaption(_("Select amount of items to drop.")); - okButton->setActionEventId("Drop"); break; case AMOUNT_STORE_ADD: setCaption(_("Select amount of items to store.")); - okButton->setActionEventId("AddStore"); break; case AMOUNT_STORE_REMOVE: - setCaption(_("Select amount of items to remove from storage.")); - okButton->setActionEventId("RemoveStore"); + setCaption(_("Select amount of items to retrieve.")); break; default: break; @@ -122,26 +118,34 @@ void ItemAmountWindow::action(const gcn::ActionEvent &event) { amount = static_cast<int>(mItemAmountSlide->getValue()); } - else if (event.getId() == "Drop") - { - player_node->dropItem(mItem, mItemAmountTextField->getValue()); - scheduleDelete(); - } - else if (event.getId() == "AddTrade") - { - tradeWindow->tradeItem(mItem, mItemAmountTextField->getValue()); - scheduleDelete(); - } - else if (event.getId() == "AddStore") + else if (event.getId() == "Ok" || event.getId() == "All") { - storageWindow->addStore(mItem, mItemAmountTextField->getValue()); - scheduleDelete(); - } - else if (event.getId() == "RemoveStore") - { - storageWindow->removeStore(mItem, mItemAmountTextField->getValue()); + if (event.getId() == "All") { + amount = mMax; + } + + switch (mUsage) + { + case AMOUNT_TRADE_ADD: + tradeWindow->tradeItem(mItem, amount); + break; + case AMOUNT_ITEM_DROP: + player_node->dropItem(mItem, amount); + break; + case AMOUNT_STORE_ADD: + storageWindow->addStore(mItem, amount); + break; + case AMOUNT_STORE_REMOVE: + storageWindow->removeStore(mItem, amount); + break; + default: + return; + break; + } + scheduleDelete(); } + mItemAmountTextField->setValue(amount); mItemAmountSlide->setValue(amount); } diff --git a/src/gui/item_amount.h b/src/gui/item_amount.h index 26cca32c..f0534ec8 100644 --- a/src/gui/item_amount.h +++ b/src/gui/item_amount.h @@ -61,6 +61,8 @@ class ItemAmountWindow : public Window, public gcn::ActionListener IntTextField *mItemAmountTextField; /**< Item amount caption. */ Item *mItem; + int mMax, mUsage; + /** * Item Amount buttons. */ |