Merge branch 'develop' of github.com:thecodingmachine/workadventure into twemojiEmoteMenuSvelte

This commit is contained in:
Lurkars 2021-09-16 18:12:51 +02:00
commit 7922de10ff
32 changed files with 575 additions and 81 deletions

View file

@ -286,4 +286,15 @@ export class GameMap {
this.triggerAll();
}
/**
* Trigger all the callbacks (used when exiting a map)
*/
public triggerExitCallbacks(): void {
const emptyProps = new Map<string, string | boolean | number>();
for (const [oldPropName, oldPropValue] of this.lastProperties.entries()) {
// We found a property that disappeared
this.trigger(oldPropName, oldPropValue, undefined, emptyProps);
}
}
}

View file

@ -13,9 +13,27 @@ export class GameMapPropertiesListener {
constructor(private scene: GameScene, private gameMap: GameMap) {}
register() {
this.gameMap.onPropertyChange("openTab", (newValue) => {
this.gameMap.onPropertyChange("openTab", (newValue, oldvalue, allProps) => {
if (newValue === undefined) {
layoutManagerActionStore.removeAction("openTab");
}
if (typeof newValue == "string" && newValue.length) {
scriptUtils.openTab(newValue);
const openWebsiteTriggerValue = allProps.get(TRIGGER_WEBSITE_PROPERTIES);
if (openWebsiteTriggerValue && openWebsiteTriggerValue === ON_ACTION_TRIGGER_BUTTON) {
let message = allProps.get(WEBSITE_MESSAGE_PROPERTIES);
if (message === undefined) {
message = "Press SPACE or touch here to open web site in new tab";
}
layoutManagerActionStore.addAction({
uuid: "openTab",
type: "message",
message: message,
callback: () => scriptUtils.openTab(newValue),
userInputManager: this.scene.userInputManager,
});
} else {
scriptUtils.openTab(newValue);
}
}
});
this.gameMap.onPropertyChange("openWebsite", (newValue, oldValue, allProps) => {

View file

@ -94,6 +94,7 @@ import { userIsAdminStore } from "../../Stores/GameStore";
import { layoutManagerActionStore } from "../../Stores/LayoutManagerStore";
import { EmbeddedWebsiteManager } from "./EmbeddedWebsiteManager";
import { GameMapPropertiesListener } from "./GameMapPropertiesListener";
import { analyticsClient } from "../../Administration/AnalyticsClient";
import { get } from "svelte/store";
export interface GameSceneInitInterface {
@ -429,6 +430,7 @@ export class GameScene extends DirtyScene {
gameManager.gameSceneIsCreated(this);
urlManager.pushRoomIdToUrl(this.room);
analyticsClient.enteredRoom(this.room.id);
if (touchScreenManager.supportTouchScreen) {
this.pinchManager = new PinchManager(this);
@ -1255,6 +1257,8 @@ ${escapedMessage}
if (this.mapTransitioning) return;
this.mapTransitioning = true;
this.gameMap.triggerExitCallbacks();
let targetRoom: Room;
try {
targetRoom = await Room.createRoom(roomUrl);
@ -1463,6 +1467,7 @@ ${escapedMessage}
});
this.CurrentPlayer.on(requestEmoteEventName, (emoteKey: string) => {
this.connection?.emitEmoteEvent(emoteKey);
analyticsClient.launchEmote(emoteKey);
});
} catch (err) {
if (err instanceof TextureError) {
@ -1830,19 +1835,21 @@ ${escapedMessage}
jitsiFactory.start(roomName, this.playerName, jwt, jitsiConfig, jitsiInterfaceConfig, jitsiUrl, jitsiWidth);
this.connection?.setSilent(true);
mediaManager.hideGameOverlay();
analyticsClient.enteredJitsi(roomName, this.room.id);
//permit to stop jitsi when user close iframe
mediaManager.addTriggerCloseJitsiFrameButton("close-jisi", () => {
mediaManager.addTriggerCloseJitsiFrameButton("close-jitsi", () => {
this.stopJitsi();
});
}
public stopJitsi(): void {
this.connection?.setSilent(false);
const silent = this.gameMap.getCurrentProperties().get("silent");
this.connection?.setSilent(!!silent);
jitsiFactory.stop();
mediaManager.showGameOverlay();
mediaManager.removeTriggerCloseJitsiFrameButton("close-jisi");
mediaManager.removeTriggerCloseJitsiFrameButton("close-jitsi");
}
//todo: put this into an 'orchestrator' scene (EntryScene?)