Merge pull request #1379 from thecodingmachine/popup_improvements
Improving popup
This commit is contained in:
commit
5fa8c1de9a
2 changed files with 24 additions and 19 deletions
|
@ -1,38 +1,35 @@
|
||||||
import {sendToWorkadventure} from "../IframeApiContribution";
|
import { sendToWorkadventure } from "../IframeApiContribution";
|
||||||
import type {LoadSoundEvent} from "../../Events/LoadSoundEvent";
|
import type { LoadSoundEvent } from "../../Events/LoadSoundEvent";
|
||||||
import type {PlaySoundEvent} from "../../Events/PlaySoundEvent";
|
import type { PlaySoundEvent } from "../../Events/PlaySoundEvent";
|
||||||
import type {StopSoundEvent} from "../../Events/StopSoundEvent";
|
import type { StopSoundEvent } from "../../Events/StopSoundEvent";
|
||||||
import SoundConfig = Phaser.Types.Sound.SoundConfig;
|
import SoundConfig = Phaser.Types.Sound.SoundConfig;
|
||||||
|
|
||||||
export class Sound {
|
export class Sound {
|
||||||
constructor(private url: string) {
|
constructor(private url: string) {
|
||||||
sendToWorkadventure({
|
sendToWorkadventure({
|
||||||
"type": 'loadSound',
|
type: "loadSound",
|
||||||
"data": {
|
data: {
|
||||||
url: this.url,
|
url: this.url,
|
||||||
} as LoadSoundEvent
|
} as LoadSoundEvent,
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public play(config: SoundConfig) {
|
public play(config: SoundConfig | undefined) {
|
||||||
sendToWorkadventure({
|
sendToWorkadventure({
|
||||||
"type": 'playSound',
|
type: "playSound",
|
||||||
"data": {
|
data: {
|
||||||
url: this.url,
|
url: this.url,
|
||||||
config
|
config,
|
||||||
} as PlaySoundEvent
|
} as PlaySoundEvent,
|
||||||
|
|
||||||
});
|
});
|
||||||
return this.url;
|
return this.url;
|
||||||
}
|
}
|
||||||
public stop() {
|
public stop() {
|
||||||
sendToWorkadventure({
|
sendToWorkadventure({
|
||||||
"type": 'stopSound',
|
type: "stopSound",
|
||||||
"data": {
|
data: {
|
||||||
url: this.url,
|
url: this.url,
|
||||||
} as StopSoundEvent
|
} as StopSoundEvent,
|
||||||
|
|
||||||
});
|
});
|
||||||
return this.url;
|
return this.url;
|
||||||
}
|
}
|
||||||
|
|
|
@ -953,9 +953,13 @@ export class GameScene extends DirtyScene {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const escapedMessage = HtmlUtils.escapeHtml(openPopupEvent.message);
|
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}
|
${escapedMessage}
|
||||||
</div> `;
|
</div> `;
|
||||||
|
}
|
||||||
|
|
||||||
const buttonContainer = '<div class="buttonContainer"</div>';
|
const buttonContainer = '<div class="buttonContainer"</div>';
|
||||||
html += buttonContainer;
|
html += buttonContainer;
|
||||||
let id = 0;
|
let id = 0;
|
||||||
|
@ -985,7 +989,11 @@ ${escapedMessage}
|
||||||
const btnId = id;
|
const btnId = id;
|
||||||
button.onclick = () => {
|
button.onclick = () => {
|
||||||
iframeListener.sendButtonClickedEvent(openPopupEvent.popupId, btnId);
|
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;
|
button.disabled = true;
|
||||||
|
setTimeout(() => {
|
||||||
|
button.disabled = false;
|
||||||
|
}, 100);
|
||||||
};
|
};
|
||||||
id++;
|
id++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue