summaryrefslogtreecommitdiff
path: root/src/gui/inventory.cpp
diff options
context:
space:
mode:
authorEugenio Favalli <elvenprogrammer@gmail.com>2005-02-11 17:21:55 +0000
committerEugenio Favalli <elvenprogrammer@gmail.com>2005-02-11 17:21:55 +0000
commit448fe8430f5f0ae81101fe86d664f98be1a92201 (patch)
tree76737e4447cca1dd24c4e9203a2d2ea674d72a1e /src/gui/inventory.cpp
parent528ded235f60c349272ecbf428731b2f579ed758 (diff)
downloadmana-448fe8430f5f0ae81101fe86d664f98be1a92201.tar.gz
mana-448fe8430f5f0ae81101fe86d664f98be1a92201.tar.bz2
mana-448fe8430f5f0ae81101fe86d664f98be1a92201.tar.xz
mana-448fe8430f5f0ae81101fe86d664f98be1a92201.zip
Working on equipment
Diffstat (limited to 'src/gui/inventory.cpp')
-rw-r--r--src/gui/inventory.cpp22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/gui/inventory.cpp b/src/gui/inventory.cpp
index 259f728d..db5dfb54 100644
--- a/src/gui/inventory.cpp
+++ b/src/gui/inventory.cpp
@@ -67,10 +67,10 @@ void InventoryWindow::draw(gcn::Graphics *graphics)
}
-int InventoryWindow::addItem(int index, int id, int quantity) {
+int InventoryWindow::addItem(int index, int id, int quantity, bool equipment) {
/*items[index].id = id;
items[index].quantity += quantity;*/
- items->addItem(index, id, quantity);
+ items->addItem(index, id, quantity, equipment);
return 0;
}
@@ -116,13 +116,27 @@ int InventoryWindow::dropItem(int index, int quantity) {
return 0;
}
+void InventoryWindow::equipItem(int index) {
+ WFIFOW(0) = net_w_value(0x00a9);
+ WFIFOW(2) = net_w_value(index);
+ WFIFOW(4) = net_w_value(0);
+ WFIFOSET(6);
+ while ((out_size > 0)) flush();
+}
+
void InventoryWindow::action(const std::string &eventId)
{
//if(selectedItem >= 0 && selectedItem <= INVENTORY_SIZE) {
if (items->getIndex() != -1) {
if (eventId == "use") {
- useItem(items->getIndex(), items->getId());
- } else if (eventId == "drop") {
+ if(items->isEquipment(items->getIndex())) {
+ equipItem(items->getIndex());
+ }
+ else {
+ useItem(items->getIndex(), items->getId());
+ }
+ }
+ else if (eventId == "drop") {
dropItem(items->getIndex(), items->getQuantity());
// Temp: drop all the items, you should choose quantity instead
}