3
0
mirror of https://github.com/britzl/monarch.git synced 2025-06-27 10:27:49 +02:00

More documentation improvements

This commit is contained in:
Björn Ritzl 2017-09-28 08:34:29 +02:00
parent 240c039d03
commit 52ce9929a1
2 changed files with 13 additions and 11 deletions

View File

@ -16,38 +16,40 @@ Monarch screens are created in individual collections and loaded through collect
* **Screen Id (hash)** - A unique id that can be used to reference the screen when navigating your app * **Screen Id (hash)** - A unique id that can be used to reference the screen when navigating your app
* **Popup (boolean)** - Check this if the screen should be treated as a [popup](#popups) * **Popup (boolean)** - Check this if the screen should be treated as a [popup](#popups)
* **Transition Url (url)** - Optional URL to call when the screen is about to be shown/hidden. Use this to trigger a transition (see the section on [transitions](#transitions)) * **Transition Url (url)** - Optional URL to call when the screen is about to be shown/hidden. Use this to trigger a transition (see the section on [transitions](#transitions))
* **Controller Url (url)** - Optional URL to call when the screen gains or loses focus. * **Focus Url (url)** - Optional URL to call when the screen gains or loses focus.
![](docs/setup.png)
## Navigating between screens ## Navigating between screens
The navigation in Monarch is based around a stack of screens. When a screen is shown it is pushed to the top of the stack. When going back to a previous screen the topmost screen on the stack is removed. Example: The navigation in Monarch is based around a stack of screens. When a screen is shown it is pushed to the top of the stack. When going back to a previous screen the topmost screen on the stack is removed. Example:
* Showing screen A * Showing screen A
* Stack is [A] * Stack is ````[A]````
* Showing screen B * Showing screen B
* Stack is [A, B] - (B is on top) * Stack is ````[A, B]```` - (B is on top)
* Going back * Going back
* Stack is [A] * Stack is ````[A]````
### Showing a new screen ### Showing a new screen
You show a screen in one of two ways: You show a screen in one of two ways:
1. Post a ````show```` message to the ````screen.script```` 1. Post a ````show```` message to the ````screen.script````
2. Call ````monarch.show(screen_id, [options], [data], [callback])```` 2. Call ````monarch.show()```` (see below)
Showing a screen will push it to the top of the stack and trigger an optional transition. The previous screen will be hidden (with an optional transition) unless the screen to be shown is a [popup](#popups). Showing a screen will push it to the top of the stack and trigger an optional transition. The previous screen will be hidden (with an optional transition) unless the screen to be shown is a [popup](#popups).
#### Preventing duplicates in the stack #### Preventing duplicates in the stack
You can pass an optional ````clear```` flag when showing a screen (either as a key value pair in the options table when calling ````monarch.show()```` or in the message). If the clear flag is set Monarch will search the stack for the screen in question. If the screen already exists in the stack and the clear flag is set Monarch will remove all screens between the current top and the screen in question. Example: You can pass an optional ````clear```` flag when showing a screen (either as a key value pair in the options table when calling ````monarch.show()```` or in the message). If the clear flag is set Monarch will search the stack for the screen in question. If the screen already exists in the stack and the clear flag is set Monarch will remove all screens between the current top and the screen in question. Example:
* Stack is [A, B, C, D] - (D is on top) * Stack is ````[A, B, C, D]```` - (D is on top)
* A call to ````monarch.show(B, { clear = true })```` is made * A call to ````monarch.show(B, { clear = true })```` is made
* Stack is [A, B] * Stack is ````[A, B]````
### Going back to a previous screen ### Going back to a previous screen
You navigate back in the screen hierarchy in one of two ways: You navigate back in the screen hierarchy in one of two ways:
1. Post a ````back```` message to the ````screen.script```` 1. Post a ````back```` message to the ````screen.script````
2. Call ````monarch.back()```` 2. Call ````monarch.back()```` (see below)
## Input focus ## Input focus
@ -56,11 +58,11 @@ Monarch will acquire and release input focus on the game objects containing the
## Popups ## Popups
A screen that is flagged as a popup (see list of screen properties above) will be treated slightly differently when it comes to navigation. If a popup is at the top of the stack (ie currently shown) and another screen or popup is shown then the current popup will be removed from the stack. This means that it is not possible to have a popup anywhere in the stack but the top. This also means that you cannot navigate back to a popup since popups can only exist on the top of the stack. Another important difference between normal screens and popups is that when a popup is shown on top of a non-popup the current top screen will not be unloaded and instead remain visible in the background. A screen that is flagged as a popup (see list of screen properties above) will be treated slightly differently when it comes to navigation. If a popup is at the top of the stack (ie currently shown) and another screen or popup is shown then the current popup will be removed from the stack. This means that it is not possible to have a popup anywhere in the stack but the top. This also means that you cannot navigate back to a popup since popups can only exist on the top of the stack. Another important difference between normal screens and popups is that when a popup is shown on top of a non-popup the current top screen will not be unloaded and instead remain visible in the background.
* Stack is [A, B] * Stack is ````[A, B]````
* A call to ````monarch.show(C)```` is made and C is a popup * A call to ````monarch.show(C)```` is made and C is a popup
* Stack is [A, B, C] * Stack is ````[A, B, C]````
* A call to ````monarch.show(D)```` * A call to ````monarch.show(D)````
* Stack is [A, B, D] * Stack is ````[A, B, D]````
## Transitions ## Transitions
You can add optional transitions when navigating between screens. The default behavior is that screen navigation is instant but if you have defined a transition for a screen Monarch will wait until the transition is completed before proceeding. The Transition Show In/Out and Transition Back In/Out properties described above should be URLs to one or more scripts with on_message handlers for the following messages: You can add optional transitions when navigating between screens. The default behavior is that screen navigation is instant but if you have defined a transition for a screen Monarch will wait until the transition is completed before proceeding. The Transition Show In/Out and Transition Back In/Out properties described above should be URLs to one or more scripts with on_message handlers for the following messages:

BIN
docs/setup.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB