temp
This commit is contained in:
parent
50f3af81e4
commit
1ce801cced
@ -70,7 +70,7 @@
|
||||
|
||||
{#if $menuIconVisible}
|
||||
<div>
|
||||
<MenuIcon game ={game}></MenuIcon>
|
||||
<MenuIcon></MenuIcon>
|
||||
</div>
|
||||
{/if}
|
||||
{#if $menuVisible}
|
||||
|
@ -4,7 +4,6 @@
|
||||
import {gameManager} from "../../Phaser/Game/GameManager";
|
||||
import type {Game} from "../../Phaser/Game/Game";
|
||||
|
||||
export let game: Game;
|
||||
let inputSendTextActive = true;
|
||||
let uploadMusicActive = false;
|
||||
|
||||
@ -33,10 +32,10 @@
|
||||
</div>
|
||||
<div class="main-input">
|
||||
{#if inputSendTextActive}
|
||||
<InputTextGlobalMessage game={game} gameManager={gameManager}></InputTextGlobalMessage>
|
||||
<InputTextGlobalMessage gameManager={gameManager}></InputTextGlobalMessage>
|
||||
{/if}
|
||||
{#if uploadMusicActive}
|
||||
<UploadAudioGlobalMessage game={game} gameManager={gameManager}></UploadAudioGlobalMessage>
|
||||
<UploadAudioGlobalMessage gameManager={gameManager}></UploadAudioGlobalMessage>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,12 +1,10 @@
|
||||
<script lang="ts">
|
||||
import {consoleGlobalMessageManagerFocusStore, consoleGlobalMessageManagerVisibleStore } from "../../Stores/ConsoleGlobalMessageManagerStore";
|
||||
import {onMount} from "svelte";
|
||||
import type {Game} from "../../Phaser/Game/Game";
|
||||
import type {GameManager} from "../../Phaser/Game/GameManager";
|
||||
import type {PlayGlobalMessageInterface} from "../../Connexion/ConnexionModels";
|
||||
import {AdminMessageEventTypes} from "../../Connexion/AdminMessagesService";
|
||||
import type {Quill} from "quill";
|
||||
import {LoginSceneName} from "../../Phaser/Login/LoginScene";
|
||||
|
||||
//toolbar
|
||||
export const toolbarOptions = [
|
||||
@ -32,10 +30,9 @@
|
||||
// remove formatting button
|
||||
];
|
||||
|
||||
export let game: Game;
|
||||
export let gameManager: GameManager;
|
||||
|
||||
let gameScene = gameManager.getCurrentGameScene(game.scene.getScene(LoginSceneName));
|
||||
let gameScene = gameManager.getCurrentGameScene();
|
||||
let quill: Quill;
|
||||
let INPUT_CONSOLE_MESSAGE: HTMLDivElement;
|
||||
|
||||
|
@ -1,21 +1,18 @@
|
||||
<script lang="ts">
|
||||
import {HtmlUtils} from "../../WebRtc/HtmlUtils";
|
||||
import type {Game} from "../../Phaser/Game/Game";
|
||||
import type {GameManager} from "../../Phaser/Game/GameManager";
|
||||
import {consoleGlobalMessageManagerFocusStore, consoleGlobalMessageManagerVisibleStore} from "../../Stores/ConsoleGlobalMessageManagerStore";
|
||||
import {AdminMessageEventTypes} from "../../Connexion/AdminMessagesService";
|
||||
import type {PlayGlobalMessageInterface} from "../../Connexion/ConnexionModels";
|
||||
import uploadFile from "../images/music-file.svg";
|
||||
import {LoginSceneName} from "../../Phaser/Login/LoginScene";
|
||||
|
||||
interface EventTargetFiles extends EventTarget {
|
||||
files: Array<File>;
|
||||
}
|
||||
|
||||
export let game: Game;
|
||||
export let gameManager: GameManager;
|
||||
|
||||
let gameScene = gameManager.getCurrentGameScene(game.scene.getScene(LoginSceneName));
|
||||
let gameScene = gameManager.getCurrentGameScene();
|
||||
let fileinput: HTMLInputElement;
|
||||
let filename: string;
|
||||
let filesize: string;
|
||||
|
@ -3,7 +3,7 @@
|
||||
import EditProfileMenu from "./EditProfileMenu.svelte";
|
||||
|
||||
enum SubMenus {
|
||||
gameQuality = 1,
|
||||
settings = 1,
|
||||
editProfile,
|
||||
shareUrl,
|
||||
}
|
||||
@ -13,6 +13,13 @@
|
||||
function switchMenu(menu: SubMenus) {
|
||||
activeSubMenu = menu;
|
||||
}
|
||||
|
||||
function gotToCreateMapPage() {
|
||||
//const sparkHost = 'https://'+window.location.host.replace('play.', '')+'/choose-map.html';
|
||||
//TODO fix me: this button can to send us on WorkAdventure BO.
|
||||
const sparkHost = "https://workadventu.re/getting-started";
|
||||
window.open(sparkHost, "_blank");
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@ -20,17 +27,17 @@
|
||||
<section class="menuNav">
|
||||
<nav>
|
||||
<ul>
|
||||
<li class:active={activeSubMenu === SubMenus.gameQuality } on:click={switchMenu(SubMenus.gameQuality)}>GameQuality</li>
|
||||
<li class:active={activeSubMenu === SubMenus.editProfile } on:click={switchMenu(SubMenus.editProfile)}>Edit Profile</li>
|
||||
<li class:active={activeSubMenu === 3 } on:click={switchMenu(3)}>Share Url </li>
|
||||
<li class:active={activeSubMenu === 3 } on:click={switchMenu(3)}>Create Map</li>
|
||||
<li class:active={activeSubMenu === 3 } on:click={switchMenu(3)}>Go to Menu</li>
|
||||
<li class:active={activeSubMenu === SubMenus.settings } on:click={() => switchMenu(SubMenus.settings)}>Settings</li>
|
||||
<li class:active={activeSubMenu === SubMenus.shareUrl } on:click={() => switchMenu(SubMenus.shareUrl)}>Share Url</li>
|
||||
<li class:active={activeSubMenu === SubMenus.editProfile } on:click={() => switchMenu(SubMenus.editProfile)}>Edit Profile</li>
|
||||
<li on:click={() => gotToCreateMapPage()}>Create Map</li>
|
||||
<li>Go to Menu</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</section>
|
||||
|
||||
<section class="subMenuContainer">
|
||||
{#if activeSubMenu === SubMenus.gameQuality}
|
||||
{#if activeSubMenu === SubMenus.settings}
|
||||
<GameQualityMenu></GameQualityMenu>
|
||||
{:else if activeSubMenu === SubMenus.editProfile}
|
||||
<EditProfileMenu></EditProfileMenu>
|
||||
|
@ -1,8 +1,6 @@
|
||||
<script lang="typescript">
|
||||
import { Game } from "../../Phaser/Game/Game";
|
||||
import {menuVisible} from "../../Stores/MenuStore";
|
||||
|
||||
export let game: Game;
|
||||
let isOpen : Boolean = false;
|
||||
|
||||
function openMenu(){
|
||||
@ -15,7 +13,7 @@
|
||||
<main class="menuIcon">
|
||||
<section>
|
||||
<button on:click|preventDefault={openMenu}>
|
||||
<img src="/static/images/logo-WA-min.png">
|
||||
<img src="/static/images/logo-WA-min.png" alt="open menu">
|
||||
</button>
|
||||
</section>
|
||||
</main>
|
||||
|
@ -20,6 +20,8 @@ export class GameManager {
|
||||
private companion: string | null;
|
||||
private startRoom!: Room;
|
||||
currentGameSceneName: string | null = null;
|
||||
// Note: this scenePlugin is the scenePlugin of the EntryScene. We should always provide a key in methods called on this scenePlugin.
|
||||
private scenePlugin!: Phaser.Scenes.ScenePlugin;
|
||||
|
||||
constructor() {
|
||||
this.playerName = localUserStore.getName();
|
||||
@ -28,8 +30,9 @@ export class GameManager {
|
||||
}
|
||||
|
||||
public async init(scenePlugin: Phaser.Scenes.ScenePlugin): Promise<string> {
|
||||
this.scenePlugin = scenePlugin;
|
||||
this.startRoom = await connectionManager.initGameConnexion();
|
||||
await this.loadMap(this.startRoom, scenePlugin);
|
||||
await this.loadMap(this.startRoom);
|
||||
|
||||
if (!this.playerName) {
|
||||
return LoginSceneName;
|
||||
@ -69,21 +72,20 @@ export class GameManager {
|
||||
return this.companion;
|
||||
}
|
||||
|
||||
public async loadMap(room: Room, scenePlugin: Phaser.Scenes.ScenePlugin): Promise<void> {
|
||||
public async loadMap(room: Room): Promise<void> {
|
||||
const roomID = room.id;
|
||||
const mapDetail = await room.getMapDetail();
|
||||
|
||||
const gameIndex = scenePlugin.getIndex(roomID);
|
||||
const gameIndex = this.scenePlugin.getIndex(roomID);
|
||||
if (gameIndex === -1) {
|
||||
const game: Phaser.Scene = new GameScene(room, mapDetail.mapUrl);
|
||||
scenePlugin.add(roomID, game, false);
|
||||
this.scenePlugin.add(roomID, game, false);
|
||||
}
|
||||
}
|
||||
|
||||
public goToStartingMap(scenePlugin: Phaser.Scenes.ScenePlugin): void {
|
||||
console.log("starting " + (this.currentGameSceneName || this.startRoom.id));
|
||||
scenePlugin.start(this.currentGameSceneName || this.startRoom.id);
|
||||
scenePlugin.launch(MenuSceneName);
|
||||
public goToStartingMap(): void {
|
||||
this.scenePlugin.start(this.currentGameSceneName || this.startRoom.id);
|
||||
this.scenePlugin.launch(MenuSceneName);
|
||||
|
||||
if (
|
||||
!localUserStore.getHelpCameraSettingsShown() &&
|
||||
@ -105,33 +107,33 @@ export class GameManager {
|
||||
* Temporary leave a gameScene to go back to the loginScene for example.
|
||||
* This will close the socket connections and stop the gameScene, but won't remove it.
|
||||
*/
|
||||
leaveGame(scene: Phaser.Scene, targetSceneName: string, sceneClass: Phaser.Scene): void {
|
||||
leaveGame(targetSceneName: string, sceneClass: Phaser.Scene): void {
|
||||
if (this.currentGameSceneName === null) throw "No current scene id set!";
|
||||
const gameScene: GameScene = scene.scene.get(this.currentGameSceneName) as GameScene;
|
||||
const gameScene: GameScene = this.scenePlugin.get(this.currentGameSceneName) as GameScene;
|
||||
gameScene.cleanupClosingScene();
|
||||
scene.scene.stop(this.currentGameSceneName);
|
||||
scene.scene.sleep(MenuSceneName);
|
||||
if (!scene.scene.get(targetSceneName)) {
|
||||
scene.scene.add(targetSceneName, sceneClass, false);
|
||||
this.scenePlugin.stop(this.currentGameSceneName);
|
||||
this.scenePlugin.sleep(MenuSceneName);
|
||||
if (!this.scenePlugin.get(targetSceneName)) {
|
||||
this.scenePlugin.add(targetSceneName, sceneClass, false);
|
||||
}
|
||||
scene.scene.run(targetSceneName);
|
||||
this.scenePlugin.run(targetSceneName);
|
||||
}
|
||||
|
||||
/**
|
||||
* follow up to leaveGame()
|
||||
*/
|
||||
tryResumingGame(scene: Phaser.Scene, fallbackSceneName: string) {
|
||||
tryResumingGame(fallbackSceneName: string) {
|
||||
if (this.currentGameSceneName) {
|
||||
scene.scene.start(this.currentGameSceneName);
|
||||
scene.scene.wake(MenuSceneName);
|
||||
this.scenePlugin.start(this.currentGameSceneName);
|
||||
this.scenePlugin.wake(MenuSceneName);
|
||||
} else {
|
||||
scene.scene.run(fallbackSceneName);
|
||||
this.scenePlugin.run(fallbackSceneName);
|
||||
}
|
||||
}
|
||||
|
||||
public getCurrentGameScene(scene: Phaser.Scene): GameScene {
|
||||
public getCurrentGameScene(): GameScene {
|
||||
if (this.currentGameSceneName === null) throw "No current scene id set!";
|
||||
return scene.scene.get(this.currentGameSceneName) as GameScene;
|
||||
return this.scenePlugin.get(this.currentGameSceneName) as GameScene;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1248,7 +1248,7 @@ ${escapedMessage}
|
||||
private loadNextGame(exitSceneIdentifier: string): Promise<void> {
|
||||
const { roomId, hash } = Room.getIdFromIdentifier(exitSceneIdentifier, this.MapUrlFile, this.instance);
|
||||
const room = new Room(roomId);
|
||||
return gameManager.loadMap(room, this.scene).catch(() => {});
|
||||
return gameManager.loadMap(room).catch(() => {});
|
||||
}
|
||||
|
||||
//todo: in a dedicated class/function?
|
||||
@ -1306,7 +1306,7 @@ ${escapedMessage}
|
||||
});
|
||||
} catch (err) {
|
||||
if (err instanceof TextureError) {
|
||||
gameManager.leaveGame(this, SelectCharacterSceneName, new SelectCharacterScene());
|
||||
gameManager.leaveGame(SelectCharacterSceneName, new SelectCharacterScene());
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
|
@ -38,6 +38,6 @@ export class EnableCameraScene extends ResizableScene {
|
||||
enableCameraSceneVisibilityStore.hideEnableCameraScene();
|
||||
|
||||
this.scene.sleep(EnableCameraSceneName);
|
||||
gameManager.goToStartingMap(this.scene);
|
||||
gameManager.goToStartingMap();
|
||||
}
|
||||
}
|
||||
|
@ -330,18 +330,18 @@ export class MenuScene extends Phaser.Scene {
|
||||
switch ((event?.target as HTMLInputElement).id) {
|
||||
case "changeNameButton":
|
||||
this.closeSideMenu();
|
||||
gameManager.leaveGame(this, LoginSceneName, new LoginScene());
|
||||
gameManager.leaveGame(LoginSceneName, new LoginScene());
|
||||
break;
|
||||
case "sparkButton":
|
||||
this.gotToCreateMapPage();
|
||||
break;
|
||||
case "changeSkinButton":
|
||||
this.closeSideMenu();
|
||||
gameManager.leaveGame(this, SelectCharacterSceneName, new SelectCharacterScene());
|
||||
gameManager.leaveGame(SelectCharacterSceneName, new SelectCharacterScene());
|
||||
break;
|
||||
case "changeCompanionButton":
|
||||
this.closeSideMenu();
|
||||
gameManager.leaveGame(this, SelectCompanionSceneName, new SelectCompanionScene());
|
||||
gameManager.leaveGame(SelectCompanionSceneName, new SelectCompanionScene());
|
||||
break;
|
||||
case "closeButton":
|
||||
this.closeSideMenu();
|
||||
|
Loading…
Reference in New Issue
Block a user