parent
fa3ffe4d7a
commit
c8692a08ce
@ -5,18 +5,17 @@ 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};
|
||||||
|
|
||||||
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 => {
|
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 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;
|
||||||
|
|
||||||
promiseLoadLogoTexture = new Promise<Phaser.GameObjects.Image>((res) => {
|
const 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{
|
||||||
@ -32,36 +31,24 @@ export const addLoader = (scene: Phaser.Scene): void => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
progressContainer = scene.add.graphics();
|
const progressContainer = scene.add.graphics();
|
||||||
progress = scene.add.graphics();
|
const 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();
|
||||||
});
|
});
|
||||||
}
|
|
||||||
if(progress){
|
|
||||||
progress.destroy();
|
progress.destroy();
|
||||||
}
|
|
||||||
if(progressContainer){
|
|
||||||
progressContainer.destroy();
|
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, endLoader} from "../Components/Loader";
|
import {addLoader} 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,8 +497,6 @@ 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, endLoader} from "../Components/Loader";
|
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";
|
||||||
@ -112,8 +112,6 @@ 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,6 +6,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 {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, endLoader} from "../Components/Loader";
|
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";
|
||||||
@ -47,6 +47,7 @@ export class SelectCharacterScene extends AbstractCharacterScene {
|
|||||||
});
|
});
|
||||||
})
|
})
|
||||||
this.playerModels = loadAllDefaultModels(this.load);
|
this.playerModels = loadAllDefaultModels(this.load);
|
||||||
|
addLoader(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
create() {
|
create() {
|
||||||
@ -97,7 +98,6 @@ 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, endLoader } from "../Components/Loader";
|
import { addLoader } 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,6 +38,8 @@ 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() {
|
||||||
@ -83,8 +85,6 @@ 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