Added controller compatibility for the consumable item crafting menu. Fixed bug for selecting buttons that would become disabled causing infinite menu loop. Added checkes fo auto-resolve default button and immediately close out the loop. Release Build 7299.

pull/35/head
sigonasr2 1 year ago
parent e5ace36a60
commit a723ac50fc
  1. 86
      Adventures in Lestoria/ConsumableCraftItemWindow.cpp
  2. 19
      Adventures in Lestoria/Menu.cpp
  3. 4
      Adventures in Lestoria/MenuItemButton.h
  4. 4
      Adventures in Lestoria/MenuItemItemButton.h
  5. 2
      Adventures in Lestoria/MenuType.h
  6. 4
      Adventures in Lestoria/TODO.txt
  7. 2
      Adventures in Lestoria/Version.h
  8. BIN
      x64/Release/Adventures in Lestoria.exe

@ -45,6 +45,7 @@ INCLUDE_ITEM_DATA
using A=Attribute;
void Menu::InitializeConsumableCraftItemWindow(){
static bool incrementButtonDisabled=false;
Menu*consumableCraftItemWindow=CreateMenu(CONSUMABLE_CRAFT_ITEM,CENTERED,{240,96});
consumableCraftItemWindow->ADD("Item Name Header",MenuLabel)(geom2d::rect<float>{{2,-4},{consumableCraftItemWindow->size.x-4,12}},"Item Name",1.0f,ComponentAttr::SHADOW|ComponentAttr::OUTLINE|ComponentAttr::BACKGROUND)END;
@ -71,12 +72,18 @@ void Menu::InitializeConsumableCraftItemWindow(){
consumableCraftItemWindow->ADD("Increase Craft amount Button",MenuComponent)(geom2d::rect<float>{{consumableCraftItemWindow->size.x/2+80+2,34},{12,12}},"+",[&](MenuFuncData data){
uint8_t qty=std::clamp(GetQuantity()+1,1,99);
if(!incrementButtonDisabled){
Component<MenuLabel>(CONSUMABLE_CRAFT_ITEM,"Amount to Craft Amount Label")->SetLabel(std::to_string(qty));
}
incrementButtonDisabled=false;
return true;
})END;
consumableCraftItemWindow->ADD("Decrease Craft amount Button",MenuComponent)(geom2d::rect<float>{{consumableCraftItemWindow->size.x/2+48-14,34},{12,12}},"-",[](MenuFuncData data){
uint8_t qty=std::clamp(GetQuantity()-1,1,99);
if(!incrementButtonDisabled){
Component<MenuLabel>(CONSUMABLE_CRAFT_ITEM,"Amount to Craft Amount Label")->SetLabel(std::to_string(qty));
}
incrementButtonDisabled=false;
return true;
})END;
@ -97,4 +104,83 @@ void Menu::InitializeConsumableCraftItemWindow(){
data.component.lock()->SetGrayedOut(!item.lock()->CanEnhanceItem(qty));
return true;
})END;
consumableCraftItemWindow->SetupKeyboardNavigation(
[](MenuType type,Data&returnData){ //On Open
if(Component<MenuComponent>(type,"Craft Button")->IsGreyedOut()){
returnData="Back Button";
}else{
returnData="Craft Button";
}
},
{ //Button Key
{game->KEY_START,{[](MenuFuncData data){
if(Component<MenuComponent>(data.menu.GetType(),"Craft Button")->IsGreyedOut()){
return "";
}else{
return "Craft Button";
}
},[](MenuType type){
Component<MenuComponent>(type,"Craft Button")->Click();
}}},
{{game->KEY_SHOULDER,Pressed},{"Qty Up/Down",[](MenuType type){}}},
{{game->KEY_FASTSCROLLDOWN,PressedDAS},{"",[](MenuType type){
Component<MenuComponent>(type,"Increase Craft amount Button")->Click();
if(Component<MenuComponent>(type,"Craft Button")->IsGreyedOut()){
Component<MenuComponent>(type,"Decrease Craft amount Button")->Click();
}
}}},
{{game->KEY_FASTSCROLLUP,PressedDAS},{"",[](MenuType type){
bool foundValidAmt=!Component<MenuComponent>(type,"Craft Button")->IsGreyedOut();
Component<MenuComponent>(type,"Decrease Craft amount Button")->Click();
if(foundValidAmt&&Component<MenuComponent>(type,"Craft Button")->IsGreyedOut()){
Component<MenuComponent>(type,"Increase Craft amount Button")->Click();
}
}}},
{{game->KEY_SCROLL,Pressed},{"Navigate",[](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;
if(Menu::menus[type]->GetSelection().lock()->GetName()=="Increase Craft amount Button"){
Component<MenuComponent>(type,"Increase Craft amount Button")->Click();
if(Component<MenuComponent>(type,"Craft Button")->IsGreyedOut()){
Component<MenuComponent>(type,"Decrease Craft amount Button")->Click();
}
}else
if(Menu::menus[type]->GetSelection().lock()->GetName()=="Decrease Craft amount Button"){
bool foundValidAmt=!Component<MenuComponent>(type,"Craft Button")->IsGreyedOut();
Component<MenuComponent>(type,"Decrease Craft amount Button")->Click();
if(foundValidAmt&&Component<MenuComponent>(type,"Craft Button")->IsGreyedOut()){
Component<MenuComponent>(type,"Increase Craft 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
{"Back Button",{
.up="Decrease Craft amount Button",
.down="Decrease Craft amount Button",
.left="Craft Button",
.right="Craft Button",}},
{"Craft Button",{
.up="Increase Craft amount Button",
.down="Increase Craft amount Button",
.left="Back Button",
.right="Back Button",}},
{"Increase Craft amount Button",{
.up="Craft Button",
.down="Craft Button",
.left="Decrease Craft amount Button",
.right="Decrease Craft amount Button",}},
{"Decrease Craft amount Button",{
.up="Back Button",
.down="Back Button",
.left="Increase Craft amount Button",
.right="Increase Craft amount Button",}},
});
}

@ -368,6 +368,18 @@ void Menu::KeyboardButtonNavigation(AiL*game,vf2d menuPos){
}
if(navigationGroups.count(selectionButtonName)){
Navigation nav=navigationGroups[selectionButtonName];
if(selection.lock()->IsGreyedOut()||selection.lock()->IsDisabled()){
// If the button is greyed out or disabled, this is an invalid selection. We will try to reset to a default, but we need to break out of this loop.
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);
}
break;
}
if(game->KEY_UP.PressedDAS()||game->KEY_SCROLLUP.AnalogDAS(0.5f)<-0.5f){
SoundEffect::PlaySFX("Menu Navigate",SoundEffect::CENTERED);
SetMouseNavigation(false);
@ -414,7 +426,12 @@ void Menu::KeyboardButtonNavigation(AiL*game,vf2d menuPos){
}
}else
if(!Menu::UsingMouseNavigation()){
if(std::holds_alternative<ButtonName>(defaultButton)&&std::get<ButtonName>(defaultButton).length()>0||std::holds_alternative<std::weak_ptr<MenuComponent>>(defaultButton))SetSelection(defaultButton,true);
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);
}
}else{
break; //There's no reason to be doing anything here if we navigate with the mouse.
}

@ -117,11 +117,11 @@ protected:
labelDescriptionText="";
}
if(itemNameLabelName!=""){
Component<MenuLabel>(parentMenu,itemNameLabelName)->label=labelNameText;
Component<MenuLabel>(parentMenu,itemNameLabelName)->SetLabel(labelNameText);
Component<MenuLabel>(parentMenu,itemNameLabelName)->Enable();
}
if(itemDescriptionLabelName!=""){
Component<MenuLabel>(parentMenu,itemDescriptionLabelName)->label=labelDescriptionText;
Component<MenuLabel>(parentMenu,itemDescriptionLabelName)->SetLabel(labelDescriptionText);
Component<MenuLabel>(parentMenu,itemDescriptionLabelName)->Enable();
}
}

@ -134,11 +134,11 @@ protected:
std::for_each(labelDescriptionText.begin(),labelDescriptionText.end(),[](char&c){c='?';});
}
if(itemNameLabelName!=""){
Component<MenuLabel>(parentMenu,itemNameLabelName)->label=labelNameText;
Component<MenuLabel>(parentMenu,itemNameLabelName)->SetLabel(labelNameText);
Component<MenuLabel>(parentMenu,itemNameLabelName)->Enable();
}
if(itemDescriptionLabelName!=""){
Component<MenuLabel>(parentMenu,itemDescriptionLabelName)->label=labelDescriptionText;
Component<MenuLabel>(parentMenu,itemDescriptionLabelName)->SetLabel(labelDescriptionText);
Component<MenuLabel>(parentMenu,itemDescriptionLabelName)->Enable();
}
}

@ -58,7 +58,7 @@ enum MenuType{
BLACKSMITH, //100% Controller Compatibility
CRAFT_ITEM, //100% Controller Compatibility
CRAFT_CONSUMABLE, //100% Controller Compatibility
CONSUMABLE_CRAFT_ITEM, //0% Controller Compatibility
CONSUMABLE_CRAFT_ITEM, //100% Controller Compatibility
SAVE_FILE_NAME, //100% Controller Compatibility
LOAD_GAME, //75% Controller Compatibility - Online Mode Tab switching
USER_ID, //0% Controller Compatibility

@ -1,7 +1,5 @@
January 1st
===========
- XP Bar
- Implement escape menu during gameplay.
- If you leave a stage, the stage complete window still shows up, showing only the loot you obtained that session.
@ -18,8 +16,6 @@ January 31st
- Loading Screen
- Title Screen setpieces
- Lock up unimplemented classes.
- Add Death screen (Zoom in on fatal blow, slow time down... Display some game over text... Allow retry or return to world map.)
- Hide mouse cursor during controller play. Reveal it again during mouse play.

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

Loading…
Cancel
Save