Implemented Loadout selection item buttons, corrected inventory window missing category variables, corrected loadout item selection logic, updated inventory window layout.

This commit is contained in:
2023-11-14 23:20:13 -06:00
parent 0c9a341e89
commit f427928ca6
19 changed files with 289 additions and 87 deletions
-29
View File
@@ -749,33 +749,4 @@ void Player::ConsumeMana(int amt){
void Player::SetSizeMult(float size){
this->size=size;
}
Item&Player::GetLoadoutItem(int slot){
if(slot<0||slot>loadout.size()-1)ERR("Invalid inventory slot "+std::to_string(slot)+", please choose a slot in range (0-"+std::to_string(loadout.size()-1)+").");
return loadout[slot];
}
void Player::SetLoadoutItem(int slot,std::string itemName){
if(slot<0||slot>loadout.size()-1)ERR("Invalid inventory slot "+std::to_string(slot)+", please choose a slot in range (0-"+std::to_string(loadout.size()-1)+").");
if(Inventory::GetItemCount(itemName)>0){
GetLoadoutItem(slot)=Inventory::GetItem(itemName);
GetLoadoutItem(slot).amt=std::min((uint32_t)"Player.Item Loadout Limit"_I,GetLoadoutItem(slot).Amt()); //We are only allowed to have up to 10 maximum of an item on a journey.
}else{
ERR("Trying to set item "+itemName+" in Loadout slot "+std::to_string(slot)+" when said item does not exist in our inventory!");
}
}
void Player::UseLoadoutItem(int slot){
if(slot<0||slot>loadout.size()-1)ERR("Invalid inventory slot "+std::to_string(slot)+", please choose a slot in range (0-"+std::to_string(loadout.size()-1)+").");
if(GetLoadoutItem(slot).Amt()>0){
Inventory::UseItem(loadout[slot].Name());
GetLoadoutItem(slot).OnUseAction();
GetLoadoutItem(slot).amt--;
}
}
void Player::ClearLoadoutItem(int slot){
if(slot<0||slot>loadout.size()-1)ERR("Invalid inventory slot "+std::to_string(slot)+", please choose a slot in range (0-"+std::to_string(loadout.size()-1)+").");
loadout[slot]={};
}