From 448fe8430f5f0ae81101fe86d664f98be1a92201 Mon Sep 17 00:00:00 2001 From: Eugenio Favalli Date: Fri, 11 Feb 2005 17:21:55 +0000 Subject: Working on equipment --- src/gui/inventory.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'src/gui/inventory.cpp') 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 } -- cgit v1.2.3-70-g09d2