Updated Launcher documentation WIP (markdown)

UnknownShadow200 2023-06-29 23:52:07 +10:00
parent 57faf97064
commit 7d11fcdfcb

@ -17,7 +17,7 @@ A Launcher Screen (shorted to `LScreen`) consists of the following members:
TODO: Talk about LScreen_Reset somewhere
### Required members
## Required members
#### `void (*Init)(struct LScreen* s)`
@ -29,38 +29,43 @@ At a minimum, the `widgets` and `numWidgets` members must be initialised here
Points to an array containing pointers to the widgets in the screen
Example:
#### `int numWidgets`
Number of widgets in the screen
### Example:
```C
static struct LWidget* simpleScreen_widgets[] = {
(struct LWidget*)&SimpleScreen.iptField,
(struct LWidget*)&SimpleScreen.btnBack
};
...
s->widgets = simpleScreen_widgets;
void SimpleScreen_Init(struct LScreen* s) {
s->widgets = simpleScreen_widgets;
s->numWidgets = Array_Elems(simpleScreen_widgets);
...
}
```
#### `int numWidgets`
Number of widgets in the screen
Example:
```C
s->numWidgets = Array_Elems(simpleScreen_widgets);
```
### Optional members
TODO
## Optional members - general
#### `void (*Show)(struct LScreen* s)`
Optional. Called every time this screen appears. (i.e. switching to this screen)
#### `void (*Free)(struct LScreen* s)`
Optional. Called every time this screen disappears. (i.e. switching to another screen)
#### `void (*Layout)(struct LScreen* s)`
Optional. Can be used to customise widget layout, but usually it's unnecessary to override the default method
#### `void (*Tick)(struct LScreen* s)`
#### `void (*DrawBackground)(struct LScreen* s, struct Context2D* ctx)`
Optional. Can be used to implement functionality that required periodic checking
## Optional members - input
#### `void (*KeyDown)(struct LScreen* s, int key, cc_bool wasDown)`
@ -68,16 +73,24 @@ TODO
#### `void (*MouseWheel)(struct LScreen* s, float delta)`
#### `void (*ResetArea)(struct Context2D* ctx, int x, int y, int width, int height)`
#### `struct LWidget* onEnterWidget`
Optional. Can be used to set the widget automatically clicked on when `Enter` is pressed and no other interactable widget is hovered over.
#### `struct LWidget* hoveredWidget`
#### `struct LWidget* selectedWidget`
## Optional members - drawing
#### `void (*DrawBackground)(struct LScreen* s, struct Context2D* ctx)`
#### `void (*ResetArea)(struct Context2D* ctx, int x, int y, int width, int height)`
#### `const char* title`
TODO: this is kinda required usually... ?
How a launcher screen works
@ -90,9 +103,13 @@ Background drawing
TODO
TODO mention interactable widgets
## Widget layout / positioning
TODO. talk about anchoring and offsets
TODO. talk about anchoring and offsets. maybe move to screen?
example image of all the different anchors/offsets
## Widget types
@ -110,6 +127,7 @@ TODO. talk about anchoring and offsets
TODO
TODO mention how struct declarion works. maybe should be in earlier section?
Example usage:
```C