diff --git a/front/dist/resources/html/gameMenu.html b/front/dist/resources/html/gameMenu.html index f0faf5c5..d5e9ad7e 100644 --- a/front/dist/resources/html/gameMenu.html +++ b/front/dist/resources/html/gameMenu.html @@ -30,6 +30,9 @@
+
+ +
diff --git a/front/src/Phaser/Companion/CompanionTexturesLoadingManager.ts b/front/src/Phaser/Companion/CompanionTexturesLoadingManager.ts index b7859a70..1c74b64f 100644 --- a/front/src/Phaser/Companion/CompanionTexturesLoadingManager.ts +++ b/front/src/Phaser/Companion/CompanionTexturesLoadingManager.ts @@ -1,7 +1,11 @@ import LoaderPlugin = Phaser.Loader.LoaderPlugin; import { COMPANION_RESOURCES, CompanionResourceDescriptionInterface } from "./CompanionTextures"; -export const loadAll = (loader: LoaderPlugin): Promise => { +export const getAllResources = (): CompanionResourceDescriptionInterface[] => { + return COMPANION_RESOURCES; +} + +export const lazyLoadAllResources = (loader: LoaderPlugin): Promise => { const promises: Promise[] = []; COMPANION_RESOURCES.forEach((resource: CompanionResourceDescriptionInterface) => { diff --git a/front/src/Phaser/Login/SelectCompanionScene.ts b/front/src/Phaser/Login/SelectCompanionScene.ts index 9b1cb09a..5a6cc160 100644 --- a/front/src/Phaser/Login/SelectCompanionScene.ts +++ b/front/src/Phaser/Login/SelectCompanionScene.ts @@ -1,13 +1,13 @@ import Image = Phaser.GameObjects.Image; import Rectangle = Phaser.GameObjects.Rectangle; -import {gameManager} from "../Game/GameManager"; import { addLoader } from "../Components/Loader"; -import {TextField} from "../Components/TextField"; +import { gameManager} from "../Game/GameManager"; import { ResizableScene } from "./ResizableScene"; -import {EnableCameraSceneName} from "./EnableCameraScene"; -import {localUserStore} from "../../Connexion/LocalUserStore"; -import { loadAll } from "../Companion/CompanionTexturesLoadingManager"; +import { TextField } from "../Components/TextField"; +import { EnableCameraSceneName } from "./EnableCameraScene"; +import { localUserStore } from "../../Connexion/LocalUserStore"; import { CompanionResourceDescriptionInterface } from "../Companion/CompanionTextures"; +import { getAllResources, lazyLoadAllResources } from "../Companion/CompanionTexturesLoadingManager"; export const SelectCompanionSceneName = "SelectCompanionScene"; @@ -38,10 +38,12 @@ export class SelectCompanionScene extends ResizableScene { } preload() { - loadAll(this.load).then(resourceDescriptions => { - resourceDescriptions.forEach(resourceDescription => { - this.companionModels.push(resourceDescription); - }); + lazyLoadAllResources(this.load).then(() => { + console.log("Loaded all companion textures."); + }); + + getAllResources().forEach(model => { + this.companionModels.push(model); }); this.load.image(LoginTextures.icon, "resources/logos/tcm_full.png"); diff --git a/front/src/Phaser/Menu/MenuScene.ts b/front/src/Phaser/Menu/MenuScene.ts index 58e7f0a6..f29fd39d 100644 --- a/front/src/Phaser/Menu/MenuScene.ts +++ b/front/src/Phaser/Menu/MenuScene.ts @@ -1,5 +1,6 @@ import {LoginScene, LoginSceneName} from "../Login/LoginScene"; import {SelectCharacterScene, SelectCharacterSceneName} from "../Login/SelectCharacterScene"; +import {SelectCompanionScene, SelectCompanionSceneName} from "../Login/SelectCompanionScene"; import {gameManager} from "../Game/GameManager"; import {localUserStore} from "../../Connexion/LocalUserStore"; import {mediaManager} from "../../WebRtc/MediaManager"; @@ -277,6 +278,10 @@ export class MenuScene extends Phaser.Scene { this.closeSideMenu(); gameManager.leaveGame(this, SelectCharacterSceneName, new SelectCharacterScene()); break; + case 'changeCompanionButton': + this.closeSideMenu(); + gameManager.leaveGame(this, SelectCompanionSceneName, new SelectCompanionScene()); + break; case 'closeButton': this.closeSideMenu(); break;