Corrected GetInventorySlot() to return actual slot when there are multiple unique instances of an item instead of just the first index.

This commit is contained in:
2023-12-31 17:04:34 -06:00
parent 0e5d871c68
commit 4daf4f0135
3 changed files with 22 additions and 2 deletions
+10
View File
@@ -169,7 +169,12 @@ void Menu::InitializeCharacterMenuWindow(){
for(const std::string&attribute:displayAttrs){
statsBeforeEquip.push_back(game->GetPlayer()->GetStat(attribute));
}
std::weak_ptr<Item>equippedItem=Inventory::GetEquip(slot);
std::weak_ptr<Item>otherItem;
if(slot==EquipSlot::RING1)otherItem=Inventory::GetEquip(EquipSlot::RING2);
else
if(slot==EquipSlot::RING2)otherItem=Inventory::GetEquip(EquipSlot::RING1);
Inventory::EquipItem(buttonItem,slot);
for(int counter=0;const std::string&attribute:displayAttrs){
StatLabel*statDisplayLabel=Component<StatLabel>(CHARACTER_MENU,"Attribute "+std::string(ItemAttribute::Get(attribute).Name())+" Label");
@@ -181,6 +186,11 @@ void Menu::InitializeCharacterMenuWindow(){
if(!ISBLANK(equippedItem)){
Inventory::EquipItem(equippedItem,slot);
}
if(!ISBLANK(otherItem)){
if(slot==EquipSlot::RING1)Inventory::EquipItem(otherItem,EquipSlot::RING2);
else
if(slot==EquipSlot::RING2)Inventory::EquipItem(otherItem,EquipSlot::RING1);
}
}else{
ERR("WARNING! Attempting to cast a button that isn't a RowItemDisplay!");
}