Merge pull request #1398 from tabascoeye/develop

add possibility to set size of coWebsite and Jitsis via map property
This commit is contained in:
Kharhamel 2021-09-01 14:42:41 +02:00 committed by GitHub
commit ad60993b9a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 6 deletions

View file

@ -835,7 +835,8 @@ export class GameScene extends DirtyScene {
newValue as string, newValue as string,
this.MapUrlFile, this.MapUrlFile,
allProps.get("openWebsiteAllowApi") as boolean | undefined, allProps.get("openWebsiteAllowApi") as boolean | undefined,
allProps.get("openWebsitePolicy") as string | undefined allProps.get("openWebsitePolicy") as string | undefined,
allProps.get("openWebsiteWidth") as number | undefined
); );
layoutManagerActionStore.removeAction("openWebsite"); layoutManagerActionStore.removeAction("openWebsite");
}; };
@ -1839,8 +1840,9 @@ ${escapedMessage}
"jitsiInterfaceConfig" "jitsiInterfaceConfig"
); );
const jitsiUrl = allProps.get("jitsiUrl") as string | undefined; const jitsiUrl = allProps.get("jitsiUrl") as string | undefined;
const jitsiWidth = allProps.get("jitsiWidth") as number | undefined;
jitsiFactory.start(roomName, this.playerName, jwt, jitsiConfig, jitsiInterfaceConfig, jitsiUrl); jitsiFactory.start(roomName, this.playerName, jwt, jitsiConfig, jitsiInterfaceConfig, jitsiUrl, jitsiWidth);
this.connection?.setSilent(true); this.connection?.setSilent(true);
mediaManager.hideGameOverlay(); mediaManager.hideGameOverlay();

View file

@ -48,6 +48,10 @@ class CoWebsiteManager {
this.cowebsiteDiv.style.width = width + "px"; this.cowebsiteDiv.style.width = width + "px";
} }
set widthPercent(width: number) {
this.cowebsiteDiv.style.width = width + "%";
}
get height(): number { get height(): number {
return this.cowebsiteDiv.clientHeight; return this.cowebsiteDiv.clientHeight;
} }
@ -162,7 +166,7 @@ class CoWebsiteManager {
return iframe; return iframe;
} }
public loadCoWebsite(url: string, base: string, allowApi?: boolean, allowPolicy?: string): void { public loadCoWebsite(url: string, base: string, allowApi?: boolean, allowPolicy?: string, widthPercent?: number): void {
this.load(); this.load();
this.cowebsiteMainDom.innerHTML = ``; this.cowebsiteMainDom.innerHTML = ``;
@ -186,6 +190,9 @@ class CoWebsiteManager {
.then(() => Promise.race([onloadPromise, onTimeoutPromise])) .then(() => Promise.race([onloadPromise, onTimeoutPromise]))
.then(() => { .then(() => {
this.open(); this.open();
if (widthPercent) {
this.widthPercent = widthPercent;
}
setTimeout(() => { setTimeout(() => {
this.fire(); this.fire();
}, animationTime); }, animationTime);
@ -199,13 +206,16 @@ class CoWebsiteManager {
/** /**
* Just like loadCoWebsite but the div can be filled by the user. * Just like loadCoWebsite but the div can be filled by the user.
*/ */
public insertCoWebsite(callback: (cowebsite: HTMLDivElement) => Promise<void>): void { public insertCoWebsite(callback: (cowebsite: HTMLDivElement) => Promise<void>, widthPercent?: number): void {
this.load(); this.load();
this.cowebsiteMainDom.innerHTML = ``; this.cowebsiteMainDom.innerHTML = ``;
this.currentOperationPromise = this.currentOperationPromise this.currentOperationPromise = this.currentOperationPromise
.then(() => callback(this.cowebsiteMainDom)) .then(() => callback(this.cowebsiteMainDom))
.then(() => { .then(() => {
this.open(); this.open();
if (widthPercent) {
this.widthPercent = widthPercent;
}
setTimeout(() => { setTimeout(() => {
this.fire(); this.fire();
}, animationTime); }, animationTime);

View file

@ -82,7 +82,7 @@ class JitsiFactory {
return slugify(instance.replace('/', '-') + "-" + roomName); return slugify(instance.replace('/', '-') + "-" + roomName);
} }
public start(roomName: string, playerName:string, jwt?: string, config?: object, interfaceConfig?: object, jitsiUrl?: string): void { public start(roomName: string, playerName:string, jwt?: string, config?: object, interfaceConfig?: object, jitsiUrl?: string, jitsiWidth?: number): void {
coWebsiteManager.insertCoWebsite((async cowebsiteDiv => { coWebsiteManager.insertCoWebsite((async cowebsiteDiv => {
// Jitsi meet external API maintains some data in local storage // Jitsi meet external API maintains some data in local storage
// which is sent via the appData URL parameter when joining a // which is sent via the appData URL parameter when joining a
@ -120,7 +120,7 @@ class JitsiFactory {
this.jitsiApi.addListener('audioMuteStatusChanged', this.audioCallback); this.jitsiApi.addListener('audioMuteStatusChanged', this.audioCallback);
this.jitsiApi.addListener('videoMuteStatusChanged', this.videoCallback); this.jitsiApi.addListener('videoMuteStatusChanged', this.videoCallback);
}); });
})); }), jitsiWidth);
} }
public async stop(): Promise<void> { public async stop(): Promise<void> {