From 94517c0f4b61950839936ca9847648550b89efc9 Mon Sep 17 00:00:00 2001 From: TabascoEye Date: Fri, 10 Sep 2021 23:17:04 +0200 Subject: [PATCH] add the possibilities of "onaction" and message to new "openTab" property --- .../Phaser/Game/GameMapPropertiesListener.ts | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/front/src/Phaser/Game/GameMapPropertiesListener.ts b/front/src/Phaser/Game/GameMapPropertiesListener.ts index db100935..950e1ebc 100644 --- a/front/src/Phaser/Game/GameMapPropertiesListener.ts +++ b/front/src/Phaser/Game/GameMapPropertiesListener.ts @@ -13,9 +13,27 @@ export class GameMapPropertiesListener { constructor(private scene: GameScene, private gameMap: GameMap) {} register() { - this.gameMap.onPropertyChange("openTab", (newValue) => { + this.gameMap.onPropertyChange("openTab", (newValue, oldvalue, allProps) => { + if (newValue === undefined) { + layoutManagerActionStore.removeAction("openTab"); + } if (typeof newValue == "string" && newValue.length) { - scriptUtils.openTab(newValue); + const openWebsiteTriggerValue = allProps.get(TRIGGER_WEBSITE_PROPERTIES); + if (openWebsiteTriggerValue && openWebsiteTriggerValue === ON_ACTION_TRIGGER_BUTTON) { + let message = allProps.get(WEBSITE_MESSAGE_PROPERTIES); + if (message === undefined) { + message = "Press SPACE or touch here to open web site in new tab"; + } + layoutManagerActionStore.addAction({ + uuid: "openTab", + type: "message", + message: message, + callback: () => scriptUtils.openTab(newValue), + userInputManager: this.scene.userInputManager, + }); + } else { + scriptUtils.openTab(newValue); + } } }); this.gameMap.onPropertyChange("openWebsite", (newValue, oldValue, allProps) => {