Added partial keyboard functionality to character equip menu. Fix bugs with scrolling reset system. Release Build 7162.

This commit is contained in:
2024-02-12 02:03:27 -06:00
parent c35f1509f4
commit fd9fdc0924
9 changed files with 125 additions and 26 deletions
+23 -20
View File
@@ -303,6 +303,13 @@ void Menu::OpenMenu(MenuType menu,bool cover){
void Menu::KeyboardButtonNavigation(AiL*game,vf2d menuPos){
std::weak_ptr<MenuComponent>prevSelection=selection;
if(game->KEY_UP.Released()||game->KEY_RIGHT.Released()||game->KEY_LEFT.Released()||game->KEY_DOWN.Released()||
game->KEY_BACK.Released()||game->KEY_CONFIRM.Released()||game->KEY_START.Released()||game->KEY_SELECT.Released()||
game->KEY_SCROLLDOWN.Released()||game->KEY_SCROLLUP.Released()||game->KEY_SCROLLVERT.Analog()!=0.f||game->KEY_MENU.Released()){
SetMouseNavigation(game->GetMouse(Mouse::LEFT).bReleased||game->GetMouse(Mouse::RIGHT).bReleased||game->GetMouse(Mouse::MIDDLE).bReleased); //If a click occurs we use mouse controls.
buttonHoldTime=0;
}
if(!Menu::UsingMouseNavigation()){
for(auto&[input,data]:inputGroups){
@@ -398,13 +405,7 @@ void Menu::KeyboardButtonNavigation(AiL*game,vf2d menuPos){
if(iterationCount==MAX_ITERATIONS)ERR("WARNING! We've entered the max iteration count of automatic Menu navigation! THIS LIKELY MEANS WE'VE DONE SOMETHING TERRIBLY WRONG!");
}while(iterationCount<MAX_ITERATIONS&&(selection.lock()->grayedOut||selection.lock()->disable));
}
if(game->KEY_UP.Released()||game->KEY_RIGHT.Released()||game->KEY_LEFT.Released()||game->KEY_DOWN.Released()||
game->KEY_BACK.Released()||game->KEY_CONFIRM.Released()||game->KEY_START.Released()||game->KEY_SELECT.Released()||
game->KEY_SCROLLDOWN.Released()||game->KEY_SCROLLUP.Released()||game->KEY_SCROLLVERT.Analog()!=0.f){
SetMouseNavigation(game->GetMouse(Mouse::LEFT).bReleased||game->GetMouse(Mouse::RIGHT).bReleased||game->GetMouse(Mouse::MIDDLE).bReleased); //If a click occurs we use mouse controls.
buttonHoldTime=0;
}
if(&*prevSelection.lock()!=&*selection.lock()){
if(!selection.expired()&&selection.lock()->disableOutsideWindow){
bool handled=false;
@@ -681,17 +682,18 @@ void Menu::SetSelection(std::weak_ptr<MenuComponent>button,const bool scroll,con
keyboardSelection=button;
}
if(!selection.lock()->parentComponent.expired()&&reset){
auto scrollWindow=selection.lock()->parentComponent.lock();
scrollWindow->targetScrollOffset.y=0.f;
scrollWindow->scrollOffset.y=0.f;
scrollWindow->selectionIndex=0.f;
}
if(scroll&&!UsingMouseNavigation()&&!button.lock()->parentComponent.expired()){
auto scrollWindow=button.lock()->parentComponent.lock();
scrollWindow->HandleOutsideDisabledButtonSelection(Menu::menus[button.lock()->parentMenu]->components[button.lock()->GetName()]);
scrollWindow->selectionIndex=scrollWindow->GetComponentIndex(selection);
}
if(!selection.lock()->parentComponent.expired()&&reset){
auto scrollWindow=selection.lock()->parentComponent.lock();
scrollWindow->targetScrollOffset.y=0.f;
scrollWindow->selectionIndex=0.f;
}
}
void Menu::SetSelection(std::string_view button,const bool scroll,const bool reset){
@@ -701,20 +703,21 @@ void Menu::SetSelection(std::string_view button,const bool scroll,const bool res
keyboardSelection=selection;
}
if(!selection.lock()->parentComponent.expired()&&reset){
auto scrollWindow=selection.lock()->parentComponent.lock();
scrollWindow->targetScrollOffset.y=0.f;
scrollWindow->scrollOffset.y=0.f;
scrollWindow->selectionIndex=0.f;
}
if(scroll&&!UsingMouseNavigation()&&!selection.lock()->parentComponent.expired()){
auto scrollWindow=selection.lock()->parentComponent.lock();
scrollWindow->HandleOutsideDisabledButtonSelection(Menu::menus[selection.lock()->parentMenu]->components[selection.lock()->GetName()]);
scrollWindow->selectionIndex=scrollWindow->GetComponentIndex(selection);
}
if(!selection.lock()->parentComponent.expired()&&reset){
auto scrollWindow=selection.lock()->parentComponent.lock();
scrollWindow->targetScrollOffset.y=0.f;
scrollWindow->selectionIndex=0.f;
}
}
void Menu::SetSelection(std::variant<std::string,std::weak_ptr<MenuComponent>>button,const bool reset){
void Menu::SetSelection(Data button,const bool reset){
if(std::holds_alternative<std::string>(button)){
SetSelection(std::string_view(std::get<std::string>(button)),true,reset);
}else