]> git.localhorst.tv Git - l2e.git/commitdiff
implemented item dropping
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Sat, 17 Nov 2012 13:28:56 +0000 (14:28 +0100)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Sat, 17 Nov 2012 13:31:24 +0000 (14:31 +0100)
src/common/Inventory.cpp
src/common/Inventory.h
src/menu/InventoryMenu.cpp

index e7dbe726e356ca2408669d2e88e8e42cec5213ea..d8ba20c08af5a35c0af1d1311ab2474259634449 100644 (file)
@@ -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)) {
index db6c7052e7d908c6b38339efd6d0b3c8a6d9330b..aaf315cc6bd7cd4608706bb3e99e1a36984f60bd 100644 (file)
@@ -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; }
 
index bdd94cebf5937f1b439e340f9cef7b2b365d6976..437cd9cb03d096c72d722ded4c13f2d910d5afb4 100644 (file)
@@ -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 {