Revert "Fix loader logo WA (#991)"

This reverts commit fa3ffe4d7a.
This commit is contained in:
Gregoire Parant 2021-05-04 15:15:23 +02:00
parent fa3ffe4d7a
commit c8692a08ce
6 changed files with 23 additions and 39 deletions

View File

@ -5,18 +5,17 @@ const TextName: string = 'Loading...';
const LogoResource: string = 'resources/logos/logo.png';
const LogoFrame: ImageFrameConfig = {frameWidth: 307, frameHeight: 59};
let promiseLoadLogoTexture: Promise<Phaser.GameObjects.Image>|null = null;
let loadingText: Phaser.GameObjects.Text|null = null;
let progressContainer: Phaser.GameObjects.Graphics|null = null;
let progress: Phaser.GameObjects.Graphics|null = null;
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;
const padding: number = 5;
promiseLoadLogoTexture = new Promise<Phaser.GameObjects.Image>((res) => {
const promiseLoadLogoTexture = new Promise<Phaser.GameObjects.Image>((res) => {
if(scene.load.textureManager.exists(LogoNameIndex)){
return res(scene.add.image(scene.game.renderer.width / 2, scene.game.renderer.height / 2 - 150, LogoNameIndex));
}else{
@ -32,36 +31,24 @@ export const addLoader = (scene: Phaser.Scene): void => {
});
});
progressContainer = scene.add.graphics();
progress = scene.add.graphics();
const progressContainer = scene.add.graphics();
const progress = scene.add.graphics();
progressContainer.fillStyle(0x444444, 0.8);
progressContainer.fillRect((scene.game.renderer.width - loadingBarWidth) / 2 - padding, scene.game.renderer.height / 2 + 50 - padding, loadingBarWidth + padding * 2, loadingBarHeight + padding * 2);
scene.load.on('progress', (value: number) => {
if(progress){
progress.clear();
progress.fillStyle(0xBBBBBB, 1);
progress.fillRect((scene.game.renderer.width - loadingBarWidth) / 2, scene.game.renderer.height / 2 + 50, loadingBarWidth * value, loadingBarHeight);
}
});
scene.load.on('complete', () => {
endLoader(scene);
});
}
export const endLoader = (scene: Phaser.Scene): void => {
if(loadingText){
loadingText.destroy();
}
if(promiseLoadLogoTexture){
promiseLoadLogoTexture.then((resLoadingImage: Phaser.GameObjects.Image) => {
resLoadingImage.destroy();
});
}
if(progress){
progress.destroy();
}
if(progressContainer){
progressContainer.destroy();
}
});
}

View File

@ -71,7 +71,7 @@ import {ChatModeIcon} from "../Components/ChatModeIcon";
import {OpenChatIcon, openChatIconName} from "../Components/OpenChatIcon";
import {SelectCharacterScene, SelectCharacterSceneName} from "../Login/SelectCharacterScene";
import {TextureError} from "../../Exception/TextureError";
import {addLoader, endLoader} from "../Components/Loader";
import {addLoader} from "../Components/Loader";
import {ErrorSceneName} from "../Reconnecting/ErrorScene";
import {localUserStore} from "../../Connexion/LocalUserStore";
import {iframeListener} from "../../Api/IframeListener";
@ -497,8 +497,6 @@ export class GameScene extends ResizableScene implements CenterListener {
if (!this.room.isDisconnected()) {
this.connect();
}
endLoader(this);
}
/**

View File

@ -5,7 +5,7 @@ import Sprite = Phaser.GameObjects.Sprite;
import Container = Phaser.GameObjects.Container;
import {gameManager} from "../Game/GameManager";
import {localUserStore} from "../../Connexion/LocalUserStore";
import {addLoader, endLoader} from "../Components/Loader";
import {addLoader} from "../Components/Loader";
import {BodyResourceDescriptionInterface} from "../Entity/PlayerTextures";
import {AbstractCharacterScene} from "./AbstractCharacterScene";
import {areCharacterLayersValid} from "../../Connexion/LocalUser";
@ -112,8 +112,6 @@ export class CustomizeScene extends AbstractCharacterScene {
this.moveLayers();
this.updateSelectedLayer();
}
endLoader(this);
}
private moveCursorHorizontally(index: number): void {

View File

@ -6,6 +6,7 @@ import {EnableCameraSceneName} from "./EnableCameraScene";
import {CustomizeSceneName} from "./CustomizeScene";
import {localUserStore} from "../../Connexion/LocalUserStore";
import {loadAllDefaultModels} from "../Entity/PlayerTexturesLoadingManager";
import {addLoader} from "../Components/Loader";
import {BodyResourceDescriptionInterface} from "../Entity/PlayerTextures";
import {AbstractCharacterScene} from "./AbstractCharacterScene";
import {areCharacterLayersValid} from "../../Connexion/LocalUser";

View File

@ -5,7 +5,7 @@ import {EnableCameraSceneName} from "./EnableCameraScene";
import {CustomizeSceneName} from "./CustomizeScene";
import {localUserStore} from "../../Connexion/LocalUserStore";
import {loadAllDefaultModels} from "../Entity/PlayerTexturesLoadingManager";
import {addLoader, endLoader} from "../Components/Loader";
import {addLoader} from "../Components/Loader";
import {BodyResourceDescriptionInterface} from "../Entity/PlayerTextures";
import {AbstractCharacterScene} from "./AbstractCharacterScene";
import {areCharacterLayersValid} from "../../Connexion/LocalUser";
@ -47,6 +47,7 @@ export class SelectCharacterScene extends AbstractCharacterScene {
});
})
this.playerModels = loadAllDefaultModels(this.load);
addLoader(this);
}
create() {
@ -97,7 +98,6 @@ export class SelectCharacterScene extends AbstractCharacterScene {
this.input.keyboard.on('keydown-DOWN', () => {
this.moveToDown();
});
endLoader(this);
}
protected nextSceneToCameraScene(): void {

View File

@ -1,6 +1,6 @@
import Image = Phaser.GameObjects.Image;
import Rectangle = Phaser.GameObjects.Rectangle;
import { addLoader, endLoader } from "../Components/Loader";
import { addLoader } from "../Components/Loader";
import { gameManager} from "../Game/GameManager";
import { ResizableScene } from "./ResizableScene";
import { EnableCameraSceneName } from "./EnableCameraScene";
@ -38,6 +38,8 @@ export class SelectCompanionScene extends ResizableScene {
getAllCompanionResources(this.load).forEach(model => {
this.companionModels.push(model);
});
addLoader(this);
}
create() {
@ -83,8 +85,6 @@ export class SelectCompanionScene extends ResizableScene {
this.createCurrentCompanion();
this.updateSelectedCompanion();
endLoader(this);
}
update(time: number, delta: number): void {