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-11-13 21:26:34 -06:00
inventoryWindow - > I ( A : : LOADOUT_SLOT ) = 0 ;
2023-11-11 17:31:53 -06:00
InventoryScrollableWindowComponent * inventory = NEW InventoryScrollableWindowComponent ( INVENTORY , { { 1 , 0 } , { windowSize . x , float ( totalSpacing * 3 - itemSpacing ) } } ) ;
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-11-11 00:54:50 -06:00
MenuLabel * itemNameLabel = NEW MenuLabel { INVENTORY , geom2d : : rect < float > ( vf2d { 2 , float ( initialInvHeight * totalSpacing + itemSpacing - 16 ) } , { windowSize . x - 4 , windowSize . y - 108 } ) , " " , 1 , ComponentAttr : : SHADOW } ;
2023-10-11 16:20:07 -05:00
inventoryWindow - > AddComponent ( " itemName " , itemNameLabel ) ;
2023-11-11 00:54:50 -06:00
MenuLabel * itemDescriptionLabel = NEW MenuLabel { INVENTORY , geom2d : : rect < float > ( vf2d { 2 , float ( initialInvHeight * totalSpacing + itemSpacing ) } , { windowSize . x - 4 , windowSize . y - 108 } ) , " " , 1 , ComponentAttr : : SHADOW } ;
2023-10-11 16:20:07 -05:00
inventoryWindow - > AddComponent ( " itemDescription " , itemDescriptionLabel ) ;
2023-10-07 13:33:27 -05:00
}