Fixing loading logo being displayed when nothing was loaded

This commit is contained in:
David Négrier 2021-02-09 12:41:35 +01:00
parent 8389fad877
commit f6e93da48a
5 changed files with 14 additions and 8 deletions

View File

@ -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;

View File

@ -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.

View File

@ -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;

View File

@ -278,7 +278,7 @@
{
"name":"exitUrl",
"type":"string",
"value":"\/@\/tcm\/workadventure\/floor1"
"value":"..\/Floor1\/floor1.json"
}],
"type":"tilelayer",
"visible":true,

View File

@ -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
}