mirror of
https://github.com/Insality/druid.git
synced 2025-09-27 10:02:18 +02:00
Update docs
This commit is contained in:
@@ -1,29 +1,30 @@
|
||||
# Advanced Druid setup
|
||||
# Advanced Druid Setup
|
||||
|
||||
|
||||
## Input bindings
|
||||
## Input Bindings
|
||||
|
||||
As default input bindings **Druid** uses the `/builtins/input/all.input_binding`.
|
||||
By default, **Druid** utilizes the `/builtins/input/all.input_binding` for input bindings.
|
||||
|
||||
**Druid** requires the following input bindings:
|
||||
|
||||
- Mouse trigger - `Button 1` -> `touch` _For basic input components_
|
||||
- Mouse trigger - `Wheel up` -> `mouse_wheel_up` _For scroll component_
|
||||
- Mouse trigger - `Wheel down` -> `mouse_wheel_down` _For scroll component_
|
||||
- Key trigger - `Backspace` -> `key_backspace` _For back_handler component, input component_
|
||||
- Key trigger - `Back` -> `key_back` _For back_handler component, Android back button, input component_
|
||||
- Key trigger - `Enter` -> `key_enter` _For input component, optional_
|
||||
- Key trigger - `Esc` -> `key_esc` _For input component, optional_
|
||||
- Touch triggers - `Touch multi` -> `touch_multi` _For scroll component_
|
||||
- Mouse trigger: `Button 1` -> `touch` (for basic input components)
|
||||
- Mouse trigger: `Wheel up` -> `mouse_wheel_up` (for Scroll component)
|
||||
- Mouse trigger: `Wheel down` -> `mouse_wheel_down` (for Scroll component)
|
||||
- Key trigger: `Backspace` -> `key_backspace` (for BackHandler component, input component)
|
||||
- Key trigger: `Back` -> `key_back` (for BackHandler component, Android back button, input component)
|
||||
- Key trigger: `Enter` -> `key_enter` (for Input component, optional)
|
||||
- Key trigger: `Esc` -> `key_esc` (for Input component, optional)
|
||||
- Touch triggers: `Touch multi` -> `touch_multi` (for Scroll component)
|
||||
|
||||

|
||||

|
||||
|
||||
|
||||
## Change key bindings [optional]
|
||||
If you have to use your own key bindings (and key name), you can change it in your *game.project* file.
|
||||
## Changing Key Bindings (optional)
|
||||
|
||||
Here is current default values for key bindings:
|
||||
If you need to use your own key bindings or key names, you can modify them in your *game.project* file.
|
||||
|
||||
Here are the default values for key bindings:
|
||||
```
|
||||
[druid]
|
||||
input_text = text
|
||||
@@ -39,22 +40,22 @@ input_scroll_down = mouse_wheel_down
|
||||
```
|
||||
|
||||
|
||||
## Input capturing [optional]
|
||||
## Input Capturing (optional)
|
||||
|
||||
By default, **Druid** will auto-capture input focus, if any input component will be created. So you don't need to call `msg.post(".", "acquire_input_focus")`
|
||||
By default, **Druid** automatically captures input focus if any input component is created. Therefore, you do not need to call `msg.post(".", "acquire_input_focus")`.
|
||||
|
||||
If you don't need this behaviour, you can disable it by setting `druid.no_auto_input` field in _game.project_:
|
||||
If you do not require this behavior, you can disable it by setting the `druid.no_auto_input` field in the _game.project_ file:
|
||||
```
|
||||
[druid]
|
||||
no_auto_input = 1
|
||||
```
|
||||
|
||||
|
||||
## Template name check [optional]
|
||||
## Template Name Check (optional)
|
||||
|
||||
By default, **Druid** will auto check the parent component template name to build the full template name for component.
|
||||
By default, **Druid** automatically checks the parent component's template name to construct the full template name for the component. It's used in user custom components.
|
||||
|
||||
If for some reason you want to pass the full template name by yourself, you can disable it by setting `druid.no_auto_template` field in _game.project_:
|
||||
If, for some reason, you want to pass the full template name manually, you can disable this feature by setting the `druid.no_auto_template` field in the _game.project_ file:
|
||||
|
||||
```
|
||||
[druid]
|
||||
@@ -62,47 +63,46 @@ no_auto_template = 1
|
||||
```
|
||||
|
||||
|
||||
## Stencil check [optional]
|
||||
## Stencil Check (optional)
|
||||
|
||||
When creating input components inside stencil nodes, **Druid** automatically setup `component:set_click_zone()` on _late_init_ component step to restrict input clicks outside this stencil zone.
|
||||
For example: button inside scroll stencil nodes.
|
||||
When creating input components inside stencil nodes, **Druid** automatically sets up `component:set_click_zone()` during the _late_init_ component step to restrict input clicks outside of the stencil zone. This is particularly useful for buttons inside scroll stencil nodes.
|
||||
|
||||
To disable this feature add next field in your _game.project_ file
|
||||
To disable this feature, add the following field to your _game.project_ file:
|
||||
```
|
||||
[druid]
|
||||
no_stencil_check = 1
|
||||
```
|
||||
|
||||
|
||||
## Code bindings [optional]
|
||||
## Code Bindings (optional)
|
||||
|
||||
Adjust **Druid** settings, if needed:
|
||||
Adjust **Druid** settings as needed:
|
||||
```lua
|
||||
local druid = require("druid.druid")
|
||||
|
||||
-- Used for button component and custom components
|
||||
-- Callback should play sound by name: function(sound_id) ... end
|
||||
-- The callback should play the sound by name: function(sound_id) ... end
|
||||
druid.set_sound_function(function(sound_id)
|
||||
-- sound_system.play(sound_id)
|
||||
end)
|
||||
|
||||
-- Used for lang_text component
|
||||
-- Callback should return localized string by locale id: function(locale_id) ... end
|
||||
-- The callback should return the localized string by locale ID: function(locale_id) ... end
|
||||
druid.set_text_function(function(locale_id)
|
||||
-- return lang.get(locale_id)
|
||||
end)
|
||||
|
||||
-- Used for change default Druid style
|
||||
-- Used to change the default Druid style
|
||||
druid.set_default_style(your_style)
|
||||
|
||||
-- Call this function on language changing in the game,
|
||||
-- Call this function when the language changes in the game,
|
||||
-- to retranslate all lang_text components:
|
||||
local function on_language_change()
|
||||
druid.on_language_change()
|
||||
end
|
||||
|
||||
-- Call this function inside window.set_listener
|
||||
-- to catch game focus lost/gained callbacks:
|
||||
-- to capture game focus lost/gained callbacks:
|
||||
-- window.set_listener(function(self, event, data) druid.on_window_callback(event, data) end))
|
||||
local function on_window_callback(self, event, data)
|
||||
druid.on_window_callback(event)
|
||||
|
Reference in New Issue
Block a user