@ -141,16 +141,8 @@ std::function<void(InventoryScrollableWindowComponent&component,ITCategory cat)>
[ ] ( InventoryScrollableWindowComponent & component , ITCategory cat ) {
std : : vector < std : : shared_ptr < Item > > weapons ;
std : : copy_if ( Inventory : : get ( " Equipment " ) . begin ( ) , Inventory : : get ( " Equipment " ) . end ( ) , std : : back_inserter ( weapons ) , [ ] ( std : : shared_ptr < Item > item ) { return item . get ( ) - > IsWeapon ( ) ; } ) ;
//We only want to refresh the inventory slots if the component count no longer matches what's actually in our inventory.
if ( component . components . size ( ) < weapons . size ( ) ) { //We need more space to display our items.
component . AddButtonOnSlotUpdate ( cat ) ;
} else
if ( component . components . size ( ) > weapons . size ( ) ) { //There are empty spots, so let's clean up.
component . RemoveAllComponents ( ) ;
for ( std : : weak_ptr < Item > item : Inventory : : get ( cat ) ) {
component . AddButtonOnSlotUpdate ( cat ) ;
}
}
component . RemoveAllComponents ( ) ;
component . AddButtonOnSlotUpdate ( cat ) ;
} ;
std : : function < void ( InventoryScrollableWindowComponent & component , ITCategory cat ) > InventoryCreator : : RowPlayerWeapons_AddButtonOnSlotUpdate =
[ ] ( InventoryScrollableWindowComponent & component , ITCategory cat ) {
@ -158,17 +150,17 @@ std::function<void(InventoryScrollableWindowComponent&component,ITCategory cat)>
std : : copy_if ( Inventory : : get ( " Equipment " ) . begin ( ) , Inventory : : get ( " Equipment " ) . end ( ) , std : : back_inserter ( weapons ) , [ ] ( std : : shared_ptr < Item > item ) { return item . get ( ) - > IsWeapon ( ) ; } ) ;
RowInventoryScrollableWindowComponent * c = DYNAMIC_CAST < RowInventoryScrollableWindowComponent * > ( & component ) ;
size_t invSize = c - > components . size ( ) + 1 ;
int invWidth = int ( c - > rect . size . x / ( float ( c - > options . size . x ) + c - > options . padding ) ) ;
int x = int ( ( invSize - 1 ) % invWidth ) ;
int y = int ( ( invSize - 1 ) / invWidth ) ;
int itemIndex = y * invWidth + x ;
vf2d buttonSize = c - > options . size ;
vf2d totalSpacing = { c - > options . padding + buttonSize . x , c - > options . padding + buttonSize . y } ;
for ( std : : shared_ptr < Item > weapon : weapons ) {
auto newItem = c - > ADD ( " item_ " + cat + " _ " + std : : to_string ( itemIndex ) , RowItemDisplay ) ( { totalSpacing * vf2d { float ( x ) , float ( y ) } , buttonSize } , weapon , c - > inventoryButtonClickAction , c - > itemNameLabelName , c - > itemDescriptionLabelName , c - > inventoryButtonsActive ? ButtonAttr : : NONE : ButtonAttr : : UNSELECTABLE ) END ;
size_t invSize = c - > components . size ( ) + 1 ;
int invWidth = int ( c - > rect . size . x / ( float ( c - > options . size . x ) + c - > options . padding ) ) ;
int x = int ( ( invSize - 1 ) % invWidth ) ;
int y = int ( ( invSize - 1 ) / invWidth ) ;
int itemIndex = y * invWidth + x ;
auto newItem = c - > ADD ( " item_Weapon_ " + std : : to_string ( itemIndex ) , RowItemDisplay ) ( { totalSpacing * vf2d { float ( x ) , float ( y ) } , buttonSize } , weapon , c - > inventoryButtonClickAction , c - > itemNameLabelName , c - > itemDescriptionLabelName , c - > inventoryButtonsActive ? ButtonAttr : : NONE : ButtonAttr : : UNSELECTABLE ) END ;
newItem - > SetCompactDescriptions ( c - > compact = = COMPACT ) ;
newItem - > SetPriceLabelType ( c - > priceLabel ) ;
newItem - > SetHoverFunc ( c - > inventoryButtonHoverAction ) ;
@ -182,16 +174,8 @@ std::function<void(InventoryScrollableWindowComponent&component,ITCategory cat)>
[ ] ( InventoryScrollableWindowComponent & component , ITCategory cat ) {
std : : vector < std : : shared_ptr < Item > > armor ;
std : : copy_if ( Inventory : : get ( " Equipment " ) . begin ( ) , Inventory : : get ( " Equipment " ) . end ( ) , std : : back_inserter ( armor ) , [ ] ( std : : shared_ptr < Item > item ) { return item . get ( ) - > IsArmor ( ) ; } ) ;
//We only want to refresh the inventory slots if the component count no longer matches what's actually in our inventory.
if ( component . components . size ( ) < armor . size ( ) ) { //We need more space to display our items.
component . AddButtonOnSlotUpdate ( cat ) ;
} else
if ( component . components . size ( ) > armor . size ( ) ) { //There are empty spots, so let's clean up.
component . RemoveAllComponents ( ) ;
for ( std : : weak_ptr < Item > item : Inventory : : get ( cat ) ) {
component . AddButtonOnSlotUpdate ( cat ) ;
}
}
component . RemoveAllComponents ( ) ;
component . AddButtonOnSlotUpdate ( cat ) ;
} ;
std : : function < void ( InventoryScrollableWindowComponent & component , ITCategory cat ) > InventoryCreator : : RowPlayerArmor_AddButtonOnSlotUpdate =
[ ] ( InventoryScrollableWindowComponent & component , ITCategory cat ) {
@ -199,17 +183,17 @@ std::function<void(InventoryScrollableWindowComponent&component,ITCategory cat)>
std : : copy_if ( Inventory : : get ( " Equipment " ) . begin ( ) , Inventory : : get ( " Equipment " ) . end ( ) , std : : back_inserter ( armor ) , [ ] ( std : : shared_ptr < Item > item ) { return item . get ( ) - > IsArmor ( ) ; } ) ;
RowInventoryScrollableWindowComponent * c = DYNAMIC_CAST < RowInventoryScrollableWindowComponent * > ( & component ) ;
size_t invSize = c - > components . size ( ) + 1 ;
int invWidth = int ( c - > rect . size . x / ( float ( c - > options . size . x ) + c - > options . padding ) ) ;
int x = int ( ( invSize - 1 ) % invWidth ) ;
int y = int ( ( invSize - 1 ) / invWidth ) ;
int itemIndex = y * invWidth + x ;
vf2d buttonSize = c - > options . size ;
vf2d totalSpacing = { c - > options . padding + buttonSize . x , c - > options . padding + buttonSize . y } ;
for ( std : : shared_ptr < Item > armor : armor ) {
auto newItem = c - > ADD ( " item_ " + cat + " _ " + std : : to_string ( itemIndex ) , RowItemDisplay ) ( { totalSpacing * vf2d { float ( x ) , float ( y ) } , buttonSize } , armor , c - > inventoryButtonClickAction , c - > itemNameLabelName , c - > itemDescriptionLabelName , c - > inventoryButtonsActive ? ButtonAttr : : NONE : ButtonAttr : : UNSELECTABLE ) END ;
size_t invSize = c - > components . size ( ) + 1 ;
int invWidth = int ( c - > rect . size . x / ( float ( c - > options . size . x ) + c - > options . padding ) ) ;
int x = int ( ( invSize - 1 ) % invWidth ) ;
int y = int ( ( invSize - 1 ) / invWidth ) ;
int itemIndex = y * invWidth + x ;
auto newItem = c - > ADD ( " item_Armor_ " + std : : to_string ( itemIndex ) , RowItemDisplay ) ( { totalSpacing * vf2d { float ( x ) , float ( y ) } , buttonSize } , armor , c - > inventoryButtonClickAction , c - > itemNameLabelName , c - > itemDescriptionLabelName , c - > inventoryButtonsActive ? ButtonAttr : : NONE : ButtonAttr : : UNSELECTABLE ) END ;
newItem - > SetCompactDescriptions ( c - > compact = = COMPACT ) ;
newItem - > SetPriceLabelType ( c - > priceLabel ) ;
newItem - > SetHoverFunc ( c - > inventoryButtonHoverAction ) ;