Revert "Merge branch 'update-game-tiles' into metadataScriptingApi"
This reverts commit796a9418d3
, reversing changes made to3506063e65
.
This commit is contained in:
parent
796a9418d3
commit
1110f4fb7f
@ -17,7 +17,6 @@ import type { LayerEvent } from './LayerEvent';
|
|||||||
import type { SetPropertyEvent } from "./setPropertyEvent";
|
import type { SetPropertyEvent } from "./setPropertyEvent";
|
||||||
import type { TagEvent } from "./TagEvent";
|
import type { TagEvent } from "./TagEvent";
|
||||||
import type { TilesetEvent } from "./TilesetEvent";
|
import type { TilesetEvent } from "./TilesetEvent";
|
||||||
import type { UpdateTileEvent } from "./UpdateTileEvent";
|
|
||||||
|
|
||||||
export interface TypedMessageEvent<T> extends MessageEvent {
|
export interface TypedMessageEvent<T> extends MessageEvent {
|
||||||
data: T
|
data: T
|
||||||
@ -44,8 +43,7 @@ export type IframeEventMap = {
|
|||||||
setProperty: SetPropertyEvent
|
setProperty: SetPropertyEvent
|
||||||
getDataLayer: undefined
|
getDataLayer: undefined
|
||||||
getTag: undefined
|
getTag: undefined
|
||||||
tilesetEvent: TilesetEvent
|
tilsetEvent: TilesetEvent
|
||||||
updateTileEvent: UpdateTileEvent
|
|
||||||
}
|
}
|
||||||
export interface IframeEvent<T extends keyof IframeEventMap> {
|
export interface IframeEvent<T extends keyof IframeEventMap> {
|
||||||
type: T;
|
type: T;
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
import * as tg from "generic-type-guard";
|
|
||||||
|
|
||||||
|
|
||||||
export const isUpdateTileEvent = tg.isArray(
|
|
||||||
new tg.IsInterface().withProperties({
|
|
||||||
x: tg.isNumber,
|
|
||||||
y: tg.isNumber,
|
|
||||||
tile: tg.isUnion(tg.isNumber, tg.isString),
|
|
||||||
layer: tg.isString
|
|
||||||
}).get()
|
|
||||||
);
|
|
||||||
/**
|
|
||||||
* A message sent from the game to the iFrame when a user enters or leaves a zone marked with the "zone" property.
|
|
||||||
*/
|
|
||||||
export type UpdateTileEvent = tg.GuardedType<typeof isUpdateTileEvent>;
|
|
@ -21,7 +21,6 @@ import { isMenuItemRegisterEvent } from './Events/MenuItemRegisterEvent';
|
|||||||
import type { MenuItemClickedEvent } from './Events/MenuItemClickedEvent';
|
import type { MenuItemClickedEvent } from './Events/MenuItemClickedEvent';
|
||||||
import type { TagEvent } from "./Events/TagEvent";
|
import type { TagEvent } from "./Events/TagEvent";
|
||||||
import { isTilesetEvent, TilesetEvent } from "./Events/TilesetEvent";
|
import { isTilesetEvent, TilesetEvent } from "./Events/TilesetEvent";
|
||||||
import { isUpdateTileEvent, UpdateTileEvent } from './Events/UpdateTileEvent';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -36,6 +35,12 @@ class IframeListener {
|
|||||||
private readonly _openPopupStream: Subject<OpenPopupEvent> = new Subject();
|
private readonly _openPopupStream: Subject<OpenPopupEvent> = new Subject();
|
||||||
public readonly openPopupStream = this._openPopupStream.asObservable();
|
public readonly openPopupStream = this._openPopupStream.asObservable();
|
||||||
|
|
||||||
|
private readonly _openTabStream: Subject<OpenTabEvent> = new Subject();
|
||||||
|
public readonly openTabStream = this._openTabStream.asObservable();
|
||||||
|
|
||||||
|
private readonly _goToPageStream: Subject<GoToPageEvent> = new Subject();
|
||||||
|
public readonly goToPageStream = this._goToPageStream.asObservable();
|
||||||
|
|
||||||
private readonly _openCoWebSiteStream: Subject<OpenCoWebSiteEvent> = new Subject();
|
private readonly _openCoWebSiteStream: Subject<OpenCoWebSiteEvent> = new Subject();
|
||||||
public readonly openCoWebSiteStream = this._openCoWebSiteStream.asObservable();
|
public readonly openCoWebSiteStream = this._openCoWebSiteStream.asObservable();
|
||||||
|
|
||||||
@ -81,9 +86,6 @@ class IframeListener {
|
|||||||
private readonly _tilesetLoaderStream: Subject<TilesetEvent> = new Subject();
|
private readonly _tilesetLoaderStream: Subject<TilesetEvent> = new Subject();
|
||||||
public readonly tilesetLoaderStream = this._tilesetLoaderStream.asObservable();
|
public readonly tilesetLoaderStream = this._tilesetLoaderStream.asObservable();
|
||||||
|
|
||||||
private readonly _updateTileStream: Subject<UpdateTileEvent> = new Subject();
|
|
||||||
public readonly updateTileStream = this._updateTileStream.asObservable();
|
|
||||||
|
|
||||||
private readonly iframes = new Set<HTMLIFrameElement>();
|
private readonly iframes = new Set<HTMLIFrameElement>();
|
||||||
private readonly scripts = new Map<string, HTMLIFrameElement>();
|
private readonly scripts = new Map<string, HTMLIFrameElement>();
|
||||||
private sendPlayerMove: boolean = false;
|
private sendPlayerMove: boolean = false;
|
||||||
@ -154,10 +156,8 @@ class IframeListener {
|
|||||||
this._registerMenuCommandStream.next(payload.data.menutItem)
|
this._registerMenuCommandStream.next(payload.data.menutItem)
|
||||||
} else if (payload.type == "getTag") {
|
} else if (payload.type == "getTag") {
|
||||||
this._tagListStream.next();
|
this._tagListStream.next();
|
||||||
} else if (payload.type == "tilesetEvent" && isTilesetEvent(payload.data)) {
|
} else if (payload.type == "tilsetEvent" && isTilesetEvent(payload.data)) {
|
||||||
this._tilesetLoaderStream.next(payload.data);
|
this._tilesetLoaderStream.next(payload.data);
|
||||||
} else if (payload.type == "updateTileEvent" && isUpdateTileEvent(payload.data)) {
|
|
||||||
this._updateTileStream.next(payload.data)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, false);
|
}, false);
|
||||||
|
@ -80,7 +80,6 @@ import CanvasTexture = Phaser.Textures.CanvasTexture;
|
|||||||
import GameObject = Phaser.GameObjects.GameObject;
|
import GameObject = Phaser.GameObjects.GameObject;
|
||||||
import FILE_LOAD_ERROR = Phaser.Loader.Events.FILE_LOAD_ERROR;
|
import FILE_LOAD_ERROR = Phaser.Loader.Events.FILE_LOAD_ERROR;
|
||||||
import DOMElement = Phaser.GameObjects.DOMElement;
|
import DOMElement = Phaser.GameObjects.DOMElement;
|
||||||
import EVENT_TYPE = Phaser.Scenes.Events
|
|
||||||
import type { Subscription } from "rxjs";
|
import type { Subscription } from "rxjs";
|
||||||
import { worldFullMessageStream } from "../../Connexion/WorldFullMessageStream";
|
import { worldFullMessageStream } from "../../Connexion/WorldFullMessageStream";
|
||||||
import { lazyLoadCompanionResource } from "../Companion/CompanionTexturesLoadingManager";
|
import { lazyLoadCompanionResource } from "../Companion/CompanionTexturesLoadingManager";
|
||||||
@ -911,33 +910,12 @@ ${escapedMessage}
|
|||||||
iframeListener.sendUserTagList({list: this.connection.getAllTag()});
|
iframeListener.sendUserTagList({list: this.connection.getAllTag()});
|
||||||
}))
|
}))
|
||||||
|
|
||||||
/*
|
|
||||||
this.iframeSubscriptionList.push(iframeListener.tilesetLoaderStream.subscribe((tileset) => {
|
this.iframeSubscriptionList.push(iframeListener.tilesetLoaderStream.subscribe((tileset) => {
|
||||||
//this.load.tilemapTiledJSON('logo', tileset.imgUrl);
|
//this.load.tilemapTiledJSON('logo', tileset.imgUrl);
|
||||||
this.load.image('logo', tileset.imgUrl);
|
this.load.image('logo', tileset.imgUrl);
|
||||||
this.Terrains.push(this.Map.addTilesetImage(tileset.name, tileset.imgUrl, tileset.tilewidth, tileset.tileheight, tileset.margin, tileset.spacing));
|
this.Terrains.push(this.Map.addTilesetImage(tileset.name, tileset.imgUrl, tileset.tilewidth, tileset.tileheight, tileset.margin, tileset.spacing));
|
||||||
this.gameMap.addTerrain(this.Terrains[this.Terrains.length - 1]);
|
this.gameMap.addTerrain(this.Terrains[this.Terrains.length - 1]);
|
||||||
}))
|
}))
|
||||||
*/
|
|
||||||
|
|
||||||
this.iframeSubscriptionList.push(iframeListener.updateTileStream.subscribe(event => {
|
|
||||||
for (const eventTile of event) {
|
|
||||||
const layer = this.gameMap.findPhaserLayer(eventTile.layer);
|
|
||||||
if (layer) {
|
|
||||||
const tile = layer.getTileAt(eventTile.x, eventTile.y)
|
|
||||||
if (typeof eventTile.tile == "string") {
|
|
||||||
const tileIndex = this.getIndexForTileType(eventTile.tile);
|
|
||||||
if (tileIndex) {
|
|
||||||
tile.index = tileIndex
|
|
||||||
} else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
tile.index = eventTile.tile
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}))
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -967,19 +945,6 @@ ${escapedMessage}
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private getIndexForTileType(tileType: string): number | null {
|
|
||||||
for (const tileset of this.mapFile.tilesets) {
|
|
||||||
if (tileset.tiles) {
|
|
||||||
for (const tilesetTile of tileset.tiles) {
|
|
||||||
if (tilesetTile.type == tileType) {
|
|
||||||
return tileset.firstgid + tilesetTile.id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
private getMapDirUrl(): string {
|
private getMapDirUrl(): string {
|
||||||
return this.MapUrlFile.substr(0, this.MapUrlFile.lastIndexOf('/'));
|
return this.MapUrlFile.substr(0, this.MapUrlFile.lastIndexOf('/'));
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,7 @@ export interface ITiledTileSet {
|
|||||||
tilewidth: number;
|
tilewidth: number;
|
||||||
transparentcolor: string;
|
transparentcolor: string;
|
||||||
terrains: ITiledMapTerrain[];
|
terrains: ITiledMapTerrain[];
|
||||||
tiles: Array<ITile>;
|
tiles: {[key: string]: { terrain: number[] }};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refers to external tileset file (should be JSON)
|
* Refers to external tileset file (should be JSON)
|
||||||
@ -178,11 +178,6 @@ export interface ITiledTileSet {
|
|||||||
source: string;
|
source: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ITile {
|
|
||||||
id: number,
|
|
||||||
type?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ITiledMapTerrain {
|
export interface ITiledMapTerrain {
|
||||||
name: string;
|
name: string;
|
||||||
tile: number;
|
tile: number;
|
||||||
|
@ -26,6 +26,8 @@ interface WorkAdventureApi {
|
|||||||
onEnterZone(name: string, callback: () => void): void;
|
onEnterZone(name: string, callback: () => void): void;
|
||||||
onLeaveZone(name: string, callback: () => void): void;
|
onLeaveZone(name: string, callback: () => void): void;
|
||||||
openPopup(targetObject: string, message: string, buttons: ButtonDescriptor[]): Popup;
|
openPopup(targetObject: string, message: string, buttons: ButtonDescriptor[]): Popup;
|
||||||
|
openTab(url: string): void;
|
||||||
|
goToPage(url: string): void;
|
||||||
openCoWebSite(url: string): void;
|
openCoWebSite(url: string): void;
|
||||||
closeCoWebSite(): void;
|
closeCoWebSite(): void;
|
||||||
disablePlayerControls() : void;
|
disablePlayerControls() : void;
|
||||||
@ -165,7 +167,7 @@ window.WA = {
|
|||||||
|
|
||||||
loadTileset(name: string, imgUrl : string, tilewidth : number, tileheight : number, margin : number, spacing : number): void {
|
loadTileset(name: string, imgUrl : string, tilewidth : number, tileheight : number, margin : number, spacing : number): void {
|
||||||
postToParent({
|
postToParent({
|
||||||
type: "updateTileEvent",
|
type: "tilsetEvent",
|
||||||
data: {
|
data: {
|
||||||
name: name,
|
name: name,
|
||||||
imgUrl: imgUrl,
|
imgUrl: imgUrl,
|
||||||
@ -274,6 +276,24 @@ window.WA = {
|
|||||||
window.parent.postMessage({ 'type': 'removeBubble' }, '*');
|
window.parent.postMessage({ 'type': 'removeBubble' }, '*');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
openTab(url: string): void {
|
||||||
|
window.parent.postMessage({
|
||||||
|
"type": 'openTab',
|
||||||
|
"data": {
|
||||||
|
url
|
||||||
|
} as OpenTabEvent
|
||||||
|
}, '*');
|
||||||
|
},
|
||||||
|
|
||||||
|
goToPage(url: string): void {
|
||||||
|
window.parent.postMessage({
|
||||||
|
"type": 'goToPage',
|
||||||
|
"data": {
|
||||||
|
url
|
||||||
|
} as GoToPageEvent
|
||||||
|
}, '*');
|
||||||
|
},
|
||||||
|
|
||||||
openCoWebSite(url: string): void {
|
openCoWebSite(url: string): void {
|
||||||
window.parent.postMessage({
|
window.parent.postMessage({
|
||||||
"type": 'openCoWebSite',
|
"type": 'openCoWebSite',
|
||||||
|
Loading…
Reference in New Issue
Block a user