@ -133,26 +133,37 @@ void Menu::InitializeCharacterMenuWindow(){
ScrollableWindowComponent * equipList = Component < ScrollableWindowComponent > ( data . component - > parentMenu , " Equip List " ) ;
equipList - > RemoveAllComponents ( ) ;
for ( int counter = 0 ; const std : : weak_ptr < Item > it : availableEquipment ) {
const static auto OppositeRingSlotDoesNotMatchCurrentEquip = [ ] ( RowItemDisplay * comp ) {
EquipSlot slot = EquipSlot ( comp - > I ( Attribute : : EQUIP_TYPE ) ) ;
std : : weak_ptr < Item > otherItem ;
if ( slot = = EquipSlot : : RING1 ) otherItem = Inventory : : GetEquip ( EquipSlot : : RING2 ) ;
else
if ( slot = = EquipSlot : : RING2 ) otherItem = Inventory : : GetEquip ( EquipSlot : : RING1 ) ;
return ISBLANK ( otherItem ) | | ( & * comp - > GetItem ( ) . lock ( ) ! = & * otherItem . lock ( ) ) ;
} ;
auto equip = equipList - > ADD ( " Equip Item " + std : : to_string ( counter ) , RowItemDisplay ) ( { { 2 , 2 + counter * 29.f } , { 120 - 15 , 28 } } , it ,
[ ] ( MenuFuncData data ) {
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! " ) ;
if ( OppositeRingSlotDoesNotMatchCurrentEquip ( comp ) ) { //If we find that the opposite ring slot is equipped to us, this would be an item swap or the exact same ring, therefore no stat calculations apply.
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 ; const std : : string & attribute : displayAttrs ) {
StatLabel * statDisplayLabel = Component < StatLabel > ( CHARACTER_MENU , " Attribute " + std : : string ( ItemAttribute : : Get ( 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 ( ) ) ;
}
comp - > SetSelected ( true ) ;
for ( int counter = 0 ; const std : : string & attribute : displayAttrs ) {
StatLabel * statDisplayLabel = Component < StatLabel > ( CHARACTER_MENU , " Attribute " + std : : string ( ItemAttribute : : Get ( 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! " ) ;
}
@ -175,21 +186,23 @@ void Menu::InitializeCharacterMenuWindow(){
if ( slot = = EquipSlot : : RING1 ) otherItem = Inventory : : GetEquip ( EquipSlot : : RING2 ) ;
else
if ( slot = = EquipSlot : : RING2 ) otherItem = Inventory : : GetEquip ( EquipSlot : : RING1 ) ;
Inventory : : EquipItem ( buttonItem , slot ) ;
for ( int counter = 0 ; const std : : string & attribute : displayAttrs ) {
StatLabel * statDisplayLabel = Component < StatLabel > ( CHARACTER_MENU , " Attribute " + std : : string ( ItemAttribute : : Get ( attribute ) . Name ( ) ) + " Label " ) ;
int statChangeAmt = game - > GetPlayer ( ) - > GetStat ( attribute ) - statsBeforeEquip [ counter ] ;
statDisplayLabel - > SetStatChangeAmt ( statChangeAmt ) ;
counter + + ;
}
Inventory : : UnequipItem ( slot ) ;
if ( ! ISBLANK ( equippedItem ) ) {
Inventory : : EquipItem ( equippedItem , slot ) ;
}
if ( ! ISBLANK ( otherItem ) ) {
if ( slot = = EquipSlot : : RING1 ) Inventory : : EquipItem ( otherItem , EquipSlot : : RING2 ) ;
else
if ( slot = = EquipSlot : : RING2 ) Inventory : : EquipItem ( otherItem , EquipSlot : : RING1 ) ;
if ( OppositeRingSlotDoesNotMatchCurrentEquip ( button ) ) { //If we find that the opposite ring slot is equipped to us, this would be an item swap or the exact same ring, therefore no stat calculations apply.
Inventory : : EquipItem ( buttonItem , slot ) ;
for ( int counter = 0 ; const std : : string & attribute : displayAttrs ) {
StatLabel * statDisplayLabel = Component < StatLabel > ( CHARACTER_MENU , " Attribute " + std : : string ( ItemAttribute : : Get ( attribute ) . Name ( ) ) + " Label " ) ;
int statChangeAmt = game - > GetPlayer ( ) - > GetStat ( attribute ) - statsBeforeEquip [ counter ] ;
statDisplayLabel - > SetStatChangeAmt ( statChangeAmt ) ;
counter + + ;
}
Inventory : : UnequipItem ( slot ) ;
if ( ! ISBLANK ( equippedItem ) ) {
Inventory : : EquipItem ( equippedItem , slot ) ;
}
if ( ! ISBLANK ( otherItem ) ) {
if ( slot = = EquipSlot : : RING1 ) Inventory : : EquipItem ( otherItem , EquipSlot : : RING2 ) ;
else
if ( slot = = EquipSlot : : RING2 ) Inventory : : EquipItem ( otherItem , EquipSlot : : RING1 ) ;
}
}
} else {
ERR ( " WARNING! Attempting to cast a button that isn't a RowItemDisplay! " ) ;
@ -226,12 +239,17 @@ void Menu::InitializeCharacterMenuWindow(){
equipmentWindowOpened = true ;
return true ;
} , [ ] ( MenuFuncData data ) { //On Mouse Hover
if ( Component < MenuLabel > ( data . component - > parentMenu , " Item Equip Description " ) - > GetLabel ( ) ! = " " ) {
EquipSlot slot = DYNAMIC_CAST < EquipSlotButton * > ( data . component ) - > GetSlot ( ) ;
const std : : weak_ptr < Item > equip = Inventory : : GetEquip ( slot ) ;
if ( ! ISBLANK ( equip ) ) {
Component < CharacterRotatingDisplay > ( data . component - > parentMenu , " Character Rotating Display " ) - > Enable ( false ) ;
}
return true ;
} , [ ] ( MenuFuncData data ) { //On Mouse Out
if ( Component < MenuLabel > ( data . component - > parentMenu , " Item Equip Description " ) - > GetLabel ( ) ! = " " & & ! equipmentWindowOpened ) {
if ( ! equipmentWindowOpened ) {
Component < MenuLabel > ( data . component - > parentMenu , " Item Equip Description " ) - > SetLabel ( " " ) ;
Component < MenuLabel > ( data . component - > parentMenu , " Item Equip Name " ) - > Enable ( false ) ;
Component < MenuLabel > ( data . component - > parentMenu , " Item Equip Description " ) - > Enable ( false ) ;
Component < CharacterRotatingDisplay > ( data . component - > parentMenu , " Character Rotating Display " ) - > Enable ( true ) ;
}
return true ;
@ -258,9 +276,9 @@ void Menu::InitializeCharacterMenuWindow(){
characterMenuWindow - > ADD ( " Back button " , MenuComponent ) ( { { windowSize . x / 2 - 64 , windowSize . y } , { 128 , 12 } } , " Back " , [ ] ( MenuFuncData data ) { Menu : : stack . pop_back ( ) ; return true ; } ) END ;
auto itemNameDisplay = characterMenuWindow - > ADD ( " Item Name " , MenuLabel ) ( { { 0 , 28 } , { 120 , 12 } } , " " , 1 , ComponentAttr : : BACKGROUND | ComponentAttr : : LEFT_ALIGN | ComponentAttr : : OUTLINE | ComponentAttr : : SHADOW ) END ;
auto itemNameDisplay = characterMenuWindow - > ADD ( " Item Name " , MenuLabel ) ( { { 0 , 28 } , { 120 , 12 } } , " " , 1 , ComponentAttr : : BACKGROUND | ComponentAttr : : LEFT_ALIGN | ComponentAttr : : OUTLINE | ComponentAttr : : SHADOW | ComponentAttr : : FIT_TO_LABEL ) END ;
auto itemDescriptionDisplay = characterMenuWindow - > ADD ( " Item Description " , MenuLabel ) ( { { 0 , 40 } , { 120 , windowSize . y - 49 } } , " " , 1 , ComponentAttr : : BACKGROUND | ComponentAttr : : LEFT_ALIGN | ComponentAttr : : OUTLINE | ComponentAttr : : SHADOW ) END ;
auto itemEquipNameDisplay = characterMenuWindow - > ADD ( " Item Equip Name " , MenuLabel ) ( { { 123 , 28 } , { 120 , 12 } } , " " , 1 , ComponentAttr : : BACKGROUND | ComponentAttr : : LEFT_ALIGN | ComponentAttr : : OUTLINE | ComponentAttr : : SHADOW ) END ;
auto itemEquipNameDisplay = characterMenuWindow - > ADD ( " Item Equip Name " , MenuLabel ) ( { { 123 , 28 } , { 120 , 12 } } , " " , 1 , ComponentAttr : : BACKGROUND | ComponentAttr : : LEFT_ALIGN | ComponentAttr : : OUTLINE | ComponentAttr : : SHADOW | ComponentAttr : : FIT_TO_LABEL ) END ;
auto itemEquipDescriptionDisplay = characterMenuWindow - > ADD ( " Item Equip Description " , MenuLabel ) ( { { 123 , 40 } , { 120 , windowSize . y - 49 } } , " " , 1 , ComponentAttr : : BACKGROUND | ComponentAttr : : LEFT_ALIGN | ComponentAttr : : OUTLINE | ComponentAttr : : SHADOW ) END ;
itemNameDisplay - > Enable ( false ) ;