Fixing linting
This commit is contained in:
parent
d3bd99b5ee
commit
2cbf5b56af
12 changed files with 164 additions and 175 deletions
|
@ -12,8 +12,7 @@ export type PropertyChangeCallback = (
|
|||
|
||||
export type layerChangeCallback = (
|
||||
layersChangedByAction: Array<ITiledMapLayer>,
|
||||
allLayersOnNewPosition: Array<ITiledMapLayer>,
|
||||
|
||||
allLayersOnNewPosition: Array<ITiledMapLayer>
|
||||
) => void;
|
||||
|
||||
/**
|
||||
|
@ -81,7 +80,7 @@ export class GameMap {
|
|||
}
|
||||
|
||||
private getLayersByKey(key: number): Array<ITiledMapLayer> {
|
||||
return this.flatLayers.filter(flatLayer => flatLayer.type === 'tilelayer' && flatLayer.data[key] !== 0);
|
||||
return this.flatLayers.filter((flatLayer) => flatLayer.type === "tilelayer" && flatLayer.data[key] !== 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -134,14 +133,13 @@ export class GameMap {
|
|||
const enterLayers = new Set(layersByNewKey);
|
||||
const leaveLayers = new Set(layersByOldKey);
|
||||
|
||||
enterLayers.forEach(layer => {
|
||||
enterLayers.forEach((layer) => {
|
||||
if (leaveLayers.has(layer)) {
|
||||
leaveLayers.delete(layer);
|
||||
enterLayers.delete(layer);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if (enterLayers.size > 0) {
|
||||
const layerArray = Array.from(enterLayers);
|
||||
for (const callback of this.enterLayerCallbacks) {
|
||||
|
|
|
@ -1,37 +1,37 @@
|
|||
export enum GameMapProperties {
|
||||
ALLOW_API = 'allowApi',
|
||||
AUDIO_LOOP = 'audioLoop',
|
||||
AUDIO_VOLUME = 'audioVolume',
|
||||
COLLIDES = 'collides',
|
||||
DEFAULT = 'default',
|
||||
EXIT_URL = 'exitUrl',
|
||||
EXIT_SCENE_URL = 'exitSceneUrl',
|
||||
FONT_FAMILY = 'font-family',
|
||||
JITSI_ADMIN_ROOM_TAG = 'jitsiRoomAdminTag',
|
||||
JITSI_CONFIG = 'jitsiConfig',
|
||||
JITSI_INTERFACE_CONFIG = 'jitsiInterfaceConfig',
|
||||
JITSI_ROOM = 'jitsiRoom',
|
||||
JITSI_TRIGGER = 'jitsiTrigger',
|
||||
JITSI_TRIGGER_MESSAGE = 'jitsiTriggerMessage',
|
||||
JITSI_URL = 'jitsiUrl',
|
||||
JITSI_WIDTH = 'jitsiWidth',
|
||||
NAME = 'name',
|
||||
OPEN_TAB = 'openTab',
|
||||
OPEN_WEBSITE = 'openWebsite',
|
||||
OPEN_WEBSITE_ALLOW_API = 'openWebsiteAllowApi',
|
||||
OPEN_WEBSITE_POLICY = 'openWebsitePolicy',
|
||||
OPEN_WEBSITE_WIDTH = 'openWebsiteWidth',
|
||||
OPEN_WEBSITE_POSITION = 'openWebsitePosition',
|
||||
OPEN_WEBSITE_TRIGGER = 'openWebsiteTrigger',
|
||||
OPEN_WEBSITE_TRIGGER_MESSAGE = 'openWebsiteTriggerMessage',
|
||||
PLAY_AUDIO = 'playAudio',
|
||||
PLAY_AUDIO_LOOP = 'playAudioLoop',
|
||||
READABLE_BY = 'readableBy',
|
||||
SCRIPT = 'script',
|
||||
SILENT = 'silent',
|
||||
START = 'start',
|
||||
START_LAYER = 'startLayer',
|
||||
URL = 'url',
|
||||
WRITABLE_BY = 'writableBy',
|
||||
ZONE = 'zone',
|
||||
ALLOW_API = "allowApi",
|
||||
AUDIO_LOOP = "audioLoop",
|
||||
AUDIO_VOLUME = "audioVolume",
|
||||
COLLIDES = "collides",
|
||||
DEFAULT = "default",
|
||||
EXIT_URL = "exitUrl",
|
||||
EXIT_SCENE_URL = "exitSceneUrl",
|
||||
FONT_FAMILY = "font-family",
|
||||
JITSI_ADMIN_ROOM_TAG = "jitsiRoomAdminTag",
|
||||
JITSI_CONFIG = "jitsiConfig",
|
||||
JITSI_INTERFACE_CONFIG = "jitsiInterfaceConfig",
|
||||
JITSI_ROOM = "jitsiRoom",
|
||||
JITSI_TRIGGER = "jitsiTrigger",
|
||||
JITSI_TRIGGER_MESSAGE = "jitsiTriggerMessage",
|
||||
JITSI_URL = "jitsiUrl",
|
||||
JITSI_WIDTH = "jitsiWidth",
|
||||
NAME = "name",
|
||||
OPEN_TAB = "openTab",
|
||||
OPEN_WEBSITE = "openWebsite",
|
||||
OPEN_WEBSITE_ALLOW_API = "openWebsiteAllowApi",
|
||||
OPEN_WEBSITE_POLICY = "openWebsitePolicy",
|
||||
OPEN_WEBSITE_WIDTH = "openWebsiteWidth",
|
||||
OPEN_WEBSITE_POSITION = "openWebsitePosition",
|
||||
OPEN_WEBSITE_TRIGGER = "openWebsiteTrigger",
|
||||
OPEN_WEBSITE_TRIGGER_MESSAGE = "openWebsiteTriggerMessage",
|
||||
PLAY_AUDIO = "playAudio",
|
||||
PLAY_AUDIO_LOOP = "playAudioLoop",
|
||||
READABLE_BY = "readableBy",
|
||||
SCRIPT = "script",
|
||||
SILENT = "silent",
|
||||
START = "start",
|
||||
START_LAYER = "startLayer",
|
||||
URL = "url",
|
||||
WRITABLE_BY = "writableBy",
|
||||
ZONE = "zone",
|
||||
}
|
||||
|
|
|
@ -4,10 +4,8 @@ import { scriptUtils } from "../../Api/ScriptUtils";
|
|||
import type { CoWebsite } from "../../WebRtc/CoWebsiteManager";
|
||||
import { coWebsiteManager } from "../../WebRtc/CoWebsiteManager";
|
||||
import { layoutManagerActionStore } from "../../Stores/LayoutManagerStore";
|
||||
import { get } from 'svelte/store';
|
||||
import {
|
||||
ON_ACTION_TRIGGER_BUTTON,
|
||||
} from "../../WebRtc/LayoutManager";
|
||||
import { get } from "svelte/store";
|
||||
import { ON_ACTION_TRIGGER_BUTTON } from "../../WebRtc/LayoutManager";
|
||||
import type { ITiledMapLayer } from "../Map/ITiledMap";
|
||||
import { GameMapProperties } from "./GameMapProperties";
|
||||
|
||||
|
@ -18,8 +16,8 @@ enum OpenCoWebsiteState {
|
|||
}
|
||||
|
||||
interface OpenCoWebsite {
|
||||
coWebsite: CoWebsite | undefined,
|
||||
state: OpenCoWebsiteState
|
||||
coWebsite: CoWebsite | undefined;
|
||||
state: OpenCoWebsiteState;
|
||||
}
|
||||
|
||||
export class GameMapPropertiesListener {
|
||||
|
@ -53,10 +51,10 @@ export class GameMapPropertiesListener {
|
|||
}
|
||||
});
|
||||
|
||||
// Open a new co-website by the property.
|
||||
// Open a new co-website by the property.
|
||||
this.gameMap.onEnterLayer((newLayers) => {
|
||||
const handler = () => {
|
||||
newLayers.forEach(layer => {
|
||||
newLayers.forEach((layer) => {
|
||||
if (!layer.properties) {
|
||||
return;
|
||||
}
|
||||
|
@ -69,8 +67,8 @@ export class GameMapPropertiesListener {
|
|||
let websiteTriggerProperty: string | undefined;
|
||||
let websiteTriggerMessageProperty: string | undefined;
|
||||
|
||||
layer.properties.forEach(property => {
|
||||
switch(property.name) {
|
||||
layer.properties.forEach((property) => {
|
||||
switch (property.name) {
|
||||
case GameMapProperties.OPEN_WEBSITE:
|
||||
openWebsiteProperty = property.value as string | undefined;
|
||||
break;
|
||||
|
@ -111,26 +109,28 @@ export class GameMapPropertiesListener {
|
|||
});
|
||||
|
||||
const openWebsiteFunction = () => {
|
||||
coWebsiteManager.loadCoWebsite(
|
||||
openWebsiteProperty as string,
|
||||
this.scene.MapUrlFile,
|
||||
allowApiProperty,
|
||||
websitePolicyProperty,
|
||||
websiteWidthProperty,
|
||||
websitePositionProperty,
|
||||
).then(coWebsite => {
|
||||
const coWebsiteOpen = this.coWebsitesOpenByLayer.get(layer);
|
||||
if (coWebsiteOpen && coWebsiteOpen.state === OpenCoWebsiteState.MUST_BE_CLOSE) {
|
||||
coWebsiteManager.closeCoWebsite(coWebsite);
|
||||
this.coWebsitesOpenByLayer.delete(layer);
|
||||
this.coWebsitesActionTriggerByLayer.delete(layer);
|
||||
} else {
|
||||
this.coWebsitesOpenByLayer.set(layer, {
|
||||
coWebsite,
|
||||
state: OpenCoWebsiteState.OPENED
|
||||
});
|
||||
}
|
||||
});
|
||||
coWebsiteManager
|
||||
.loadCoWebsite(
|
||||
openWebsiteProperty as string,
|
||||
this.scene.MapUrlFile,
|
||||
allowApiProperty,
|
||||
websitePolicyProperty,
|
||||
websiteWidthProperty,
|
||||
websitePositionProperty
|
||||
)
|
||||
.then((coWebsite) => {
|
||||
const coWebsiteOpen = this.coWebsitesOpenByLayer.get(layer);
|
||||
if (coWebsiteOpen && coWebsiteOpen.state === OpenCoWebsiteState.MUST_BE_CLOSE) {
|
||||
coWebsiteManager.closeCoWebsite(coWebsite);
|
||||
this.coWebsitesOpenByLayer.delete(layer);
|
||||
this.coWebsitesActionTriggerByLayer.delete(layer);
|
||||
} else {
|
||||
this.coWebsitesOpenByLayer.set(layer, {
|
||||
coWebsite,
|
||||
state: OpenCoWebsiteState.OPENED,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
layoutManagerActionStore.removeAction(actionUuid);
|
||||
};
|
||||
|
@ -161,7 +161,7 @@ export class GameMapPropertiesListener {
|
|||
// Close opened co-websites on leave the layer who contain the property.
|
||||
this.gameMap.onLeaveLayer((oldLayers) => {
|
||||
const handler = () => {
|
||||
oldLayers.forEach(layer => {
|
||||
oldLayers.forEach((layer) => {
|
||||
if (!layer.properties) {
|
||||
return;
|
||||
}
|
||||
|
@ -169,8 +169,8 @@ export class GameMapPropertiesListener {
|
|||
let openWebsiteProperty: string | undefined;
|
||||
let websiteTriggerProperty: string | undefined;
|
||||
|
||||
layer.properties.forEach(property => {
|
||||
switch(property.name) {
|
||||
layer.properties.forEach((property) => {
|
||||
switch (property.name) {
|
||||
case GameMapProperties.OPEN_WEBSITE:
|
||||
openWebsiteProperty = property.value as string | undefined;
|
||||
break;
|
||||
|
@ -216,9 +216,10 @@ export class GameMapPropertiesListener {
|
|||
return;
|
||||
}
|
||||
|
||||
const action = actionStore && actionStore.length > 0 ?
|
||||
actionStore.find(action => action.uuid === actionTriggerUuid) : undefined;
|
||||
|
||||
const action =
|
||||
actionStore && actionStore.length > 0
|
||||
? actionStore.find((action) => action.uuid === actionTriggerUuid)
|
||||
: undefined;
|
||||
|
||||
if (action) {
|
||||
layoutManagerActionStore.removeAction(actionTriggerUuid);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue