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
+7 -2
View File
@@ -60,8 +60,13 @@ void Menu::InitializeLoadGameWindow(){
Component<MenuComponent>(type,"Go Back Button")->Click();
}}},
{game->KEY_SCROLL,{"Scroll Up/Down",[](MenuType type){
auto&scrollWindow=Component<ScrollableWindowComponent>(type,"Game Files List");
scrollWindow->SetScrollAmount(scrollWindow->GetScrollAmount()+game->KEY_SCROLL.Analog()*game->GetElapsedTime()*"Interface.AnalogScrollSpeed"_F);
auto scrollWindow=Component<ScrollableWindowComponent>(type,"Game Files List");
scrollWindow->SetScrollAmount(scrollWindow->GetScrollAmount()-vf2d{0,game->KEY_SCROLL.Analog()*game->GetElapsedTime()*"Interface.AnalogScrollSpeed"_F});
for(auto component:scrollWindow->GetComponents()){
if(geom2d::overlaps(scrollWindow->GetPos()+scrollWindow->GetSize()/2,geom2d::rect<float>{component.lock()->GetPos(),component.lock()->GetSize()})){
Menu::menus[type]->SetSelection(component);
}
}
}}},
}
,{ //Button Navigation Rules