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
+23 -1
View File
@@ -281,6 +281,10 @@ void Menu::Draw(AiL*game){
draggingComponent->DrawDecal(window,this==Menu::stack.back());
}
}
if(Menu::stack.back()==this){
helpDisplay.Draw();
}
};
void Menu::OpenMenu(MenuType menu,bool cover){
@@ -297,7 +301,24 @@ void Menu::KeyboardButtonNavigation(AiL*game,vf2d menuPos){
std::weak_ptr<MenuComponent>prevSelection=selection;
for(auto&[input,data]:inputGroups){
if(input.Released()||input.Analog()!=0.f){
bool activated=false;
switch(input.GetEngageType()){
case Released:{
activated=input.GetGroup().Released();
}break;
case Pressed:{
activated=input.GetGroup().Pressed();
}break;
case Held:{
activated=input.GetGroup().Held();
}break;
case Analog:{
activated=input.GetGroup().Analog()!=0.f;
}break;
[[unlikely]]default:ERR(std::format("WARNING! Unhandled input engage type {}! THIS SHOULD NOT BE HAPPENING!",int(input.GetEngageType())));
}
if(activated){
SetMouseNavigation(false);
auto&action=data.second;
if(std::holds_alternative<ButtonName>(action))Component<MenuComponent>(type,std::get<ButtonName>(action))->Click();
@@ -624,6 +645,7 @@ MenuFuncData::MenuFuncData(Menu&menu,AiL*const game,std::weak_ptr<MenuComponent>
void Menu::SetupKeyboardNavigation(MenuDataFunc onOpen,MenuInputGroups inputGroups,ButtonNavigationGroups navigationGroups){
this->onOpenFunc=onOpen;
this->inputGroups=inputGroups;
helpDisplay.Initialize(inputGroups);
this->navigationGroups=navigationGroups;
}