Add in input helper text when navigating using keyboard/gamepads. Fix scrollwheel navigation for ScrollingWindowComponent referencing the wrong variable to add to (after the targeted scroll destination change).

This commit is contained in:
2024-01-20 12:50:12 -06:00
parent a97bc7b2f0
commit 9dc2a0a4c2
15 changed files with 571 additions and 178 deletions
+18 -10
View File
@@ -47,6 +47,20 @@ void Menu::InitializeLoadGameWindow(){
loadGameWindow->ADD("Game Files List",ScrollableWindowComponent)(geom2d::rect<float>{{-8,4},{112,116}})END;
loadGameWindow->ADD("Go Back Button",MenuComponent)(geom2d::rect<float>{{24,124},{48,12}},"Back",[](MenuFuncData menu){Menu::CloseMenu();return true;})END;
#pragma region ScrollWindow macro lambda
#define ScrollWindow(amount) \
[](MenuType type){ \
auto scrollWindow=Component<ScrollableWindowComponent>(type,"Game Files List"); \
float scrollAmt=amount*game->GetElapsedTime()*"Interface.AnalogScrollSpeed"_F; \
\
scrollWindow->SetScrollAmount(scrollWindow->GetTargetScrollAmount()-vf2d{0,amount*game->GetElapsedTime()*"Interface.AnalogScrollSpeed"_F}); \
\
/*Height of these buttons is 48.*/ \
scrollWindow->IncreaseSelectionIndex(scrollAmt/48.f); \
}
#pragma endregion
loadGameWindow->SetupKeyboardNavigation(
[](MenuType type,Data&returnData){ //On Open
if(SaveFile::GetSaveFileCount()>0){
@@ -56,18 +70,12 @@ void Menu::InitializeLoadGameWindow(){
}
},
{ //Button Key
{game->KEY_BACK,{"Back to Title Screen",[](MenuType type){
{{game->KEY_BACK},{"Back to Title Screen",[](MenuType type){
Component<MenuComponent>(type,"Go Back Button")->Click();
}}},
{game->KEY_SCROLL,{"Scroll Up/Down",[](MenuType type){
auto scrollWindow=Component<ScrollableWindowComponent>(type,"Game Files List");
float scrollAmt=game->KEY_SCROLL.Analog()*game->GetElapsedTime()*"Interface.AnalogScrollSpeed"_F;
scrollWindow->SetScrollAmount(scrollWindow->GetTargetScrollAmount()-vf2d{0,game->KEY_SCROLL.Analog()*game->GetElapsedTime()*"Interface.AnalogScrollSpeed"_F});
//Height of these buttons is 48.
scrollWindow->IncreaseSelectionIndex(scrollAmt/48.f);
}}},
{{game->KEY_SCROLL,Analog},{"Scroll",ScrollWindow(game->KEY_SCROLL.Analog())}},
{{game->KEY_SCROLLUP,Held},{"Scroll Up",ScrollWindow(-1.0f)}},
{{game->KEY_SCROLLDOWN,Held},{"Scroll Down",ScrollWindow(1.0f)}},
}
,{ //Button Navigation Rules
{"Game Files List",{