From a044afd34ca46eb82f4ecee1bfbf1de2bc0cc805 Mon Sep 17 00:00:00 2001 From: _Bastler <_Bastler@bstly.de> Date: Mon, 1 Nov 2021 19:14:53 +0100 Subject: [PATCH] fix cowebsite --- .../Phaser/Game/GameMapPropertiesListener.ts | 18 +++++++++----- front/src/Phaser/Game/GameScene.ts | 24 +------------------ 2 files changed, 13 insertions(+), 29 deletions(-) diff --git a/front/src/Phaser/Game/GameMapPropertiesListener.ts b/front/src/Phaser/Game/GameMapPropertiesListener.ts index 3ae6d714..d86becc5 100644 --- a/front/src/Phaser/Game/GameMapPropertiesListener.ts +++ b/front/src/Phaser/Game/GameMapPropertiesListener.ts @@ -16,6 +16,7 @@ enum OpenCoWebsiteState { LOADING, OPENED, MUST_BE_CLOSE, + TRIGGER, } interface OpenCoWebsite { @@ -106,11 +107,6 @@ export class GameMapPropertiesListener { return; } - this.coWebsitesOpenByLayer.set(layer, { - coWebsite: undefined, - state: OpenCoWebsiteState.LOADING, - }); - const openWebsiteFunction = () => { coWebsiteManager.loadCoWebsite( openWebsiteProperty as string, @@ -137,6 +133,11 @@ export class GameMapPropertiesListener { }; if (websiteTriggerProperty && websiteTriggerProperty === ON_ACTION_TRIGGER_BUTTON) { + this.coWebsitesOpenByLayer.set(layer, { + coWebsite: undefined, + state: OpenCoWebsiteState.TRIGGER, + }); + if (!websiteTriggerMessageProperty) { websiteTriggerMessageProperty = "Press SPACE or touch here to open web site"; } @@ -151,6 +152,11 @@ export class GameMapPropertiesListener { userInputManager: this.scene.userInputManager, }); } else { + this.coWebsitesOpenByLayer.set(layer, { + coWebsite: undefined, + state: OpenCoWebsiteState.LOADING, + }); + openWebsiteFunction(); } }); @@ -196,7 +202,7 @@ export class GameMapPropertiesListener { return; } - if (coWebsiteOpen.state !== OpenCoWebsiteState.OPENED) { + if (coWebsiteOpen.state !== OpenCoWebsiteState.OPENED && coWebsiteOpen.state !== OpenCoWebsiteState.TRIGGER) { return; } diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 11540e05..449266ae 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -1183,29 +1183,7 @@ export class GameScene extends DirtyScene { ); this.iframeSubscriptionList.push(iframeListener.unregisterIFrameStream.subscribe(() => { - const allProps = this.gameMap.getCurrentProperties(); - if (allProps.get("openWebsite") == null) { - layoutManagerActionStore.removeAction("openWebsite"); - } else { - const openWebsiteFunction = () => { - coWebsiteManager.loadCoWebsite(allProps.get("openWebsite") as string, this.MapUrlFile, allProps.get('openWebsiteAllowApi') as boolean | undefined, allProps.get('openWebsitePolicy') as string | undefined); - layoutManagerActionStore.removeAction("openWebsite"); - - }; - - let message = allProps.get(WEBSITE_MESSAGE_PROPERTIES); - if (message === undefined) { - message = 'Press SPACE or touch here to open web site'; - } - - layoutManagerActionStore.addAction({ - uuid: "openWebsite", - type: "message", - message: message, - callback: () => openWebsiteFunction(), - userInputManager: this.userInputManager, - }); - } + // TODO: open trigger })); this.iframeSubscriptionList.push(iframeListener.setTilesStream.subscribe((eventTiles) => {