summaryrefslogtreecommitdiff
path: root/src/gui/item_amount.cpp
diff options
context:
space:
mode:
authorAaron Marks <nymacro@gmail.com>2005-06-03 03:15:37 +0000
committerAaron Marks <nymacro@gmail.com>2005-06-03 03:15:37 +0000
commitf4bab20b13d4b11522171b21b35d26ee43727206 (patch)
tree86ac021f074599f6d44779ba0a9656543d098cd9 /src/gui/item_amount.cpp
parentd7414de0f52f45b0b05d3ca99e85e31d17669e65 (diff)
downloadmana-f4bab20b13d4b11522171b21b35d26ee43727206.tar.gz
mana-f4bab20b13d4b11522171b21b35d26ee43727206.tar.bz2
mana-f4bab20b13d4b11522171b21b35d26ee43727206.tar.xz
mana-f4bab20b13d4b11522171b21b35d26ee43727206.zip
Added IntTextBox class (a TextBox which only accepts integers).
Changed passive label in drop item dialog to IntTextBox.
Diffstat (limited to 'src/gui/item_amount.cpp')
-rw-r--r--src/gui/item_amount.cpp38
1 files changed, 14 insertions, 24 deletions
diff --git a/src/gui/item_amount.cpp b/src/gui/item_amount.cpp
index a2aabfb4..5cac1746 100644
--- a/src/gui/item_amount.cpp
+++ b/src/gui/item_amount.cpp
@@ -30,7 +30,7 @@ ItemAmountWindow::ItemAmountWindow(int usage, Window *parent):
Window("Select amount of items to drop.", true, parent)
{
// New labels
- itemAmountLabel = new gcn::Label("1");
+ itemAmountTextBox = new IntTextBox(1);
// New buttons
itemAmountMinusButton = new Button("-");
@@ -38,6 +38,8 @@ ItemAmountWindow::ItemAmountWindow(int usage, Window *parent):
itemAmountOkButton = new Button("Okay");
itemAmountCancelButton = new Button("Cancel");
+ itemAmountTextBox->setRange(1, inventoryWindow->items->getQuantity());
+
// Set button events Id
itemAmountMinusButton->setEventId("Minus");
itemAmountPlusButton->setEventId("Plus");
@@ -45,14 +47,15 @@ ItemAmountWindow::ItemAmountWindow(int usage, Window *parent):
itemAmountCancelButton->setEventId("Cancel");
// Set position
- itemAmountLabel->setPosition(35, 10);
+ itemAmountTextBox->setPosition(35, 10);
+ itemAmountTextBox->setSize(24, 16);
itemAmountPlusButton->setPosition(60, 5);
itemAmountMinusButton->setPosition(10, 5);
itemAmountOkButton->setPosition(10, 40);
itemAmountCancelButton->setPosition(60, 40);
// Assemble
- add(itemAmountLabel);
+ add(itemAmountTextBox);
add(itemAmountPlusButton);
add(itemAmountMinusButton);
add(itemAmountOkButton);
@@ -84,7 +87,7 @@ ItemAmountWindow::ItemAmountWindow(int usage, Window *parent):
ItemAmountWindow::~ItemAmountWindow()
{
- delete itemAmountLabel;
+ delete itemAmountTextBox;
delete itemAmountPlusButton;
delete itemAmountMinusButton;
delete itemAmountOkButton;
@@ -93,46 +96,33 @@ ItemAmountWindow::~ItemAmountWindow()
void ItemAmountWindow::resetAmount()
{
- amount = 1;
- itemAmountLabel->setCaption("1");
+ itemAmountTextBox->setInt(1);
}
void ItemAmountWindow::action(const std::string& eventId)
{
+
if (eventId == "Cancel")
{
scheduleDelete();
}
else if (eventId == "Drop")
{
- inventoryWindow->dropItem(inventoryWindow->items->getIndex(), amount);
+ inventoryWindow->dropItem(inventoryWindow->items->getIndex(), itemAmountTextBox->getInt());
scheduleDelete();
}
else if (eventId == "AddTrade")
{
- tradeWindow->tradeItem(inventoryWindow->items->getIndex(), amount);
+ tradeWindow->tradeItem(inventoryWindow->items->getIndex(), itemAmountTextBox->getInt());
scheduleDelete();
}
else if (eventId == "Plus")
{
- if (amount < inventoryWindow->items->getQuantity())
- {
- char tmpplus[128];
- amount++;
- sprintf(tmpplus, "%i", amount);
- itemAmountLabel->setCaption(tmpplus);
- itemAmountLabel->adjustSize();
- }
+ itemAmountTextBox->setInt(itemAmountTextBox->getInt() + 1);
}
else if (eventId == "Minus")
{
- if (amount > 1)
- {
- char tmpminus[128];
- amount--;
- sprintf(tmpminus, "%i", amount);
- itemAmountLabel->setCaption(tmpminus);
- itemAmountLabel->adjustSize();
- }
+ itemAmountTextBox->setInt(itemAmountTextBox->getInt() + 1);
}
}
+