@ -77,7 +77,7 @@ void Menu::InitializeMerchantWindow(){
buyTab - > selectionType = SelectionType : : HIGHLIGHT ;
buyTab - > selectionType = SelectionType : : HIGHLIGHT ;
auto sellTab = merchantWindow - > ADD ( " Sell Tab " , MenuComponent ) ( { { merchantWindow - > size . x / 2 + 2 , 0 } , { merchantWindow - > size . x / 2 - 4 , 24 } } , " Sell " , [ ] ( MenuFuncData data ) {
auto sellTab = merchantWindow - > ADD ( " Sell Tab " , MenuComponent ) ( { { merchantWindow - > size . x / 2 + 2 , 0 } , { merchantWindow - > size . x / 2 - 4 , 24 } } , " Sell " , [ ] ( MenuFuncData data ) {
Component < RowMerchant InventoryScrollableWindowComponent > ( MERCHANT , " Merchant Inventory Display " ) - > Enable ( false ) ;
Component < RowInventoryScrollableWindowComponent > ( MERCHANT , " Merchant Inventory Display " ) - > Enable ( false ) ;
Component < MenuComponent > ( MERCHANT , " Buy Tab " ) - > selected = false ;
Component < MenuComponent > ( MERCHANT , " Buy Tab " ) - > selected = false ;
Component < MenuComponent > ( MERCHANT , " Inventory Tabs Outline " ) - > Enable ( true ) ;
Component < MenuComponent > ( MERCHANT , " Inventory Tabs Outline " ) - > Enable ( true ) ;
for ( auto & [ category , items ] : ITEM_CATEGORIES ) {
for ( auto & [ category , items ] : ITEM_CATEGORIES ) {
@ -119,6 +119,7 @@ void Menu::InitializeMerchantWindow(){
Component < MenuItemItemButton > ( data . menu . GetType ( ) , " Item Icon " ) - > UpdateIcon ( ) ;
Component < MenuItemItemButton > ( data . menu . GetType ( ) , " Item Icon " ) - > UpdateIcon ( ) ;
return true ;
return true ;
} , { . padding = 1 , . size = { 220 - 13 , 28 } } ) END ;
} , { . padding = 1 , . size = { 220 - 13 , 28 } } ) END ;
inventoryDisplay - > SetPriceLabelType ( PriceLabel : : BUY_LABEL ) ;
for ( auto & [ category , items ] : ITEM_CATEGORIES ) {
for ( auto & [ category , items ] : ITEM_CATEGORIES ) {
Menu : : AddMerchantInventoryListener ( inventoryDisplay , category ) ;
Menu : : AddMerchantInventoryListener ( inventoryDisplay , category ) ;
@ -148,22 +149,24 @@ void Menu::InitializeMerchantWindow(){
button - > SetSelectionType ( HIGHLIGHT ) ;
button - > SetSelectionType ( HIGHLIGHT ) ;
button - > S ( A : : CATEGORY_NAME ) = category ;
button - > S ( A : : CATEGORY_NAME ) = category ;
auto inventoryDisplay = merchantWindow - > ADD ( " Inventory Display - " + category , RowInventoryScrollableWindowComponent ) ( { { 72 , 28 } , { 150 , merchantWindow - > size . y - 44 } } , category , " Item Name Label " , " Item Description Label " ,
auto inventoryDisplay = merchantWindow - > ADD ( " Inventory Display - " + category , RowInventoryScrollableWindowComponent ) ( { { 72 , 28 } , { 150 , merchantWindow - > size . y - 44 } } , " Item Name Label " , " Item Description Label " ,
[ ] ( MenuFuncData data ) {
[ ] ( MenuFuncData data ) {
RowItemDisplay * item = dynamic_cast < RowItemDisplay * > ( data . component ) ;
RowItemDisplay * item = dynamic_cast < RowItemDisplay * > ( data . component ) ;
Component < MenuLabel > ( SELL_ITEM , " Item Sell Header " ) - > S ( A : : ITEM_NAME ) = item - > GetItem ( ) . lock ( ) - > ActualName ( ) ;
if ( item - > GetItem ( ) . lock ( ) - > CanBeSold ( ) ) {
Component < MenuLabel > ( SELL_ITEM , " Price per item Amount Label " ) - > SetLabel ( std : : to_string ( item - > GetItem ( ) . lock ( ) - > BuyValue ( ) ) ) ;
Component < MenuLabel > ( SELL_ITEM , " Item Sell Header " ) - > S ( A : : ITEM_NAME ) = item - > GetItem ( ) . lock ( ) - > ActualName ( ) ;
Component < MenuLabel > ( SELL_ITEM , " Amount to sell Amount Label " ) - > SetLabel ( " 1 " ) ;
Component < MenuLabel > ( SELL_ITEM , " Price per item Amount Label " ) - > SetLabel ( std : : to_string ( item - > GetItem ( ) . lock ( ) - > SellValue ( ) ) ) ;
Component < MenuLabel > ( SELL_ITEM , " Total Price Amount Label " ) - > SetLabel ( std : : to_string ( item - > GetItem ( ) . lock ( ) - > BuyValue ( ) ) ) ;
Component < MenuLabel > ( SELL_ITEM , " Amount to sell Amount Label " ) - > SetLabel ( " 1 " ) ;
Merchant & merchant = Merchant : : GetCurrentTravelingMerchant ( ) ;
Component < MenuLabel > ( SELL_ITEM , " Total Price Amount Label " ) - > SetLabel ( std : : to_string ( item - > GetItem ( ) . lock ( ) - > SellValue ( ) ) ) ;
bool canPurchase = merchant . CanPurchaseItem ( item - > GetItem ( ) . lock ( ) - > ActualName ( ) , 1 ) ;
Merchant & merchant = Merchant : : GetCurrentTravelingMerchant ( ) ;
bool canPurchase = merchant . CanSellItem ( item - > GetItem ( ) . lock ( ) - > ActualName ( ) , 1 ) ;
std : : string colorCode = " " ;
if ( ! canPurchase ) colorCode = " #FF0000 " ;
std : : string colorCode = " " ;
Component < MenuLabel > ( SELL_ITEM , " Total Price Amount Label " ) - > SetLabel ( colorCode + std : : to_string ( item - > GetItem ( ) . lock ( ) - > BuyValue ( ) ) ) ;
if ( ! canPurchase ) colorCode = " #FF0000 " ;
Component < MenuLabel > ( SELL_ITEM , " Item Purchase Header " ) - > SetLabel ( " Buying " + item - > GetItem ( ) . lock ( ) - > DisplayName ( ) ) ;
Component < MenuLabel > ( SELL_ITEM , " Total Price Amount Label " ) - > SetLabel ( colorCode + std : : to_string ( item - > GetItem ( ) . lock ( ) - > SellValue ( ) ) ) ;
Component < MenuComponent > ( SELL_ITEM , " Purchase Button " ) - > SetGrayedOut ( ! merchant . CanPurchaseItem ( item - > GetItem ( ) . lock ( ) - > ActualName ( ) , 1 ) ) ;
Component < MenuLabel > ( SELL_ITEM , " Item Sell Header " ) - > SetLabel ( " Selling " + item - > GetItem ( ) . lock ( ) - > DisplayName ( ) ) ;
Menu : : OpenMenu ( SELL_ITEM ) ;
Component < MenuComponent > ( SELL_ITEM , " Sell Button " ) - > SetGrayedOut ( ! merchant . CanSellItem ( item - > GetItem ( ) . lock ( ) - > ActualName ( ) , 1 ) ) ;
Menu : : OpenMenu ( SELL_ITEM ) ;
}
return true ;
return true ;
} ,
} ,
[ ] ( MenuFuncData data ) {
[ ] ( MenuFuncData data ) {
@ -176,6 +179,7 @@ void Menu::InitializeMerchantWindow(){
Component < MenuItemItemButton > ( data . menu . GetType ( ) , " Item Icon " ) - > UpdateIcon ( ) ;
Component < MenuItemItemButton > ( data . menu . GetType ( ) , " Item Icon " ) - > UpdateIcon ( ) ;
return true ;
return true ;
} , { . padding = 1 , . size = { 137 , 28 } } ) END ;
} , { . padding = 1 , . size = { 137 , 28 } } ) END ;
inventoryDisplay - > SetPriceLabelType ( PriceLabel : : SELL_LABEL ) ;
if ( first ) {
if ( first ) {
merchantWindow - > S ( A : : LAST_INVENTORY_TYPE_OPENED ) = category ;
merchantWindow - > S ( A : : LAST_INVENTORY_TYPE_OPENED ) = category ;