Incorporate dynamic pointer cast fix
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
@@ -56,11 +56,11 @@ void Menu::InitializeConsumableInventoryWindow(){
|
||||
|
||||
auto consumableWindow=inventoryWindow->ADD("inventory",InventoryScrollableWindowComponent)(geom2d::rect<float>{{0,15},{windowSize.x,96.f}},"itemName","itemDescription",
|
||||
[&](MenuFuncData data){
|
||||
std::weak_ptr<MenuItemButton>button=dynamic_pointer_cast<MenuItemButton>(data.component.lock());
|
||||
std::weak_ptr<MenuItemButton>button=DYNAMIC_POINTER_CAST<MenuItemButton>(data.component.lock());
|
||||
data.game->ClearLoadoutItem(data.menu.I(A::LOADOUT_SLOT));
|
||||
for(std::weak_ptr<MenuComponent>component:data.parentComponent.lock()->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.lock()->GetName().starts_with("item")){
|
||||
std::weak_ptr<MenuItemButton>button2=dynamic_pointer_cast<MenuItemButton>(component.lock());//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.
|
||||
std::weak_ptr<MenuItemButton>button2=DYNAMIC_POINTER_CAST<MenuItemButton>(component.lock());//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.expired())ERR("Could not cast item to a MenuItemButton*!");
|
||||
if(&*button2.lock()==&*button.lock()){
|
||||
if(button2.lock()->selected!=-1){
|
||||
|
||||
Reference in New Issue
Block a user