From fd5b598b63baa90547add8001819ce5654bd6c86 Mon Sep 17 00:00:00 2001 From: jonny Date: Fri, 28 May 2021 01:18:00 +0200 Subject: [PATCH] Bubble [WIP] (still need to do the javascript part) --- front/src/Api/iframe/Bubble.ts | 20 +++++++++++++++++++ front/src/Api/iframe/IframeApiContribution.ts | 2 +- front/src/iframe_api.ts | 20 ++++--------------- 3 files changed, 25 insertions(+), 17 deletions(-) create mode 100644 front/src/Api/iframe/Bubble.ts diff --git a/front/src/Api/iframe/Bubble.ts b/front/src/Api/iframe/Bubble.ts new file mode 100644 index 00000000..b0f070cb --- /dev/null +++ b/front/src/Api/iframe/Bubble.ts @@ -0,0 +1,20 @@ +import { IframeApiContribution } from './IframeApiContribution'; + +class WorkadventureNavigationCommands extends IframeApiContribution { + + readonly subObjectIdentifier = "bubble" + + readonly addMethodsAtRoot = true + callbacks = [] + displayBubble(): void { + window.parent.postMessage({ 'type': 'displayBubble' }, '*'); + } + + removeBubble(): void { + window.parent.postMessage({ 'type': 'removeBubble' }, '*'); + } + +} + + +export default new WorkadventureNavigationCommands(); \ No newline at end of file diff --git a/front/src/Api/iframe/IframeApiContribution.ts b/front/src/Api/iframe/IframeApiContribution.ts index 25e1cde0..f1fb3cd5 100644 --- a/front/src/Api/iframe/IframeApiContribution.ts +++ b/front/src/Api/iframe/IframeApiContribution.ts @@ -20,7 +20,7 @@ export interface IframeCallbackContribution, callback: (payloadData: T) => void } -export type PossibleSubobjects = "zone" | "chat" | "ui" | "nav" | "sound" | "cowebsite" | "player" +export type PossibleSubobjects = "zone" | "chat" | "ui" | "nav" | "sound" | "cowebsite" | "player" | "bubble" /** * !! be aware that the implemented attributes (addMethodsAtRoot and subObjectIdentifier) must be readonly * diff --git a/front/src/iframe_api.ts b/front/src/iframe_api.ts index 395c9d01..42cc34e1 100644 --- a/front/src/iframe_api.ts +++ b/front/src/iframe_api.ts @@ -11,7 +11,9 @@ const importType = Promise.all([ import("./Api/iframe/Sound"), import("./Api/iframe/zone-events"), import("./Api/iframe/Navigation"), - import("./Api/iframe/CoWebsite") + import("./Api/iframe/CoWebsite"), + import("./Api/iframe/Player"), + import("./Api/iframe/Bubble") ]) @@ -46,10 +48,7 @@ type WorkAdventureApiFiles = { } & SubObjectTypes export interface WorkAdventureApi extends WorkAdventureApiFiles { - disablePlayerControls(): void; - restorePlayerControls(): void; - displayBubble(): void; - removeBubble(): void; + } declare global { @@ -62,17 +61,6 @@ declare global { window.WA = { - - - displayBubble(): void { - window.parent.postMessage({ 'type': 'displayBubble' }, '*'); - }, - - removeBubble(): void { - window.parent.postMessage({ 'type': 'removeBubble' }, '*'); - }, - - ...({} as WorkAdventureApiFiles), }