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.

pull/35/head
sigonasr2 9 months ago
parent 5d315ada93
commit d8d50f74a7
  1. 6
      Adventures in Lestoria/BuyItemWindow.cpp
  2. 10
      Adventures in Lestoria/Menu.cpp
  3. 4
      Adventures in Lestoria/MenuType.h
  4. 48
      Adventures in Lestoria/MerchantWindow.cpp
  5. 85
      Adventures in Lestoria/SellItemWindow.cpp
  6. 2
      Adventures in Lestoria/Version.h
  7. BIN
      x64/Release/Adventures in Lestoria.exe

@ -120,7 +120,7 @@ void Menu::InitializeBuyItemWindow(){
},[](MenuType type){
Component<MenuComponent>(type,"Purchase Button")->Click();
}}},
{{game->KEY_SHOULDER},{"Qty Up/Down",[](MenuType type){}}},
{{game->KEY_SHOULDER,Pressed},{"Qty Up/Down",[](MenuType type){}}},
{{game->KEY_FASTSCROLLDOWN,PressedDAS},{"",[](MenuType type){
Component<MenuComponent>(type,"Increase buy amount Button")->Click();
if(Component<MenuComponent>(type,"Purchase Button")->IsGreyedOut()){
@ -134,7 +134,9 @@ void Menu::InitializeBuyItemWindow(){
Component<MenuComponent>(type,"Increase buy amount Button")->Click();
}
}}},
{game->KEY_BACK,{"Back",[](MenuType type){}}},
{game->KEY_BACK,{"Back",[](MenuType type){
Menu::CloseMenu();
}}},
{{game->KEY_CONFIRM,PressedDAS},{"",[](MenuType type){
if(Menu::menus[type]->GetSelection().expired())return;
incrementButtonDisabled=false;

@ -316,6 +316,16 @@ void Menu::KeyboardButtonNavigation(AiL*game,vf2d menuPos){
buttonHoldTime=0;
}
if(!Menu::UsingMouseNavigation()&&keyboardSelection.expired()){
//Since our keyboard selection expired, we need something selected here since we're in keyboard navigation mode.
if(onOpenFunc){
Data returnData;
onOpenFunc(GetType(),returnData);
defaultButton=returnData;
if(std::holds_alternative<ButtonName>(returnData)&&std::get<ButtonName>(returnData).length()>0||std::holds_alternative<std::weak_ptr<MenuComponent>>(returnData))SetSelection(returnData,true);
}
}
for(auto&[input,data]:inputGroups){
bool activated=false;
switch(input.GetEngageType()){

@ -41,7 +41,7 @@ enum MenuType{
///////////////////////////////////////////////////////////
/*DO NOT REMOVE!!*/ENUM_START,///////////////////////////////
///////////////////////////////////////////////////////////
// 44% Controller Compatibility. (100 total items, 4 items per menu * 25 menus)
// 52% Controller Compatibility. (100 total items, 4 items per menu * 25 menus)
INVENTORY_CONSUMABLES, //100% Controller Compatibility
CLASS_INFO, //100% Controller Compatibility
CLASS_SELECTION, //100% Controller Compatibility
@ -54,7 +54,7 @@ enum MenuType{
INVENTORY, //100% Controller Compatibility
MERCHANT, //100% Controller Compatibility
BUY_ITEM, //100% Controller Compatibility
SELL_ITEM, //0% Controller Compatibility
SELL_ITEM, //100% Controller Compatibility
BLACKSMITH, //0% Controller Compatibility
CRAFT_ITEM, //0% Controller Compatibility
CRAFT_CONSUMABLE, //0% Controller Compatibility

@ -245,7 +245,19 @@ void Menu::InitializeMerchantWindow(){
merchantWindow->SetupKeyboardNavigation(
[](MenuType type,Data&returnData){ //On Open
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",
}},
});
}

@ -43,6 +43,7 @@ All rights reserved.
using A=Attribute;
void Menu::InitializeSellItemWindow(){
static bool incrementButtonDisabled=false;
Menu*sellItemWindow=CreateMenu(SELL_ITEM,CENTERED,{192,72});
static auto GetQuantity=[&](){
return std::stoi(Component<MenuLabel>(SELL_ITEM,"Amount to sell Amount Label")->GetLabel());
@ -72,11 +73,17 @@ void Menu::InitializeSellItemWindow(){
sellItemWindow->ADD("Amount to sell Amount Label",MenuLabel)(geom2d::rect<float>{{sellItemWindow->size.x/2+48,34},{32,12}},"0",1.0f,ComponentAttr::SHADOW|ComponentAttr::OUTLINE|ComponentAttr::FIT_TO_LABEL)END;
sellItemWindow->ADD("Increase sell amount Button",MenuComponent)(geom2d::rect<float>{{sellItemWindow->size.x/2+80+2,34},{12,12}},"+",[&](MenuFuncData data){
if(!incrementButtonDisabled){
UpdateMenu(GetQuantity()+1);
}
incrementButtonDisabled=false;
return true;
})END;
sellItemWindow->ADD("Decrease sell amount Button",MenuComponent)(geom2d::rect<float>{{sellItemWindow->size.x/2+48-14,34},{12,12}},"-",[](MenuFuncData data){
if(!incrementButtonDisabled){
UpdateMenu(GetQuantity()-1);
}
incrementButtonDisabled=false;
return true;
})END;
@ -93,4 +100,82 @@ void Menu::InitializeSellItemWindow(){
Menu::CloseMenu();
return true;
})END;
sellItemWindow->SetupKeyboardNavigation(
[](MenuType type,Data&returnData){ //On Open
if(Component<MenuComponent>(type,"Sell Button")->IsGreyedOut()){
returnData="Cancel Button";
}else{
returnData="Sell Button";
}
},
{ //Button Key
{game->KEY_START,{[](MenuFuncData data){
if(Component<MenuComponent>(data.menu.GetType(),"Sell Button")->IsGreyedOut()){
return "";
}else{
return "Sell";
}
},[](MenuType type){
Component<MenuComponent>(type,"Sell Button")->Click();
}}},
{{game->KEY_SHOULDER,Pressed},{"Qty Up/Down",[](MenuType type){}}},
{{game->KEY_FASTSCROLLDOWN,PressedDAS},{"",[](MenuType type){
Component<MenuComponent>(type,"Increase sell amount Button")->Click();
if(Component<MenuComponent>(type,"Sell Button")->IsGreyedOut()){
Component<MenuComponent>(type,"Decrease sell amount Button")->Click();
}
}}},
{{game->KEY_FASTSCROLLUP,PressedDAS},{"",[](MenuType type){
bool foundValidAmt=!Component<MenuComponent>(type,"Sell Button")->IsGreyedOut();
Component<MenuComponent>(type,"Decrease sell amount Button")->Click();
if(foundValidAmt&&Component<MenuComponent>(type,"Sell Button")->IsGreyedOut()){
Component<MenuComponent>(type,"Increase sell amount Button")->Click();
}
}}},
{game->KEY_BACK,{"Back",[](MenuType type){
Menu::CloseMenu();
}}},
{{game->KEY_CONFIRM,PressedDAS},{"",[](MenuType type){
if(Menu::menus[type]->GetSelection().expired())return;
incrementButtonDisabled=false;
if(Menu::menus[type]->GetSelection().lock()->GetName()=="Increase sell amount Button"){
Component<MenuComponent>(type,"Increase sell amount Button")->Click();
if(Component<MenuComponent>(type,"Sell Button")->IsGreyedOut()){
Component<MenuComponent>(type,"Decrease sell amount Button")->Click();
}
}else
if(Menu::menus[type]->GetSelection().lock()->GetName()=="Decrease sell amount Button"){
bool foundValidAmt=!Component<MenuComponent>(type,"Sell Button")->IsGreyedOut();
Component<MenuComponent>(type,"Decrease sell amount Button")->Click();
if(foundValidAmt&&Component<MenuComponent>(type,"Sell Button")->IsGreyedOut()){
Component<MenuComponent>(type,"Increase sell amount Button")->Click();
}
}
incrementButtonDisabled=true; //We handled the clicks ourselves, we don't want it to cause another click on release.
}}},
{game->KEY_CONFIRM,{"Select",[](MenuType type){}}},
}
,{ //Button Navigation Rules
{"Cancel Button",{
.up="Decrease sell amount Button",
.down="Decrease sell amount Button",
.left="Sell Button",
.right="Sell Button",}},
{"Sell Button",{
.up="Increase sell amount Button",
.down="Increase sell amount Button",
.left="Cancel Button",
.right="Cancel Button",}},
{"Increase sell amount Button",{
.up="Sell Button",
.down="Sell Button",
.left="Decrease sell amount Button",
.right="Decrease sell amount Button",}},
{"Decrease sell amount Button",{
.up="Cancel Button",
.down="Cancel Button",
.left="Increase sell amount Button",
.right="Increase sell amount Button",}},
});
}

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 0
#define VERSION_MINOR 3
#define VERSION_PATCH 0
#define VERSION_BUILD 7242
#define VERSION_BUILD 7249
#define stringify(a) stringify_(a)
#define stringify_(a) #a

Loading…
Cancel
Save