Skip to content

Commit

Permalink
documentation and CHANGELOG
Browse files Browse the repository at this point in the history
  • Loading branch information
GRL78 committed Aug 27, 2021
1 parent ebcf4a6 commit 12108bc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## Version develop

### Updates
- New scripting API features :
- Use `WA.ui.registerMenuCommand(commandDescriptor: string, options: MenuOptions): Menu` to add a custom menu or an iframe to the menu.

## Version 1.4.14

### Updates
- New scripting API features :
- Use `WA.room.loadTileset(url: string) : Promise<number>` to load a tileset from a JSON file.
Expand Down
1 change: 1 addition & 0 deletions docs/maps/api-deprecated.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ The list of functions below is **deprecated**. You should not use those but. use
- Method `WA.onChatMessage` is deprecated. It has been renamed to `WA.chat.onChatMessage`.
- Method `WA.onEnterZone` is deprecated. It has been renamed to `WA.room.onEnterZone`.
- Method `WA.onLeaveZone` is deprecated. It has been renamed to `WA.room.onLeaveZone`.
- Method `WA.ui.registerMenuCommand` parameter `callback` is deprecated. Use `WA.ui.registerMenuCommand(commandDescriptor: string, options: MenuOptions)`.
33 changes: 15 additions & 18 deletions docs/maps/api-ui.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,15 @@ WA.room.onLeaveZone('myZone', () => {
### Add custom menu

```
WA.ui.registerMenuCommand(commandDescriptor: string, options: MenuOptions | ((commandDescriptor: string) => void)): Menu
WA.ui.registerMenuCommand(commandDescriptor: string, options: MenuOptions): 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.
`options` attribute accepts an object with three properties :
- `callback : (commandDescriptor: string) => void` : A click on the custom menu will trigger the `callback`.
- `iframe: string` : A click on the custom menu will open the `iframe` inside the menu.
- `allowApi?: boolean` : Allow the iframe of the custom menu to use the Scripting API.

Important : `options` accepts only `callback` or `iframe` not both.

Custom menu exist only until the map is unloaded, or you leave the iframe zone of the script.

Expand All @@ -90,20 +92,15 @@ Custom menu exist only until the map is unloaded, or you leave the iframe zone o

Example:
```javascript
//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();
})
const menu = WA.ui.registerMenuCommand('menu test',
{
callback: () => {
WA.chat.sendChatMessage('test');
}
})

//Add an iframe in the menu
WA.ui.registerMenuCommand('iframe', {iframe: 'myIframe.html', allowApi: true});
// Some time later, if you want to remove the menu:
menu.remove();
```

Please note that `registerMenuCommand` returns an object of the `Menu` class.
Expand Down

0 comments on commit 12108bc

Please sign in to comment.