Corrected bug for removing sub-component items that were not selectable (and thus, were never added to button navigation lists)
This commit is contained in:
@@ -56,7 +56,28 @@ void Menu::InitializeConsumableInventoryWindow(){
|
||||
|
||||
inventoryWindow->I(A::LOADOUT_SLOT)=0;
|
||||
|
||||
InventoryScrollableWindowComponent*inventory=NEW InventoryScrollableWindowComponent(INVENTORY,{{1,20},{windowSize.x,float(totalSpacing*3-itemSpacing)}},"Consumables","itemName","itemDescription");
|
||||
InventoryScrollableWindowComponent*inventory=NEW InventoryScrollableWindowComponent(INVENTORY,{{1,20},{windowSize.x,float(totalSpacing*3-itemSpacing)}},"Consumables","itemName","itemDescription",
|
||||
[&](MenuFuncData data){
|
||||
MenuItemButton*button=(MenuItemButton*)data.component;
|
||||
data.game->ClearLoadoutItem(data.menu.I(A::LOADOUT_SLOT));
|
||||
for(MenuComponent*component:data.parentComponent->GetComponents()){ //HACK ALERT! If we are accessing a parent component, it's because we are dealing with a scrolling window component, which has sub-components. So this should be a safe cast to make.
|
||||
if(component->GetName().starts_with("item")){
|
||||
MenuItemButton*button2=(MenuItemButton*)component;//HACK ALERT! This is probably an item since we populated item lists using this name for the components. So we assume these are MenuItemButton classes.
|
||||
if(button2==button){
|
||||
if(button2->selected!=-1){
|
||||
data.game->ClearLoadoutItem(button2->selected);
|
||||
}
|
||||
button2->selected=-1;
|
||||
}
|
||||
if(button2->selected==data.menu.I(A::LOADOUT_SLOT)){
|
||||
button2->selected=-1;
|
||||
}
|
||||
}
|
||||
}
|
||||
button->selected=data.menu.I(A::LOADOUT_SLOT);
|
||||
data.game->SetLoadoutItem(button->selected,button->GetItem().Name());
|
||||
return true;
|
||||
});
|
||||
inventoryWindow->AddComponent("inventory",inventory);
|
||||
|
||||
//We don't have to actually populate the inventory list because now when an item gets added, it will automatically add the correct component in for us.
|
||||
|
||||
Reference in New Issue
Block a user