diff --git a/src/battle-scene.ts b/src/battle-scene.ts index da2fd87aa52..a9796698f3f 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -63,7 +63,6 @@ import { STARTING_WAVE_OVERRIDE, OPP_SPECIES_OVERRIDE, SEED_OVERRIDE, STARTING_B import {InputsController} from "./inputs-controller"; import {UiInputs} from "./ui-inputs"; - export const bypassLogin = import.meta.env.VITE_BYPASS_LOGIN === "1"; const DEBUG_RNG = false; diff --git a/src/inputs-controller.ts b/src/inputs-controller.ts index 821f7f706c8..881c486c967 100644 --- a/src/inputs-controller.ts +++ b/src/inputs-controller.ts @@ -41,44 +41,44 @@ export class InputsController extends Phaser.Plugins.ScenePlugin { private time: Time; constructor(scene: Phaser.Scene, pluginManager: Phaser.Plugins.PluginManager, pluginKey: string) { - super(scene, pluginManager, pluginKey); - this.game = pluginManager.game; - this.scene = scene; - this.time = this.scene.time; - this.buttonKeys = []; + super(scene, pluginManager, pluginKey); + this.game = pluginManager.game; + this.scene = scene; + this.time = this.scene.time; + this.buttonKeys = []; - for (const b of Utils.getEnumValues(Button)) { - this.interactions[b] = { - pressTime: false, - isPressed: false, - } - } - // We don't want the menu key to be repeated - delete this.interactions[Button.MENU]; + for (const b of Utils.getEnumValues(Button)) { + this.interactions[b] = { + pressTime: false, + isPressed: false, + } + } + // We don't want the menu key to be repeated + delete this.interactions[Button.MENU]; } boot() { - this.eventEmitter = this.systems.events; - this.events = new Phaser.Events.EventEmitter(); - this.game.events.on(Phaser.Core.Events.STEP, this.update, this); + this.eventEmitter = this.systems.events; + this.events = new Phaser.Events.EventEmitter(); + this.game.events.on(Phaser.Core.Events.STEP, this.update, this); - if (typeof this.systems.input.gamepad !== 'undefined') { - this.systems.input.gamepad.on('connected', function (thisGamepad) { - this.refreshGamepads(); - this.setupGamepad(thisGamepad); - }, this); + if (typeof this.systems.input.gamepad !== 'undefined') { + this.systems.input.gamepad.on('connected', function (thisGamepad) { + this.refreshGamepads(); + this.setupGamepad(thisGamepad); + }, this); - // Check to see if the gamepad has already been setup by the browser - this.systems.input.gamepad.refreshPads(); - if (this.systems.input.gamepad.total) { - this.refreshGamepads(); - for (const thisGamepad of this.gamepads) { - this.systems.input.gamepad.emit('connected', thisGamepad); - } - } + // Check to see if the gamepad has already been setup by the browser + this.systems.input.gamepad.refreshPads(); + if (this.systems.input.gamepad.total) { + this.refreshGamepads(); + for (const thisGamepad of this.gamepads) { + this.systems.input.gamepad.emit('connected', thisGamepad); + } + } - this.systems.input.gamepad.on('down', this.gamepadButtonDown, this); - this.systems.input.gamepad.on('up', this.gamepadButtonUp, this); + this.systems.input.gamepad.on('down', this.gamepadButtonDown, this); + this.systems.input.gamepad.on('up', this.gamepadButtonUp, this); } // Keyboard @@ -86,139 +86,139 @@ export class InputsController extends Phaser.Plugins.ScenePlugin { } update() { - for (const b of Utils.getEnumValues(Button)) { - if (!this.interactions.hasOwnProperty(b)) continue; - if (this.repeatInputDurationJustPassed(b)) { - this.events.emit('input_down', { - controller_type: 'keyboard', - button: b, - }); - this.setLastProcessedMovementTime(b); - } - } + for (const b of Utils.getEnumValues(Button)) { + if (!this.interactions.hasOwnProperty(b)) continue; + if (this.repeatInputDurationJustPassed(b)) { + this.events.emit('input_down', { + controller_type: 'keyboard', + button: b, + }); + this.setLastProcessedMovementTime(b); + } + } } setupGamepad(thisGamepad): void { - let gamepadID = thisGamepad.id.toLowerCase(); - const mappedPad = this.mapGamepad(gamepadID); - this.player = { - 'mapping': mappedPad.gamepadMapping, - } + let gamepadID = thisGamepad.id.toLowerCase(); + const mappedPad = this.mapGamepad(gamepadID); + this.player = { + 'mapping': mappedPad.gamepadMapping, + } } refreshGamepads() :void { - // Sometimes, gamepads are undefined. For some reason. - this.gamepads = this.systems.input.gamepad.gamepads.filter(function (el) { - return el != null; - }); + // Sometimes, gamepads are undefined. For some reason. + this.gamepads = this.systems.input.gamepad.gamepads.filter(function (el) { + return el != null; + }); - for (const [index, thisGamepad] of this.gamepads.entries()) { - thisGamepad.index = index; // Overwrite the gamepad index, in case we had undefined gamepads earlier - } + for (const [index, thisGamepad] of this.gamepads.entries()) { + thisGamepad.index = index; // Overwrite the gamepad index, in case we had undefined gamepads earlier + } } getActionGamepadMapping() { - const gamepadMapping = {}; - gamepadMapping[this.player.mapping.LC_N] = Button.UP; - gamepadMapping[this.player.mapping.LC_S] = Button.DOWN; - gamepadMapping[this.player.mapping.LC_W] = Button.LEFT; - gamepadMapping[this.player.mapping.LC_E] = Button.RIGHT; - gamepadMapping[this.player.mapping.TOUCH] = Button.SUBMIT; - gamepadMapping[this.player.mapping.RC_S] = Button.ACTION; - gamepadMapping[this.player.mapping.RC_E] = Button.CANCEL; - gamepadMapping[this.player.mapping.SELECT] = Button.STATS; - gamepadMapping[this.player.mapping.START] = Button.MENU; - gamepadMapping[this.player.mapping.RB] = Button.CYCLE_SHINY; - gamepadMapping[this.player.mapping.LB] = Button.CYCLE_FORM; - gamepadMapping[this.player.mapping.LT] = Button.CYCLE_GENDER; - gamepadMapping[this.player.mapping.RT] = Button.CYCLE_ABILITY; - gamepadMapping[this.player.mapping.RC_W] = Button.CYCLE_NATURE; - gamepadMapping[this.player.mapping.RC_N] = Button.CYCLE_VARIANT; - gamepadMapping[this.player.mapping.LS] = Button.SPEED_UP; - gamepadMapping[this.player.mapping.RS] = Button.SLOW_DOWN; + const gamepadMapping = {}; + gamepadMapping[this.player.mapping.LC_N] = Button.UP; + gamepadMapping[this.player.mapping.LC_S] = Button.DOWN; + gamepadMapping[this.player.mapping.LC_W] = Button.LEFT; + gamepadMapping[this.player.mapping.LC_E] = Button.RIGHT; + gamepadMapping[this.player.mapping.TOUCH] = Button.SUBMIT; + gamepadMapping[this.player.mapping.RC_S] = Button.ACTION; + gamepadMapping[this.player.mapping.RC_E] = Button.CANCEL; + gamepadMapping[this.player.mapping.SELECT] = Button.STATS; + gamepadMapping[this.player.mapping.START] = Button.MENU; + gamepadMapping[this.player.mapping.RB] = Button.CYCLE_SHINY; + gamepadMapping[this.player.mapping.LB] = Button.CYCLE_FORM; + gamepadMapping[this.player.mapping.LT] = Button.CYCLE_GENDER; + gamepadMapping[this.player.mapping.RT] = Button.CYCLE_ABILITY; + gamepadMapping[this.player.mapping.RC_W] = Button.CYCLE_NATURE; + gamepadMapping[this.player.mapping.RC_N] = Button.CYCLE_VARIANT; + gamepadMapping[this.player.mapping.LS] = Button.SPEED_UP; + gamepadMapping[this.player.mapping.RS] = Button.SLOW_DOWN; - return gamepadMapping; + return gamepadMapping; } gamepadButtonDown(pad, button, value): void { - const actionMapping = this.getActionGamepadMapping(); - const buttonDown = actionMapping.hasOwnProperty(button.index) && actionMapping[button.index]; - if (buttonDown !== undefined) { - this.events.emit('input_down', { - controller_type: 'gamepad', - button: buttonDown, - }); - this.setLastProcessedMovementTime(buttonDown); - } + const actionMapping = this.getActionGamepadMapping(); + const buttonDown = actionMapping.hasOwnProperty(button.index) && actionMapping[button.index]; + if (buttonDown !== undefined) { + this.events.emit('input_down', { + controller_type: 'gamepad', + button: buttonDown, + }); + this.setLastProcessedMovementTime(buttonDown); + } } gamepadButtonUp(pad, button, value): void { - const actionMapping = this.getActionGamepadMapping(); - const buttonUp = actionMapping.hasOwnProperty(button.index) && actionMapping[button.index]; - if (buttonUp !== undefined) { - this.events.emit('input_up', { - controller_type: 'gamepad', - button: buttonUp, - }); - this.delLastProcessedMovementTime(buttonUp); - } + const actionMapping = this.getActionGamepadMapping(); + const buttonUp = actionMapping.hasOwnProperty(button.index) && actionMapping[button.index]; + if (buttonUp !== undefined) { + this.events.emit('input_up', { + controller_type: 'gamepad', + button: buttonUp, + }); + this.delLastProcessedMovementTime(buttonUp); + } } setupKeyboardControls(): void { - const keyCodes = Phaser.Input.Keyboard.KeyCodes; - const keyConfig = { - [Button.UP]: [keyCodes.UP, keyCodes.W], - [Button.DOWN]: [keyCodes.DOWN, keyCodes.S], - [Button.LEFT]: [keyCodes.LEFT, keyCodes.A], - [Button.RIGHT]: [keyCodes.RIGHT, keyCodes.D], - [Button.SUBMIT]: [keyCodes.ENTER], - [Button.ACTION]: [keyCodes.SPACE, keyCodes.Z], - [Button.CANCEL]: [keyCodes.BACKSPACE, keyCodes.X], - [Button.MENU]: [keyCodes.ESC, keyCodes.M], - [Button.STATS]: [keyCodes.SHIFT, keyCodes.C], - [Button.CYCLE_SHINY]: [keyCodes.R], - [Button.CYCLE_FORM]: [keyCodes.F], - [Button.CYCLE_GENDER]: [keyCodes.G], - [Button.CYCLE_ABILITY]: [keyCodes.E], - [Button.CYCLE_NATURE]: [keyCodes.N], - [Button.CYCLE_VARIANT]: [keyCodes.V], - [Button.SPEED_UP]: [keyCodes.PLUS], - [Button.SLOW_DOWN]: [keyCodes.MINUS] - }; - const mobileKeyConfig = {}; - for (const b of Utils.getEnumValues(Button)) { - const keys: Phaser.Input.Keyboard.Key[] = []; - if (keyConfig.hasOwnProperty(b)) { - for (let k of keyConfig[b]) - keys.push(this.systems.input.keyboard.addKey(k, false)); - mobileKeyConfig[Button[b]] = keys[0]; - } - this.buttonKeys[b] = keys; - } + const keyCodes = Phaser.Input.Keyboard.KeyCodes; + const keyConfig = { + [Button.UP]: [keyCodes.UP, keyCodes.W], + [Button.DOWN]: [keyCodes.DOWN, keyCodes.S], + [Button.LEFT]: [keyCodes.LEFT, keyCodes.A], + [Button.RIGHT]: [keyCodes.RIGHT, keyCodes.D], + [Button.SUBMIT]: [keyCodes.ENTER], + [Button.ACTION]: [keyCodes.SPACE, keyCodes.Z], + [Button.CANCEL]: [keyCodes.BACKSPACE, keyCodes.X], + [Button.MENU]: [keyCodes.ESC, keyCodes.M], + [Button.STATS]: [keyCodes.SHIFT, keyCodes.C], + [Button.CYCLE_SHINY]: [keyCodes.R], + [Button.CYCLE_FORM]: [keyCodes.F], + [Button.CYCLE_GENDER]: [keyCodes.G], + [Button.CYCLE_ABILITY]: [keyCodes.E], + [Button.CYCLE_NATURE]: [keyCodes.N], + [Button.CYCLE_VARIANT]: [keyCodes.V], + [Button.SPEED_UP]: [keyCodes.PLUS], + [Button.SLOW_DOWN]: [keyCodes.MINUS] + }; + const mobileKeyConfig = {}; + for (const b of Utils.getEnumValues(Button)) { + const keys: Phaser.Input.Keyboard.Key[] = []; + if (keyConfig.hasOwnProperty(b)) { + for (let k of keyConfig[b]) + keys.push(this.systems.input.keyboard.addKey(k, false)); + mobileKeyConfig[Button[b]] = keys[0]; + } + this.buttonKeys[b] = keys; + } - initTouchControls(mobileKeyConfig); - this.listenInputKeyboard(); + initTouchControls(mobileKeyConfig); + this.listenInputKeyboard(); } listenInputKeyboard(): void { - this.buttonKeys.forEach((row, index) => { - for (const key of row) { - key.on('down', () => { - this.events.emit('input_down', { - controller_type: 'keyboard', - button: index, - }); - this.setLastProcessedMovementTime(index); - }); - key.on('up', () => { - this.events.emit('input_up', { - controller_type: 'keyboard', - button: index, - }); - this.delLastProcessedMovementTime(index); - }); - } - }) + this.buttonKeys.forEach((row, index) => { + for (const key of row) { + key.on('down', () => { + this.events.emit('input_down', { + controller_type: 'keyboard', + button: index, + }); + this.setLastProcessedMovementTime(index); + }); + key.on('up', () => { + this.events.emit('input_up', { + controller_type: 'keyboard', + button: index, + }); + this.delLastProcessedMovementTime(index); + }); + } + }); } mapGamepad(id) { @@ -244,24 +244,24 @@ export class InputsController extends Phaser.Plugins.ScenePlugin { * firing a repeated input - this is to prevent multiple buttons from firing repeatedly. */ repeatInputDurationJustPassed(button: Button): boolean { - if (this.buttonLock === null || this.buttonLock !== button) { - return false; - } - if (this.time.now - this.interactions[button].pressTime >= repeatInputDelayMillis) { - this.buttonLock = null; - return true; - } + if (this.buttonLock === null || this.buttonLock !== button) { + return false; + } + if (this.time.now - this.interactions[button].pressTime >= repeatInputDelayMillis) { + this.buttonLock = null; + return true; + } } setLastProcessedMovementTime(button: Button): void { - if (!this.interactions.hasOwnProperty(button)) return; - this.buttonLock = button; - this.interactions[button].pressTime = this.time.now; + if (!this.interactions.hasOwnProperty(button)) return; + this.buttonLock = button; + this.interactions[button].pressTime = this.time.now; } delLastProcessedMovementTime(button: Button): void { - if (!this.interactions.hasOwnProperty(button)) return; - this.buttonLock = null; - this.interactions[button].pressTime = null; + if (!this.interactions.hasOwnProperty(button)) return; + this.buttonLock = null; + this.interactions[button].pressTime = null; } } \ No newline at end of file diff --git a/src/ui-inputs.ts b/src/ui-inputs.ts index 66f9951d826..68168845a03 100644 --- a/src/ui-inputs.ts +++ b/src/ui-inputs.ts @@ -8,15 +8,15 @@ import SettingsUiHandler from "#app/ui/settings-ui-handler"; export class UiInputs extends Phaser.Plugins.ScenePlugin { - private game: Phaser.Game; + private game: Phaser.Game; private scene: Phaser.Scene; - private events; + private events; constructor(scene: Phaser.Scene, pluginManager: Phaser.Plugins.PluginManager, pluginKey: string) { super(scene, pluginManager, pluginKey); this.game = pluginManager.game; this.scene = scene; - this.events = this.scene.inputController.events + this.events = this.scene.inputController.events } boot() { @@ -24,136 +24,136 @@ export class UiInputs extends Phaser.Plugins.ScenePlugin { } listenInputs(): void { - this.events.on('input_down', (event) => { - const actions = this.getActionsKeyDown(); - if (!actions.hasOwnProperty(event.button)) return; - const [inputSuccess, vibrationLength] = actions[event.button](); - if (inputSuccess && this.scene.enableVibration && typeof navigator.vibrate !== 'undefined') - navigator.vibrate(vibrationLength); - }, this); + this.events.on('input_down', (event) => { + const actions = this.getActionsKeyDown(); + if (!actions.hasOwnProperty(event.button)) return; + const [inputSuccess, vibrationLength] = actions[event.button](); + if (inputSuccess && this.scene.enableVibration && typeof navigator.vibrate !== 'undefined') + navigator.vibrate(vibrationLength); + }, this); - this.events.on('input_up', (event) => { - const actions = this.getActionsKeyUp(); - if (!actions.hasOwnProperty(event.button)) return; - const [inputSuccess, vibrationLength] = actions[event.button](); - if (inputSuccess && this.scene.enableVibration && typeof navigator.vibrate !== 'undefined') - navigator.vibrate(vibrationLength); - }, this); + this.events.on('input_up', (event) => { + const actions = this.getActionsKeyUp(); + if (!actions.hasOwnProperty(event.button)) return; + const [inputSuccess, vibrationLength] = actions[event.button](); + if (inputSuccess && this.scene.enableVibration && typeof navigator.vibrate !== 'undefined') + navigator.vibrate(vibrationLength); + }, this); } getActionsKeyDown() { - const actions = {}; - actions[Button.UP] = () => this.buttonDirection(Button.UP); - actions[Button.DOWN] = () => this.buttonDirection(Button.DOWN); - actions[Button.LEFT] = () => this.buttonDirection(Button.LEFT); - actions[Button.RIGHT] = () => this.buttonDirection(Button.RIGHT); - actions[Button.SUBMIT] = () => this.buttonTouch(); - actions[Button.ACTION] = () => this.buttonAb(Button.ACTION); - actions[Button.CANCEL] = () => this.buttonAb(Button.CANCEL); - actions[Button.MENU] = () => this.buttonMenu(); - actions[Button.STATS] = () => this.buttonStats(true); - actions[Button.CYCLE_SHINY] = () => this.buttonCycleOption(Button.CYCLE_SHINY); - actions[Button.CYCLE_FORM] = () => this.buttonCycleOption(Button.CYCLE_FORM); - actions[Button.CYCLE_GENDER] = () => this.buttonCycleOption(Button.CYCLE_GENDER); - actions[Button.CYCLE_ABILITY] = () => this.buttonCycleOption(Button.CYCLE_ABILITY); - actions[Button.CYCLE_NATURE] = () => this.buttonCycleOption(Button.CYCLE_NATURE); - actions[Button.CYCLE_VARIANT] = () => this.buttonCycleOption(Button.CYCLE_VARIANT); - actions[Button.SPEED_UP] = () => this.buttonSpeedChange(); - actions[Button.SLOW_DOWN] = () => this.buttonSpeedChange(false); - return actions; + const actions = {}; + actions[Button.UP] = () => this.buttonDirection(Button.UP); + actions[Button.DOWN] = () => this.buttonDirection(Button.DOWN); + actions[Button.LEFT] = () => this.buttonDirection(Button.LEFT); + actions[Button.RIGHT] = () => this.buttonDirection(Button.RIGHT); + actions[Button.SUBMIT] = () => this.buttonTouch(); + actions[Button.ACTION] = () => this.buttonAb(Button.ACTION); + actions[Button.CANCEL] = () => this.buttonAb(Button.CANCEL); + actions[Button.MENU] = () => this.buttonMenu(); + actions[Button.STATS] = () => this.buttonStats(true); + actions[Button.CYCLE_SHINY] = () => this.buttonCycleOption(Button.CYCLE_SHINY); + actions[Button.CYCLE_FORM] = () => this.buttonCycleOption(Button.CYCLE_FORM); + actions[Button.CYCLE_GENDER] = () => this.buttonCycleOption(Button.CYCLE_GENDER); + actions[Button.CYCLE_ABILITY] = () => this.buttonCycleOption(Button.CYCLE_ABILITY); + actions[Button.CYCLE_NATURE] = () => this.buttonCycleOption(Button.CYCLE_NATURE); + actions[Button.CYCLE_VARIANT] = () => this.buttonCycleOption(Button.CYCLE_VARIANT); + actions[Button.SPEED_UP] = () => this.buttonSpeedChange(); + actions[Button.SLOW_DOWN] = () => this.buttonSpeedChange(false); + return actions; } getActionsKeyUp() { - const actions = {}; - actions[Button.STATS] = () => this.buttonStats(false); - return actions; + const actions = {}; + actions[Button.STATS] = () => this.buttonStats(false); + return actions; } buttonDirection(direction): Array { - const inputSuccess = this.scene.ui.processInput(direction); - const vibrationLength = 5; - return [inputSuccess, vibrationLength]; + const inputSuccess = this.scene.ui.processInput(direction); + const vibrationLength = 5; + return [inputSuccess, vibrationLength]; } buttonAb(button): Array { - const inputSuccess = this.scene.ui.processInput(button); - return [inputSuccess, 0]; + const inputSuccess = this.scene.ui.processInput(button); + return [inputSuccess, 0]; } buttonTouch(): Array { - const inputSuccess = this.scene.ui.processInput(Button.SUBMIT) || this.scene.ui.processInput(Button.ACTION); - return [inputSuccess, 0]; + const inputSuccess = this.scene.ui.processInput(Button.SUBMIT) || this.scene.ui.processInput(Button.ACTION); + return [inputSuccess, 0]; } buttonStats(pressed = true): Array { - if (pressed) { - for (let p of this.scene.getField().filter(p => p?.isActive(true))) - p.toggleStats(true); - } else { - for (let p of this.scene.getField().filter(p => p?.isActive(true))) - p.toggleStats(false); - } - return [true, 0]; + if (pressed) { + for (let p of this.scene.getField().filter(p => p?.isActive(true))) + p.toggleStats(true); + } else { + for (let p of this.scene.getField().filter(p => p?.isActive(true))) + p.toggleStats(false); + } + return [true, 0]; } buttonMenu(): Array { - let inputSuccess; - if (this.scene.disableMenu) - return [true, 0]; - switch (this.scene.ui?.getMode()) { - case Mode.MESSAGE: - if (!(this.scene.ui.getHandler() as MessageUiHandler).pendingPrompt) - return [true, 0]; - case Mode.TITLE: - case Mode.COMMAND: - case Mode.FIGHT: - case Mode.BALL: - case Mode.TARGET_SELECT: - case Mode.SAVE_SLOT: - case Mode.PARTY: - case Mode.SUMMARY: - case Mode.STARTER_SELECT: - case Mode.CONFIRM: - case Mode.OPTION_SELECT: - this.scene.ui.setOverlayMode(Mode.MENU); - inputSuccess = true; - break; - case Mode.MENU: - case Mode.SETTINGS: - case Mode.ACHIEVEMENTS: - this.scene.ui.revertMode(); - this.scene.playSound('select'); - inputSuccess = true; - break; - default: - return [true, 0]; - } - return [inputSuccess, 0]; + let inputSuccess; + if (this.scene.disableMenu) + return [true, 0]; + switch (this.scene.ui?.getMode()) { + case Mode.MESSAGE: + if (!(this.scene.ui.getHandler() as MessageUiHandler).pendingPrompt) + return [true, 0]; + case Mode.TITLE: + case Mode.COMMAND: + case Mode.FIGHT: + case Mode.BALL: + case Mode.TARGET_SELECT: + case Mode.SAVE_SLOT: + case Mode.PARTY: + case Mode.SUMMARY: + case Mode.STARTER_SELECT: + case Mode.CONFIRM: + case Mode.OPTION_SELECT: + this.scene.ui.setOverlayMode(Mode.MENU); + inputSuccess = true; + break; + case Mode.MENU: + case Mode.SETTINGS: + case Mode.ACHIEVEMENTS: + this.scene.ui.revertMode(); + this.scene.playSound('select'); + inputSuccess = true; + break; + default: + return [true, 0]; + } + return [inputSuccess, 0]; } buttonCycleOption(button): Array { - let inputSuccess; - if (this.scene.ui?.getHandler() instanceof StarterSelectUiHandler) { - inputSuccess = this.scene.ui.processInput(button); - } - return [inputSuccess, 0]; + let inputSuccess; + if (this.scene.ui?.getHandler() instanceof StarterSelectUiHandler) { + inputSuccess = this.scene.ui.processInput(button); + } + return [inputSuccess, 0]; } buttonSpeedChange(up= true): Array { - if (up) { - if (this.scene.gameSpeed < 5) { - this.scene.gameData.saveSetting(Setting.Game_Speed, settingOptions[Setting.Game_Speed].indexOf(`${this.scene.gameSpeed}x`) + 1); - if (this.scene.ui?.getMode() === Mode.SETTINGS) - (this.scene.ui.getHandler() as SettingsUiHandler).show([]); - } - return [0, 0]; - } - if (this.scene.gameSpeed > 1) { - this.scene.gameData.saveSetting(Setting.Game_Speed, Math.max(settingOptions[Setting.Game_Speed].indexOf(`${this.scene.gameSpeed}x`) - 1, 0)); - if (this.scene.ui?.getMode() === Mode.SETTINGS) - (this.scene.ui.getHandler() as SettingsUiHandler).show([]); - } - return [0, 0]; + if (up) { + if (this.scene.gameSpeed < 5) { + this.scene.gameData.saveSetting(Setting.Game_Speed, settingOptions[Setting.Game_Speed].indexOf(`${this.scene.gameSpeed}x`) + 1); + if (this.scene.ui?.getMode() === Mode.SETTINGS) + (this.scene.ui.getHandler() as SettingsUiHandler).show([]); + } + return [0, 0]; + } + if (this.scene.gameSpeed > 1) { + this.scene.gameData.saveSetting(Setting.Game_Speed, Math.max(settingOptions[Setting.Game_Speed].indexOf(`${this.scene.gameSpeed}x`) - 1, 0)); + if (this.scene.ui?.getMode() === Mode.SETTINGS) + (this.scene.ui.getHandler() as SettingsUiHandler).show([]); + } + return [0, 0]; } } \ No newline at end of file