Merge pull request #1379 from thecodingmachine/popup_improvements

Improving popup
This commit is contained in:
David Négrier 2021-08-19 09:52:35 +02:00 committed by GitHub
commit 5fa8c1de9a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 19 deletions

View file

@ -1,38 +1,35 @@
import {sendToWorkadventure} from "../IframeApiContribution";
import type {LoadSoundEvent} from "../../Events/LoadSoundEvent";
import type {PlaySoundEvent} from "../../Events/PlaySoundEvent";
import type {StopSoundEvent} from "../../Events/StopSoundEvent";
import { sendToWorkadventure } from "../IframeApiContribution";
import type { LoadSoundEvent } from "../../Events/LoadSoundEvent";
import type { PlaySoundEvent } from "../../Events/PlaySoundEvent";
import type { StopSoundEvent } from "../../Events/StopSoundEvent";
import SoundConfig = Phaser.Types.Sound.SoundConfig;
export class Sound {
constructor(private url: string) {
sendToWorkadventure({
"type": 'loadSound',
"data": {
type: "loadSound",
data: {
url: this.url,
} as LoadSoundEvent
} as LoadSoundEvent,
});
}
public play(config: SoundConfig) {
public play(config: SoundConfig | undefined) {
sendToWorkadventure({
"type": 'playSound',
"data": {
type: "playSound",
data: {
url: this.url,
config
} as PlaySoundEvent
config,
} as PlaySoundEvent,
});
return this.url;
}
public stop() {
sendToWorkadventure({
"type": 'stopSound',
"data": {
type: "stopSound",
data: {
url: this.url,
} as StopSoundEvent
} as StopSoundEvent,
});
return this.url;
}

View file

@ -953,9 +953,13 @@ export class GameScene extends DirtyScene {
return;
}
const escapedMessage = HtmlUtils.escapeHtml(openPopupEvent.message);
let html = `<div id="container" hidden><div class="nes-container with-title is-centered">
let html = '<div id="container" hidden>';
if (escapedMessage) {
html += `<div class="nes-container with-title is-centered">
${escapedMessage}
</div> `;
}
const buttonContainer = '<div class="buttonContainer"</div>';
html += buttonContainer;
let id = 0;
@ -985,7 +989,11 @@ ${escapedMessage}
const btnId = id;
button.onclick = () => {
iframeListener.sendButtonClickedEvent(openPopupEvent.popupId, btnId);
// Disable for a short amount of time to let time to the script to remove the popup
button.disabled = true;
setTimeout(() => {
button.disabled = false;
}, 100);
};
id++;
}