From ebcf4a6ae3f30a3a20ea379759d0e826f0646ee3 Mon Sep 17 00:00:00 2001 From: GRL Date: Fri, 27 Aug 2021 14:49:57 +0200 Subject: [PATCH] Add documentation delete unused test map --- docs/maps/api-ui.md | 51 +++++-- docs/maps/images/custom-menu-iframe.png | Bin 0 -> 14317 bytes docs/maps/images/custom-menu-navbar.png | Bin 0 -> 3302 bytes maps/tests/MenuSvelte.json | 136 ------------------- maps/tests/Metadata/customIframeMenu.html | 4 +- maps/tests/Metadata/customIframeMenuApi.html | 4 +- maps/tests/Metadata/customMenu.js | 4 +- 7 files changed, 47 insertions(+), 152 deletions(-) create mode 100644 docs/maps/images/custom-menu-iframe.png create mode 100644 docs/maps/images/custom-menu-navbar.png delete mode 100644 maps/tests/MenuSvelte.json diff --git a/docs/maps/api-ui.md b/docs/maps/api-ui.md index e4b9425d..3239890a 100644 --- a/docs/maps/api-ui.md +++ b/docs/maps/api-ui.md @@ -68,25 +68,56 @@ WA.room.onLeaveZone('myZone', () => { ### Add custom menu -```typescript -WA.ui.registerMenuCommand(menuCommand: string, callback: (menuCommand: string) => void): void ``` -Add a custom menu item containing the text `commandDescriptor` in the main menu. A click on the menu will trigger the `callback`. +WA.ui.registerMenuCommand(commandDescriptor: string, options: MenuOptions | ((commandDescriptor: string) => void)): Menu +``` +Add a custom menu item containing the text `commandDescriptor` in the navbar of the menu. +`options` attributes can have three values : +- `(commandDescriptor: string) => void` : That value is deprecated. But will work like the second value. +- `{callback : (commandDescriptor: string) => void, allowApi?: boolean = true}` : A click on the custom menu will trigger the `callback`. The `allowApi` attribute is not used with the `callback`. +- `{iframe: string, allowApi?: boolean = true}` : A click on the custom menu will open the `iframe` inside the menu. The `allowApi` attribute allow the `iframe` to use the Scripting API. + Custom menu exist only until the map is unloaded, or you leave the iframe zone of the script. -Example: +
+
+ +
+
+ +
+
+Example: ```javascript - -WA.ui.registerMenuCommand("test", () => { - WA.chat.sendChatMessage("test clicked", "menu cmd") +//Add a callback menu in a zone +let menu: undefined; +WA.room.onEnterZone('myZone', () => { + menu = WA.ui.registerMenuCommand('menu test', {callback: () => { + WA.chat.sendChatMessage('test'); + }}) +}) +//Remove the callback menu when the player leave the zone +WA.room.onLeaveZone('myZone', () => { + menu.remove(); }) +//Add an iframe in the menu +WA.ui.registerMenuCommand('iframe', {iframe: 'myIframe.html', allowApi: true}); ``` -
- -
+Please note that `registerMenuCommand` returns an object of the `Menu` class. + +The `Menu` class contains a single method: `remove(): void`. This will obviously remove the menu when called. + +```javascript +class Menu { + /** + * Remove the menu + */ + remove() {}; +} +``` diff --git a/docs/maps/images/custom-menu-iframe.png b/docs/maps/images/custom-menu-iframe.png new file mode 100644 index 0000000000000000000000000000000000000000..9df2aa5fdd63353319ed2e2898111a9ec2f1604a GIT binary patch literal 14317 zcmeHtd0bQ1)^@D5ts_ON2#6>ar~@D%^APF)RY6o#WUe5@0)h}`NJ48>5Cjzk8A7Ni z$QS_`!W5Mu$dG`{W0c4kAV3HKLXvNvK-AY>Z+q|izTfZtsf1` z(32;O)~}IR1B1cVAN}d@X&7u(JPfvS<2PS{|5_= zy!hpOP0>|qzuXsJt-rAT($=3IHd)r;TO_}zbq?KeSho6glA(&BnA*iddybyUXezy5 zTdkJ6M)KA-@oF4dNgIXrD>G88rRpCvegE6WGlmxiDmMG^C&w*{5pffVseu70gzWTr znip4_j4%OeI^J?y$xLMOqL%$pyrK}psAVM&35 z*ES-#imtYklWSWQSL_+I;t$b|(ly4rPNf`^Id^#&jXx`?eJlWswx+Z{i9~1a#I^AkFn91~n(kju<>3d`hd?_@dR_nNj!@`u!-??0>gzktrhmCdiS4g+ zprVuVH5d$gT*Kw7?ipH#z&1dC!oJ_6z7o3LHttvlT@7-J9otQ)X5%umPG2c3;v*Eg zXXndtBGA3l?*>hGt0s7V@`TC-Rp>74)$gB~^0Nan%ez*!VBH;DbdS8n!R?p|%3pi%eY{fF~59|{Ajzc(>Mu?+Q?a{WU zXYp-`*JhQ5^3$h+X4xFGk%d4ehQDIRLBx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zK3)N@AtS{Fs)igb>12rMm>=z~kPQgE07<~6(iIl%&_#rh!W0 zQ!}5o8oqYo#VHOnozMTW%}nNz5_(|m Custom Iframe Menu - -GO TO WA BY IFRAME + +

This is an iframe in a custom menu.

\ No newline at end of file diff --git a/maps/tests/Metadata/customIframeMenuApi.html b/maps/tests/Metadata/customIframeMenuApi.html index 7b67f087..afe840cc 100644 --- a/maps/tests/Metadata/customIframeMenuApi.html +++ b/maps/tests/Metadata/customIframeMenuApi.html @@ -14,7 +14,7 @@ }) - -

This iframe send you a message in the chat.

+ +

This is an iframe in a custom menu.

\ No newline at end of file diff --git a/maps/tests/Metadata/customMenu.js b/maps/tests/Metadata/customMenu.js index 11c327ea..ba66ee0d 100644 --- a/maps/tests/Metadata/customMenu.js +++ b/maps/tests/Metadata/customMenu.js @@ -1,10 +1,10 @@ let menuIframeApi = undefined; -WA.ui.registerMenuCommand('TO WA', () => { +WA.ui.registerMenuCommand('custom callback menu', () => { WA.nav.openTab("https://workadventu.re/"); }) -WA.ui.registerMenuCommand('TO WA BY IFRAME', {iframe: 'customIframeMenu.html'}); +WA.ui.registerMenuCommand('custom iframe menu', {iframe: 'customIframeMenu.html'}); WA.room.onEnterZone('iframeMenu', () => { menuIframeApi = WA.ui.registerMenuCommand('IFRAME USE API', {iframe: 'customIframeMenuApi.html', allowApi: true});