Refactored dynamic cast to do internal error checking. Refactored all inventory and button slot update functions in menu components so they no longer require virtual dispatch when all we require is some passing of lamba functions to update inventories.
This commit is contained in:
@@ -90,7 +90,7 @@ void Menu::InitializeInventoryWindow(){
|
||||
|
||||
auto inventoryDisplay=inventoryWindow->ADD("Inventory Display - "+category,RowInventoryScrollableWindowComponent)({{72,28},{150,inventoryWindow->size.y-44}},"Item Name Label","Item Description Label",DO_NOTHING,
|
||||
[](MenuFuncData data){
|
||||
Component<MenuItemItemButton>(data.menu.GetType(),"Item Icon")->SetItem(dynamic_cast<RowItemDisplay*>(data.component)->GetItem());
|
||||
Component<MenuItemItemButton>(data.menu.GetType(),"Item Icon")->SetItem(DYNAMIC_CAST<RowItemDisplay*>(data.component)->GetItem());
|
||||
Component<MenuItemItemButton>(data.menu.GetType(),"Item Icon")->UpdateIcon();
|
||||
return true;
|
||||
},
|
||||
@@ -98,7 +98,9 @@ void Menu::InitializeInventoryWindow(){
|
||||
Component<MenuItemItemButton>(data.menu.GetType(),"Item Icon")->SetItem(Item::BLANK);
|
||||
Component<MenuItemItemButton>(data.menu.GetType(),"Item Icon")->UpdateIcon();
|
||||
return true;
|
||||
},{.padding=1,.size={137,28}})END;
|
||||
},
|
||||
InventoryCreator::RowPlayer_InventoryUpdate,
|
||||
{.padding=1,.size={137,28}})END;
|
||||
|
||||
if(first){
|
||||
inventoryWindow->S(A::LAST_INVENTORY_TYPE_OPENED)=category;
|
||||
|
||||
Reference in New Issue
Block a user