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

This commit is contained in:
_Bastler 2021-08-19 10:36:23 +02:00
commit 6ff4f4f52e
2 changed files with 20 additions and 18 deletions

View File

@ -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;
} }

View File

@ -992,6 +992,11 @@ export class GameScene extends DirtyScene {
inputValue = HtmlUtils.getElementByIdOrFail<HTMLInputElement>(`popupinput-${openPopupEvent.popupId}`).value; inputValue = HtmlUtils.getElementByIdOrFail<HTMLInputElement>(`popupinput-${openPopupEvent.popupId}`).value;
} }
iframeListener.sendButtonClickedEvent(openPopupEvent.popupId, btnId, openPopupEvent.input, inputValue); iframeListener.sendButtonClickedEvent(openPopupEvent.popupId, btnId, openPopupEvent.input, inputValue);
// 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++; id++;
} }