mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-06 16:32:16 +02:00
disable all key pressed when trying to open a modal
This commit is contained in:
parent
4aad37a758
commit
30826c2101
@ -34,6 +34,7 @@ export class InputsController {
|
||||
private interactions: Map<Button, Map<string, boolean>> = new Map();
|
||||
private time: Time;
|
||||
private player: Map<String, GamepadMapping> = new Map();
|
||||
public modalOpen: boolean = false;
|
||||
|
||||
constructor(scene: Phaser.Scene) {
|
||||
this.scene = scene;
|
||||
@ -79,9 +80,14 @@ export class InputsController {
|
||||
}
|
||||
|
||||
update(): void {
|
||||
if (this.modalOpen) {
|
||||
this.modalOpen = false;
|
||||
this.deactivatePressedKey();
|
||||
return;
|
||||
}
|
||||
for (const b of Utils.getEnumValues(Button)) {
|
||||
if (!this.interactions.hasOwnProperty(b)) continue;
|
||||
if (this.repeatInputDurationJustPassed(b)) {
|
||||
if (this.repeatInputDurationJustPassed(b) && this.interactions[b].isPressed) {
|
||||
this.events.emit('input_down', {
|
||||
controller_type: 'repeated',
|
||||
button: b,
|
||||
@ -166,8 +172,8 @@ export class InputsController {
|
||||
[Button.LEFT]: [keyCodes.LEFT, keyCodes.A],
|
||||
[Button.RIGHT]: [keyCodes.RIGHT, keyCodes.D],
|
||||
[Button.SUBMIT]: [keyCodes.ENTER],
|
||||
[Button.ACTION]: [keyCodes.SPACE, this.scene.abSwapped ? keyCodes.X : keyCodes.Z],
|
||||
[Button.CANCEL]: [keyCodes.BACKSPACE, this.scene.abSwapped ? keyCodes.Z : keyCodes.X],
|
||||
[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],
|
||||
@ -248,11 +254,22 @@ export class InputsController {
|
||||
if (!this.interactions.hasOwnProperty(button)) return;
|
||||
this.buttonLock = button;
|
||||
this.interactions[button].pressTime = this.time.now;
|
||||
this.interactions[button].isPressed = true;
|
||||
}
|
||||
|
||||
delLastProcessedMovementTime(button: Button): void {
|
||||
if (!this.interactions.hasOwnProperty(button)) return;
|
||||
this.buttonLock = null;
|
||||
this.interactions[button].pressTime = null;
|
||||
this.interactions[button].isPressed = false;
|
||||
}
|
||||
|
||||
deactivatePressedKey(): void {
|
||||
this.buttonLock = null;
|
||||
for (const b of Utils.getEnumValues(Button)) {
|
||||
if (!this.interactions.hasOwnProperty(b)) return;
|
||||
this.interactions[b].pressTime = null;
|
||||
this.interactions[b].isPressed = false;
|
||||
}
|
||||
}
|
||||
}
|
@ -125,6 +125,7 @@ export default class MenuUiHandler extends MessageUiHandler {
|
||||
manageDataOptions.push({
|
||||
label: i18next.t("menuUiHandler:importSession"),
|
||||
handler: () => {
|
||||
this.scene.inputController.modalOpen = true;
|
||||
confirmSlot(i18next.t("menuUiHandler:importSlotSelect"), () => true, slotId => this.scene.gameData.importData(GameDataType.SESSION, slotId));
|
||||
return true;
|
||||
},
|
||||
@ -155,6 +156,7 @@ export default class MenuUiHandler extends MessageUiHandler {
|
||||
manageDataOptions.push({
|
||||
label: i18next.t("menuUiHandler:importData"),
|
||||
handler: () => {
|
||||
this.scene.inputController.modalOpen = true;
|
||||
this.scene.gameData.importData(GameDataType.SYSTEM);
|
||||
return true;
|
||||
},
|
||||
@ -188,6 +190,7 @@ export default class MenuUiHandler extends MessageUiHandler {
|
||||
{
|
||||
label: 'Wiki',
|
||||
handler: () => {
|
||||
this.scene.inputController.modalOpen = true;
|
||||
window.open(wikiUrl, '_blank').focus();
|
||||
return true;
|
||||
},
|
||||
@ -196,6 +199,7 @@ export default class MenuUiHandler extends MessageUiHandler {
|
||||
{
|
||||
label: 'Discord',
|
||||
handler: () => {
|
||||
this.scene.inputController.modalOpen = true;
|
||||
window.open(discordUrl, '_blank').focus();
|
||||
return true;
|
||||
},
|
||||
@ -204,6 +208,7 @@ export default class MenuUiHandler extends MessageUiHandler {
|
||||
{
|
||||
label: 'GitHub',
|
||||
handler: () => {
|
||||
this.scene.inputController.modalOpen = true;
|
||||
window.open(githubUrl, '_blank').focus();
|
||||
return true;
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user