#pragma once #include "Crawler.h" #include "olcPixelGameEngine.h" #include "safemap.h" #include "Item.h" #include "MenuItemButton.h" #include "MenuLabel.h" #include "InventoryScrollableWindowComponent.h" typedef Attribute A; void Menu::InitializeInventoryWindow(){ int invWidth="ThemeGlobal.InventoryWidth"_I; int initialInvHeight="ThemeGlobal.InventoryHeight"_I; int itemSpacing="ThemeGlobal.InventoryItemSpacing"_I; int buttonSize="ThemeGlobal.InventoryButtonSize"_I; int totalSpacing=buttonSize+itemSpacing; vf2d windowSize={float(totalSpacing*invWidth-itemSpacing+2+24),float(totalSpacing*(3+1)-itemSpacing+24)}; //Need space for the button. Menu*inventoryWindow=CreateMenu(INVENTORY,CENTERED,windowSize); InventoryScrollableWindowComponent*inventory=NEW InventoryScrollableWindowComponent(INVENTORY,{{1,0},{windowSize.x,float(totalSpacing*3-itemSpacing)}},nullptr,[](MenuFuncData data){}); inventoryWindow->AddComponent("inventory",inventory); Menu::AddInventoryListener(inventory,"Consumables"); Menu::AddInventoryListener(inventory,"Equipment"); Menu::AddInventoryListener(inventory,"Accessories"); Menu::AddInventoryListener(inventory,"Materials"); //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. MenuLabel*itemNameLabel=NEW MenuLabel{INVENTORY,geom2d::rect(vf2d{2,float(initialInvHeight*totalSpacing+itemSpacing-16)},{windowSize.x-4,windowSize.y-108}),"",1,ComponentAttr::SHADOW}; inventoryWindow->AddComponent("itemName",itemNameLabel); MenuLabel*itemDescriptionLabel=NEW MenuLabel{INVENTORY,geom2d::rect(vf2d{2,float(initialInvHeight*totalSpacing+itemSpacing)},{windowSize.x-4,windowSize.y-108}),"",1,ComponentAttr::SHADOW}; inventoryWindow->AddComponent("itemDescription",itemDescriptionLabel); }