This commit is contained in:
_Bastler
2022-01-26 12:44:08 +01:00
parent 31f6847b53
commit e3b58a0d56
23 changed files with 131 additions and 94 deletions
+2 -1
View File
@@ -6,7 +6,8 @@ export const isButtonClickedEvent = new tg.IsInterface()
buttonId: tg.isNumber,
input: tg.isBoolean,
inputValue: tg.isString,
}).get();
})
.get();
/**
* A message sent from the game to the iFrame when a user enters or leaves a zone marked with the "zone" property.
*/
+2 -1
View File
@@ -4,7 +4,8 @@ export const isClosePopupEvent = new tg.IsInterface()
.withProperties({
popupId: tg.isNumber,
inputValue: tg.isString,
}).get();
})
.get();
/**
* A message sent from the iFrame to the game to add a message in the chat.
+4 -3
View File
@@ -13,9 +13,10 @@ export const isOpenPopupEvent = new tg.IsInterface()
targetObject: tg.isString,
message: tg.isString,
buttons: tg.isArray(isButtonDescriptor),
popupClass : tg.isString,
input: tg.isBoolean
}).get();
popupClass: tg.isString,
input: tg.isBoolean,
})
.get();
/**
* A message sent from the iFrame to the game to add a message in the chat.
+3 -3
View File
@@ -283,7 +283,7 @@ class IframeListener {
unregisterIframe(iframe: HTMLIFrameElement): void {
this._unregisterIFrameStream.next();
this.iframeCloseCallbacks.get(iframe)?.forEach(callback => {
this.iframeCloseCallbacks.get(iframe)?.forEach((callback) => {
callback();
});
this.iframes.delete(iframe);
@@ -478,7 +478,7 @@ class IframeListener {
});
}
sendButtonClickedEvent(popupId: number, buttonId: number, input : boolean, inputValue : string | null): void {
sendButtonClickedEvent(popupId: number, buttonId: number, input: boolean, inputValue: string | null): void {
this.postMessage({
type: "buttonClickedEvent",
data: {
@@ -486,7 +486,7 @@ class IframeListener {
buttonId,
input,
inputValue,
} as ButtonClickedEvent
} as ButtonClickedEvent,
});
}
+6 -7
View File
@@ -2,11 +2,10 @@ import { sendToWorkadventure } from "../IframeApiContribution";
import type { ClosePopupEvent } from "../../Events/ClosePopupEvent";
export class Popup {
inputValue: string;
constructor(private id: number) {
this.inputValue = '';
this.inputValue = "";
}
/**
@@ -14,11 +13,11 @@ export class Popup {
*/
public close(): void {
sendToWorkadventure({
'type': 'closePopup',
'data': {
'popupId': this.id,
'inputValue': this.inputValue,
} as ClosePopupEvent
type: "closePopup",
data: {
popupId: this.id,
inputValue: this.inputValue,
} as ClosePopupEvent,
});
}
}
+5 -4
View File
@@ -131,12 +131,13 @@ export class WorkadventureRoomCommands extends IframeApiContribution<Workadventu
}
async getProperty(layerName: string, propertyName: string): Promise<string | number | boolean | undefined> {
const event = await queryWorkadventure({
type: "getProperty", data: {
const event = await queryWorkadventure({
type: "getProperty",
data: {
layerName: layerName,
propertyName: propertyName,
propertyValue : undefined,
}
propertyValue: undefined,
},
});
return event.propertyValue;
}
+8 -2
View File
@@ -85,7 +85,13 @@ export class WorkAdventureUiCommands extends IframeApiContribution<WorkAdventure
}),
];
openPopup(targetObject: string, message: string, buttons: ButtonDescriptor[], popupClass : string = "", input: boolean = false): Popup {
openPopup(
targetObject: string,
message: string,
buttons: ButtonDescriptor[],
popupClass: string = "",
input: boolean = false
): Popup {
popupId++;
const popup = new Popup(popupId);
const btnMap = new Map<number, () => void>();
@@ -114,7 +120,7 @@ export class WorkAdventureUiCommands extends IframeApiContribution<WorkAdventure
};
}),
popupClass,
input
input,
},
});