The open source repository for the action RPG game in development by Sig Productions titled 'Adventures in Lestoria'! https://forums.lestoria.net
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
AdventuresInLestoria/Crawler/InventoryWindow.cpp

37 lines
1.8 KiB

#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<float>(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<float>(vf2d{2,float(initialInvHeight*totalSpacing+itemSpacing)},{windowSize.x-4,windowSize.y-108}),"",1,ComponentAttr::SHADOW};
inventoryWindow->AddComponent("itemDescription",itemDescriptionLabel);
}