This commit is contained in:
_Bastler
2022-01-26 12:44:08 +01:00
parent 31f6847b53
commit e3b58a0d56
23 changed files with 131 additions and 94 deletions
+36 -24
View File
@@ -282,7 +282,7 @@ export class GameScene extends DirtyScene {
const base = new URL(window.location.href);
base.pathname = "";
const url = new URL(file.src, base.toString());
const host = url.host.split(":")[ 0 ];
const host = url.host.split(":")[0];
if (
window.location.protocol === "https:" &&
file.src === this.MapUrlFile &&
@@ -337,8 +337,8 @@ export class GameScene extends DirtyScene {
//eslint-disable-next-line @typescript-eslint/no-explicit-any
(this.load as any).rexWebFont({
custom: {
families: [ "Press Start 2P" ],
urls: [ "/resources/fonts/fonts.css" ],
families: ["Press Start 2P"],
urls: ["/resources/fonts/fonts.css"],
testString: "abcdefg",
},
});
@@ -387,7 +387,7 @@ export class GameScene extends DirtyScene {
}
}
for (const [ itemType, objectsOfType ] of this.objectsByType) {
for (const [itemType, objectsOfType] of this.objectsByType) {
// FIXME: we would ideally need for the loader to WAIT for the import to be performed, which means writing our own loader plugin.
let itemFactory: ItemFactoryInterface;
@@ -787,8 +787,8 @@ export class GameScene extends DirtyScene {
if (item === undefined) {
console.warn(
'Received an event about object "' +
message.itemId +
'" but cannot find this item on the map.'
message.itemId +
'" but cannot find this item on the map.'
);
return;
}
@@ -1061,8 +1061,8 @@ export class GameScene extends DirtyScene {
} else {
console.error(
"Error while opening a popup. Cannot find an object on the map with name '" +
openPopupEvent.targetObject +
"'. The first parameter of WA.openPopup() must be the name of a rectangle object in your map."
openPopupEvent.targetObject +
"'. The first parameter of WA.openPopup() must be the name of a rectangle object in your map."
);
return;
}
@@ -1070,7 +1070,7 @@ export class GameScene extends DirtyScene {
let html = `<div id="container" hidden><div class="nes-container with-title is-centered">`;
html += escapedMessage;
if (openPopupEvent.input) {
html += `<input id="popupinput-${openPopupEvent.popupId}" class="nes-input" />`
html += `<input id="popupinput-${openPopupEvent.popupId}" class="nes-input" />`;
}
html += `</div>`;
@@ -1102,11 +1102,18 @@ export class GameScene extends DirtyScene {
);
const btnId = id;
button.onclick = () => {
let inputValue = '';
let inputValue = "";
if (openPopupEvent.input) {
inputValue = HtmlUtils.getElementByIdOrFail<HTMLInputElement>(`popupinput-${openPopupEvent.popupId}`).value;
inputValue = HtmlUtils.getElementByIdOrFail<HTMLInputElement>(
`popupinput-${openPopupEvent.popupId}`
).value;
}
iframeListener.sendButtonClickedEvent(openPopupEvent.popupId, btnId, openPopupEvent.input, inputValue);
iframeListener.sendButtonClickedEvent(
openPopupEvent.popupId,
btnId,
openPopupEvent.input,
inputValue
);
// Disable for a short amount of time to let time to the script to remove the popup
button.disabled = true;
setTimeout(() => {
@@ -1370,18 +1377,20 @@ export class GameScene extends DirtyScene {
})
);
this.iframeSubscriptionList.push(iframeListener.setTilesStream.subscribe((eventTiles) => {
for (const eventTile of eventTiles) {
this.gameMap.putTile(eventTile.tile, eventTile.x, eventTile.y, eventTile.layer);
}
}))
this.iframeSubscriptionList.push(
iframeListener.setTilesStream.subscribe((eventTiles) => {
for (const eventTile of eventTiles) {
this.gameMap.putTile(eventTile.tile, eventTile.x, eventTile.y, eventTile.layer);
}
})
);
iframeListener.registerAnswerer("loadTileset", (eventTileset) => {
return this.connectionAnswerPromise.then(() => {
const jsonTilesetDir = eventTileset.url.substr(0, eventTileset.url.lastIndexOf("/"));
//Initialise the firstgid to 1 because if there is no tileset in the tilemap, the firstgid will be 1
let newFirstgid = 1;
const lastTileset = this.mapFile.tilesets[ this.mapFile.tilesets.length - 1 ];
const lastTileset = this.mapFile.tilesets[this.mapFile.tilesets.length - 1];
if (lastTileset) {
//If there is at least one tileset in the tilemap then calculate the firstgid of the new tileset
newFirstgid = lastTileset.firstgid + lastTileset.tilecount;
@@ -1530,14 +1539,14 @@ export class GameScene extends DirtyScene {
if (phaserLayers === []) {
console.warn(
'Could not find layer with name that contains "' +
layerName +
'" when calling WA.hideLayer / WA.showLayer'
layerName +
'" when calling WA.hideLayer / WA.showLayer'
);
return;
}
for (let i = 0; i < phaserLayers.length; i++) {
phaserLayers[ i ].setVisible(visible);
phaserLayers[ i ].setCollisionByProperty({ collides: true }, visible);
phaserLayers[i].setVisible(visible);
phaserLayers[i].setCollisionByProperty({ collides: true }, visible);
}
}
this.markDirty();
@@ -2191,7 +2200,10 @@ export class GameScene extends DirtyScene {
layoutManagerActionStore.removeAction("jitsi");
} else {
const openJitsiRoomFunction = () => {
const roomName = jitsiFactory.getRoomName(allProps.get(GameMapProperties.JITSI_ROOM) as string, this.instance);
const roomName = jitsiFactory.getRoomName(
allProps.get(GameMapProperties.JITSI_ROOM) as string,
this.instance
);
const jitsiUrl = allProps.get(GameMapProperties.JITSI_URL) as string | undefined;
if (JITSI_PRIVATE_MODE && !jitsiUrl) {
const adminTag = allProps.get(GameMapProperties.JITSI_ADMIN_ROOM_TAG) as string | undefined;
@@ -2201,7 +2213,7 @@ export class GameScene extends DirtyScene {
this.startJitsi(roomName, undefined);
}
layoutManagerActionStore.removeAction("jitsi");
}
};
let message = allProps.get(GameMapProperties.JITSI_TRIGGER_MESSAGE);
if (message === undefined) {