Converted menu storage to pointers.
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
INCLUDE_GFX
|
||||
typedef Attribute A;
|
||||
|
||||
const Menu Menu::InitializeInventoryWindow(){
|
||||
Menu*Menu::InitializeInventoryWindow(){
|
||||
constexpr int invWidth=5;
|
||||
constexpr int invHeight=3;
|
||||
constexpr int totalItemSlots=invWidth*invHeight;
|
||||
@@ -19,7 +19,7 @@ const Menu Menu::InitializeInventoryWindow(){
|
||||
constexpr int buttonSize=24;
|
||||
constexpr int totalSpacing=buttonSize+itemSpacing;
|
||||
|
||||
Menu inventoryWindow(CENTERED,{totalSpacing*invWidth-itemSpacing,totalSpacing*(invHeight+1)-itemSpacing});
|
||||
Menu*inventoryWindow=new Menu(CENTERED,{totalSpacing*invWidth-itemSpacing,totalSpacing*(invHeight+1)-itemSpacing});
|
||||
|
||||
MenuFunc useItemFunc=[](MenuFuncData data){
|
||||
MenuItemButton*button=(MenuItemButton*)data.component;
|
||||
@@ -30,14 +30,14 @@ const Menu Menu::InitializeInventoryWindow(){
|
||||
for(int x=0;x<invWidth;x++){
|
||||
int itemIndex=y*invWidth+x;
|
||||
MenuItemButton*button=new MenuItemButton{INVENTORY,{{float(totalSpacing*x),float(totalSpacing*y)},{float(buttonSize),float(buttonSize)}},Inventory::get("Consumables"),itemIndex,useItemFunc};
|
||||
inventoryWindow.AddComponent("item"+std::to_string(itemIndex),button);
|
||||
inventoryWindow->AddComponent("item"+std::to_string(itemIndex),button);
|
||||
}
|
||||
}
|
||||
|
||||
MenuLabel*itemNameLabel=new MenuLabel{INVENTORY,vf2d{0,invHeight*totalSpacing-4},"",false,true};
|
||||
inventoryWindow.AddComponent("itemName",itemNameLabel);
|
||||
MenuLabel*itemDescriptionLabel=new MenuLabel{INVENTORY,vf2d{2+inventoryWindow.size.x/2,invHeight*totalSpacing+4+itemSpacing},"",true,true};
|
||||
inventoryWindow.AddComponent("itemDescription",itemDescriptionLabel);
|
||||
inventoryWindow->AddComponent("itemName",itemNameLabel);
|
||||
MenuLabel*itemDescriptionLabel=new MenuLabel{INVENTORY,vf2d{2+inventoryWindow->size.x/2,invHeight*totalSpacing+4+itemSpacing},"",true,true};
|
||||
inventoryWindow->AddComponent("itemDescription",itemDescriptionLabel);
|
||||
|
||||
return inventoryWindow;
|
||||
}
|
||||
Reference in New Issue
Block a user