From 517b3a644bbd92e4d2f1c31b5110e6a57365a431 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 15 Oct 2020 14:35:09 +0200 Subject: [PATCH] Fixing URL not being rewritten when changing maps --- front/src/Phaser/Game/GameManager.ts | 2 +- front/src/Phaser/Game/GameScene.ts | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/front/src/Phaser/Game/GameManager.ts b/front/src/Phaser/Game/GameManager.ts index cca1a5b2..7622381a 100644 --- a/front/src/Phaser/Game/GameManager.ts +++ b/front/src/Phaser/Game/GameManager.ts @@ -64,7 +64,7 @@ export class GameManager { public async goToStartingMap(scenePlugin: Phaser.Scenes.ScenePlugin) { const url = await this.startRoom.getMapUrl(); console.log('Starting scene '+url); - scenePlugin.start(url, {startLayerName: 'global'}); + scenePlugin.start(url); } } diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 4e209c42..ae3924d3 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -417,6 +417,13 @@ export class GameScene extends ResizableScene implements CenterListener { context.stroke(); this.circleTexture.refresh(); + // Let's alter browser history + let path = this.room.id; + if (this.startLayerName) { + path += '#'+this.startLayerName; + } + window.history.pushState({}, 'WorkAdventure', path); + // Let's pause the scene if the connection is not established yet if (this.connection === undefined) { // Let's wait 0.5 seconds before printing the "connecting" screen to avoid blinking