mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-08-03 18:57:27 -04:00
Updated Launcher documentation WIP (markdown)
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
|
TODO: Talk about LScreen_Reset somewhere
|
||||||
|
|
||||||
### Required members
|
## Required members
|
||||||
|
|
||||||
#### `void (*Init)(struct LScreen* s)`
|
#### `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
|
Points to an array containing pointers to the widgets in the screen
|
||||||
|
|
||||||
Example:
|
#### `int numWidgets`
|
||||||
|
|
||||||
|
Number of widgets in the screen
|
||||||
|
|
||||||
|
### Example:
|
||||||
```C
|
```C
|
||||||
static struct LWidget* simpleScreen_widgets[] = {
|
static struct LWidget* simpleScreen_widgets[] = {
|
||||||
(struct LWidget*)&SimpleScreen.iptField,
|
(struct LWidget*)&SimpleScreen.iptField,
|
||||||
(struct LWidget*)&SimpleScreen.btnBack
|
(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`
|
## Optional members - general
|
||||||
|
|
||||||
Number of widgets in the screen
|
|
||||||
|
|
||||||
Example:
|
|
||||||
```C
|
|
||||||
s->numWidgets = Array_Elems(simpleScreen_widgets);
|
|
||||||
```
|
|
||||||
|
|
||||||
### Optional members
|
|
||||||
|
|
||||||
TODO
|
|
||||||
|
|
||||||
#### `void (*Show)(struct LScreen* s)`
|
#### `void (*Show)(struct LScreen* s)`
|
||||||
|
|
||||||
|
Optional. Called every time this screen appears. (i.e. switching to this screen)
|
||||||
|
|
||||||
#### `void (*Free)(struct LScreen* s)`
|
#### `void (*Free)(struct LScreen* s)`
|
||||||
|
|
||||||
|
Optional. Called every time this screen disappears. (i.e. switching to another screen)
|
||||||
|
|
||||||
#### `void (*Layout)(struct LScreen* s)`
|
#### `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 (*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)`
|
#### `void (*KeyDown)(struct LScreen* s, int key, cc_bool wasDown)`
|
||||||
|
|
||||||
@ -68,16 +73,24 @@ TODO
|
|||||||
|
|
||||||
#### `void (*MouseWheel)(struct LScreen* s, float delta)`
|
#### `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* 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* hoveredWidget`
|
||||||
|
|
||||||
#### `struct LWidget* selectedWidget`
|
#### `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`
|
#### `const char* title`
|
||||||
|
|
||||||
|
TODO: this is kinda required usually... ?
|
||||||
|
|
||||||
|
|
||||||
How a launcher screen works
|
How a launcher screen works
|
||||||
|
|
||||||
@ -90,9 +103,13 @@ Background drawing
|
|||||||
|
|
||||||
TODO
|
TODO
|
||||||
|
|
||||||
|
TODO mention interactable widgets
|
||||||
|
|
||||||
## Widget layout / positioning
|
## 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
|
## Widget types
|
||||||
|
|
||||||
@ -110,6 +127,7 @@ TODO. talk about anchoring and offsets
|
|||||||
|
|
||||||
TODO
|
TODO
|
||||||
|
|
||||||
|
TODO mention how struct declarion works. maybe should be in earlier section?
|
||||||
|
|
||||||
Example usage:
|
Example usage:
|
||||||
```C
|
```C
|
||||||
|
Loading…
x
Reference in New Issue
Block a user