From 2914aa1972728d055c2f1ea30ed9b6b61ebcf76b Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Sun, 1 Oct 2023 01:18:27 -0500 Subject: [PATCH] When a column matches up in a previous row, we should jump up to that menu item instead. --- Crawler/Menu.cpp | 18 ++++++++++++++++++ Crawler/Version.h | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Crawler/Menu.cpp b/Crawler/Menu.cpp index 3af2371f..baa92ad9 100644 --- a/Crawler/Menu.cpp +++ b/Crawler/Menu.cpp @@ -141,7 +141,16 @@ void Menu::KeyboardButtonNavigation(Crawler*game){ }else{ for(auto&key:buttons){ 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; + 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; break; } @@ -174,7 +183,16 @@ void Menu::KeyboardButtonNavigation(Crawler*game){ prevInd=key.first; } if(prevInd!=-1){ + int previousButtonX=buttons[selection.y][selection.x].rect.pos.x; 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. int lastInd=-1; for(auto&key:buttons){ diff --git a/Crawler/Version.h b/Crawler/Version.h index 44a33eda..9a4e177a 100644 --- a/Crawler/Version.h +++ b/Crawler/Version.h @@ -2,7 +2,7 @@ #define VERSION_MAJOR 0 #define VERSION_MINOR 2 #define VERSION_PATCH 0 -#define VERSION_BUILD 1643 +#define VERSION_BUILD 1644 #define stringify(a) stringify_(a) #define stringify_(a) #a