Added hover button functionality to MenuItemButton component and to InventorySrollableWindowComponent item buttons created via that component. Implemented inventory screen.

This commit is contained in:
2023-12-12 05:20:51 -06:00
parent e4f63a3550
commit 5abc789bcd
8 changed files with 142 additions and 36 deletions
+27 -1
View File
@@ -40,6 +40,9 @@ All rights reserved.
#include "Menu.h"
#include "MenuLabel.h"
#include "InventoryScrollableWindowComponent.h"
#include "MenuIconButton.h"
#include "MenuItemButton.h"
#include "MenuItemItemButton.h"
INCLUDE_game
INCLUDE_ITEM_CATEGORIES
@@ -84,7 +87,15 @@ void Menu::InitializeInventoryWindow(){
button->SetSelectionType(HIGHLIGHT);
button->S(A::CATEGORY_NAME)=category;
auto inventoryDisplay=inventoryWindow->ADD("Inventory Display - "+category,InventoryScrollableWindowComponent)({{72,28},{150,inventoryWindow->size.y-44}},category,"","",DO_NOTHING)END;
auto inventoryDisplay=inventoryWindow->ADD("Inventory Display - "+category,InventoryScrollableWindowComponent)({{72,28},{150,inventoryWindow->size.y-44}},category,"Item Name Label","Item Description Label",DO_NOTHING,
[](MenuFuncData data){
Component<MenuItemItemButton>(data.menu.GetType(),"Item Icon")->SetItem(dynamic_cast<MenuItemButton*>(data.component)->GetItem());
return true;
},
[](MenuFuncData data){
Component<MenuItemItemButton>(data.menu.GetType(),"Item Icon")->SetItem(Item::BLANK);
return true;
})END;
if(first){
lastInventoryTypeOpened=category;
@@ -92,9 +103,24 @@ void Menu::InitializeInventoryWindow(){
}
inventoryDisplay->Enable(first);
inventoryDisplay->SetCompactDescriptions(false);
yOffset+=20;
first=false;
}
#pragma endregion
#pragma region Inventory Description
float inventoryDescriptionWidth=inventoryWindow->pos.x+inventoryWindow->size.x-26-224;
inventoryWindow->ADD("Item Description Outline",MenuLabel)({{224,28},{inventoryDescriptionWidth,inventoryWindow->size.y-44}},"",1,LEFT_ALIGN|OUTLINE|BACKGROUND)END
->decal=true;
auto itemIcon=inventoryWindow->ADD("Item Icon",MenuItemItemButton)({{226+inventoryDescriptionWidth/2-24,30},{48,48}},Item::BLANK,MenuType::ENUM_END,DO_NOTHING,"","",IconButtonAttr::NOT_SELECTABLE)END;
itemIcon->SetShowQuantity(false);
itemIcon->decal=true;
inventoryWindow->ADD("Item Name Label",MenuLabel)({{226,84},{inventoryDescriptionWidth-6,12}},"",0.75f,LEFT_ALIGN|SHADOW)END
->decal=true;
inventoryWindow->ADD("Item Description Label",MenuLabel)({{226,94},{inventoryDescriptionWidth-6,inventoryWindow->size.y-44-66}},"",0.5f,LEFT_ALIGN|SHADOW)END
->decal=true;
#pragma endregion
}