added world menu
This commit is contained in:
parent
8cc1584c2e
commit
bb7f83cee6
@ -2,6 +2,7 @@
|
|||||||
import {fly} from "svelte/transition";
|
import {fly} from "svelte/transition";
|
||||||
import SettingsSubMenu from "./SettingsSubMenu.svelte";
|
import SettingsSubMenu from "./SettingsSubMenu.svelte";
|
||||||
import ProfileSubMenu from "./ProfileSubMenu.svelte";
|
import ProfileSubMenu from "./ProfileSubMenu.svelte";
|
||||||
|
import WorldsSubMenu from "./WorldsSubMenu.svelte";
|
||||||
import CreateMapSubMenu from "./CreateMapSubMenu.svelte";
|
import CreateMapSubMenu from "./CreateMapSubMenu.svelte";
|
||||||
import AboutRoomSubMenu from "./AboutRoomSubMenu.svelte";
|
import AboutRoomSubMenu from "./AboutRoomSubMenu.svelte";
|
||||||
import GlobalMessageSubMenu from "./GlobalMessagesSubMenu.svelte";
|
import GlobalMessageSubMenu from "./GlobalMessagesSubMenu.svelte";
|
||||||
@ -52,6 +53,9 @@
|
|||||||
case SubMenusInterface.profile:
|
case SubMenusInterface.profile:
|
||||||
activeComponent = ProfileSubMenu;
|
activeComponent = ProfileSubMenu;
|
||||||
break;
|
break;
|
||||||
|
case SubMenusInterface.worlds:
|
||||||
|
activeComponent = WorldsSubMenu;
|
||||||
|
break;
|
||||||
case SubMenusInterface.createMap:
|
case SubMenusInterface.createMap:
|
||||||
activeComponent = CreateMapSubMenu;
|
activeComponent = CreateMapSubMenu;
|
||||||
break;
|
break;
|
||||||
|
@ -48,6 +48,13 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="customize-main">
|
<div class="customize-main">
|
||||||
|
<section>
|
||||||
|
<button type="button" class="nes-btn" on:click|preventDefault={openEditSkinScene}>Edit Skin</button>
|
||||||
|
<button type="button" class="nes-btn" on:click|preventDefault={openEditCompanionScene}>Edit Companion</button>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<button type="button" class="nes-btn" on:click|preventDefault={openEnableCameraScene}>Setup camera</button>
|
||||||
|
</section>
|
||||||
{#if $userIsConnected}
|
{#if $userIsConnected}
|
||||||
<section>
|
<section>
|
||||||
{#if PROFILE_URL != undefined}
|
{#if PROFILE_URL != undefined}
|
||||||
@ -58,27 +65,23 @@
|
|||||||
<button type="button" class="nes-btn" on:click|preventDefault={logOut}>Log out</button>
|
<button type="button" class="nes-btn" on:click|preventDefault={logOut}>Log out</button>
|
||||||
</section>
|
</section>
|
||||||
{:else}
|
{:else}
|
||||||
<section>
|
<section>
|
||||||
<a type="button" class="nes-btn" href="/login">Sign in</a>
|
<a type="button" class="nes-btn" href="/login">Sign in</a>
|
||||||
</section>
|
</section>
|
||||||
{/if}
|
{/if}
|
||||||
<section>
|
|
||||||
<button type="button" class="nes-btn" on:click|preventDefault={openEditSkinScene}>Edit Skin</button>
|
|
||||||
<button type="button" class="nes-btn" on:click|preventDefault={openEditCompanionScene}>Edit Companion</button>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<button type="button" class="nes-btn" on:click|preventDefault={openEnableCameraScene}>Setup camera</button>
|
|
||||||
</section>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
div.customize-main{
|
div.customize-main {
|
||||||
section {
|
overflow-y: auto;
|
||||||
display: flex;
|
height: 90%;
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
section {
|
||||||
flex-wrap: wrap;
|
display: flex;
|
||||||
margin-bottom: 20px;
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
|
||||||
iframe {
|
iframe {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
42
front/src/Components/Menu/WorldsSubMenu.svelte
Normal file
42
front/src/Components/Menu/WorldsSubMenu.svelte
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<script lang="typescript">
|
||||||
|
import { connectionManager } from "../../Connexion/ConnectionManager";
|
||||||
|
import type { World } from "../../Connexion/World";
|
||||||
|
|
||||||
|
|
||||||
|
let worlds = connectionManager.getWorlds();
|
||||||
|
|
||||||
|
|
||||||
|
function worldRoomId(world: World) {
|
||||||
|
return world.roomId;
|
||||||
|
}
|
||||||
|
|
||||||
|
function worldRoomName(world: World) {
|
||||||
|
return world.roomId.replace(window.location.origin + "/", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
function worldPlayer(world: World) {
|
||||||
|
return world.player;
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="customize-main">
|
||||||
|
{#await worlds then data}
|
||||||
|
<table class="nes-table is-bordered is-dark">
|
||||||
|
{#each data as world}
|
||||||
|
<tr>
|
||||||
|
<td><a href="{worldRoomId(world)}">{worldRoomName(world)}</a></td>
|
||||||
|
<td>{worldPlayer(world)}</td>
|
||||||
|
</tr>
|
||||||
|
{/each}
|
||||||
|
</table>
|
||||||
|
{/await}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
div.customize-main {
|
||||||
|
table.nes-table {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
@ -317,6 +317,21 @@ class ConnectionManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getWorlds() {
|
||||||
|
|
||||||
|
const token = localUserStore.getAuthToken();
|
||||||
|
if (!token) {
|
||||||
|
throw "No token provided";
|
||||||
|
}
|
||||||
|
|
||||||
|
const { worlds } = await Axios.get(`${PUSHER_URL}/worlds`, { params: { token } }).then((res) => {
|
||||||
|
return res.data;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return worlds;
|
||||||
|
}
|
||||||
|
|
||||||
get currentRoom() {
|
get currentRoom() {
|
||||||
return this._currentRoom;
|
return this._currentRoom;
|
||||||
}
|
}
|
||||||
|
4
front/src/Connexion/World.ts
Normal file
4
front/src/Connexion/World.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
export interface World {
|
||||||
|
roomId: string;
|
||||||
|
player: string[];
|
||||||
|
}
|
@ -34,6 +34,7 @@ export const warningContainerStore = createWarningContainerStore();
|
|||||||
export enum SubMenusInterface {
|
export enum SubMenusInterface {
|
||||||
settings = "Settings",
|
settings = "Settings",
|
||||||
profile = "Profile",
|
profile = "Profile",
|
||||||
|
worlds = "Worlds",
|
||||||
createMap = "Create a Map",
|
createMap = "Create a Map",
|
||||||
aboutRoom = "About the Room",
|
aboutRoom = "About the Room",
|
||||||
globalMessages = "Global Messages",
|
globalMessages = "Global Messages",
|
||||||
@ -44,6 +45,7 @@ function createSubMenusStore() {
|
|||||||
const { subscribe, update } = writable<string[]>([
|
const { subscribe, update } = writable<string[]>([
|
||||||
SubMenusInterface.settings,
|
SubMenusInterface.settings,
|
||||||
SubMenusInterface.profile,
|
SubMenusInterface.profile,
|
||||||
|
SubMenusInterface.worlds,
|
||||||
SubMenusInterface.createMap,
|
SubMenusInterface.createMap,
|
||||||
SubMenusInterface.aboutRoom,
|
SubMenusInterface.aboutRoom,
|
||||||
SubMenusInterface.globalMessages,
|
SubMenusInterface.globalMessages,
|
||||||
|
@ -119,29 +119,27 @@ export class MapController extends BaseController {
|
|||||||
throw Error("Token cannot to be check on Hydra");
|
throw Error("Token cannot to be check on Hydra");
|
||||||
}
|
}
|
||||||
|
|
||||||
const worlds: Map<String, PusherRoom> = socketManager.getWorlds();
|
const result: any[] = [];
|
||||||
|
for (const room of socketManager.getWorlds().values()) {
|
||||||
const result: any = {};
|
const world : any = {};
|
||||||
|
world.roomId = room.roomUrl;
|
||||||
for (const room of worlds.values()) {
|
world.player = [];
|
||||||
result[room.roomUrl] = room.getListeners().size;
|
|
||||||
/*
|
|
||||||
for (const listener of room.getListeners()) {
|
for (const listener of room.getListeners()) {
|
||||||
const position: any = {};
|
const position: any = {};
|
||||||
position.name = listener.name;
|
position.name = listener.name;
|
||||||
position.roomId = listener.roomId;
|
position.roomId = listener.roomId;
|
||||||
position.position = listener.position;
|
position.position = listener.position;
|
||||||
position.viewport = listener.viewport;
|
position.viewport = listener.viewport;
|
||||||
result.push(position);
|
world.player.push(listener.name);
|
||||||
}
|
}
|
||||||
*/
|
result.push(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res
|
return res
|
||||||
.writeStatus("200 OK")
|
.writeStatus("200 OK")
|
||||||
.writeHeader("Content-Type", "application/json")
|
.writeHeader("Content-Type", "application/json")
|
||||||
.end(
|
.end(
|
||||||
JSON.stringify(result)
|
JSON.stringify({ worlds: result })
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return this.errorToResponse(error, res);
|
return this.errorToResponse(error, res);
|
||||||
|
Loading…
Reference in New Issue
Block a user