Add documentation
delete unused test map
This commit is contained in:
parent
cb7b98de0d
commit
ebcf4a6ae3
7 changed files with 47 additions and 152 deletions
|
@ -68,25 +68,56 @@ WA.room.onLeaveZone('myZone', () => {
|
||||||
|
|
||||||
### Add custom menu
|
### 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.
|
Custom menu exist only until the map is unloaded, or you leave the iframe zone of the script.
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col">
|
||||||
|
<img src="images/custom-menu-navbar.png" class="figure-img img-fluid rounded" alt="" />
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<img src="images/custom-menu-iframe.png" class="figure-img img-fluid rounded" alt="" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
|
//Add a callback menu in a zone
|
||||||
WA.ui.registerMenuCommand("test", () => {
|
let menu: undefined;
|
||||||
WA.chat.sendChatMessage("test clicked", "menu cmd")
|
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});
|
||||||
```
|
```
|
||||||
|
|
||||||
<div class="col">
|
Please note that `registerMenuCommand` returns an object of the `Menu` class.
|
||||||
<img src="images/menu-command.png" class="figure-img img-fluid rounded" alt="" />
|
|
||||||
</div>
|
The `Menu` class contains a single method: `remove(): void`. This will obviously remove the menu when called.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
class Menu {
|
||||||
|
/**
|
||||||
|
* Remove the menu
|
||||||
|
*/
|
||||||
|
remove() {};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
BIN
docs/maps/images/custom-menu-iframe.png
Normal file
BIN
docs/maps/images/custom-menu-iframe.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
BIN
docs/maps/images/custom-menu-navbar.png
Normal file
BIN
docs/maps/images/custom-menu-navbar.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
|
@ -1,136 +0,0 @@
|
||||||
{ "compressionlevel":-1,
|
|
||||||
"height":20,
|
|
||||||
"infinite":false,
|
|
||||||
"layers":[
|
|
||||||
{
|
|
||||||
"data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 34, 34, 0, 0, 0, 0, 0, 0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
|
|
||||||
"name":"playSoundLoop",
|
|
||||||
"opacity":1,
|
|
||||||
"type":"tilelayer",
|
|
||||||
"visible":true,
|
|
||||||
"width":20,
|
|
||||||
"x":0,
|
|
||||||
"y":0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"draworder":"topdown",
|
|
||||||
"id":5,
|
|
||||||
"name":"floorLayer",
|
|
||||||
"objects":[
|
|
||||||
{
|
|
||||||
"height":19.296875,
|
|
||||||
"id":2,
|
|
||||||
"name":"",
|
|
||||||
"rotation":0,
|
|
||||||
"text":
|
|
||||||
{
|
|
||||||
"text":"Play Sound",
|
|
||||||
"wrap":true
|
|
||||||
},
|
|
||||||
"type":"",
|
|
||||||
"visible":true,
|
|
||||||
"width":107.109375,
|
|
||||||
"x":258.4453125,
|
|
||||||
"y":197.018229166667
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"height":19.296875,
|
|
||||||
"id":3,
|
|
||||||
"name":"",
|
|
||||||
"rotation":0,
|
|
||||||
"text":
|
|
||||||
{
|
|
||||||
"text":"Bonjour Monde",
|
|
||||||
"wrap":true
|
|
||||||
},
|
|
||||||
"type":"",
|
|
||||||
"visible":true,
|
|
||||||
"width":107.109375,
|
|
||||||
"x":-348.221354166667,
|
|
||||||
"y":257.018229166667
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"height":55.296875,
|
|
||||||
"id":4,
|
|
||||||
"name":"",
|
|
||||||
"rotation":0,
|
|
||||||
"text":
|
|
||||||
{
|
|
||||||
"text":"Play Sound Loop\nexit Zone Stop Sound \n",
|
|
||||||
"wrap":true
|
|
||||||
},
|
|
||||||
"type":"",
|
|
||||||
"visible":true,
|
|
||||||
"width":176.442708333333,
|
|
||||||
"x":243.778645833333,
|
|
||||||
"y":368.3515625
|
|
||||||
}],
|
|
||||||
"opacity":1,
|
|
||||||
"type":"objectgroup",
|
|
||||||
"visible":true,
|
|
||||||
"x":0,
|
|
||||||
"y":0
|
|
||||||
}],
|
|
||||||
"nextlayerid":8,
|
|
||||||
"nextobjectid":5,
|
|
||||||
"orientation":"orthogonal",
|
|
||||||
"renderorder":"right-down",
|
|
||||||
"tiledversion":"1.6.0",
|
|
||||||
"tileheight":32,
|
|
||||||
"tilesets":[
|
|
||||||
{
|
|
||||||
"columns":11,
|
|
||||||
"firstgid":1,
|
|
||||||
"image":"tileset1.png",
|
|
||||||
"imageheight":352,
|
|
||||||
"imagewidth":352,
|
|
||||||
"margin":0,
|
|
||||||
"name":"tileset1",
|
|
||||||
"spacing":0,
|
|
||||||
"tilecount":121,
|
|
||||||
"tileheight":32,
|
|
||||||
"tilewidth":32
|
|
||||||
}],
|
|
||||||
"tilewidth":32,
|
|
||||||
"type":"map",
|
|
||||||
"version":"1.6",
|
|
||||||
"width":20
|
|
||||||
}
|
|
|
@ -3,7 +3,7 @@
|
||||||
<head>
|
<head>
|
||||||
<title>Custom Iframe Menu</title>
|
<title>Custom Iframe Menu</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body style="text-align: center">
|
||||||
<a href="https://workadventu.re/">GO TO WA BY IFRAME</a>
|
<p style="color: whitesmoke">This is an iframe in a custom menu.</p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -14,7 +14,7 @@
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body style="text-align: center">
|
||||||
<p>This iframe send you a message in the chat.</p>
|
<p style="color: whitesmoke">This is an iframe in a custom menu.</p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -1,10 +1,10 @@
|
||||||
let menuIframeApi = undefined;
|
let menuIframeApi = undefined;
|
||||||
|
|
||||||
WA.ui.registerMenuCommand('TO WA', () => {
|
WA.ui.registerMenuCommand('custom callback menu', () => {
|
||||||
WA.nav.openTab("https://workadventu.re/");
|
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', () => {
|
WA.room.onEnterZone('iframeMenu', () => {
|
||||||
menuIframeApi = WA.ui.registerMenuCommand('IFRAME USE API', {iframe: 'customIframeMenuApi.html', allowApi: true});
|
menuIframeApi = WA.ui.registerMenuCommand('IFRAME USE API', {iframe: 'customIframeMenuApi.html', allowApi: true});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue