From f6e93da48a364871327e8d45b58aa402cbb7cfeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Tue, 9 Feb 2021 12:41:35 +0100 Subject: [PATCH] Fixing loading logo being displayed when nothing was loaded --- front/src/Phaser/Components/Loader.ts | 4 ++++ front/src/Phaser/Game/GameScene.ts | 4 ++-- front/src/Phaser/Login/SelectCharacterScene.ts | 4 +++- maps/Floor0/floor0.json | 2 +- maps/Floor1/floor1.json | 8 ++++---- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/front/src/Phaser/Components/Loader.ts b/front/src/Phaser/Components/Loader.ts index 0eda58dc..1ee18b32 100644 --- a/front/src/Phaser/Components/Loader.ts +++ b/front/src/Phaser/Components/Loader.ts @@ -6,6 +6,10 @@ const LogoResource: string = 'resources/logos/logo.png'; const LogoFrame: ImageFrameConfig = {frameWidth: 307, frameHeight: 59}; export const addLoader = (scene: Phaser.Scene): void => { + // If there is nothing to load, do not display the loader. + if (scene.load.list.entries.length === 0) { + return; + } let loadingText: Phaser.GameObjects.Text|null = null; const loadingBarWidth: number = Math.floor(scene.game.renderer.width / 3); const loadingBarHeight: number = 16; diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 29e6a0e3..1b4cf567 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -183,8 +183,6 @@ export class GameScene extends ResizableScene implements CenterListener { //hook preload scene preload(): void { - addLoader(this); - const localUser = localUserStore.getLocalUser(); const textures = localUser?.textures; if (textures) { @@ -215,6 +213,8 @@ export class GameScene extends ResizableScene implements CenterListener { this.load.spritesheet('layout_modes', 'resources/objects/layout_modes.png', {frameWidth: 32, frameHeight: 32}); this.load.bitmapFont('main_font', 'resources/fonts/arcade.png', 'resources/fonts/arcade.xml'); + + addLoader(this); } // FIXME: we need to put a "unknown" instead of a "any" and validate the structure of the JSON we are receiving. diff --git a/front/src/Phaser/Login/SelectCharacterScene.ts b/front/src/Phaser/Login/SelectCharacterScene.ts index 905c9ae4..e47cf38a 100644 --- a/front/src/Phaser/Login/SelectCharacterScene.ts +++ b/front/src/Phaser/Login/SelectCharacterScene.ts @@ -59,6 +59,8 @@ export class SelectCharacterScene extends AbstractCharacterScene { this.playerModels = loadAllDefaultModels(this.load); this.load.image(LoginTextures.customizeButton, 'resources/objects/customize.png'); this.load.image(LoginTextures.customizeButtonSelected, 'resources/objects/customize_selected.png'); + + addLoader(this); } create() { @@ -123,7 +125,7 @@ export class SelectCharacterScene extends AbstractCharacterScene { /*create user*/ this.createCurrentPlayer(); - + const playerNumber = localUserStore.getPlayerCharacterIndex(); if (playerNumber && playerNumber !== -1) { this.selectedRectangleXPos = playerNumber % this.nbCharactersPerRow; diff --git a/maps/Floor0/floor0.json b/maps/Floor0/floor0.json index 3bbd67cd..6a88f78d 100644 --- a/maps/Floor0/floor0.json +++ b/maps/Floor0/floor0.json @@ -278,7 +278,7 @@ { "name":"exitUrl", "type":"string", - "value":"\/@\/tcm\/workadventure\/floor1" + "value":"..\/Floor1\/floor1.json" }], "type":"tilelayer", "visible":true, diff --git a/maps/Floor1/floor1.json b/maps/Floor1/floor1.json index 6deb3bf5..1894ed42 100644 --- a/maps/Floor1/floor1.json +++ b/maps/Floor1/floor1.json @@ -83,9 +83,9 @@ "opacity":1, "properties":[ { - "name":"exitSceneUrl", + "name":"exitUrl", "type":"string", - "value":"\/@\/tcm\/workadventure\/floor0#down-the-stairs" + "value":"..\/Floor0\/floor0.json" }], "type":"tilelayer", "visible":true, @@ -264,7 +264,7 @@ "nextobjectid":1, "orientation":"orthogonal", "renderorder":"right-down", - "tiledversion":"1.4.2", + "tiledversion":"1.3.3", "tileheight":32, "tilesets":[ { @@ -1959,6 +1959,6 @@ }], "tilewidth":32, "type":"map", - "version":1.4, + "version":1.2, "width":46 } \ No newline at end of file