|
|
|
#pragma once
|
|
|
|
#include "Crawler.h"
|
|
|
|
#include "DEFINES.h"
|
|
|
|
#include "olcPixelGameEngine.h"
|
|
|
|
#include "safemap.h"
|
|
|
|
#include "Item.h"
|
|
|
|
#include "MenuItemButton.h"
|
|
|
|
|
|
|
|
INCLUDE_GFX
|
|
|
|
typedef Attribute A;
|
|
|
|
|
|
|
|
const Menu Menu::InitializeInventoryWindow(){
|
|
|
|
constexpr int invWidth=5;
|
|
|
|
constexpr int invHeight=3;
|
|
|
|
constexpr int totalItemSlots=invWidth*invHeight;
|
|
|
|
|
|
|
|
constexpr int itemSpacing=8;
|
|
|
|
constexpr int buttonSize=24;
|
|
|
|
constexpr int totalSpacing=buttonSize+itemSpacing;
|
|
|
|
|
|
|
|
Menu inventoryWindow(CENTERED,{totalSpacing*invWidth-itemSpacing,totalSpacing*(invHeight+1)-itemSpacing});
|
|
|
|
|
|
|
|
MenuFunc useItemFunc=[](MenuFuncData data){
|
|
|
|
MenuItemButton*button=(MenuItemButton*)data.component;
|
|
|
|
button->UseItem();
|
|
|
|
};
|
|
|
|
|
|
|
|
for(int y=0;y<invHeight;y++){
|
|
|
|
for(int x=0;x<invWidth;x++){
|
|
|
|
int itemIndex=y*invWidth+x;
|
|
|
|
MenuItemButton*button=new MenuItemButton{{{float(totalSpacing*x),float(totalSpacing*y)},{float(buttonSize),float(buttonSize)}},Inventory::get("Consumables"),itemIndex,useItemFunc};
|
|
|
|
inventoryWindow.AddComponent("item"+std::to_string(itemIndex),button);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return inventoryWindow;
|
|
|
|
}
|