Reverts adding scale to the camera updated event and uses it directly from the website manager
This commit is contained in:
parent
f761858328
commit
7eda8a45a7
@ -28,7 +28,6 @@ import type { MessageReferenceEvent } from "./ui/TriggerActionMessageEvent";
|
|||||||
import { isMessageReferenceEvent, isTriggerActionMessageEvent } from "./ui/TriggerActionMessageEvent";
|
import { isMessageReferenceEvent, isTriggerActionMessageEvent } from "./ui/TriggerActionMessageEvent";
|
||||||
import type { MenuRegisterEvent, UnregisterMenuEvent } from "./ui/MenuRegisterEvent";
|
import type { MenuRegisterEvent, UnregisterMenuEvent } from "./ui/MenuRegisterEvent";
|
||||||
import type { ChangeLayerEvent } from "./ChangeLayerEvent";
|
import type { ChangeLayerEvent } from "./ChangeLayerEvent";
|
||||||
import { isPlayerPropertyEvent } from "./PlayerPropertyEvent";
|
|
||||||
import { isPlayerPosition } from "./PlayerPosition";
|
import { isPlayerPosition } from "./PlayerPosition";
|
||||||
import type { WasCameraUpdatedEvent } from "./WasCameraUpdatedEvent";
|
import type { WasCameraUpdatedEvent } from "./WasCameraUpdatedEvent";
|
||||||
|
|
||||||
|
@ -26,8 +26,8 @@ export class EmbeddedWebsiteManager {
|
|||||||
position: {
|
position: {
|
||||||
x: website.phaserObject.x,
|
x: website.phaserObject.x,
|
||||||
y: website.phaserObject.y,
|
y: website.phaserObject.y,
|
||||||
width: rect["width"],
|
width: website.phaserObject.width,
|
||||||
height: rect["height"],
|
height: website.phaserObject.height,
|
||||||
},
|
},
|
||||||
origin: website.origin,
|
origin: website.origin,
|
||||||
scale: website.scale,
|
scale: website.scale,
|
||||||
@ -111,14 +111,18 @@ export class EmbeddedWebsiteManager {
|
|||||||
website.phaserObject.y = embeddedWebsiteEvent.y;
|
website.phaserObject.y = embeddedWebsiteEvent.y;
|
||||||
}
|
}
|
||||||
if (embeddedWebsiteEvent?.width !== undefined) {
|
if (embeddedWebsiteEvent?.width !== undefined) {
|
||||||
website.iframe.style.width = embeddedWebsiteEvent.width + "px";
|
website.position.width = embeddedWebsiteEvent.width;
|
||||||
|
website.iframe.style.width = embeddedWebsiteEvent.width / website.phaserObject.scale + "px";
|
||||||
}
|
}
|
||||||
if (embeddedWebsiteEvent?.height !== undefined) {
|
if (embeddedWebsiteEvent?.height !== undefined) {
|
||||||
website.iframe.style.height = embeddedWebsiteEvent.height + "px";
|
website.position.height = embeddedWebsiteEvent.height;
|
||||||
|
website.iframe.style.height = embeddedWebsiteEvent.height / website.phaserObject.scale + "px";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (embeddedWebsiteEvent?.scale !== undefined) {
|
if (embeddedWebsiteEvent?.scale !== undefined) {
|
||||||
website.phaserObject.scale = embeddedWebsiteEvent.scale;
|
website.phaserObject.scale = embeddedWebsiteEvent.scale;
|
||||||
|
website.iframe.style.width = website.position.width / embeddedWebsiteEvent.scale + "px";
|
||||||
|
website.iframe.style.height = website.position.height / embeddedWebsiteEvent.scale + "px";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -145,9 +149,9 @@ export class EmbeddedWebsiteManager {
|
|||||||
name,
|
name,
|
||||||
url,
|
url,
|
||||||
/*x,
|
/*x,
|
||||||
y,
|
y,
|
||||||
width,
|
width,
|
||||||
height,*/
|
height,*/
|
||||||
allow,
|
allow,
|
||||||
allowApi,
|
allowApi,
|
||||||
visible,
|
visible,
|
||||||
@ -173,49 +177,43 @@ export class EmbeddedWebsiteManager {
|
|||||||
const absoluteUrl = new URL(embeddedWebsiteEvent.url, this.gameScene.MapUrlFile).toString();
|
const absoluteUrl = new URL(embeddedWebsiteEvent.url, this.gameScene.MapUrlFile).toString();
|
||||||
|
|
||||||
const iframe = document.createElement("iframe");
|
const iframe = document.createElement("iframe");
|
||||||
|
const scale = embeddedWebsiteEvent.scale ?? 1;
|
||||||
|
|
||||||
iframe.src = absoluteUrl;
|
iframe.src = absoluteUrl;
|
||||||
iframe.tabIndex = -1;
|
iframe.tabIndex = -1;
|
||||||
iframe.style.width = embeddedWebsiteEvent.position.width + "px";
|
iframe.style.width = embeddedWebsiteEvent.position.width / scale + "px";
|
||||||
iframe.style.height = embeddedWebsiteEvent.position.height + "px";
|
iframe.style.height = embeddedWebsiteEvent.position.height / scale + "px";
|
||||||
iframe.style.margin = "0";
|
iframe.style.margin = "0";
|
||||||
iframe.style.padding = "0";
|
iframe.style.padding = "0";
|
||||||
iframe.style.border = "none";
|
iframe.style.border = "none";
|
||||||
|
|
||||||
let embeddedWebsite;
|
const domElement = new DOMElement(
|
||||||
let domElement;
|
this.gameScene,
|
||||||
|
embeddedWebsiteEvent.position.x,
|
||||||
|
embeddedWebsiteEvent.position.y,
|
||||||
|
iframe
|
||||||
|
);
|
||||||
|
domElement.setOrigin(0, 0);
|
||||||
|
if (embeddedWebsiteEvent.scale) {
|
||||||
|
domElement.scale = embeddedWebsiteEvent.scale;
|
||||||
|
}
|
||||||
|
domElement.setVisible(visible);
|
||||||
|
|
||||||
switch (embeddedWebsiteEvent.origin) {
|
switch (embeddedWebsiteEvent.origin) {
|
||||||
case "player":
|
case "player":
|
||||||
domElement = new DOMElement(
|
|
||||||
this.gameScene,
|
|
||||||
embeddedWebsiteEvent.position.x,
|
|
||||||
embeddedWebsiteEvent.position.y,
|
|
||||||
iframe
|
|
||||||
);
|
|
||||||
if (embeddedWebsiteEvent.scale) {
|
|
||||||
domElement.scale = embeddedWebsiteEvent.scale;
|
|
||||||
}
|
|
||||||
this.gameScene.CurrentPlayer.add(domElement);
|
this.gameScene.CurrentPlayer.add(domElement);
|
||||||
|
|
||||||
embeddedWebsite = {
|
|
||||||
...embeddedWebsiteEvent,
|
|
||||||
phaserObject: domElement,
|
|
||||||
iframe: iframe,
|
|
||||||
};
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "map":
|
case "map":
|
||||||
default:
|
default:
|
||||||
embeddedWebsite = {
|
this.gameScene.add.existing(domElement);
|
||||||
...embeddedWebsiteEvent,
|
|
||||||
phaserObject: this.gameScene.add
|
|
||||||
.dom(embeddedWebsiteEvent.position.x, embeddedWebsiteEvent.position.y, iframe)
|
|
||||||
.setVisible(visible)
|
|
||||||
.setOrigin(0, 0),
|
|
||||||
iframe: iframe,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const embeddedWebsite = {
|
||||||
|
...embeddedWebsiteEvent,
|
||||||
|
phaserObject: domElement,
|
||||||
|
iframe: iframe,
|
||||||
|
};
|
||||||
|
|
||||||
if (embeddedWebsiteEvent.allowApi) {
|
if (embeddedWebsiteEvent.allowApi) {
|
||||||
iframeListener.registerIframe(iframe);
|
iframeListener.registerIframe(iframe);
|
||||||
}
|
}
|
||||||
|
@ -754,13 +754,13 @@ export class GameScene extends DirtyScene {
|
|||||||
|
|
||||||
//listen event to share the actual worldView when the camera is updated
|
//listen event to share the actual worldView when the camera is updated
|
||||||
this.cameras.main.on("followupdate", (camera: Camera) => {
|
this.cameras.main.on("followupdate", (camera: Camera) => {
|
||||||
const worldView: WasCameraUpdatedEvent = {
|
const cameraEvent: WasCameraUpdatedEvent = {
|
||||||
x: camera.worldView.x,
|
x: camera.worldView.x,
|
||||||
y: camera.worldView.y,
|
y: camera.worldView.y,
|
||||||
width: camera.worldView.width,
|
width: camera.worldView.width,
|
||||||
height: camera.worldView.height,
|
height: camera.worldView.height,
|
||||||
};
|
};
|
||||||
iframeListener.sendCameraUpdated(worldView);
|
iframeListener.sendCameraUpdated(cameraEvent);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Set up variables manager
|
// Set up variables manager
|
||||||
@ -1290,7 +1290,6 @@ ${escapedMessage}
|
|||||||
layoutManagerActionStore.removeAction(message.uuid);
|
layoutManagerActionStore.removeAction(message.uuid);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
iframeListener.registerAnswerer("getPlayerPosition", () => {
|
iframeListener.registerAnswerer("getPlayerPosition", () => {
|
||||||
return {
|
return {
|
||||||
x: this.CurrentPlayer.x,
|
x: this.CurrentPlayer.x,
|
||||||
|
Loading…
Reference in New Issue
Block a user