From 8d0411e8a3250a0ed04006d824e951cf0a928ac4 Mon Sep 17 00:00:00 2001 From: "DESKTOP-FMM8UI0\\CLV" Date: Wed, 10 Mar 2021 09:23:45 +0100 Subject: [PATCH] can manage position and width/height of a popUp using a square in Tiled --- front/src/Phaser/Game/GameScene.ts | 11 +++++++---- maps/tests/script_api.json | 8 ++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index ca47690c..47d3cf3b 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -391,7 +391,6 @@ export class GameScene extends ResizableScene implements CenterListener { this.popUpWidth = Math.floor(object.width); this.popUpHeight = Math.floor(object.height); } - } } } @@ -757,17 +756,21 @@ export class GameScene extends ResizableScene implements CenterListener { private listenToIframeEvents(): void { iframeListener.openPopupStream.subscribe((openPopupEvent) => { const escapedMessage = HtmlUtils.escapeHtml(openPopupEvent.message); - let html = `
${escapedMessage} -
`; + `; let id = 0; for (const button of openPopupEvent.buttons) { html += ``; id++; } - const domElement = this.add.dom(this.popUpX, this.popUpY,).createFromHTML(html); + const domElement = this.add.dom(this.popUpX + this.popUpWidth/2 , + this.popUpY + this.popUpHeight/2).createFromHTML(html); + let container : HTMLDivElement = domElement.getChildByID("container") as HTMLDivElement; + container.style.width = this.popUpWidth + "px"; + container.style.height = this.popUpHeight + "px"; domElement.scale = 0; domElement.setClassName('popUpElement'); diff --git a/maps/tests/script_api.json b/maps/tests/script_api.json index e82ab12b..7889877d 100644 --- a/maps/tests/script_api.json +++ b/maps/tests/script_api.json @@ -75,15 +75,15 @@ "name":"floorLayer", "objects":[ { - "height":195.65688359926, + "height":162.662798398032, "id":1, "name":"myPopup", "rotation":0, "type":"", "visible":true, - "width":315.393884378036, - "x":-0.29745661104063, - "y":-0.433231160918936 + "width":16.3413326605909, + "x":275.392367109435, + "y":141.649957637921 }], "opacity":1, "type":"objectgroup",