mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-07 08:52:17 +02:00
in fact, checking the if the focus is lost is a better solution
This commit is contained in:
parent
30826c2101
commit
a7b0ad2f21
@ -34,7 +34,6 @@ 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;
|
||||||
@ -55,6 +54,10 @@ export class InputsController {
|
|||||||
|
|
||||||
init(): void {
|
init(): void {
|
||||||
this.events = new Phaser.Events.EventEmitter();
|
this.events = new Phaser.Events.EventEmitter();
|
||||||
|
// Handle the game losing focus
|
||||||
|
this.scene.game.events.on(Phaser.Core.Events.BLUR, () => {
|
||||||
|
this.loseFocus()
|
||||||
|
})
|
||||||
|
|
||||||
if (typeof this.scene.input.gamepad !== 'undefined') {
|
if (typeof this.scene.input.gamepad !== 'undefined') {
|
||||||
this.scene.input.gamepad.on('connected', function (thisGamepad) {
|
this.scene.input.gamepad.on('connected', function (thisGamepad) {
|
||||||
@ -79,12 +82,11 @@ export class InputsController {
|
|||||||
this.setupKeyboardControls();
|
this.setupKeyboardControls();
|
||||||
}
|
}
|
||||||
|
|
||||||
update(): void {
|
loseFocus(): void {
|
||||||
if (this.modalOpen) {
|
|
||||||
this.modalOpen = false;
|
|
||||||
this.deactivatePressedKey();
|
this.deactivatePressedKey();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
update(): void {
|
||||||
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) && this.interactions[b].isPressed) {
|
if (this.repeatInputDurationJustPassed(b) && this.interactions[b].isPressed) {
|
||||||
|
@ -125,7 +125,6 @@ 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;
|
||||||
},
|
},
|
||||||
@ -156,7 +155,6 @@ 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;
|
||||||
},
|
},
|
||||||
@ -190,7 +188,6 @@ 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;
|
||||||
},
|
},
|
||||||
@ -199,7 +196,6 @@ 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;
|
||||||
},
|
},
|
||||||
@ -208,7 +204,6 @@ 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