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

This commit is contained in:
_Bastler 2021-06-04 21:08:43 +02:00
commit d20ca2f15b
9 changed files with 65 additions and 15 deletions

View File

@ -8,7 +8,7 @@ function close(): boolean {
</script> </script>
<dialog class="error-dialog nes-dialog is-dark is-rounded" id="dialog-dark-rounded" open> <div class="error-div nes-container is-dark is-rounded" open>
<p class="nes-text is-error title">Error</p> <p class="nes-text is-error title">Error</p>
<div class="body"> <div class="body">
{#each $errorStore as error} {#each $errorStore as error}
@ -18,12 +18,16 @@ function close(): boolean {
<div class="button-bar"> <div class="button-bar">
<button class="nes-btn is-error" on:click={close}>Close</button> <button class="nes-btn is-error" on:click={close}>Close</button>
</div> </div>
</dialog> </div>
<style lang="scss"> <style lang="scss">
dialog.error-dialog { div.error-div {
pointer-events: auto; pointer-events: auto;
top: 10%; margin-top: 10vh;
margin-right: auto;
margin-left: auto;
width: max-content;
max-width: 80vw;
.button-bar { .button-bar {
text-align: center; text-align: center;

View File

@ -14,14 +14,15 @@
pointer-events: all; pointer-events: all;
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;
width: 515px; width: 530px;
margin-top: 200px; margin-top: 200px;
max-width: 100vw;
.defaultCard { .defaultCard {
border-radius: 5px; border-radius: 5px;
border: 2px black solid; border: 2px black solid;
background-color: whitesmoke; background-color: whitesmoke;
width: 500px; width: 530px;
header { header {
padding: 5px; padding: 5px;
@ -30,7 +31,7 @@
iframe { iframe {
border: 0; border: 0;
width: 515px; width: 530px;
height: 270px; height: 270px;
overflow: hidden; overflow: hidden;
} }
@ -60,5 +61,4 @@
<div class="buttonContainer"> <div class="buttonContainer">
<button class="nes-btn is-popUpElement" on:click={closeCard}>Close</button> <button class="nes-btn is-popUpElement" on:click={closeCard}>Close</button>
</div> </div>
</section> </section>

View File

@ -236,6 +236,9 @@ export class CustomizeScene extends AbstractCharacterScene {
} }
} }
public onResize(): void { public onResize(): void {
this.moveLayers(); this.moveLayers();

View File

@ -60,7 +60,6 @@ class WaScaleManager {
public saveZoom(): void { public saveZoom(): void {
this._saveZoom = this.hdpiManager.zoomModifier; this._saveZoom = this.hdpiManager.zoomModifier;
console.log(this._saveZoom);
} }
public restoreZoom(): void{ public restoreZoom(): void{

View File

@ -9,8 +9,18 @@ function createErrorStore() {
return { return {
subscribe, subscribe,
addErrorMessage: (e: string|Error): void => { addErrorMessage: (e: string|Error): void => {
update((messages) => { update((messages: string[]) => {
messages.push(e.toString()); let message: string;
if (e instanceof Error) {
message = e.message;
} else {
message = e;
}
if (!messages.includes(message)) {
messages.push(message);
}
return messages; return messages;
}); });
}, },

View File

@ -0,0 +1,8 @@
export class WebviewOnOldIOS extends Error {
static NAME = 'WebviewOnOldIOS';
constructor() {
super('Your iOS version cannot use video/audio in the browser unless you are using Safari. Please switch to Safari or upgrade iOS to 14.3 or above.');
this.name = WebviewOnOldIOS.NAME;
}
}

View File

@ -6,6 +6,8 @@ import {userMovingStore} from "./GameStore";
import {HtmlUtils} from "../WebRtc/HtmlUtils"; import {HtmlUtils} from "../WebRtc/HtmlUtils";
import {BrowserTooOldError} from "./Errors/BrowserTooOldError"; import {BrowserTooOldError} from "./Errors/BrowserTooOldError";
import {errorStore} from "./ErrorStore"; import {errorStore} from "./ErrorStore";
import {isIOS} from "../WebRtc/DeviceUtils";
import {WebviewOnOldIOS} from "./Errors/WebviewOnOldIOS";
/** /**
* A store that contains the camera state requested by the user (on or off). * A store that contains the camera state requested by the user (on or off).
@ -421,6 +423,13 @@ export const localStreamStore = derived<Readable<MediaStreamConstraints>, LocalS
constraints constraints
}); });
return; return;
} else if (isIOS()) {
set({
type: 'error',
error: new WebviewOnOldIOS(),
constraints
});
return;
} else { } else {
set({ set({
type: 'error', type: 'error',
@ -598,7 +607,7 @@ microphoneListStore.subscribe((devices) => {
localStreamStore.subscribe(streamResult => { localStreamStore.subscribe(streamResult => {
if (streamResult.type === 'error') { if (streamResult.type === 'error') {
if (streamResult.error.name === BrowserTooOldError.NAME) { if (streamResult.error.name === BrowserTooOldError.NAME || streamResult.error.name === WebviewOnOldIOS.NAME) {
errorStore.addErrorMessage(streamResult.error); errorStore.addErrorMessage(streamResult.error);
} }
} }

View File

@ -0,0 +1,12 @@
export function isIOS(): boolean {
return [
'iPad Simulator',
'iPhone Simulator',
'iPod Simulator',
'iPad',
'iPhone',
'iPod'
].includes(navigator.platform)
// iPad on iOS 13 detection
|| (navigator.userAgent.includes("Mac") && "ontouchend" in document)
}

View File

@ -65,6 +65,7 @@ export class MediaManager {
} }
}); });
let isScreenSharing = false;
screenSharingLocalStreamStore.subscribe((result) => { screenSharingLocalStreamStore.subscribe((result) => {
if (result.type === 'error') { if (result.type === 'error') {
console.error(result.error); console.error(result.error);
@ -75,10 +76,14 @@ export class MediaManager {
} }
if (result.stream !== null) { if (result.stream !== null) {
isScreenSharing = true;
this.addScreenSharingActiveVideo('me', DivImportance.Normal); this.addScreenSharingActiveVideo('me', DivImportance.Normal);
HtmlUtils.getElementByIdOrFail<HTMLVideoElement>('screen-sharing-me').srcObject = result.stream; HtmlUtils.getElementByIdOrFail<HTMLVideoElement>('screen-sharing-me').srcObject = result.stream;
} else { } else {
this.removeActiveScreenSharingVideo('me'); if (isScreenSharing) {
isScreenSharing = false;
this.removeActiveScreenSharingVideo('me');
}
} }
}); });
@ -145,7 +150,7 @@ export class MediaManager {
<img title="report this user" src="resources/logos/report.svg"> <img title="report this user" src="resources/logos/report.svg">
<span>Report/Block</span> <span>Report/Block</span>
</button> </button>
<video id="${userId}" autoplay></video> <video id="${userId}" autoplay playsinline></video>
<img src="resources/logos/blockSign.svg" id="blocking-${userId}" class="block-logo"> <img src="resources/logos/blockSign.svg" id="blocking-${userId}" class="block-logo">
<div id="soundMeter-${userId}" class="sound-progress"> <div id="soundMeter-${userId}" class="sound-progress">
<span></span> <span></span>
@ -182,7 +187,7 @@ export class MediaManager {
userId = this.getScreenSharingId(userId); userId = this.getScreenSharingId(userId);
const html = ` const html = `
<div id="div-${userId}" class="video-container"> <div id="div-${userId}" class="video-container">
<video id="${userId}" autoplay></video> <video id="${userId}" autoplay playsinline></video>
</div> </div>
`; `;