mirror of
https://github.com/Insality/druid
synced 2025-06-27 10:27:48 +02:00
2.1 KiB
2.1 KiB
druid API
at /druid/druid.lua
Entry point for Druid UI Framework. Create a new Druid instance and adjust the Druid settings here.
Table of Contents
Functions
- new
- set_default_style
- set_text_function
- set_sound_function
- init_window_listener
- on_window_callback
- on_language_change
new
druid.new(context, [style])
Create a new Druid instance for creating GUI components.
-
Parameters:
context
(table): The Druid context. Usually, this is the self of the gui_script. It is passed into all Druid callbacks.[style]
(table|nil): The Druid style table to override style parameters for this Druid instance.
-
Returns:
druid_instance
(druid.instance): The new Druid instance
set_default_style
druid.set_default_style(style)
Set the default style for all Druid instances.
- Parameters:
style
(table): Default style
set_text_function
druid.set_text_function(callback)
Set the text function for the LangText component.
- Parameters:
callback
(fun(text_id: string):string): Get localized text function
set_sound_function
druid.set_sound_function(callback)
Set the sound function to able components to play sounds.
- Parameters:
callback
(fun(sound_id: string)): Sound play callback
init_window_listener
druid.init_window_listener()
Subscribe Druid to the window listener. It will override your previous window listener, so if you have one, you should call M.on_window_callback manually.
on_window_callback
druid.on_window_callback(window_event)
Set the window callback to enable Druid window events.
- Parameters:
window_event
(constant): Event param from window listener
on_language_change
druid.on_language_change()
Call this function when the game language changes. It will notify all Druid instances to update the lang text components.