diff --git a/Adventures in Lestoria/BuyItemWindow.cpp b/Adventures in Lestoria/BuyItemWindow.cpp index ba7ed11e..e9482a86 100644 --- a/Adventures in Lestoria/BuyItemWindow.cpp +++ b/Adventures in Lestoria/BuyItemWindow.cpp @@ -120,7 +120,7 @@ void Menu::InitializeBuyItemWindow(){ },[](MenuType type){ Component(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(type,"Increase buy amount Button")->Click(); if(Component(type,"Purchase Button")->IsGreyedOut()){ @@ -134,7 +134,9 @@ void Menu::InitializeBuyItemWindow(){ Component(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; diff --git a/Adventures in Lestoria/Menu.cpp b/Adventures in Lestoria/Menu.cpp index 74905446..e1ed6a72 100644 --- a/Adventures in Lestoria/Menu.cpp +++ b/Adventures in Lestoria/Menu.cpp @@ -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(returnData)&&std::get(returnData).length()>0||std::holds_alternative>(returnData))SetSelection(returnData,true); + } + } + for(auto&[input,data]:inputGroups){ bool activated=false; switch(input.GetEngageType()){ diff --git a/Adventures in Lestoria/MenuType.h b/Adventures in Lestoria/MenuType.h index 24d157a5..e5236de5 100644 --- a/Adventures in Lestoria/MenuType.h +++ b/Adventures in Lestoria/MenuType.h @@ -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 diff --git a/Adventures in Lestoria/MerchantWindow.cpp b/Adventures in Lestoria/MerchantWindow.cpp index 63ea0c69..33dca5ec 100644 --- a/Adventures in Lestoria/MerchantWindow.cpp +++ b/Adventures in Lestoria/MerchantWindow.cpp @@ -245,7 +245,19 @@ void Menu::InitializeMerchantWindow(){ merchantWindow->SetupKeyboardNavigation( [](MenuType type,Data&returnData){ //On Open - returnData=Component(type,"Merchant Inventory Display")->GetComponents()[0]; + if(Component(type,"Merchant Inventory Display")->IsEnabled()){ + returnData=Component(type,"Merchant Inventory Display")->GetComponents()[0]; + }else{ + auto itemList=Component(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(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(MERCHANT,"Buy Tab")->selected){ + auto merchantList=Component(type,"Merchant Inventory Display"); + returnData=merchantList->GetComponents()[0]; + }else{ + auto inventory=Component(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(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(MERCHANT,"Buy Tab")->selected){ + auto merchantList=Component(type,"Merchant Inventory Display"); + returnData=merchantList->GetComponents()[0]; + }else{ + auto inventory=Component(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(type,std::format("{} Inventory Tab",Menu::menus[type]->S(A::LAST_INVENTORY_TYPE_OPENED))); + } + } + }, + .left="Buy Tab", + .right="Buy Tab", + }}, }); } \ No newline at end of file diff --git a/Adventures in Lestoria/SellItemWindow.cpp b/Adventures in Lestoria/SellItemWindow.cpp index 3eb22313..88965c90 100644 --- a/Adventures in Lestoria/SellItemWindow.cpp +++ b/Adventures in Lestoria/SellItemWindow.cpp @@ -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(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{{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{{sellItemWindow->size.x/2+80+2,34},{12,12}},"+",[&](MenuFuncData data){ - UpdateMenu(GetQuantity()+1); + if(!incrementButtonDisabled){ + UpdateMenu(GetQuantity()+1); + } + incrementButtonDisabled=false; return true; })END; sellItemWindow->ADD("Decrease sell amount Button",MenuComponent)(geom2d::rect{{sellItemWindow->size.x/2+48-14,34},{12,12}},"-",[](MenuFuncData data){ - UpdateMenu(GetQuantity()-1); + 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(type,"Sell Button")->IsGreyedOut()){ + returnData="Cancel Button"; + }else{ + returnData="Sell Button"; + } + }, + { //Button Key + {game->KEY_START,{[](MenuFuncData data){ + if(Component(data.menu.GetType(),"Sell Button")->IsGreyedOut()){ + return ""; + }else{ + return "Sell"; + } + },[](MenuType type){ + Component(type,"Sell Button")->Click(); + }}}, + {{game->KEY_SHOULDER,Pressed},{"Qty Up/Down",[](MenuType type){}}}, + {{game->KEY_FASTSCROLLDOWN,PressedDAS},{"",[](MenuType type){ + Component(type,"Increase sell amount Button")->Click(); + if(Component(type,"Sell Button")->IsGreyedOut()){ + Component(type,"Decrease sell amount Button")->Click(); + } + }}}, + {{game->KEY_FASTSCROLLUP,PressedDAS},{"",[](MenuType type){ + bool foundValidAmt=!Component(type,"Sell Button")->IsGreyedOut(); + Component(type,"Decrease sell amount Button")->Click(); + if(foundValidAmt&&Component(type,"Sell Button")->IsGreyedOut()){ + Component(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(type,"Increase sell amount Button")->Click(); + if(Component(type,"Sell Button")->IsGreyedOut()){ + Component(type,"Decrease sell amount Button")->Click(); + } + }else + if(Menu::menus[type]->GetSelection().lock()->GetName()=="Decrease sell amount Button"){ + bool foundValidAmt=!Component(type,"Sell Button")->IsGreyedOut(); + Component(type,"Decrease sell amount Button")->Click(); + if(foundValidAmt&&Component(type,"Sell Button")->IsGreyedOut()){ + Component(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",}}, + }); } \ No newline at end of file diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index 7de29b88..9b956349 100644 --- a/Adventures in Lestoria/Version.h +++ b/Adventures in Lestoria/Version.h @@ -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 diff --git a/x64/Release/Adventures in Lestoria.exe b/x64/Release/Adventures in Lestoria.exe index e431d37c..d6ebbf5a 100644 Binary files a/x64/Release/Adventures in Lestoria.exe and b/x64/Release/Adventures in Lestoria.exe differ