Added keyboard/controller controls for scrollable menu components beyond bounds for disabled controls.

This commit is contained in:
2023-10-17 00:50:58 -05:00
parent 958a1866c7
commit 340690a26b
6 changed files with 38 additions and 5 deletions
+20 -2
View File
@@ -402,9 +402,19 @@ void Menu::KeyboardButtonNavigation(Crawler*game,vf2d menuPos){
}
if(prevSelection!=selection){
if(selection!=vi2d{-1,-1}&&buttons[selection.y][selection.x]->disabled){
selection=prevSelection;
bool handled=false;
if(!MOUSE_NAVIGATION){
//Let's transfer some information about our selection being off the screen. Our intention with keyboard controls is that the screen will scroll to the correct location instead.
//If we return false, then we handled it ourselves, no need to go back to the previous selection.
if(HandleOutsideDisabledButtonSelection(buttons[selection.y][selection.x])){
handled=true;
}
}
if(!handled){
// If the new selection of a button on this frame is disabled for some reason and we didn't handle it, we need to go back to what we had selected before.
selection=prevSelection;
}
}
// If the new selection of a button on this frame is disabled for some reason, we need to go back to what we had selected before.
}
}
@@ -489,4 +499,12 @@ Pixel Menu::GetRenderColor(){
col=WHITE*"ThemeGlobal.MenuUnfocusedColorMult"_F;
}
return col;
}
bool Menu::HandleOutsideDisabledButtonSelection(MenuComponent*disabledButton){
if(disabledButton->parentComponent!=nullptr){
return disabledButton->parentComponent->HandleOutsideDisabledButtonSelection(disabledButton);
}else{
return false;
}
}