mirror of
https://github.com/Insality/druid
synced 2025-06-27 10:27:48 +02:00
Set functions to setup sound/text from external sources
This commit is contained in:
parent
8eda125d72
commit
09ae21a367
15
README.md
15
README.md
@ -15,14 +15,17 @@ Or point to the ZIP file of a [specific release](https://github.com/AGulev/drui
|
||||
#### Code
|
||||
Adjust druid settings:
|
||||
```lua
|
||||
local settings = require("druid.settings")
|
||||
settings.play_sound = function(name)
|
||||
...
|
||||
end
|
||||
local druid = require("druid.druid")
|
||||
|
||||
settings.get_text = function(lang_id)
|
||||
--- Function should return localized string by lang_id
|
||||
druid.set_text_function(function(lang_id)
|
||||
...
|
||||
end
|
||||
end)
|
||||
|
||||
-- Function should play sound by name
|
||||
druid.set_sound_function(function(name)
|
||||
...
|
||||
end)
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
@ -54,4 +54,6 @@ M.SPECIFIC_UI_MESSAGES = {
|
||||
[M.ON_LAYOUT_CHANGED] = "on_layout_changed"
|
||||
}
|
||||
|
||||
M.EMPTY_FUNCTION = function() end
|
||||
|
||||
return M
|
@ -84,6 +84,16 @@ function M.set_default_style(style)
|
||||
end
|
||||
|
||||
|
||||
function M.set_text_function(callback)
|
||||
settings.get_text = callback or const.EMPTY_FUNCTION
|
||||
end
|
||||
|
||||
|
||||
function M.set_sound_function(callback)
|
||||
settings.play_sound = callback or const.EMPTY_FUNCTION
|
||||
end
|
||||
|
||||
|
||||
local function input_init(self)
|
||||
if not self.input_inited then
|
||||
self.input_inited = true
|
||||
|
Loading…
x
Reference in New Issue
Block a user