|
|
|
@ -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){ |
|
|
|
|