Merge branch 'iframe_api' of https://github.com/thecodingmachine/workadventure into FTUEPopup
* 'iframe_api' of https://github.com/thecodingmachine/workadventure: Adding button clicked handling # Conflicts: # front/src/Phaser/Game/GameScene.ts
This commit is contained in:
commit
4545de8af1
5 changed files with 54 additions and 9 deletions
|
@ -275,7 +275,8 @@ export class GameScene extends ResizableScene implements CenterListener {
|
|||
break;
|
||||
}
|
||||
default:
|
||||
throw new Error('Unsupported object type: "'+ itemType +'"');
|
||||
continue;
|
||||
//throw new Error('Unsupported object type: "'+ itemType +'"');
|
||||
}
|
||||
|
||||
itemFactory.preload(this.load);
|
||||
|
@ -743,7 +744,6 @@ export class GameScene extends ResizableScene implements CenterListener {
|
|||
if (newValue === undefined || newValue === false || newValue === '') {
|
||||
iframeListener.sendLeaveEvent(oldValue as string);
|
||||
} else {
|
||||
console.log("je passe dans zone");
|
||||
iframeListener.sendEnterEvent(newValue as string);
|
||||
}
|
||||
});
|
||||
|
@ -756,9 +756,27 @@ export class GameScene extends ResizableScene implements CenterListener {
|
|||
let html = `<div class="nes-container with-title is-centered">
|
||||
${escapedMessage}
|
||||
</div>`;
|
||||
const domElement = this.add.dom(this.popUpX, this.popUpY).createFromHTML(html);
|
||||
domElement.scale = 1;
|
||||
let id = 0;
|
||||
for (const button of openPopupEvent.buttons) {
|
||||
html += `<button type="button" class="nes-btn is-${HtmlUtils.escapeHtml(button.className ?? '')}" id="popup-${openPopupEvent.popupId}-${id}">${HtmlUtils.escapeHtml(button.label)}</button>`;
|
||||
id++;
|
||||
}
|
||||
|
||||
const domElement = this.add.dom(150, 150).createFromHTML(html);
|
||||
domElement.scale = 0;
|
||||
domElement.setClassName('popUpElement');
|
||||
|
||||
id = 0;
|
||||
for (const button of openPopupEvent.buttons) {
|
||||
const button = HtmlUtils.getElementByIdOrFail<HTMLButtonElement>(`popup-${openPopupEvent.popupId}-${id}`);
|
||||
const btnId = id;
|
||||
button.onclick = () => {
|
||||
iframeListener.sendButtonClickedEvent(openPopupEvent.popupId, btnId);
|
||||
console.log('BUTTON CLICKED', btnId);
|
||||
}
|
||||
id++;
|
||||
}
|
||||
|
||||
this.tweens.add({
|
||||
targets : domElement ,
|
||||
scale : 1,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue