Implemented controller compatibility for sell item menu. Keyboard/controller menu navigation now auto-repopulates with a default selection if the current selection becomes expired for some reason (such as selling an item). Release Build 7249.

This commit is contained in:
2024-02-16 18:30:14 -06:00
parent 5d315ada93
commit d8d50f74a7
7 changed files with 153 additions and 8 deletions
+49 -1
View File
@@ -245,7 +245,19 @@ void Menu::InitializeMerchantWindow(){
merchantWindow->SetupKeyboardNavigation(
[](MenuType type,Data&returnData){ //On Open
returnData=Component<RowInventoryScrollableWindowComponent>(type,"Merchant Inventory Display")->GetComponents()[0];
if(Component<RowInventoryScrollableWindowComponent>(type,"Merchant Inventory Display")->IsEnabled()){
returnData=Component<RowInventoryScrollableWindowComponent>(type,"Merchant Inventory Display")->GetComponents()[0];
}else{
auto itemList=Component<RowInventoryScrollableWindowComponent>(type,std::format("Inventory Display - {}",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED)))->GetComponents();
if(itemList.size()>Menu::menus[type]->I(A::ITEM_SLOT)){
returnData=itemList[Menu::menus[type]->I(A::ITEM_SLOT)];
}else
if(itemList.size()>0){
returnData=itemList[0];
}else{
returnData=Component<MenuComponent>(type,std::format("{} Inventory Tab",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED)));
}
}
},
{ //Button Key
{game->KEY_BACK,{"Leave",[](MenuType type){
@@ -808,5 +820,41 @@ void Menu::InitializeMerchantWindow(){
}
},
}},
{"Buy Tab",{
.up="Leave Button",
.down=[](MenuType type,Data&returnData){
if(Component<MenuComponent>(MERCHANT,"Buy Tab")->selected){
auto merchantList=Component<RowInventoryScrollableWindowComponent>(type,"Merchant Inventory Display");
returnData=merchantList->GetComponents()[0];
}else{
auto inventory=Component<RowInventoryScrollableWindowComponent>(type,std::format("Inventory Display - {}",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED)));
if(inventory->GetComponents().size()>0){
returnData=inventory->GetComponents()[0];
}else{
returnData=Component<MenuComponent>(type,std::format("{} Inventory Tab",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED)));
}
}
},
.left="Sell Tab",
.right="Sell Tab",
}},
{"Sell Tab",{
.up="Leave Button",
.down=[](MenuType type,Data&returnData){
if(Component<MenuComponent>(MERCHANT,"Buy Tab")->selected){
auto merchantList=Component<RowInventoryScrollableWindowComponent>(type,"Merchant Inventory Display");
returnData=merchantList->GetComponents()[0];
}else{
auto inventory=Component<RowInventoryScrollableWindowComponent>(type,std::format("Inventory Display - {}",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED)));
if(inventory->GetComponents().size()>0){
returnData=inventory->GetComponents()[0];
}else{
returnData=Component<MenuComponent>(type,std::format("{} Inventory Tab",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED)));
}
}
},
.left="Buy Tab",
.right="Buy Tab",
}},
});
}