Update docs

This commit is contained in:
Insality
2025-04-15 21:49:22 +03:00
parent e2c9a7d9d6
commit 9e2a14c6dd
48 changed files with 1097 additions and 1289 deletions

View File

@@ -5,17 +5,19 @@
Entry point for Druid UI Framework.
Create a new Druid instance and adjust the Druid settings here.
## Table of Contents
## Functions
- [new](#new)
- [register](#register)
- [set_default_style](#set_default_style)
- [set_text_function](#set_text_function)
- [set_sound_function](#set_sound_function)
- [init_window_listener](#init_window_listener)
- [on_window_callback](#on_window_callback)
- [on_language_change](#on_language_change)
- [get_widget](#get_widget)
- [register_druid_as_widget](#register_druid_as_widget)
- [unregister_druid_as_widget](#unregister_druid_as_widget)
@@ -35,6 +37,23 @@ Create a new Druid instance for creating GUI components.
- **Returns:**
- `druid_instance` *(druid.instance)*: The new Druid instance
### register
---
```lua
druid.register(name, module)
```
Register a new external Druid component.
Register component just makes the druid:new_{name} function.
For example, if you register a component called "my_component", you can create it using druid:new_my_component(...).
This can be useful if you have your own "basic" components that you don't want to require in every file.
The default way to create component is `druid_instance:new(component_class, ...)`.
- **Parameters:**
- `name` *(string)*: Module name
- `module` *(table)*: Lua table with component
### set_default_style
---
@@ -102,3 +121,52 @@ druid.on_language_change()
Call this function when the game language changes.
It will notify all Druid instances to update the lang text components.
### get_widget
---
```lua
druid.get_widget(widget_class, gui_url)
```
Create a widget from the binded Druid GUI instance.
The widget will be created and all widget functions can be called from Game Object contexts.
This allow use only `druid_widget.gui_script` for GUI files and call this widget functions from Game Object script file.
Widget class here is a your lua file for the GUI scene (a widgets in Druid)
- **Parameters:**
- `widget_class` *(<T:druid.widget>)*: The class of the widget to return
- `gui_url` *(url)*: GUI url
- **Returns:**
- `widget` *(<T:druid.widget>?)*: The new created widget,
- **Example Usage:**
```lua
msg.url(nil, nil, "gui_widget") -- current game object
msg.url(nil, object_url, "gui_widget") -- other game object
```
### register_druid_as_widget
---
```lua
druid.register_druid_as_widget(druid)
```
Bind a Druid GUI instance to the current game object.
This instance now can produce widgets from `druid.get_widget()` function.
Only one widget can be set per game object.
- **Parameters:**
- `druid` *(druid.instance)*: The druid instance to register
### unregister_druid_as_widget
---
```lua
druid.unregister_druid_as_widget()
```
Should be called on final, where druid instance is destroyed.