added change companion button to menu

This commit is contained in:
Johannes Berthel 2021-04-02 23:13:03 +02:00
parent 52303c0bd6
commit 6ee4889773
4 changed files with 24 additions and 10 deletions

View File

@ -30,6 +30,9 @@
<section>
<button id="changeSkinButton">Edit skin</button>
</section>
<section>
<button id="changeCompanionButton">Edit companion</button>
</section>
<section>
<button id="editGameSettingsButton">Settings</button>
</section>

View File

@ -1,7 +1,11 @@
import LoaderPlugin = Phaser.Loader.LoaderPlugin;
import { COMPANION_RESOURCES, CompanionResourceDescriptionInterface } from "./CompanionTextures";
export const loadAll = (loader: LoaderPlugin): Promise<CompanionResourceDescriptionInterface[]> => {
export const getAllResources = (): CompanionResourceDescriptionInterface[] => {
return COMPANION_RESOURCES;
}
export const lazyLoadAllResources = (loader: LoaderPlugin): Promise<CompanionResourceDescriptionInterface[]> => {
const promises: Promise<string>[] = [];
COMPANION_RESOURCES.forEach((resource: CompanionResourceDescriptionInterface) => {

View File

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

View File

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