When a column matches up in a previous row, we should jump up to that menu item instead.

This commit is contained in:
sigonasr2 2023-10-01 01:18:27 -05:00
parent 60e46a83f2
commit 2914aa1972
2 changed files with 19 additions and 1 deletions

View File

@ -141,7 +141,16 @@ void Menu::KeyboardButtonNavigation(Crawler*game){
}else{ }else{
for(auto&key:buttons){ for(auto&key:buttons){
if(found){ //Once we discover the previous element, the next element becomes our next selection. if(found){ //Once we discover the previous element, the next element becomes our next selection.
int previousButtonX=buttons[selection.y][selection.x].rect.pos.x;
selection.y=key.first; selection.y=key.first;
int index=0;
for(auto&button:key.second){ //Try to match a button in the same column as this button first.
if(previousButtonX==button.rect.pos.x){
selection.x=index;
break;
}
index++;
}
selectedItem=true; selectedItem=true;
break; break;
} }
@ -174,7 +183,16 @@ void Menu::KeyboardButtonNavigation(Crawler*game){
prevInd=key.first; prevInd=key.first;
} }
if(prevInd!=-1){ if(prevInd!=-1){
int previousButtonX=buttons[selection.y][selection.x].rect.pos.x;
selection.y=prevInd; selection.y=prevInd;
int index=0;
for(auto&button:buttons[prevInd]){ //Try to match a button in the same column as this button first.
if(previousButtonX==button.rect.pos.x){
selection.x=index;
break;
}
index++;
}
}else{ //Since we didn't find it, it means we're at the top of the list or the list is empty. Go to the last element and use that one. }else{ //Since we didn't find it, it means we're at the top of the list or the list is empty. Go to the last element and use that one.
int lastInd=-1; int lastInd=-1;
for(auto&key:buttons){ for(auto&key:buttons){

View File

@ -2,7 +2,7 @@
#define VERSION_MAJOR 0 #define VERSION_MAJOR 0
#define VERSION_MINOR 2 #define VERSION_MINOR 2
#define VERSION_PATCH 0 #define VERSION_PATCH 0
#define VERSION_BUILD 1643 #define VERSION_BUILD 1644
#define stringify(a) stringify_(a) #define stringify(a) stringify_(a)
#define stringify_(a) #a #define stringify_(a) #a