Updated Launcher documentation WIP (markdown)

UnknownShadow200 2023-06-23 00:02:59 +10:00
parent bfa6f2d8a6
commit 9c8a1b9c83

@ -1,13 +1,93 @@
Launcher_SetScreen
## Introduction
- only one Screen can be active at a time
- a Screen is composed of widgets
In contrast to the in-game GUI, the Launcher only displays one Screen at a time
LScreen
- Init (required
- Show (optional
- Free (optional
Each Screen is composed of a background and one or more Widgets:
![image](https://github.com/UnknownShadow200/ClassiCube/assets/6509348/9dca96b6-6bea-4692-949d-347ac1073bda)
You can use the following method to switch the active Screen:
```C
void Launcher_SetScreen(struct LScreen* screen);
```
Example usage:
```C
void SimpleScreen_SetActive(void) {
struct SimpleScreen* s = &SimpleScreen;
LScreen_Reset((struct LScreen*)s);
s->Init = SimpleScreen_Init;
s->title = "Title text";
Launcher_SetScreen((struct LScreen*)s);
}
```
## What makes up a Launcher Screen
A Launcher Screen (shorted to `LScreen`) consists of the following members:
### Required members
#### `void (*Init)(struct LScreen* s)`
Called the first time this launcher screen is made active
At a minimum, the `widgets` and `numWidgets` members must be initialised here
#### `struct LWidget** widgets`
Points to an array containing pointers to the widgets in the screen
Example:
```C
static struct LWidget* simpleScreen_widgets[] = {
(struct LWidget*)&SimpleScreen.iptField,
(struct LWidget*)&SimpleScreen.btnBack
};
...
s->widgets = simpleScreen_widgets;
```
#### `int numWidgets`
Number of widgets in the screen
Example:
```C
s->numWidgets = Array_Elems(simpleScreen_widgets);
```
### Optional members
TODO
#### `void (*Show)(struct LScreen* s)`
#### `void (*Free)(struct LScreen* s)`
#### `void (*Layout)(struct LScreen* s)`
#### `void (*Tick)(struct LScreen* s)`
#### `void (*DrawBackground)(struct LScreen* s, struct Context2D* ctx)`
#### `void (*KeyDown)(struct LScreen* s, int key, cc_bool wasDown)`
#### `void (*MouseUp)(struct LScreen* s, int idx)`
#### `void (*MouseWheel)(struct LScreen* s, float delta)`
#### `void (*ResetArea)(struct Context2D* ctx, int x, int y, int width, int height)`
#### `struct LWidget* onEnterWidget`
#### `struct LWidget* hoveredWidget`
#### `struct LWidget* selectedWidget`
#### `const char* title`
```
How a launcher screen works
@ -16,4 +96,23 @@ Showing
Widget layout
Background drawing
Background drawing
## Widgets
TODO
### Button widgets
### Checkbox widgets
### Input widgets
### Label widgets
### Slider widgets
## Complete example
TODO