From 819f5845b176d8d0ec0d7da6402117ba69c33d38 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Sat, 7 Oct 2023 13:49:32 -0500 Subject: [PATCH] Swap item slot function implemented. --- Crawler/InventoryWindow.cpp | 3 --- Crawler/Item.cpp | 15 +++++++++++++++ Crawler/Item.h | 4 +++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Crawler/InventoryWindow.cpp b/Crawler/InventoryWindow.cpp index 6a2f7c6d..d19ea625 100644 --- a/Crawler/InventoryWindow.cpp +++ b/Crawler/InventoryWindow.cpp @@ -16,9 +16,6 @@ const Menu Menu::InitializeInventoryWindow(){ Menu inventoryWindow(CENTERED,{24*invWidth,24*(invHeight+1)}); - for(auto&key:Inventory::get()){ - - } for(int i=0;iinv=sortedInv.at(category); + auto index1=std::find(inv.begin(),inv.end(),it); + auto index2=std::find(inv.begin(),inv.end(),it2); + std::swap(*index1,*index2); + return true; } \ No newline at end of file diff --git a/Crawler/Item.h b/Crawler/Item.h index 649ca7b5..879b7ea3 100644 --- a/Crawler/Item.h +++ b/Crawler/Item.h @@ -31,11 +31,13 @@ class Inventory{ public: static void AddItem(IT it,int amt=1); static uint32_t GetItemCount(IT it); - static Item GetItem(IT it); + static Item GetItem(IT it)const; //Auto-executes its use function and removes the amt specified from the inventory. Multiple amounts will cause the item to execute its useFunc multiple times. static void UseItem(IT it,int amt=1); static void RemoveItem(IT it,int amt=1); static std::vector&get(ITCategory itemCategory); + + static bool SwapItems(IT it,IT it2); private: static void InsertIntoSortedInv(IT item); static bool ExecuteAction(IT item);