Swap item slot function implemented.
This commit is contained in:
parent
82848df963
commit
819f5845b1
@ -16,9 +16,6 @@ const Menu Menu::InitializeInventoryWindow(){
|
|||||||
|
|
||||||
Menu inventoryWindow(CENTERED,{24*invWidth,24*(invHeight+1)});
|
Menu inventoryWindow(CENTERED,{24*invWidth,24*(invHeight+1)});
|
||||||
|
|
||||||
for(auto&key:Inventory::get()){
|
|
||||||
|
|
||||||
}
|
|
||||||
for(int i=0;i<totalItemSlots;i++){
|
for(int i=0;i<totalItemSlots;i++){
|
||||||
inventoryWindow.GetStringVec(A::INDEXED_ITEMS).push_back();
|
inventoryWindow.GetStringVec(A::INDEXED_ITEMS).push_back();
|
||||||
}
|
}
|
||||||
|
@ -161,4 +161,19 @@ void Inventory::InsertIntoSortedInv(IT item){
|
|||||||
|
|
||||||
bool Inventory::ExecuteAction(IT item){
|
bool Inventory::ExecuteAction(IT item){
|
||||||
return ITEM_SCRIPTS.at(ITEM_DATA.at(item).useFunc)(game,ITEM_DATA[item].customProps);
|
return ITEM_SCRIPTS.at(ITEM_DATA.at(item).useFunc)(game,ITEM_DATA[item].customProps);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Inventory::SwapItems(IT it,IT it2){
|
||||||
|
ItemInfo&itemInfo1=ITEM_DATA.at(it);
|
||||||
|
ItemInfo&itemInfo2=ITEM_DATA.at(it2);
|
||||||
|
if(itemInfo1.category!=itemInfo2.category)return false;
|
||||||
|
ITCategory category=itemInfo1.category;
|
||||||
|
Item item1=GetItem(it);
|
||||||
|
Item item2=GetItem(it2);
|
||||||
|
if(item1.Amt()<=0&&item2.Amt()<=0)return false;
|
||||||
|
std::vector<IT>inv=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;
|
||||||
}
|
}
|
@ -31,11 +31,13 @@ class Inventory{
|
|||||||
public:
|
public:
|
||||||
static void AddItem(IT it,int amt=1);
|
static void AddItem(IT it,int amt=1);
|
||||||
static uint32_t GetItemCount(IT it);
|
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.
|
//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 UseItem(IT it,int amt=1);
|
||||||
static void RemoveItem(IT it,int amt=1);
|
static void RemoveItem(IT it,int amt=1);
|
||||||
static std::vector<IT>&get(ITCategory itemCategory);
|
static std::vector<IT>&get(ITCategory itemCategory);
|
||||||
|
|
||||||
|
static bool SwapItems(IT it,IT it2);
|
||||||
private:
|
private:
|
||||||
static void InsertIntoSortedInv(IT item);
|
static void InsertIntoSortedInv(IT item);
|
||||||
static bool ExecuteAction(IT item);
|
static bool ExecuteAction(IT item);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user