trigger + audioplayer improvements

This commit is contained in:
_Bastler
2021-04-21 07:44:12 +02:00
parent d55e6e9c84
commit e03cf9dc26
6 changed files with 94 additions and 17 deletions
+4
View File
@@ -52,6 +52,9 @@ class IframeListener {
private readonly _removeBubbleStream: Subject<void> = new Subject();
public readonly removeBubbleStream = this._removeBubbleStream.asObservable();
private readonly _unregisterIFrameStream: Subject<void> = new Subject();
public readonly unregisterIFrameStream = this._unregisterIFrameStream.asObservable();
private readonly iframes = new Set<HTMLIFrameElement>();
private readonly scripts = new Map<string, HTMLIFrameElement>();
@@ -119,6 +122,7 @@ class IframeListener {
}
unregisterIframe(iframe: HTMLIFrameElement): void {
this._unregisterIFrameStream.next();
this.iframes.delete(iframe);
}
+46
View File
@@ -852,6 +852,25 @@ ${escapedMessage}
scriptedBubbleSprite.destroy();
}));
this.iframeSubscriptionList.push(iframeListener.unregisterIFrameStream.subscribe(() => {
const allProps = this.gameMap.getCurrentProperties();
if(allProps.get("openWebsite") == null) {
layoutManager.removeActionButton('openWebsite', this.userInputManager);
} else {
const openWebsiteFunction = () => {
coWebsiteManager.loadCoWebsite(allProps.get("openWebsite") as string, this.MapUrlFile, allProps.get('openWebsiteAllowApi') as boolean | undefined, allProps.get('openWebsitePolicy') as string | undefined);
layoutManager.removeActionButton('openWebsite', this.userInputManager);
};
let message = allProps.get(WEBSITE_MESSAGE_PROPERTIES);
if(message === undefined) {
message = 'Press SPACE or touch here to open web site';
}
layoutManager.addActionButton('openWebsite', message.toString(), () => {
openWebsiteFunction();
}, this.userInputManager);
}
}));
}
private getMapDirUrl(): string {
@@ -1456,6 +1475,33 @@ ${escapedMessage}
mediaManager.showGameOverlay();
mediaManager.removeTriggerCloseJitsiFrameButton('close-jisi');
const allProps = this.gameMap.getCurrentProperties();
if(allProps.get("jitsiRoom") === undefined) {
layoutManager.removeActionButton('jitsiRoom', this.userInputManager);
} else {
const openJitsiRoomFunction = () => {
const roomName = jitsiFactory.getRoomName(allProps.get("jitsiRoom") as string, this.instance);
const jitsiUrl = allProps.get("jitsiUrl") as string | undefined;
if(JITSI_PRIVATE_MODE && !jitsiUrl) {
const adminTag = allProps.get("jitsiRoomAdminTag") as string | undefined;
this.connection.emitQueryJitsiJwtMessage(roomName, adminTag);
} else {
this.startJitsi(roomName, undefined);
}
layoutManager.removeActionButton('jitsiRoom', this.userInputManager);
}
let message = allProps.get(JITSI_MESSAGE_PROPERTIES);
if(message === undefined) {
message = 'Press SPACE or touch here to enter Jitsi Meet room';
}
layoutManager.addActionButton('jitsiRoom', message.toString(), () => {
openJitsiRoomFunction();
}, this.userInputManager);
}
}
//todo: put this into an 'orchestrator' scene (EntryScene?)
+22 -14
View File
@@ -11,7 +11,7 @@ enum audioStates {
const audioPlayerDivId = "audioplayer";
const audioPlayerCtrlId = "audioplayerctrl";
const audioPlayerVolId = "audioplayer_volume";
const audioPlayerMuteId = "audioplayer_volume_icon_playing";
const audioPlayerVolumeIconId = "audioplayer_volume_icon_playing";
const animationTime = 500;
class AudioManager {
@@ -21,7 +21,7 @@ class AudioManager {
private audioPlayerCtrl: HTMLDivElement;
private audioPlayerElem: HTMLAudioElement | undefined;
private audioPlayerVol: HTMLInputElement;
private audioPlayerMute: HTMLInputElement;
private audioPlayerVolumeIcon: HTMLInputElement;
private volume = 1;
private muted = false;
@@ -32,15 +32,12 @@ class AudioManager {
this.audioPlayerDiv = HtmlUtils.getElementByIdOrFail<HTMLDivElement>(audioPlayerDivId);
this.audioPlayerCtrl = HtmlUtils.getElementByIdOrFail<HTMLDivElement>(audioPlayerCtrlId);
this.audioPlayerVol = HtmlUtils.getElementByIdOrFail<HTMLInputElement>(audioPlayerVolId);
this.audioPlayerMute = HtmlUtils.getElementByIdOrFail<HTMLInputElement>(audioPlayerMuteId);
this.audioPlayerVolumeIcon = HtmlUtils.getElementByIdOrFail<HTMLInputElement>(audioPlayerVolumeIconId);
this.volume = localUserStore.getAudioPlayerVolume();
this.audioPlayerVol.value = '' + this.volume;
this.muted = localUserStore.getAudioPlayerMuted();
if (this.muted) {
this.audioPlayerMute.classList.add('muted');
}
}
public playAudio(url: string|number|boolean, mapDirUrl: string, volume: number|undefined, loop=false): void {
@@ -93,7 +90,22 @@ class AudioManager {
this.volumeReduced = reduceVolume;
this.audioPlayerElem.volume = this.volume;
this.audioPlayerVol.value = '' + this.volume;
if (this.muted) {
this.audioPlayerVol.value = '0';
this.audioPlayerVolumeIcon.classList.add('muted');
} else {
this.audioPlayerVol.value = '' + this.volume;
this.audioPlayerVolumeIcon.classList.remove('muted');
if (this.volume < 0.3) {
this.audioPlayerVolumeIcon.classList.add('low');
} else if (this.volume < 0.7) {
this.audioPlayerVolumeIcon.classList.remove('low');
this.audioPlayerVolumeIcon.classList.add('mid');
} else {
this.audioPlayerVolumeIcon.classList.remove('low');
this.audioPlayerVolumeIcon.classList.remove('mid');
}
}
this.audioPlayerElem.muted = this.muted;
}
@@ -129,18 +141,14 @@ class AudioManager {
this.muted = !this.muted;
this.changeVolume();
localUserStore.setAudioPlayerMuted(this.muted);
if (this.muted) {
this.audioPlayerMute.classList.add('muted');
} else {
this.audioPlayerMute.classList.remove('muted');
}
}
this.audioPlayerVol.oninput = (ev: Event)=> {
this.setVolume(parseFloat((<HTMLInputElement>ev.currentTarget).value));
this.muted = false;
this.changeVolume();
localUserStore.setAudioPlayerMuted(this.muted);
(<HTMLInputElement>ev.currentTarget).blur();
}
+1
View File
@@ -180,6 +180,7 @@ class CoWebsiteManager {
}
setTimeout(() => {
this.cowebsiteMainDom.innerHTML = ``;
HtmlUtils.getElementByIdOrFail(cowebsiteCloseButtonId).blur();
resolve();
}, animationTime)
}));