mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-09-24 07:23: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_")) {
|
if (this.settingBlacklisted.includes(setting) || setting.includes("BUTTON_")) {
|
||||||
success = false;
|
success = false;
|
||||||
} else if (this.optionCursors[cursor]) {
|
} else {
|
||||||
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;
|
break;
|
||||||
case Button.RIGHT: // Move selection right within the current option set.
|
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_")) {
|
if (this.settingBlacklisted.includes(setting) || setting.includes("BUTTON_")) {
|
||||||
success = false;
|
success = false;
|
||||||
} else if (this.optionCursors[cursor] < this.optionValueLabels[cursor].length - 1) {
|
} else {
|
||||||
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;
|
break;
|
||||||
case Button.CYCLE_FORM:
|
case Button.CYCLE_FORM:
|
||||||
|
@ -318,16 +318,20 @@ export class AbstractSettingsUiHandler extends MessageUiHandler {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Button.LEFT:
|
case Button.LEFT:
|
||||||
if (this.optionCursors[cursor]) {
|
// Cycle to the rightmost position when at the leftmost, otherwise move left
|
||||||
// Moves the option cursor left, if possible.
|
success = this.setOptionCursor(
|
||||||
success = this.setOptionCursor(cursor, this.optionCursors[cursor] - 1, true);
|
cursor,
|
||||||
}
|
Phaser.Math.Wrap(this.optionCursors[cursor] - 1, 0, this.optionValueLabels[cursor].length),
|
||||||
|
true,
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
case Button.RIGHT:
|
case Button.RIGHT:
|
||||||
// Moves the option cursor right, if possible.
|
// Cycle to the leftmost position when at the rightmost, otherwise move right
|
||||||
if (this.optionCursors[cursor] < this.optionValueLabels[cursor].length - 1) {
|
success = this.setOptionCursor(
|
||||||
success = this.setOptionCursor(cursor, this.optionCursors[cursor] + 1, true);
|
cursor,
|
||||||
}
|
Phaser.Math.Wrap(this.optionCursors[cursor] + 1, 0, this.optionValueLabels[cursor].length),
|
||||||
|
true,
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
case Button.CYCLE_FORM:
|
case Button.CYCLE_FORM:
|
||||||
case Button.CYCLE_SHINY:
|
case Button.CYCLE_SHINY:
|
||||||
|
Loading…
Reference in New Issue
Block a user