mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-09-23 15:03:24 +02:00
[UI] Add cyclic navigation in settings menu for LEFT/RIGHT buttons (#6404)
* feat: add cyclic navigation to settings menu * review > refactor: use Phaser.Math.Wrap instead the ternary operator
This commit is contained in:
parent
b5124ae3ce
commit
444080bb78
@ -544,8 +544,13 @@ export abstract class AbstractControlSettingsUiHandler extends UiHandler {
|
||||
}
|
||||
if (this.settingBlacklisted.includes(setting) || setting.includes("BUTTON_")) {
|
||||
success = false;
|
||||
} else if (this.optionCursors[cursor]) {
|
||||
success = this.setOptionCursor(cursor, this.optionCursors[cursor] - 1, true);
|
||||
} else {
|
||||
// Cycle to the rightmost position when at the leftmost, otherwise move left
|
||||
success = this.setOptionCursor(
|
||||
cursor,
|
||||
Phaser.Math.Wrap(this.optionCursors[cursor] - 1, 0, this.optionValueLabels[cursor].length),
|
||||
true,
|
||||
);
|
||||
}
|
||||
break;
|
||||
case Button.RIGHT: // Move selection right within the current option set.
|
||||
@ -554,8 +559,13 @@ export abstract class AbstractControlSettingsUiHandler extends UiHandler {
|
||||
}
|
||||
if (this.settingBlacklisted.includes(setting) || setting.includes("BUTTON_")) {
|
||||
success = false;
|
||||
} else if (this.optionCursors[cursor] < this.optionValueLabels[cursor].length - 1) {
|
||||
success = this.setOptionCursor(cursor, this.optionCursors[cursor] + 1, true);
|
||||
} else {
|
||||
// Cycle to the leftmost position when at the rightmost, otherwise move right
|
||||
success = this.setOptionCursor(
|
||||
cursor,
|
||||
Phaser.Math.Wrap(this.optionCursors[cursor] + 1, 0, this.optionValueLabels[cursor].length),
|
||||
true,
|
||||
);
|
||||
}
|
||||
break;
|
||||
case Button.CYCLE_FORM:
|
||||
|
@ -318,16 +318,20 @@ export class AbstractSettingsUiHandler extends MessageUiHandler {
|
||||
}
|
||||
break;
|
||||
case Button.LEFT:
|
||||
if (this.optionCursors[cursor]) {
|
||||
// Moves the option cursor left, if possible.
|
||||
success = this.setOptionCursor(cursor, this.optionCursors[cursor] - 1, true);
|
||||
}
|
||||
// Cycle to the rightmost position when at the leftmost, otherwise move left
|
||||
success = this.setOptionCursor(
|
||||
cursor,
|
||||
Phaser.Math.Wrap(this.optionCursors[cursor] - 1, 0, this.optionValueLabels[cursor].length),
|
||||
true,
|
||||
);
|
||||
break;
|
||||
case Button.RIGHT:
|
||||
// Moves the option cursor right, if possible.
|
||||
if (this.optionCursors[cursor] < this.optionValueLabels[cursor].length - 1) {
|
||||
success = this.setOptionCursor(cursor, this.optionCursors[cursor] + 1, true);
|
||||
}
|
||||
// Cycle to the leftmost position when at the rightmost, otherwise move right
|
||||
success = this.setOptionCursor(
|
||||
cursor,
|
||||
Phaser.Math.Wrap(this.optionCursors[cursor] + 1, 0, this.optionValueLabels[cursor].length),
|
||||
true,
|
||||
);
|
||||
break;
|
||||
case Button.CYCLE_FORM:
|
||||
case Button.CYCLE_SHINY:
|
||||
|
Loading…
Reference in New Issue
Block a user