diff --git a/Adventures in Lestoria/Menu.cpp b/Adventures in Lestoria/Menu.cpp index e7e74d96..6c4f4e7a 100644 --- a/Adventures in Lestoria/Menu.cpp +++ b/Adventures in Lestoria/Menu.cpp @@ -203,6 +203,7 @@ void Menu::Update(AiL*game){ } } }else{ + selection={}; for(auto&[key,component]:components){ if(component->selectable){ if(!component->disabled&&!component->grayedOut){ @@ -321,33 +322,35 @@ void Menu::SetDefaultButton(std::weak_ptrbutton){ void Menu::KeyboardButtonNavigation(AiL*game,vf2d menuPos){ std::weak_ptrprevSelection=selection; - std::string selectionButtonName=selection.lock()->GetName(); - if(navigationGroups.count(selectionButtonName)){ - Navigation nav=navigationGroups[selectionButtonName]; + if(!selection.expired()){ + std::string selectionButtonName=selection.lock()->GetName(); + if(navigationGroups.count(selectionButtonName)){ + Navigation nav=navigationGroups[selectionButtonName]; - if(game->KEY_UP.Pressed()){ - SetMouseNavigation(false); - if(std::holds_alternative(nav.up)&&std::get(nav.up).length()>0)selection=components[std::get(nav.up)]; - else - if(std::holds_alternative(nav.up))std::get(nav.up)(type); - } - if(game->KEY_DOWN.Pressed()){ - SetMouseNavigation(false); - if(std::holds_alternative(nav.down)&&std::get(nav.down).length()>0)selection=components[std::get(nav.down)]; - else - if(std::holds_alternative(nav.down))std::get(nav.down)(type); - } - if(game->KEY_LEFT.Pressed()){ - SetMouseNavigation(false); - if(std::holds_alternative(nav.left)&&std::get(nav.left).length()>0)selection=components[std::get(nav.left)]; - else - if(std::holds_alternative(nav.left))std::get(nav.left)(type); - } - if(game->KEY_RIGHT.Pressed()){ - SetMouseNavigation(false); - if(std::holds_alternative(nav.right)&&std::get(nav.right).length()>0)selection=components[std::get(nav.right)]; - else - if(std::holds_alternative(nav.right))std::get(nav.right)(type); + if(game->KEY_UP.Pressed()){ + SetMouseNavigation(false); + if(std::holds_alternative(nav.up)&&std::get(nav.up).length()>0)selection=components[std::get(nav.up)]; + else + if(std::holds_alternative(nav.up))std::get(nav.up)(type); + } + if(game->KEY_DOWN.Pressed()){ + SetMouseNavigation(false); + if(std::holds_alternative(nav.down)&&std::get(nav.down).length()>0)selection=components[std::get(nav.down)]; + else + if(std::holds_alternative(nav.down))std::get(nav.down)(type); + } + if(game->KEY_LEFT.Pressed()){ + SetMouseNavigation(false); + if(std::holds_alternative(nav.left)&&std::get(nav.left).length()>0)selection=components[std::get(nav.left)]; + else + if(std::holds_alternative(nav.left))std::get(nav.left)(type); + } + if(game->KEY_RIGHT.Pressed()){ + SetMouseNavigation(false); + if(std::holds_alternative(nav.right)&&std::get(nav.right).length()>0)selection=components[std::get(nav.right)]; + else + if(std::holds_alternative(nav.right))std::get(nav.right)(type); + } } } diff --git a/Adventures in Lestoria/Menu.h b/Adventures in Lestoria/Menu.h index b61750ff..2e19322f 100644 --- a/Adventures in Lestoria/Menu.h +++ b/Adventures in Lestoria/Menu.h @@ -163,7 +163,6 @@ public: }else{ component->depth=depth; } - RecalculateComponentCount(); if(components.count(componentKey)){ ERR("WARNING! Key "<SetupKeyboardNavigation( { diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index e2c26062..25956157 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 2 #define VERSION_PATCH 1 -#define VERSION_BUILD 5969 +#define VERSION_BUILD 5974 #define stringify(a) stringify_(a) #define stringify_(a) #a