summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/inventorywindow.cpp2
-rw-r--r--src/gui/item_amount.cpp98
-rw-r--r--src/gui/item_amount.h16
-rw-r--r--src/gui/popupmenu.cpp2
-rw-r--r--src/gui/trade.cpp2
5 files changed, 61 insertions, 59 deletions
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index 4ad4ca66..b55fe645 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -129,7 +129,7 @@ void InventoryWindow::action(const std::string &eventId)
else if (eventId == "drop")
{
// Choose amount of items to drop
- new ItemAmountWindow(AMOUNT_ITEM_DROP, this);
+ new ItemAmountWindow(AMOUNT_ITEM_DROP, this, item);
}
}
diff --git a/src/gui/item_amount.cpp b/src/gui/item_amount.cpp
index a6ca9437..52570514 100644
--- a/src/gui/item_amount.cpp
+++ b/src/gui/item_amount.cpp
@@ -25,69 +25,69 @@
#include "button.h"
#include "inttextbox.h"
-#include "inventorywindow.h"
#include "slider.h"
#include "trade.h"
#include "../inventory.h"
#include "../item.h"
-ItemAmountWindow::ItemAmountWindow(int usage, Window *parent):
- Window("Select amount of items to drop.", true, parent)
+ItemAmountWindow::ItemAmountWindow(int usage, Window *parent, Item *item):
+ Window("Select amount of items to drop.", true, parent),
+ mItem(item)
{
// New labels
- itemAmountTextBox = new IntTextBox(1);
+ mItemAmountTextBox = new IntTextBox(1);
// New buttons
- itemAmountMinusButton = new Button("-");
- itemAmountPlusButton = new Button("+");
- itemAmountSlide = new Slider(1.0);
- itemAmountOkButton = new Button("Okay");
- itemAmountCancelButton = new Button("Cancel");
+ mItemAmountMinusButton = new Button("-");
+ mItemAmountPlusButton = new Button("+");
+ mItemAmountSlide = new Slider(1.0);
+ mItemAmountOkButton = new Button("Okay");
+ mItemAmountCancelButton = new Button("Cancel");
- itemAmountTextBox->setRange(1, inventoryWindow->getItem()->getQuantity());
- itemAmountSlide->setDimension(gcn::Rectangle(5, 120, 180, 10));
+ mItemAmountTextBox->setRange(1, mItem->getQuantity());
+ mItemAmountSlide->setDimension(gcn::Rectangle(5, 120, 180, 10));
// Set button events Id
- itemAmountMinusButton->setEventId("Minus");
- itemAmountPlusButton->setEventId("Plus");
- itemAmountSlide->setEventId("Slide");
- itemAmountOkButton->setEventId("Drop");
- itemAmountCancelButton->setEventId("Cancel");
+ mItemAmountMinusButton->setEventId("Minus");
+ mItemAmountPlusButton->setEventId("Plus");
+ mItemAmountSlide->setEventId("Slide");
+ mItemAmountOkButton->setEventId("Drop");
+ mItemAmountCancelButton->setEventId("Cancel");
// Set position
- itemAmountTextBox->setPosition(35, 10);
- itemAmountTextBox->setSize(24, 16);
- itemAmountPlusButton->setPosition(60, 5);
- itemAmountMinusButton->setPosition(10, 5);
- itemAmountSlide->setPosition(10, 35);
- itemAmountOkButton->setPosition(10, 50);
- itemAmountCancelButton->setPosition(60, 50);
+ mItemAmountTextBox->setPosition(35, 10);
+ mItemAmountTextBox->setSize(24, 16);
+ mItemAmountPlusButton->setPosition(60, 5);
+ mItemAmountMinusButton->setPosition(10, 5);
+ mItemAmountSlide->setPosition(10, 35);
+ mItemAmountOkButton->setPosition(10, 50);
+ mItemAmountCancelButton->setPosition(60, 50);
// Assemble
- add(itemAmountTextBox);
- add(itemAmountPlusButton);
- add(itemAmountMinusButton);
- add(itemAmountSlide);
- add(itemAmountOkButton);
- add(itemAmountCancelButton);
-
- itemAmountPlusButton->addActionListener(this);
- itemAmountMinusButton->addActionListener(this);
- itemAmountSlide->addActionListener(this);
- itemAmountOkButton->addActionListener(this);
- itemAmountCancelButton->addActionListener(this);
+ add(mItemAmountTextBox);
+ add(mItemAmountPlusButton);
+ add(mItemAmountMinusButton);
+ add(mItemAmountSlide);
+ add(mItemAmountOkButton);
+ add(mItemAmountCancelButton);
+
+ mItemAmountPlusButton->addActionListener(this);
+ mItemAmountMinusButton->addActionListener(this);
+ mItemAmountSlide->addActionListener(this);
+ mItemAmountOkButton->addActionListener(this);
+ mItemAmountCancelButton->addActionListener(this);
resetAmount();
switch (usage) {
case AMOUNT_TRADE_ADD:
setCaption("Select amount of items to trade.");
- itemAmountOkButton->setEventId("AddTrade");
+ mItemAmountOkButton->setEventId("AddTrade");
break;
case AMOUNT_ITEM_DROP:
setCaption("Select amount of items to drop.");
- itemAmountOkButton->setEventId("Drop");
+ mItemAmountOkButton->setEventId("Drop");
break;
default:
break;
@@ -99,17 +99,17 @@ ItemAmountWindow::ItemAmountWindow(int usage, Window *parent):
ItemAmountWindow::~ItemAmountWindow()
{
- delete itemAmountTextBox;
- delete itemAmountPlusButton;
- delete itemAmountMinusButton;
- delete itemAmountSlide;
- delete itemAmountOkButton;
- delete itemAmountCancelButton;
+ delete mItemAmountTextBox;
+ delete mItemAmountPlusButton;
+ delete mItemAmountMinusButton;
+ delete mItemAmountSlide;
+ delete mItemAmountOkButton;
+ delete mItemAmountCancelButton;
}
void ItemAmountWindow::resetAmount()
{
- itemAmountTextBox->setInt(1);
+ mItemAmountTextBox->setInt(1);
}
void ItemAmountWindow::action(const std::string& eventId)
@@ -121,25 +121,25 @@ void ItemAmountWindow::action(const std::string& eventId)
}
else if (eventId == "Drop")
{
- inventory->dropItem(inventoryWindow->getItem(), itemAmountTextBox->getInt());
+ inventory->dropItem(mItem, mItemAmountTextBox->getInt());
scheduleDelete();
}
else if (eventId == "AddTrade")
{
- tradeWindow->tradeItem(inventoryWindow->getItem(), itemAmountTextBox->getInt());
+ tradeWindow->tradeItem(mItem, mItemAmountTextBox->getInt());
scheduleDelete();
}
else if (eventId == "Plus")
{
- itemAmountTextBox->setInt(itemAmountTextBox->getInt() + 1);
+ mItemAmountTextBox->setInt(mItemAmountTextBox->getInt() + 1);
}
else if (eventId == "Minus")
{
- itemAmountTextBox->setInt(itemAmountTextBox->getInt() - 1);
+ mItemAmountTextBox->setInt(mItemAmountTextBox->getInt() - 1);
}
else if (eventId == "Slide")
{
- itemAmountTextBox->setInt((int)(itemAmountSlide->getValue()*inventoryWindow->getItem()->getQuantity()));
+ mItemAmountTextBox->setInt((int)(mItemAmountSlide->getValue()*mItem->getQuantity()));
}
}
diff --git a/src/gui/item_amount.h b/src/gui/item_amount.h
index 5e485b6e..01004927 100644
--- a/src/gui/item_amount.h
+++ b/src/gui/item_amount.h
@@ -31,6 +31,7 @@
#include "../guichanfwd.h"
class IntTextBox;
+class Item;
#define AMOUNT_TRADE_ADD 1
#define AMOUNT_ITEM_DROP 2
@@ -46,7 +47,7 @@ class ItemAmountWindow : public Window, public gcn::ActionListener
/**
* Constructor.
*/
- ItemAmountWindow(int usage, Window *parent);
+ ItemAmountWindow(int usage, Window *parent, Item *item);
/**
* Destructor.
@@ -64,16 +65,17 @@ class ItemAmountWindow : public Window, public gcn::ActionListener
void resetAmount();
private:
- IntTextBox *itemAmountTextBox; /**< Item amount caption. */
+ IntTextBox *mItemAmountTextBox; /**< Item amount caption. */
+ Item *mItem;
/**
* Item Amount buttons.
*/
- gcn::Button *itemAmountPlusButton;
- gcn::Button *itemAmountMinusButton;
- gcn::Slider *itemAmountSlide;
- gcn::Button *itemAmountOkButton;
- gcn::Button *itemAmountCancelButton;
+ gcn::Button *mItemAmountPlusButton;
+ gcn::Button *mItemAmountMinusButton;
+ gcn::Slider *mItemAmountSlide;
+ gcn::Button *mItemAmountOkButton;
+ gcn::Button *mItemAmountCancelButton;
};
#endif /* _TMW_ITEM_AMOUNT_WINDOW_H */
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index a5a6128b..85b1b43a 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -198,7 +198,7 @@ void PopupMenu::handleLink(const std::string& link)
else if (link == "drop")
{
- new ItemAmountWindow(AMOUNT_ITEM_DROP, inventoryWindow);
+ new ItemAmountWindow(AMOUNT_ITEM_DROP, inventoryWindow, m_item);
}
else if (link == "description")
diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp
index 0afa4a21..f0810d0a 100644
--- a/src/gui/trade.cpp
+++ b/src/gui/trade.cpp
@@ -305,7 +305,7 @@ void TradeWindow::action(const std::string &eventId)
}
else {
// Choose amount of items to trade
- new ItemAmountWindow(AMOUNT_TRADE_ADD, this);
+ new ItemAmountWindow(AMOUNT_TRADE_ADD, this, item);
}
}
else if (eventId == "cancel")