From: Daniel Karbach Date: Sat, 17 Nov 2012 13:28:56 +0000 (+0100) Subject: implemented item dropping X-Git-Url: http://git.localhorst.tv/?a=commitdiff_plain;h=bdebc167119794e59c26a058d1155a337b1bc768;p=l2e.git implemented item dropping --- diff --git a/src/common/Inventory.cpp b/src/common/Inventory.cpp index e7dbe72..d8ba20c 100644 --- a/src/common/Inventory.cpp +++ b/src/common/Inventory.cpp @@ -53,6 +53,10 @@ void Inventory::Remove(const Item *item, int count) { } } +void Inventory::RemoveAll(const Item *item) { + Remove(item, 255); +} + Inventory::Entry *Inventory::FindItem(const Item *item) { for (int i(0); i < MaxItems(); ++i) { if (item == ItemAt(i)) { diff --git a/src/common/Inventory.h b/src/common/Inventory.h index db6c705..aaf315c 100644 --- a/src/common/Inventory.h +++ b/src/common/Inventory.h @@ -22,6 +22,7 @@ public: public: bool Add(const Item *, int count = 1); void Remove(const Item *, int count = 1); + void RemoveAll(const Item *); int MaxItems() const { return 96; } diff --git a/src/menu/InventoryMenu.cpp b/src/menu/InventoryMenu.cpp index bdd94ce..437cd9c 100644 --- a/src/menu/InventoryMenu.cpp +++ b/src/menu/InventoryMenu.cpp @@ -105,7 +105,10 @@ void InventoryMenu::HandleEvents(const Input &input) { } else if (itemMenu.SelectedIndex() == itemMenu.SecondaryIndex()) { switch (menu.Selected()) { case CHOICE_USE: - // TODO: implement item use + if (itemMenu.Selected()->CanUseOnStatusScreen()) { + // TODO: implement item use + } + itemMenu.SetActive(); break; case CHOICE_SORT: // invalid state, recover @@ -113,7 +116,11 @@ void InventoryMenu::HandleEvents(const Input &input) { itemMenu.SetInactive(); break; case CHOICE_DROP: - // TODO: implement item drop + if (itemMenu.Selected()->CanDrop()) { + parent->Game().state->inventory.RemoveAll(itemMenu.Selected()); + itemMenu.ClearEntry(itemMenu.SelectedIndex()); + } + itemMenu.SetActive(); break; } } else {