forked from workadventure/workadventure
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Delete menu by scripting API
- Loading branch information
Showing
11 changed files
with
251 additions
and
328 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import * as tg from "generic-type-guard"; | ||
|
||
/** | ||
* A message sent from a script to the game to add a new button in the menu. | ||
*/ | ||
export const isMenuItemRegisterEvent = new tg.IsInterface() | ||
.withProperties({ | ||
menuItem: tg.isString, | ||
}) | ||
.get(); | ||
|
||
export type MenuItemRegisterEvent = tg.GuardedType<typeof isMenuItemRegisterEvent>; | ||
|
||
export const isMenuItemRegisterIframeEvent = new tg.IsInterface() | ||
.withProperties({ | ||
type: tg.isSingletonString("registerMenuCommand"), | ||
data: isMenuItemRegisterEvent, | ||
}) | ||
.get(); | ||
|
||
/** | ||
* A message sent from a script to the game to add an iframe submenu in the menu. | ||
*/ | ||
export const isMenuIframeEvent = new tg.IsInterface() | ||
.withProperties({ | ||
name: tg.isString, | ||
url: tg.isString, | ||
}) | ||
.get(); | ||
|
||
export type MenuIframeRegisterEvent = tg.GuardedType<typeof isMenuIframeEvent>; | ||
|
||
/** | ||
* A message sent from a script to the game to remove a custom menu from the menu | ||
*/ | ||
export const isUnregisterMenuEvent = new tg.IsInterface() | ||
.withProperties({ | ||
name: tg.isString, | ||
}) | ||
.get(); | ||
|
||
export type UnregisterMenuEvent = tg.GuardedType<typeof isUnregisterMenuEvent>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<script lang="ts"> | ||
export let iframe: string; | ||
</script> | ||
|
||
|
||
<iframe title="customSubMenu" src="{iframe}"></iframe> | ||
|
||
<style lang="scss"> | ||
iframe { | ||
border: none; | ||
height: calc(100% - 56px); | ||
width: 100%; | ||
margin: 0; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,18 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<script> | ||
var script = document.createElement('script'); | ||
// Don't do this at home kids! The "document.referrer" part is actually inserting a XSS security. | ||
// We are OK in this precise case because the HTML page is hosted on the "maps" domain that contains only static files. | ||
script.setAttribute('src', document.referrer + 'iframe_api.js'); | ||
document.head.appendChild(script); | ||
window.addEventListener('load', () => { | ||
WA.ui.registerMenuCommand("test", () => { | ||
WA.chat.sendChatMessage("test clicked", "menu cmd") | ||
}) | ||
}) | ||
</script> | ||
</head> | ||
<body> | ||
<p>Add a custom menu</p> | ||
</body> | ||
<head> | ||
<script> | ||
var script = document.createElement('script'); | ||
// Don't do this at home kids! The "document.referrer" part is actually inserting a XSS security. | ||
// We are OK in this precise case because the HTML page is hosted on the "maps" domain that contains only static files. | ||
script.setAttribute('src', document.referrer + 'iframe_api.js'); | ||
document.head.appendChild(script); | ||
window.addEventListener('load', () => { | ||
WA.ui.registerMenuIframe('test', 'customIframeMenu.html'); | ||
}) | ||
</script> | ||
</head> | ||
<body> | ||
<p>Add a custom menu</p> | ||
</body> | ||
</html> |
Oops, something went wrong.