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:
@@ -169,7 +169,12 @@ void Menu::InitializeCharacterMenuWindow(){
|
|||||||
for(const std::string&attribute:displayAttrs){
|
for(const std::string&attribute:displayAttrs){
|
||||||
statsBeforeEquip.push_back(game->GetPlayer()->GetStat(attribute));
|
statsBeforeEquip.push_back(game->GetPlayer()->GetStat(attribute));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::weak_ptr<Item>equippedItem=Inventory::GetEquip(slot);
|
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);
|
Inventory::EquipItem(buttonItem,slot);
|
||||||
for(int counter=0;const std::string&attribute:displayAttrs){
|
for(int counter=0;const std::string&attribute:displayAttrs){
|
||||||
StatLabel*statDisplayLabel=Component<StatLabel>(CHARACTER_MENU,"Attribute "+std::string(ItemAttribute::Get(attribute).Name())+" Label");
|
StatLabel*statDisplayLabel=Component<StatLabel>(CHARACTER_MENU,"Attribute "+std::string(ItemAttribute::Get(attribute).Name())+" Label");
|
||||||
@@ -181,6 +186,11 @@ void Menu::InitializeCharacterMenuWindow(){
|
|||||||
if(!ISBLANK(equippedItem)){
|
if(!ISBLANK(equippedItem)){
|
||||||
Inventory::EquipItem(equippedItem,slot);
|
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{
|
}else{
|
||||||
ERR("WARNING! Attempting to cast a button that isn't a RowItemDisplay!");
|
ERR("WARNING! Attempting to cast a button that isn't a RowItemDisplay!");
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-1
@@ -919,7 +919,17 @@ void Item::SetAmt(uint32_t newAmt){
|
|||||||
}
|
}
|
||||||
|
|
||||||
const std::weak_ptr<Item>Inventory::GetInventorySlot(ITCategory itemCategory,size_t slot){
|
const std::weak_ptr<Item>Inventory::GetInventorySlot(ITCategory itemCategory,size_t slot){
|
||||||
return GetItem(get(itemCategory).at(slot)->ActualName())[0];
|
auto GetFirstIndex = [](ITCategory itemCategory,size_t slot){
|
||||||
|
auto firstIter=std::find_if(get(itemCategory).begin(),get(itemCategory).end(),[&](std::shared_ptr<Item>item){
|
||||||
|
if(item->ActualName()==get(itemCategory).at(slot)->ActualName())return true;
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
size_t firstIndex=firstIter-get(itemCategory).begin();
|
||||||
|
if(firstIter==get(itemCategory).end())ERR(std::format("Invalid slot {} for category {} specified!",slot,itemCategory));
|
||||||
|
return firstIndex;
|
||||||
|
};
|
||||||
|
|
||||||
|
return GetItem(get(itemCategory).at(slot)->ActualName())[slot-GetFirstIndex(itemCategory,slot)];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Item::IsBlank(std::shared_ptr<Item>item){
|
bool Item::IsBlank(std::shared_ptr<Item>item){
|
||||||
|
|||||||
+1
-1
@@ -39,7 +39,7 @@ All rights reserved.
|
|||||||
#define VERSION_MAJOR 0
|
#define VERSION_MAJOR 0
|
||||||
#define VERSION_MINOR 2
|
#define VERSION_MINOR 2
|
||||||
#define VERSION_PATCH 1
|
#define VERSION_PATCH 1
|
||||||
#define VERSION_BUILD 5140
|
#define VERSION_BUILD 5143
|
||||||
|
|
||||||
#define stringify(a) stringify_(a)
|
#define stringify(a) stringify_(a)
|
||||||
#define stringify_(a) #a
|
#define stringify_(a) #a
|
||||||
|
|||||||
Reference in New Issue
Block a user