@ -44,6 +44,7 @@ All rights reserved.
# include "RowInventoryScrollableWindowComponent.h"
# include "EnhancementStatsLabel.h"
# include "RequiredMaterialsList.h"
# include "SoundEffect.h"
INCLUDE_game
INCLUDE_ITEM_CATEGORIES
@ -52,9 +53,13 @@ INCLUDE_GFX
void Menu : : InitializeConsumableCraftingWindow ( ) {
Menu * consumableCraftingWindow = CreateMenu ( CRAFT_CONSUMABLE , CENTERED , game - > GetScreenSize ( ) - vi2d { 52 , 52 } ) ;
float windowWidth = consumableCraftingWindow - > size . x ;
consumableCraftingWindow - > ADD ( " Craft Consumables Header " , MenuLabel ) ( geom2d : : rect < float > { { 0 , 0 } , { windowWidth , 24 } } , " Consumable Crafting " , 2.f , ComponentAttr : : BACKGROUND | ComponentAttr : : SHADOW | ComponentAttr : : OUTLINE ) END ;
# pragma region Craftables Inventory Display
auto craftingItemsDisplay = consumableCraftingWindow - > ADD ( " Crafting Inventory Display " , RowInventoryScrollableWindowComponent ) ( geom2d : : rect < float > { { 2 , 28 } , { 220 , consumableCraftingWindow - > size . y - 44 } } , " Item Name Label " , " Item Description Label " ,
auto craftingItemsDisplay = consumableCraftingWindow - > ADD ( " Crafting Inventory Display " , RowInventoryScrollableWindowComponent ) ( geom2d : : rect < float > { { 0 , 28 } , { 222 , consumableCraftingWindow - > size . y - 44 } } , " Item Name Label " , " Item Description Label " ,
[ ] ( MenuFuncData data ) {
std : : weak_ptr < RowItemDisplay > comp = DYNAMIC_POINTER_CAST < RowItemDisplay > ( data . component . lock ( ) ) ;
const std : : weak_ptr < Item > item = comp . lock ( ) - > GetItem ( ) ;
@ -65,6 +70,8 @@ void Menu::InitializeConsumableCraftingWindow(){
Component < MenuComponent > ( CONSUMABLE_CRAFT_ITEM , " Craft Button " ) - > SetGrayedOut ( ! item . lock ( ) - > CanEnhanceItem ( ) ) ;
if ( item . lock ( ) - > GetEnhancementInfo ( ) [ 0 ] . chapterAvailable < = game - > GetCurrentChapter ( ) ) {
Menu : : OpenMenu ( CONSUMABLE_CRAFT_ITEM ) ;
} else {
SoundEffect : : PlaySFX ( " Locked Item " , SoundEffect : : CENTERED ) ;
}
return true ;
} ,
@ -83,7 +90,7 @@ void Menu::InitializeConsumableCraftingWindow(){
return true ;
} ,
InventoryCreator : : RowPlayerWeapons_InventoryUpdate ,
InventoryWindowOptions { . padding = 1 , . size = { 207 , 28 } }
InventoryWindowOptions { . padding = 1 , . size = { 209 , 28 } }
) END ;
craftingItemsDisplay - > SetCompactDescriptions ( CRAFTING_INFO ) ;
@ -134,4 +141,78 @@ void Menu::InitializeConsumableCraftingWindow(){
Menu : : CloseMenu ( ) ;
return true ;
} , vf2d { 2.f , 2.f } ) END ;
consumableCraftingWindow - > SetupKeyboardNavigation (
[ ] ( MenuType type , Data & returnData ) { //On Open
auto & craftingList = Component < RowInventoryScrollableWindowComponent > ( type , " Crafting Inventory Display " ) - > GetComponents ( ) ;
if ( craftingList . size ( ) > 0 ) {
returnData = craftingList [ 0 ] ;
} else {
returnData = " Back Button " ;
}
} ,
{ //Button Key
{ { game - > KEY_SHOULDER , Pressed } , { " Scroll Up/Down " , [ ] ( MenuType type ) { } } } ,
{ { game - > KEY_FASTSCROLLDOWN , PressedDAS } , { " " , [ & ] ( MenuType type ) {
if ( ! Menu : : menus [ type ] - > GetSelection ( ) . expired ( ) & &
! Menu : : menus [ type ] - > GetSelection ( ) . lock ( ) - > parentComponent . expired ( ) ) {
Menu : : menus [ type ] - > GetSelection ( ) . lock ( ) - > parentComponent . lock ( ) - > IncreaseSelectionIndex ( 3.f ) ;
}
} } } ,
{ { game - > KEY_FASTSCROLLUP , PressedDAS } , { " " , [ & ] ( MenuType type ) {
if ( ! Menu : : menus [ type ] - > GetSelection ( ) . expired ( ) & &
! Menu : : menus [ type ] - > GetSelection ( ) . lock ( ) - > parentComponent . expired ( ) ) {
Menu : : menus [ type ] - > GetSelection ( ) . lock ( ) - > parentComponent . lock ( ) - > IncreaseSelectionIndex ( - 3.f ) ;
}
} } } ,
{ { game - > KEY_SCROLL , Pressed } , { " Navigate " , [ ] ( MenuType type ) { } } } ,
{ game - > KEY_BACK , { " Back " , [ ] ( MenuType type ) {
Menu : : CloseMenu ( ) ;
} } } ,
{ game - > KEY_CONFIRM , { " Select " , [ ] ( MenuType type ) { } } } ,
}
, { //Button Navigation Rules
{ " Back Button " , {
. up = [ ] ( MenuType type , Data & returnData ) {
auto & itemList = Component < RowInventoryScrollableWindowComponent > ( type , " Crafting Inventory Display " ) - > GetComponents ( ) ;
if ( itemList . size ( ) > 0 ) {
returnData = itemList [ itemList . size ( ) - 1 ] ;
} else {
returnData = " Back Button " ;
}
} ,
. down = [ ] ( MenuType type , Data & returnData ) {
auto & itemList = Component < RowInventoryScrollableWindowComponent > ( type , " Crafting Inventory Display " ) - > GetComponents ( ) ;
if ( itemList . size ( ) > 0 ) {
returnData = itemList [ 0 ] ;
} else {
returnData = " Back Button " ;
}
} , } } ,
{ " Crafting Inventory Display " , {
. up = [ ] ( MenuType type , Data & returnData ) {
auto itemDisplay = Component < RowInventoryScrollableWindowComponent > ( type , " Crafting Inventory Display " ) ;
size_t selectedIndex = itemDisplay - > GetComponentIndex ( Menu : : menus [ type ] - > GetSelection ( ) ) ;
if ( selectedIndex ! = itemDisplay - > GetComponents ( ) . size ( ) ) {
selectedIndex - - ;
if ( selectedIndex > = itemDisplay - > GetComponents ( ) . size ( ) ) {
returnData = " Back Button " ;
} else {
returnData = itemDisplay - > GetComponents ( ) [ selectedIndex ] ;
}
} else ERR ( " WARNING! Could not get selected item within crafting inventory display! THIS SHOULD NOT BE HAPPENING! " )
} ,
. down = [ ] ( MenuType type , Data & returnData ) {
auto itemDisplay = Component < RowInventoryScrollableWindowComponent > ( type , " Crafting Inventory Display " ) ;
size_t selectedIndex = itemDisplay - > GetComponentIndex ( Menu : : menus [ type ] - > GetSelection ( ) ) ;
if ( selectedIndex ! = itemDisplay - > GetComponents ( ) . size ( ) ) {
selectedIndex + + ;
if ( selectedIndex > = itemDisplay - > GetComponents ( ) . size ( ) ) {
returnData = " Back Button " ;
} else {
returnData = itemDisplay - > GetComponents ( ) [ selectedIndex ] ;
}
} else ERR ( " WARNING! Could not get selected item within crafting inventory display! THIS SHOULD NOT BE HAPPENING! " )
} , } } ,
} ) ;
}