@ -46,6 +46,7 @@ All rights reserved.
# include "EquipSlotButton.h"
# include "Item.h"
# include "ScrollableWindowComponent.h"
# include "RowItemDisplay.h"
INCLUDE_game
INCLUDE_GFX
@ -133,26 +134,37 @@ void Menu::InitializeCharacterMenuWindow(){
ScrollableWindowComponent * equipList = Component < ScrollableWindowComponent > ( data . component - > parentMenu , " Equip List " ) ;
equipList - > RemoveAllComponents ( ) ;
for ( int counter = 0 ; Item & it : availableEquipment ) {
float xOffset = ( counter % 3 ) * 26 ;
Item & itemInvRef = Inventory : : GetItem ( it . Name ( ) ) ;
auto equip = equipList - > ADD ( " Equip Item " + std : : to_string ( counter ) , MenuItemItemButton ) ( { { 2 + xOffset , 2 } , { 24 , 24 } } , itemInvRef , MenuType : : ENUM_END ,
auto equip = equipList - > ADD ( " Equip Item " + std : : to_string ( counter ) , RowItemDisplay ) ( { { 2 , 2 + counter * 28.f } , { 120 - 12 , 28 } } , itemInvRef ,
[ ] ( MenuFuncData data ) {
MenuItemItemButton * comp = ( MenuItemItemButton * ) data . component ;
Inventory : : EquipItem ( comp - > GetItem ( ) , EquipSlot ( comp - > I ( Attribute : : EQUIP_TYPE ) ) ) ;
for ( MenuComponent * button : ( ( ScrollableWindowComponent * ) data . parentComponent ) - > GetComponents ( ) ) {
MenuItemItemButton * comp = ( MenuItemItemButton * ) button ;
comp - > SetSelected ( false ) ;
}
comp - > SetSelected ( true ) ;
for ( int counter = 0 ; ItemAttribute attribute : displayAttrs ) {
StatLabel * statDisplayLabel = Component < StatLabel > ( CHARACTER_MENU , " Attribute " + ItemAttributable : : GetDisplayInfo ( attribute ) . name + " Label " ) ;
statDisplayLabel - > SetStatChangeAmt ( 0 ) ;
RowItemDisplay * comp = dynamic_cast < RowItemDisplay * > ( data . component ) ;
if ( comp ! = nullptr ) {
Inventory : : EquipItem ( comp - > GetItem ( ) , EquipSlot ( comp - > I ( Attribute : : EQUIP_TYPE ) ) ) ;
for ( MenuComponent * button : ( ( ScrollableWindowComponent * ) data . parentComponent ) - > GetComponents ( ) ) {
RowItemDisplay * comp = dynamic_cast < RowItemDisplay * > ( button ) ;
if ( comp ! = nullptr ) {
comp - > SetSelected ( false ) ;
} else {
ERR ( " WARNING! Attempting to cast a button that isn't a RowItemDisplay! " ) ;
}
}
comp - > SetSelected ( true ) ;
for ( int counter = 0 ; ItemAttribute attribute : displayAttrs ) {
StatLabel * statDisplayLabel = Component < StatLabel > ( CHARACTER_MENU , " Attribute " + ItemAttributable : : GetDisplayInfo ( attribute ) . name + " Label " ) ;
statDisplayLabel - > SetStatChangeAmt ( 0 ) ;
}
MenuItemItemButton * equipButton = Component < MenuItemItemButton > ( CHARACTER_MENU , " Equip Slot " + slotNames [ data . parentComponent - > I ( A : : INDEXED_THEME ) ] ) ;
equipButton - > SetItem ( comp - > GetItem ( ) ) ;
} else {
ERR ( " WARNING! Attempting to cast a button that isn't a RowItemDisplay! " ) ;
}
MenuItemItemButton * equipButton = Component < MenuItemItemButton > ( CHARACTER_MENU , " Equip Slot " + slotNames [ data . parentComponent - > I ( A : : INDEXED_THEME ) ] ) ;
equipButton - > SetItem ( comp - > GetItem ( ) ) ;
return true ;
} , [ & ] ( MenuFuncData data ) {
MenuItemItemButton * button = ( MenuItemItemButton * ) data . component ;
} , " Item Name " , " Item Description " ) END ;
equip - > SetHoverFunc (
[ & ] ( MenuFuncData data ) {
RowItemDisplay * button = dynamic_cast < RowItemDisplay * > ( data . component ) ;
if ( button ! = nullptr ) {
Item & buttonItem = button - > GetItem ( ) ;
std : : vector < int > statsBeforeEquip ;
EquipSlot slot = EquipSlot ( button - > I ( Attribute : : EQUIP_TYPE ) ) ;
@ -171,16 +183,24 @@ void Menu::InitializeCharacterMenuWindow(){
if ( * equippedItem ! = Item : : BLANK ) {
Inventory : : EquipItem ( * equippedItem , slot ) ;
}
} else {
ERR ( " WARNING! Attempting to cast a button that isn't a RowItemDisplay! " ) ;
}
return true ;
} , [ ] ( MenuFuncData data ) {
} ) ;
equip - > SetMouseOutFunc (
[ ] ( MenuFuncData data ) {
for ( int counter = 0 ; ItemAttribute attribute : displayAttrs ) {
StatLabel * statDisplayLabel = Component < StatLabel > ( CHARACTER_MENU , " Attribute " + ItemAttributable : : GetDisplayInfo ( attribute ) . name + " Label " ) ;
statDisplayLabel - > SetStatChangeAmt ( 0 ) ;
counter + + ;
}
return true ;
} , " Item Name " , " Item Description " ) END ;
} ) ;
equip - > SetShowQuantity ( false ) ;
equip - > SetSelectionType ( SelectionType : : NONE ) ;
equip - > I ( Attribute : : EQUIP_TYPE ) = int ( slot ) ;
if ( Inventory : : GetEquip ( slot ) = = & itemInvRef ) {
equip - > SetSelected ( true ) ;