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