mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2024-11-26 08:46:55 +00:00
Starter select - Implement up and down offset navigation (#1480)
* Handle offset up and down navigation * add comments
This commit is contained in:
parent
7ac6016df3
commit
3f6e43a12d
@ -1339,11 +1339,27 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
|||||||
case Button.UP:
|
case Button.UP:
|
||||||
if (row) {
|
if (row) {
|
||||||
success = this.setCursor(this.cursor - 9);
|
success = this.setCursor(this.cursor - 9);
|
||||||
|
} else {
|
||||||
|
// when strictly opposite starter based on rows length
|
||||||
|
// does not exits, set cursor on the second to last row
|
||||||
|
if (this.cursor + (rows - 1) * 9 > genStarters - 1) {
|
||||||
|
success = this.setCursor(this.cursor + (rows - 2) * 9);
|
||||||
|
} else {
|
||||||
|
success = this.setCursor(this.cursor + (rows - 1) * 9);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Button.DOWN:
|
case Button.DOWN:
|
||||||
if (row < rows - 2 || (row < rows - 1 && this.cursor % 9 <= (genStarters - 1) % 9)) {
|
if (row < rows - 2 || (row < rows - 1 && this.cursor % 9 <= (genStarters - 1) % 9)) {
|
||||||
success = this.setCursor(this.cursor + 9);
|
success = this.setCursor(this.cursor + 9);
|
||||||
|
} else {
|
||||||
|
// if there is no starter below while being on the second to
|
||||||
|
// last row, adjust cursor position with one line less
|
||||||
|
if (row === rows - 2 && this.cursor + 9 > genStarters - 1) {
|
||||||
|
success = this.setCursor(this.cursor - (rows - 2) * 9);
|
||||||
|
} else {
|
||||||
|
success = this.setCursor(this.cursor - (rows - 1) * 9);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Button.LEFT:
|
case Button.LEFT:
|
||||||
|
Loading…
Reference in New Issue
Block a user