Auto targeting a component when navigating/selecting in a ScrollableWindowComponent using gamepad/keyboard controls. Added analog stick navigation to load file menu.

This commit is contained in:
2024-01-19 15:09:59 -06:00
parent df08aa9936
commit df10dc43a8
11 changed files with 69 additions and 24 deletions
+11 -1
View File
@@ -297,7 +297,7 @@ void Menu::KeyboardButtonNavigation(AiL*game,vf2d menuPos){
std::weak_ptr<MenuComponent>prevSelection=selection;
for(auto&[input,data]:inputGroups){
if(input.Released()){
if(input.Released()||input.Analog()!=0.f){
SetMouseNavigation(false);
auto&action=data.second;
if(std::holds_alternative<ButtonName>(action))Component<MenuComponent>(type,std::get<ButtonName>(action))->Click();
@@ -641,6 +641,11 @@ void Menu::SetSelection(std::weak_ptr<MenuComponent>button){
!button.lock()->parentComponent.expired()&&navigationGroups.count(button.lock()->parentComponent.lock()->GetName())){
keyboardSelection=button;
}
if(!UsingMouseNavigation()&&!button.lock()->parentComponent.expired()){
auto scrollWindow=button.lock()->parentComponent.lock();
scrollWindow->HandleOutsideDisabledButtonSelection(Menu::menus[button.lock()->parentMenu]->components[button.lock()->GetName()]);
}
}
void Menu::SetSelection(std::string_view button){
@@ -649,6 +654,11 @@ void Menu::SetSelection(std::string_view button){
!selection.lock()->parentComponent.expired()&&navigationGroups.count(selection.lock()->parentComponent.lock()->GetName())){
keyboardSelection=selection;
}
if(!UsingMouseNavigation()&&!selection.lock()->parentComponent.expired()){
auto scrollWindow=selection.lock()->parentComponent.lock();
scrollWindow->HandleOutsideDisabledButtonSelection(Menu::menus[selection.lock()->parentMenu]->components[selection.lock()->GetName()]);
}
}
void Menu::SetSelection(std::variant<std::string,std::weak_ptr<MenuComponent>>button){