2023-10-07 13:33:27 -05:00
#pragma once
#include "Crawler.h"
#include "olcPixelGameEngine.h"
#include "safemap.h"
#include "Item.h"
2023-10-07 15:47:26 -05:00
#include "MenuItemButton.h"
2023-10-07 19:06:56 -05:00
#include "MenuLabel.h"
2023-10-18 18:07:10 +00:00
#include "InventoryScrollableWindowComponent.h"
2023-10-07 13:33:27 -05:00
typedef Attribute A ;
2023-10-15 12:58:39 -05:00
void Menu :: InitializeInventoryWindow (){
2023-10-17 05:35:19 -05:00
int invWidth = "ThemeGlobal.InventoryWidth" _I ;
int initialInvHeight = "ThemeGlobal.InventoryHeight" _I ;
2023-10-07 13:33:27 -05:00
2023-10-17 05:35:19 -05:00
int itemSpacing = "ThemeGlobal.InventoryItemSpacing" _I ;
int buttonSize = "ThemeGlobal.InventoryButtonSize" _I ;
int totalSpacing = buttonSize + itemSpacing ;
2023-10-07 13:33:27 -05:00
2023-10-17 05:35:19 -05:00
vf2d windowSize = { float ( totalSpacing * invWidth - itemSpacing + 2 + 24 ), float ( totalSpacing * ( 3 + 1 ) - itemSpacing + 24 )}; //Need space for the button.
2023-10-11 19:50:12 -05:00
2023-10-15 12:58:39 -05:00
Menu * inventoryWindow = CreateMenu ( INVENTORY , CENTERED , windowSize );
2023-10-07 15:47:26 -05:00
2023-10-18 18:07:10 +00:00
InventoryScrollableWindowComponent * inventory = new InventoryScrollableWindowComponent ( INVENTORY ,{{ 1 , 0 },{ windowSize . x , float ( totalSpacing * 3 - itemSpacing )}}, nullptr ,[]( MenuFuncData data ){});
2023-10-12 18:35:45 -05:00
inventoryWindow -> AddComponent ( "inventory" , inventory );
2023-10-18 16:06:08 +00:00
Menu :: AddInventoryListener ( inventory , "Consumables" );
Menu :: AddInventoryListener ( inventory , "Equipment" );
Menu :: AddInventoryListener ( inventory , "Accessories" );
Menu :: AddInventoryListener ( inventory , "Materials" );
2023-10-12 18:35:45 -05:00
2023-10-17 05:35:19 -05:00
//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.
2023-10-07 15:47:26 -05:00
2023-10-20 22:49:12 -05:00
MenuLabel * itemNameLabel = new MenuLabel { INVENTORY , geom2d :: rect < float > ( vf2d { 2 , float ( initialInvHeight * totalSpacing - 4 )}, windowSize ), "" , 1 , false , true };
2023-10-11 16:20:07 -05:00
inventoryWindow -> AddComponent ( "itemName" , itemNameLabel );
2023-10-20 22:49:12 -05:00
MenuLabel * itemDescriptionLabel = new MenuLabel { INVENTORY , geom2d :: rect < float > ( vf2d { 2 , float ( initialInvHeight * totalSpacing + itemSpacing )},{ windowSize . x - 4 , windowSize . y - 108 }), "" , 1 , true , true };
2023-10-11 16:20:07 -05:00
inventoryWindow -> AddComponent ( "itemDescription" , itemDescriptionLabel );
2023-10-07 13:33:27 -05:00
}