Fix loader logo WA (#991)
This commit is contained in:
parent
622e0c6130
commit
fa3ffe4d7a
@ -5,17 +5,18 @@ const TextName: string = 'Loading...';
|
|||||||
const LogoResource: string = 'resources/logos/logo.png';
|
const LogoResource: string = 'resources/logos/logo.png';
|
||||||
const LogoFrame: ImageFrameConfig = {frameWidth: 307, frameHeight: 59};
|
const LogoFrame: ImageFrameConfig = {frameWidth: 307, frameHeight: 59};
|
||||||
|
|
||||||
export const addLoader = (scene: Phaser.Scene): void => {
|
let promiseLoadLogoTexture: Promise<Phaser.GameObjects.Image>|null = null;
|
||||||
// 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;
|
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 => {
|
||||||
|
|
||||||
const loadingBarWidth: number = Math.floor(scene.game.renderer.width / 3);
|
const loadingBarWidth: number = Math.floor(scene.game.renderer.width / 3);
|
||||||
const loadingBarHeight: number = 16;
|
const loadingBarHeight: number = 16;
|
||||||
const padding: number = 5;
|
const padding: number = 5;
|
||||||
|
|
||||||
const promiseLoadLogoTexture = new Promise<Phaser.GameObjects.Image>((res) => {
|
promiseLoadLogoTexture = new Promise<Phaser.GameObjects.Image>((res) => {
|
||||||
if(scene.load.textureManager.exists(LogoNameIndex)){
|
if(scene.load.textureManager.exists(LogoNameIndex)){
|
||||||
return res(scene.add.image(scene.game.renderer.width / 2, scene.game.renderer.height / 2 - 150, LogoNameIndex));
|
return res(scene.add.image(scene.game.renderer.width / 2, scene.game.renderer.height / 2 - 150, LogoNameIndex));
|
||||||
}else{
|
}else{
|
||||||
@ -31,24 +32,36 @@ export const addLoader = (scene: Phaser.Scene): void => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const progressContainer = scene.add.graphics();
|
progressContainer = scene.add.graphics();
|
||||||
const progress = scene.add.graphics();
|
progress = scene.add.graphics();
|
||||||
progressContainer.fillStyle(0x444444, 0.8);
|
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);
|
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) => {
|
scene.load.on('progress', (value: number) => {
|
||||||
|
if(progress){
|
||||||
progress.clear();
|
progress.clear();
|
||||||
progress.fillStyle(0xBBBBBB, 1);
|
progress.fillStyle(0xBBBBBB, 1);
|
||||||
progress.fillRect((scene.game.renderer.width - loadingBarWidth) / 2, scene.game.renderer.height / 2 + 50, loadingBarWidth * value, loadingBarHeight);
|
progress.fillRect((scene.game.renderer.width - loadingBarWidth) / 2, scene.game.renderer.height / 2 + 50, loadingBarWidth * value, loadingBarHeight);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
scene.load.on('complete', () => {
|
scene.load.on('complete', () => {
|
||||||
|
endLoader(scene);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export const endLoader = (scene: Phaser.Scene): void => {
|
||||||
if(loadingText){
|
if(loadingText){
|
||||||
loadingText.destroy();
|
loadingText.destroy();
|
||||||
}
|
}
|
||||||
|
if(promiseLoadLogoTexture){
|
||||||
promiseLoadLogoTexture.then((resLoadingImage: Phaser.GameObjects.Image) => {
|
promiseLoadLogoTexture.then((resLoadingImage: Phaser.GameObjects.Image) => {
|
||||||
resLoadingImage.destroy();
|
resLoadingImage.destroy();
|
||||||
});
|
});
|
||||||
progress.destroy();
|
}
|
||||||
progressContainer.destroy();
|
if(progress){
|
||||||
});
|
progress.destroy();
|
||||||
|
}
|
||||||
|
if(progressContainer){
|
||||||
|
progressContainer.destroy();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ import {ChatModeIcon} from "../Components/ChatModeIcon";
|
|||||||
import {OpenChatIcon, openChatIconName} from "../Components/OpenChatIcon";
|
import {OpenChatIcon, openChatIconName} from "../Components/OpenChatIcon";
|
||||||
import {SelectCharacterScene, SelectCharacterSceneName} from "../Login/SelectCharacterScene";
|
import {SelectCharacterScene, SelectCharacterSceneName} from "../Login/SelectCharacterScene";
|
||||||
import {TextureError} from "../../Exception/TextureError";
|
import {TextureError} from "../../Exception/TextureError";
|
||||||
import {addLoader} from "../Components/Loader";
|
import {addLoader, endLoader} from "../Components/Loader";
|
||||||
import {ErrorSceneName} from "../Reconnecting/ErrorScene";
|
import {ErrorSceneName} from "../Reconnecting/ErrorScene";
|
||||||
import {localUserStore} from "../../Connexion/LocalUserStore";
|
import {localUserStore} from "../../Connexion/LocalUserStore";
|
||||||
import {iframeListener} from "../../Api/IframeListener";
|
import {iframeListener} from "../../Api/IframeListener";
|
||||||
@ -497,6 +497,8 @@ export class GameScene extends ResizableScene implements CenterListener {
|
|||||||
if (!this.room.isDisconnected()) {
|
if (!this.room.isDisconnected()) {
|
||||||
this.connect();
|
this.connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
endLoader(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5,7 +5,7 @@ import Sprite = Phaser.GameObjects.Sprite;
|
|||||||
import Container = Phaser.GameObjects.Container;
|
import Container = Phaser.GameObjects.Container;
|
||||||
import {gameManager} from "../Game/GameManager";
|
import {gameManager} from "../Game/GameManager";
|
||||||
import {localUserStore} from "../../Connexion/LocalUserStore";
|
import {localUserStore} from "../../Connexion/LocalUserStore";
|
||||||
import {addLoader} from "../Components/Loader";
|
import {addLoader, endLoader} from "../Components/Loader";
|
||||||
import {BodyResourceDescriptionInterface} from "../Entity/PlayerTextures";
|
import {BodyResourceDescriptionInterface} from "../Entity/PlayerTextures";
|
||||||
import {AbstractCharacterScene} from "./AbstractCharacterScene";
|
import {AbstractCharacterScene} from "./AbstractCharacterScene";
|
||||||
import {areCharacterLayersValid} from "../../Connexion/LocalUser";
|
import {areCharacterLayersValid} from "../../Connexion/LocalUser";
|
||||||
@ -112,6 +112,8 @@ export class CustomizeScene extends AbstractCharacterScene {
|
|||||||
this.moveLayers();
|
this.moveLayers();
|
||||||
this.updateSelectedLayer();
|
this.updateSelectedLayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
endLoader(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private moveCursorHorizontally(index: number): void {
|
private moveCursorHorizontally(index: number): void {
|
||||||
|
@ -6,7 +6,6 @@ import {EnableCameraSceneName} from "./EnableCameraScene";
|
|||||||
import {CustomizeSceneName} from "./CustomizeScene";
|
import {CustomizeSceneName} from "./CustomizeScene";
|
||||||
import {localUserStore} from "../../Connexion/LocalUserStore";
|
import {localUserStore} from "../../Connexion/LocalUserStore";
|
||||||
import {loadAllDefaultModels} from "../Entity/PlayerTexturesLoadingManager";
|
import {loadAllDefaultModels} from "../Entity/PlayerTexturesLoadingManager";
|
||||||
import {addLoader} from "../Components/Loader";
|
|
||||||
import {BodyResourceDescriptionInterface} from "../Entity/PlayerTextures";
|
import {BodyResourceDescriptionInterface} from "../Entity/PlayerTextures";
|
||||||
import {AbstractCharacterScene} from "./AbstractCharacterScene";
|
import {AbstractCharacterScene} from "./AbstractCharacterScene";
|
||||||
import {areCharacterLayersValid} from "../../Connexion/LocalUser";
|
import {areCharacterLayersValid} from "../../Connexion/LocalUser";
|
||||||
|
@ -5,7 +5,7 @@ import {EnableCameraSceneName} from "./EnableCameraScene";
|
|||||||
import {CustomizeSceneName} from "./CustomizeScene";
|
import {CustomizeSceneName} from "./CustomizeScene";
|
||||||
import {localUserStore} from "../../Connexion/LocalUserStore";
|
import {localUserStore} from "../../Connexion/LocalUserStore";
|
||||||
import {loadAllDefaultModels} from "../Entity/PlayerTexturesLoadingManager";
|
import {loadAllDefaultModels} from "../Entity/PlayerTexturesLoadingManager";
|
||||||
import {addLoader} from "../Components/Loader";
|
import {addLoader, endLoader} from "../Components/Loader";
|
||||||
import {BodyResourceDescriptionInterface} from "../Entity/PlayerTextures";
|
import {BodyResourceDescriptionInterface} from "../Entity/PlayerTextures";
|
||||||
import {AbstractCharacterScene} from "./AbstractCharacterScene";
|
import {AbstractCharacterScene} from "./AbstractCharacterScene";
|
||||||
import {areCharacterLayersValid} from "../../Connexion/LocalUser";
|
import {areCharacterLayersValid} from "../../Connexion/LocalUser";
|
||||||
@ -47,7 +47,6 @@ export class SelectCharacterScene extends AbstractCharacterScene {
|
|||||||
});
|
});
|
||||||
})
|
})
|
||||||
this.playerModels = loadAllDefaultModels(this.load);
|
this.playerModels = loadAllDefaultModels(this.load);
|
||||||
addLoader(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
create() {
|
create() {
|
||||||
@ -98,6 +97,7 @@ export class SelectCharacterScene extends AbstractCharacterScene {
|
|||||||
this.input.keyboard.on('keydown-DOWN', () => {
|
this.input.keyboard.on('keydown-DOWN', () => {
|
||||||
this.moveToDown();
|
this.moveToDown();
|
||||||
});
|
});
|
||||||
|
endLoader(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected nextSceneToCameraScene(): void {
|
protected nextSceneToCameraScene(): void {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import Image = Phaser.GameObjects.Image;
|
import Image = Phaser.GameObjects.Image;
|
||||||
import Rectangle = Phaser.GameObjects.Rectangle;
|
import Rectangle = Phaser.GameObjects.Rectangle;
|
||||||
import { addLoader } from "../Components/Loader";
|
import { addLoader, endLoader } from "../Components/Loader";
|
||||||
import { gameManager} from "../Game/GameManager";
|
import { gameManager} from "../Game/GameManager";
|
||||||
import { ResizableScene } from "./ResizableScene";
|
import { ResizableScene } from "./ResizableScene";
|
||||||
import { EnableCameraSceneName } from "./EnableCameraScene";
|
import { EnableCameraSceneName } from "./EnableCameraScene";
|
||||||
@ -38,8 +38,6 @@ export class SelectCompanionScene extends ResizableScene {
|
|||||||
getAllCompanionResources(this.load).forEach(model => {
|
getAllCompanionResources(this.load).forEach(model => {
|
||||||
this.companionModels.push(model);
|
this.companionModels.push(model);
|
||||||
});
|
});
|
||||||
|
|
||||||
addLoader(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
create() {
|
create() {
|
||||||
@ -85,6 +83,8 @@ export class SelectCompanionScene extends ResizableScene {
|
|||||||
|
|
||||||
this.createCurrentCompanion();
|
this.createCurrentCompanion();
|
||||||
this.updateSelectedCompanion();
|
this.updateSelectedCompanion();
|
||||||
|
|
||||||
|
endLoader(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
update(time: number, delta: number): void {
|
update(time: number, delta: number): void {
|
||||||
|
Loading…
Reference in New Issue
Block a user