mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-16 05:12:19 +02:00
reset mapping to default on press the Home button
This commit is contained in:
parent
a2e0c1c5f1
commit
a6b150a48c
@ -691,6 +691,13 @@ export class InputsController {
|
|||||||
this.configs[selectedDevice].custom = mappingConfigs.custom;
|
this.configs[selectedDevice].custom = mappingConfigs.custom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resetConfigs(): void {
|
||||||
|
this.configs = new Map();
|
||||||
|
if (this.getGamepadsName()?.length)
|
||||||
|
this.setupGamepad(this.selectedDevice[Device.GAMEPAD]);
|
||||||
|
this.setupKeyboard();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Swaps a binding in the configuration.
|
* Swaps a binding in the configuration.
|
||||||
*
|
*
|
||||||
|
@ -589,6 +589,13 @@ export class GameData {
|
|||||||
return true; // Return true to indicate the operation was successful
|
return true; // Return true to indicate the operation was successful
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public resetMappingToFactory(): boolean {
|
||||||
|
if (!localStorage.hasOwnProperty('mappingConfigs')) // Check if 'mappingConfigs' exists in localStorage
|
||||||
|
return false; // If 'mappingConfigs' does not exist, return false
|
||||||
|
localStorage.removeItem('mappingConfigs');
|
||||||
|
this.scene.inputController.resetConfigs();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves a gamepad setting to localStorage.
|
* Saves a gamepad setting to localStorage.
|
||||||
*
|
*
|
||||||
|
@ -40,7 +40,9 @@ export default class SettingsKeyboardUiHandler extends AbstractSettingsUiUiHandl
|
|||||||
this.settingBlacklisted = settingKeyboardBlackList;
|
this.settingBlacklisted = settingKeyboardBlackList;
|
||||||
|
|
||||||
const deleteEvent = scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.DELETE);
|
const deleteEvent = scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.DELETE);
|
||||||
|
const restoreDefaultEvent = scene.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.HOME);
|
||||||
deleteEvent.on('up', this.onDeleteDown, this);
|
deleteEvent.on('up', this.onDeleteDown, this);
|
||||||
|
restoreDefaultEvent.on('up', this.onHomeDown, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
setSetting(scene: BattleScene, setting, value: integer): boolean {
|
setSetting(scene: BattleScene, setting, value: integer): boolean {
|
||||||
@ -66,6 +68,14 @@ export default class SettingsKeyboardUiHandler extends AbstractSettingsUiUiHandl
|
|||||||
this.layout['noKeyboard'].label = label;
|
this.layout['noKeyboard'].label = label;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the home key press event.
|
||||||
|
*/
|
||||||
|
onHomeDown(): void {
|
||||||
|
if (![Mode.SETTINGS_KEYBOARD, Mode.SETTINGS, Mode.SETTINGS_GAMEPAD].includes(this.scene.ui.getMode())) return;
|
||||||
|
this.scene.gameData.resetMappingToFactory();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle the delete key press event.
|
* Handle the delete key press event.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user