added top/down support from legacy settings
parent
d80c0e3d34
commit
4c39fd068c
|
@ -1,5 +1,4 @@
|
||||||
import BattleScene from "../battle-scene";
|
import BattleScene from "../battle-scene";
|
||||||
import { hasTouchscreen, isMobile } from "../touch-controls";
|
|
||||||
import {TextStyle, addTextObject} from "./text";
|
import {TextStyle, addTextObject} from "./text";
|
||||||
import {Mode} from "./ui";
|
import {Mode} from "./ui";
|
||||||
import UiHandler from "./ui-handler";
|
import UiHandler from "./ui-handler";
|
||||||
|
@ -227,6 +226,8 @@ export default class SettingsGamepadUiHandler extends UiHandler {
|
||||||
|
|
||||||
processInput(button: Button): boolean {
|
processInput(button: Button): boolean {
|
||||||
const ui = this.getUi();
|
const ui = this.getUi();
|
||||||
|
// Defines the maximum number of rows that can be displayed on the screen.
|
||||||
|
const rowsToDisplay = 9;
|
||||||
|
|
||||||
let success = false;
|
let success = false;
|
||||||
|
|
||||||
|
@ -242,14 +243,28 @@ export default class SettingsGamepadUiHandler extends UiHandler {
|
||||||
success = this.setCursor(this.cursor - 1);
|
success = this.setCursor(this.cursor - 1);
|
||||||
else
|
else
|
||||||
success = this.setScrollCursor(this.scrollCursor - 1);
|
success = this.setScrollCursor(this.scrollCursor - 1);
|
||||||
|
} else {
|
||||||
|
// When at the top of the menu and pressing UP, move to the bottommost item.
|
||||||
|
// First, set the cursor to the last visible element, preparing for the scroll to the end.
|
||||||
|
const successA = this.setCursor(rowsToDisplay - 1);
|
||||||
|
// Then, adjust the scroll to display the bottommost elements of the menu.
|
||||||
|
const successB = this.setScrollCursor(this.optionValueLabels.length - rowsToDisplay);
|
||||||
|
success = successA && successB; // success is just there to play the little validation sound effect
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Button.DOWN:
|
case Button.DOWN:
|
||||||
if (cursor < this.optionValueLabels.length) {
|
if (cursor < this.optionValueLabels.length - 1) {
|
||||||
if (this.cursor < 8)
|
if (this.cursor < rowsToDisplay - 1)
|
||||||
success = this.setCursor(this.cursor + 1);
|
success = this.setCursor(this.cursor + 1);
|
||||||
else if (this.scrollCursor < this.optionValueLabels.length - 9)
|
else if (this.scrollCursor < this.optionValueLabels.length - rowsToDisplay)
|
||||||
success = this.setScrollCursor(this.scrollCursor + 1);
|
success = this.setScrollCursor(this.scrollCursor + 1);
|
||||||
|
} else {
|
||||||
|
// When at the bottom of the menu and pressing DOWN, move to the topmost item.
|
||||||
|
// First, set the cursor to the first visible element, resetting the scroll to the top.
|
||||||
|
const successA = this.setCursor(0);
|
||||||
|
// Then, reset the scroll to start from the first element of the menu.
|
||||||
|
const successB = this.setScrollCursor(0);
|
||||||
|
success = successA && successB; // Indicates a successful cursor and scroll adjustment.
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Button.LEFT:
|
case Button.LEFT:
|
||||||
|
|
Loading…
Reference in New Issue