From 6a7385947d9fa132c3cb16d8dc7f5f3780ea39de Mon Sep 17 00:00:00 2001 From: Alexis Faizeau Date: Wed, 24 Nov 2021 11:55:28 +0100 Subject: [PATCH 1/3] Fix authentication mandatory --- front/src/Connexion/Room.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/front/src/Connexion/Room.ts b/front/src/Connexion/Room.ts index 2f408126..f206d318 100644 --- a/front/src/Connexion/Room.ts +++ b/front/src/Connexion/Room.ts @@ -107,7 +107,8 @@ export class Room { this._mapUrl = data.mapUrl; this._textures = data.textures; this._group = data.group; - this._authenticationMandatory = data.authenticationMandatory || DISABLE_ANONYMOUS; + this._authenticationMandatory = + data.authenticationMandatory != null ? data.authenticationMandatory : DISABLE_ANONYMOUS; this._iframeAuthentication = data.iframeAuthentication || OPID_LOGIN_SCREEN_PROVIDER; this._contactPage = data.contactPage || CONTACT_URL; return new MapDetail(data.mapUrl, data.textures); From 24640d13bba71a3f475de9483a8ba932783fc7d2 Mon Sep 17 00:00:00 2001 From: Alexis Faizeau Date: Wed, 24 Nov 2021 14:50:19 +0100 Subject: [PATCH 2/3] Fix removing of co-website action trigger --- .../Phaser/Game/GameMapPropertiesListener.ts | 80 +++++++++---------- 1 file changed, 38 insertions(+), 42 deletions(-) diff --git a/front/src/Phaser/Game/GameMapPropertiesListener.ts b/front/src/Phaser/Game/GameMapPropertiesListener.ts index 5a033d5c..dad55768 100644 --- a/front/src/Phaser/Game/GameMapPropertiesListener.ts +++ b/front/src/Phaser/Game/GameMapPropertiesListener.ts @@ -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 { @@ -29,7 +27,7 @@ export class GameMapPropertiesListener { constructor(private scene: GameScene, private gameMap: GameMap) {} register() { - this.gameMap.onPropertyChange(GameMapProperties.OPEN_TAB, (newValue, oldvalue, allProps) => { + this.gameMap.onPropertyChange(GameMapProperties.OPEN_TAB, (newValue, oldValue, allProps) => { if (newValue === undefined) { layoutManagerActionStore.removeAction("openTab"); } @@ -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; @@ -192,11 +192,6 @@ export class GameMapPropertiesListener { if (coWebsiteOpen.state === OpenCoWebsiteState.LOADING) { coWebsiteOpen.state = OpenCoWebsiteState.MUST_BE_CLOSE; - return; - } - - if (coWebsiteOpen.state !== OpenCoWebsiteState.OPENED) { - return; } if (coWebsiteOpen.coWebsite !== undefined) { @@ -216,9 +211,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); From 5c3036e18bf13dd5d8e3ee1dba794e54d13dfba2 Mon Sep 17 00:00:00 2001 From: Alexis Faizeau Date: Wed, 24 Nov 2021 15:43:01 +0100 Subject: [PATCH 3/3] Display a default skin on remote player entity --- front/src/Phaser/Entity/Character.ts | 4 ++++ .../Phaser/Entity/PlayerTexturesLoadingManager.ts | 12 +++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/front/src/Phaser/Entity/Character.ts b/front/src/Phaser/Entity/Character.ts index 7df18fcd..1211a52d 100644 --- a/front/src/Phaser/Entity/Character.ts +++ b/front/src/Phaser/Entity/Character.ts @@ -128,6 +128,10 @@ export abstract class Character extends Container { } public addTextures(textures: string[], frame?: string | number): void { + if (textures.length < 1) { + throw new TextureError("no texture given"); + } + for (const texture of textures) { if (this.scene && !this.scene.textures.exists(texture)) { throw new TextureError("texture not found"); diff --git a/front/src/Phaser/Entity/PlayerTexturesLoadingManager.ts b/front/src/Phaser/Entity/PlayerTexturesLoadingManager.ts index 92954bfb..edaeb5b8 100644 --- a/front/src/Phaser/Entity/PlayerTexturesLoadingManager.ts +++ b/front/src/Phaser/Entity/PlayerTexturesLoadingManager.ts @@ -69,13 +69,11 @@ export const lazyLoadPlayerCharacterTextures = ( } //If the loading fail, we render the default model instead. - return returnPromise - .then((keys) => - keys.map((key) => { - return typeof key !== "string" ? key.name : key; - }) - ) - .catch(() => lazyLoadPlayerCharacterTextures(loadPlugin, ["color_22", "eyes_23"])); + return returnPromise.then((keys) => + keys.map((key) => { + return typeof key !== "string" ? key.name : key; + }) + ); }; export const getRessourceDescriptor = (