Add back button navigation for character inventory menu. Fix scrolling to bottom of inventory display when switching item categories. Release Build 7204.

This commit is contained in:
2024-02-14 21:15:41 -06:00
parent fe648f8fbf
commit 0124d44a5c
4 changed files with 70 additions and 26 deletions
+45 -25
View File
@@ -89,7 +89,11 @@ void Menu::InitializeInventoryWindow(){
Component<RowInventoryScrollableWindowComponent>(data.menu.GetType(),"Inventory Display - "+data.component.lock()->S(A::CATEGORY_NAME))->Enable();
Component<MenuComponent>(data.menu.GetType(),data.component.lock()->S(A::CATEGORY_NAME)+" Inventory Tab")->SetSelected(true);
data.menu.S(A::LAST_INVENTORY_TYPE_OPENED)=data.component.lock()->S(A::CATEGORY_NAME);
data.menu.I(A::ITEM_SLOT)=Component<RowInventoryScrollableWindowComponent>(data.menu.GetType(),"Inventory Display - "+data.component.lock()->S(A::CATEGORY_NAME))->GetComponents().size()-1;
if(Component<RowInventoryScrollableWindowComponent>(data.menu.GetType(),"Inventory Display - "+data.component.lock()->S(A::CATEGORY_NAME))->GetComponents().size()>0){
data.menu.I(A::ITEM_SLOT)=0;
}else{
data.menu.I(A::ITEM_SLOT)=-1;
}
if(data.menu.I(A::ITEM_SLOT)>=0){
data.menu.SetSelection(Component<RowInventoryScrollableWindowComponent>(data.menu.GetType(),"Inventory Display - "+data.component.lock()->S(A::CATEGORY_NAME))->GetComponents()[0],true);
}
@@ -198,20 +202,42 @@ void Menu::InitializeInventoryWindow(){
{game->KEY_CONFIRM,{"Select",[](MenuType type){}}},
}
,{ //Button Navigation Rules
{"Back Button",{
.up=[](MenuType type,Data&returnData){
auto inventoryDisplay=Component<RowInventoryScrollableWindowComponent>(type,std::format("Inventory Display - {}",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED)));
if(inventoryDisplay->GetComponents().size()>0){
returnData=inventoryDisplay->GetComponents()[inventoryDisplay->GetComponents().size()-1];
}else{
returnData="Back Button";
}
},
.down=[](MenuType type,Data&returnData){
auto inventoryDisplay=Component<RowInventoryScrollableWindowComponent>(type,std::format("Inventory Display - {}",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED)));
if(inventoryDisplay->GetComponents().size()>0){
returnData=inventoryDisplay->GetComponents()[0];
}else{
returnData="Back Button";
}
},
.left=[](MenuType type,Data&returnData){
returnData=std::format("{} Inventory Tab",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED));
},
.right=[](MenuType type,Data&returnData){
returnData=std::format("{} Inventory Tab",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED));
},
}},
{"Inventory Display - Consumables",{
.up=[](MenuType type,Data&returnData){
Menu::menus[type]->I(A::ITEM_SLOT)--;
if(Menu::menus[type]->I(A::ITEM_SLOT)<0){
Menu::menus[type]->I(A::ITEM_SLOT)=Component<RowInventoryScrollableWindowComponent>(type,"Inventory Display - Consumables")->GetComponents().size()-1;
}
returnData=Component<RowInventoryScrollableWindowComponent>(type,"Inventory Display - Consumables")->GetComponents()[Menu::menus[type]->I(A::ITEM_SLOT)];
returnData="Back Button";
}else returnData=Component<RowInventoryScrollableWindowComponent>(type,"Inventory Display - Consumables")->GetComponents()[Menu::menus[type]->I(A::ITEM_SLOT)];
},
.down=[](MenuType type,Data&returnData){
Menu::menus[type]->I(A::ITEM_SLOT)++;
if(Menu::menus[type]->I(A::ITEM_SLOT)>=Component<RowInventoryScrollableWindowComponent>(type,"Inventory Display - Consumables")->GetComponents().size()){
Menu::menus[type]->I(A::ITEM_SLOT)-=Component<RowInventoryScrollableWindowComponent>(type,"Inventory Display - Consumables")->GetComponents().size();
}
returnData=Component<RowInventoryScrollableWindowComponent>(type,"Inventory Display - Consumables")->GetComponents()[Menu::menus[type]->I(A::ITEM_SLOT)];
returnData="Back Button";
}else returnData=Component<RowInventoryScrollableWindowComponent>(type,"Inventory Display - Consumables")->GetComponents()[Menu::menus[type]->I(A::ITEM_SLOT)];
},
.left=[](MenuType type,Data&returnData){
returnData=std::format("{} Inventory Tab",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED));
@@ -224,16 +250,14 @@ void Menu::InitializeInventoryWindow(){
.up=[](MenuType type,Data&returnData){
Menu::menus[type]->I(A::ITEM_SLOT)--;
if(Menu::menus[type]->I(A::ITEM_SLOT)<0){
Menu::menus[type]->I(A::ITEM_SLOT)=Component<RowInventoryScrollableWindowComponent>(type,"Inventory Display - Equipment")->GetComponents().size()-1;
}
returnData=Component<RowInventoryScrollableWindowComponent>(type,"Inventory Display - Equipment")->GetComponents()[Menu::menus[type]->I(A::ITEM_SLOT)];
returnData="Back Button";
}else returnData=Component<RowInventoryScrollableWindowComponent>(type,"Inventory Display - Equipment")->GetComponents()[Menu::menus[type]->I(A::ITEM_SLOT)];
},
.down=[](MenuType type,Data&returnData){
Menu::menus[type]->I(A::ITEM_SLOT)++;
if(Menu::menus[type]->I(A::ITEM_SLOT)>=Component<RowInventoryScrollableWindowComponent>(type,"Inventory Display - Equipment")->GetComponents().size()){
Menu::menus[type]->I(A::ITEM_SLOT)-=Component<RowInventoryScrollableWindowComponent>(type,"Inventory Display - Equipment")->GetComponents().size();
}
returnData=Component<RowInventoryScrollableWindowComponent>(type,"Inventory Display - Equipment")->GetComponents()[Menu::menus[type]->I(A::ITEM_SLOT)];
returnData="Back Button";
}else returnData=Component<RowInventoryScrollableWindowComponent>(type,"Inventory Display - Equipment")->GetComponents()[Menu::menus[type]->I(A::ITEM_SLOT)];
},
.left=[](MenuType type,Data&returnData){
returnData=std::format("{} Inventory Tab",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED));
@@ -246,16 +270,14 @@ void Menu::InitializeInventoryWindow(){
.up=[](MenuType type,Data&returnData){
Menu::menus[type]->I(A::ITEM_SLOT)--;
if(Menu::menus[type]->I(A::ITEM_SLOT)<0){
Menu::menus[type]->I(A::ITEM_SLOT)=Component<RowInventoryScrollableWindowComponent>(type,"Inventory Display - Accessories")->GetComponents().size()-1;
}
returnData=Component<RowInventoryScrollableWindowComponent>(type,"Inventory Display - Accessories")->GetComponents()[Menu::menus[type]->I(A::ITEM_SLOT)];
returnData="Back Button";
}else returnData=Component<RowInventoryScrollableWindowComponent>(type,"Inventory Display - Accessories")->GetComponents()[Menu::menus[type]->I(A::ITEM_SLOT)];
},
.down=[](MenuType type,Data&returnData){
Menu::menus[type]->I(A::ITEM_SLOT)++;
if(Menu::menus[type]->I(A::ITEM_SLOT)>=Component<RowInventoryScrollableWindowComponent>(type,"Inventory Display - Accessories")->GetComponents().size()){
Menu::menus[type]->I(A::ITEM_SLOT)-=Component<RowInventoryScrollableWindowComponent>(type,"Inventory Display - Accessories")->GetComponents().size();
}
returnData=Component<RowInventoryScrollableWindowComponent>(type,"Inventory Display - Accessories")->GetComponents()[Menu::menus[type]->I(A::ITEM_SLOT)];
returnData="Back Button";
}else returnData=Component<RowInventoryScrollableWindowComponent>(type,"Inventory Display - Accessories")->GetComponents()[Menu::menus[type]->I(A::ITEM_SLOT)];
},
.left=[](MenuType type,Data&returnData){
returnData=std::format("{} Inventory Tab",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED));
@@ -268,16 +290,14 @@ void Menu::InitializeInventoryWindow(){
.up=[](MenuType type,Data&returnData){
Menu::menus[type]->I(A::ITEM_SLOT)--;
if(Menu::menus[type]->I(A::ITEM_SLOT)<0){
Menu::menus[type]->I(A::ITEM_SLOT)=Component<RowInventoryScrollableWindowComponent>(type,"Inventory Display - Materials")->GetComponents().size()-1;
}
returnData=Component<RowInventoryScrollableWindowComponent>(type,"Inventory Display - Materials")->GetComponents()[Menu::menus[type]->I(A::ITEM_SLOT)];
returnData="Back Button";
}else returnData=Component<RowInventoryScrollableWindowComponent>(type,"Inventory Display - Materials")->GetComponents()[Menu::menus[type]->I(A::ITEM_SLOT)];
},
.down=[](MenuType type,Data&returnData){
Menu::menus[type]->I(A::ITEM_SLOT)++;
if(Menu::menus[type]->I(A::ITEM_SLOT)>=Component<RowInventoryScrollableWindowComponent>(type,"Inventory Display - Materials")->GetComponents().size()){
Menu::menus[type]->I(A::ITEM_SLOT)-=Component<RowInventoryScrollableWindowComponent>(type,"Inventory Display - Materials")->GetComponents().size();
}
returnData=Component<RowInventoryScrollableWindowComponent>(type,"Inventory Display - Materials")->GetComponents()[Menu::menus[type]->I(A::ITEM_SLOT)];
returnData="Back Button";
}else returnData=Component<RowInventoryScrollableWindowComponent>(type,"Inventory Display - Materials")->GetComponents()[Menu::menus[type]->I(A::ITEM_SLOT)];
},
.left=[](MenuType type,Data&returnData){
returnData=std::format("{} Inventory Tab",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED));