mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-08-03 18:57:27 -04:00
Updated Launcher documentation WIP (markdown)
parent
bfa6f2d8a6
commit
9c8a1b9c83
@ -1,13 +1,93 @@
|
|||||||
Launcher_SetScreen
|
## Introduction
|
||||||
|
|
||||||
- only one Screen can be active at a time
|
In contrast to the in-game GUI, the Launcher only displays one Screen at a time
|
||||||
- a Screen is composed of widgets
|
|
||||||
|
|
||||||
LScreen
|
Each Screen is composed of a background and one or more Widgets:
|
||||||
- Init (required
|
|
||||||
- Show (optional
|
|
||||||
- Free (optional
|
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
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
|
How a launcher screen works
|
||||||
|
|
||||||
@ -17,3 +97,22 @@ Showing
|
|||||||
Widget layout
|
Widget layout
|
||||||
|
|
||||||
Background drawing
|
Background drawing
|
||||||
|
|
||||||
|
|
||||||
|
## Widgets
|
||||||
|
|
||||||
|
TODO
|
||||||
|
|
||||||
|
### Button widgets
|
||||||
|
|
||||||
|
### Checkbox widgets
|
||||||
|
|
||||||
|
### Input widgets
|
||||||
|
|
||||||
|
### Label widgets
|
||||||
|
|
||||||
|
### Slider widgets
|
||||||
|
|
||||||
|
## Complete example
|
||||||
|
|
||||||
|
TODO
|
Loading…
x
Reference in New Issue
Block a user