mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-16 13:22:18 +02:00
removed the selected device in the storage, allowing changing main gamepad with a refresh
This commit is contained in:
parent
b00acc32f0
commit
34f19cec04
@ -136,9 +136,6 @@ export class InputsController {
|
|||||||
init(): void {
|
init(): void {
|
||||||
this.events = this.scene.game.events;
|
this.events = this.scene.game.events;
|
||||||
|
|
||||||
if (localStorage.hasOwnProperty('selectedDevice')) {
|
|
||||||
this.selectedDevice = JSON.parse(localStorage.getItem('selectedDevice'));
|
|
||||||
}
|
|
||||||
this.scene.game.events.on(Phaser.Core.Events.BLUR, () => {
|
this.scene.game.events.on(Phaser.Core.Events.BLUR, () => {
|
||||||
this.loseFocus()
|
this.loseFocus()
|
||||||
})
|
})
|
||||||
@ -275,7 +272,6 @@ export class InputsController {
|
|||||||
initChosenGamepad(gamepadName?: String): void {
|
initChosenGamepad(gamepadName?: String): void {
|
||||||
if (gamepadName)
|
if (gamepadName)
|
||||||
this.selectedDevice[Device.GAMEPAD] = gamepadName.toLowerCase();
|
this.selectedDevice[Device.GAMEPAD] = gamepadName.toLowerCase();
|
||||||
localStorage.setItem('selectedDevice', JSON.stringify(this.selectedDevice));
|
|
||||||
const handler = this.scene.ui?.handlers[Mode.SETTINGS_GAMEPAD] as SettingsGamepadUiHandler;
|
const handler = this.scene.ui?.handlers[Mode.SETTINGS_GAMEPAD] as SettingsGamepadUiHandler;
|
||||||
handler && handler.updateChosenGamepadDisplay()
|
handler && handler.updateChosenGamepadDisplay()
|
||||||
}
|
}
|
||||||
@ -288,7 +284,6 @@ export class InputsController {
|
|||||||
initChosenLayoutKeyboard(layoutKeyboard?: String): void {
|
initChosenLayoutKeyboard(layoutKeyboard?: String): void {
|
||||||
if (layoutKeyboard)
|
if (layoutKeyboard)
|
||||||
this.selectedDevice[Device.KEYBOARD] = layoutKeyboard.toLowerCase();
|
this.selectedDevice[Device.KEYBOARD] = layoutKeyboard.toLowerCase();
|
||||||
localStorage.setItem('selectedDevice', JSON.stringify(this.selectedDevice));
|
|
||||||
const handler = this.scene.ui?.handlers[Mode.SETTINGS_KEYBOARD] as SettingsKeyboardUiHandler;
|
const handler = this.scene.ui?.handlers[Mode.SETTINGS_KEYBOARD] as SettingsKeyboardUiHandler;
|
||||||
handler && handler.updateChosenKeyboardDisplay()
|
handler && handler.updateChosenKeyboardDisplay()
|
||||||
}
|
}
|
||||||
@ -325,7 +320,6 @@ export class InputsController {
|
|||||||
* @param thisGamepad The gamepad that is being set up.
|
* @param thisGamepad The gamepad that is being set up.
|
||||||
*/
|
*/
|
||||||
setupGamepad(thisGamepad: Phaser.Input.Gamepad.Gamepad): void {
|
setupGamepad(thisGamepad: Phaser.Input.Gamepad.Gamepad): void {
|
||||||
this.lastSource = 'gamepad';
|
|
||||||
const allGamepads = this.getGamepadsName();
|
const allGamepads = this.getGamepadsName();
|
||||||
for (const gamepad of allGamepads) {
|
for (const gamepad of allGamepads) {
|
||||||
const gamepadID = gamepad.toLowerCase();
|
const gamepadID = gamepad.toLowerCase();
|
||||||
@ -336,7 +330,7 @@ export class InputsController {
|
|||||||
this.configs[gamepadID] = config;
|
this.configs[gamepadID] = config;
|
||||||
this.scene.gameData?.saveMappingConfigs(gamepadID, this.configs[gamepadID]);
|
this.scene.gameData?.saveMappingConfigs(gamepadID, this.configs[gamepadID]);
|
||||||
}
|
}
|
||||||
this.initChosenGamepad(this.selectedDevice[Device.GAMEPAD])
|
this.lastSource = 'gamepad';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user