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

This commit is contained in:
_Bastler
2022-04-13 15:35:28 +02:00
182 changed files with 1413 additions and 2592 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
import type CancelablePromise from "cancelable-promise";
import type { Readable, Writable } from "svelte/store";
import type { Readable } from "svelte/store";
export type CoWebsiteState = "asleep" | "loading" | "ready";
+6 -6
View File
@@ -52,7 +52,7 @@ class CoWebsiteManager {
trails: number[] | undefined;
};
private resizeObserver = new ResizeObserver((entries) => {
private resizeObserver = new ResizeObserver(() => {
this.resizeAllIframes();
});
@@ -223,7 +223,7 @@ class CoWebsiteManager {
this.fire();
};
this.cowebsiteAsideHolderDom.addEventListener("mousedown", (event) => {
this.cowebsiteAsideHolderDom.addEventListener("mousedown", () => {
if (this.isFullScreen) return;
const coWebsite = this.getMainCoWebsite();
@@ -240,7 +240,7 @@ class CoWebsiteManager {
document.addEventListener("mousemove", movecallback);
});
document.addEventListener("mouseup", (event) => {
document.addEventListener("mouseup", () => {
if (!this.resizing || this.isFullScreen) return;
document.removeEventListener("mousemove", movecallback);
const coWebsite = this.getMainCoWebsite();
@@ -277,7 +277,7 @@ class CoWebsiteManager {
document.addEventListener("touchmove", movecallback);
});
document.addEventListener("touchend", (event) => {
document.addEventListener("touchend", () => {
if (!this.resizing || this.isFullScreen) return;
this.previousTouchMoveCoordinates = null;
document.removeEventListener("touchmove", movecallback);
@@ -298,7 +298,7 @@ class CoWebsiteManager {
}
private transitionListeners() {
this.cowebsiteDom.addEventListener("transitionend", (event) => {
this.cowebsiteDom.addEventListener("transitionend", () => {
if (this.cowebsiteDom.classList.contains("loading")) {
this.fire();
}
@@ -552,7 +552,7 @@ class CoWebsiteManager {
}
coWebsite.unload().catch((err) => {
console.error("Cannot unload cowebsite on remove from stack");
console.error("Cannot unload cowebsite on remove from stack", err);
});
}
+1
View File
@@ -14,6 +14,7 @@ export function getColorRgbFromHue(hue: number): { r: number; g: number; b: numb
return hsv_to_rgb(hue, 0.5, 0.95);
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function stringToDouble(string: string): number {
let num = 1;
for (const char of string.split("")) {
+39
View File
@@ -3,6 +3,8 @@ import { coWebsiteManager } from "./CoWebsiteManager";
import { requestedCameraState, requestedMicrophoneState } from "../Stores/MediaStore";
import { get } from "svelte/store";
import CancelablePromise from "cancelable-promise";
import { gameManager } from "../Phaser/Game/GameManager";
import { jitsiParticipantsCountStore, userIsJitsiDominantSpeakerStore } from "../Stores/GameStore";
interface jitsiConfigInterface {
startWithAudioMuted: boolean;
@@ -126,6 +128,8 @@ class JitsiFactory {
private jitsiApi?: JitsiApi;
private audioCallback = this.onAudioChange.bind(this);
private videoCallback = this.onVideoChange.bind(this);
private dominantSpeakerChangedCallback = this.onDominantSpeakerChanged.bind(this);
private participantsCountChangeCallback = this.onParticipantsCountChange.bind(this);
private jitsiScriptLoaded: boolean = false;
/**
@@ -203,10 +207,15 @@ class JitsiFactory {
this.jitsiApi.addListener("videoConferenceJoined", () => {
this.jitsiApi?.executeCommand("displayName", playerName);
this.updateParticipantsCountStore();
});
this.jitsiApi.addListener("audioMuteStatusChanged", this.audioCallback);
this.jitsiApi.addListener("videoMuteStatusChanged", this.videoCallback);
this.jitsiApi.addListener("dominantSpeakerChanged", this.dominantSpeakerChangedCallback);
this.jitsiApi.addListener("participantJoined", this.participantsCountChangeCallback);
this.jitsiApi.addListener("participantLeft", this.participantsCountChangeCallback);
this.jitsiApi.addListener("participantKickedOut", this.participantsCountChangeCallback);
});
cancel(() => {
@@ -241,6 +250,8 @@ class JitsiFactory {
}
public destroy() {
userIsJitsiDominantSpeakerStore.set(false);
jitsiParticipantsCountStore.set(0);
if (!this.jitsiApi) {
return;
}
@@ -265,6 +276,34 @@ class JitsiFactory {
}
}
private onDominantSpeakerChanged(data: { id: string }): void {
userIsJitsiDominantSpeakerStore.set(
//@ts-ignore
data.id === this.getCurrentParticipantId(this.jitsiApi?.getParticipantsInfo())
);
}
private onParticipantsCountChange(): void {
this.updateParticipantsCountStore();
}
private updateParticipantsCountStore(): void {
//@ts-ignore
jitsiParticipantsCountStore.set(this.jitsiApi?.getParticipantsInfo().length ?? 0);
}
private getCurrentParticipantId(
participants: { displayName: string; participantId: string }[]
): string | undefined {
const currentPlayerName = gameManager.getPlayerName();
for (const participant of participants) {
if (participant.displayName === currentPlayerName) {
return participant.participantId;
}
}
return;
}
private loadJitsiScript(domain: string): CancelablePromise<void> {
return new CancelablePromise<void>((resolve, reject, cancel) => {
if (this.jitsiScriptLoaded) {