diff --git a/README.md b/README.md index d7b3eda..9b5c4d7 100644 --- a/README.md +++ b/README.md @@ -191,6 +191,7 @@ You can find the full **Druid** functions at [Quick API Reference](api/quick_api To better understand **Druid**, read the following documentation: - [How To GUI in Defold](https://forum.defold.com/t/how-to-gui-in-defold/73256) +- [Druid Workshop](https://youtu.be/qF19qpjZe9c) - [Widgets](wiki/widgets.md) - [Druid styles](wiki/styles.md) - [Advanced Setup](wiki/advanced-setup.md) diff --git a/example/druid.gui_script b/example/druid.gui_script index 44c200b..00f597e 100644 --- a/example/druid.gui_script +++ b/example/druid.gui_script @@ -48,8 +48,18 @@ end --- Generic setup that should be done once per application ---@param self druid.example local function setup_druid(self) - lang.init() - lang.set_lang("en") -- Force default start language to EN, switch through the UI to check + lang.init({ + { id = "en", path = "/example/locales/en.json" }, + { id = "ru", path = "/example/locales/ru.json" }, + { id = "es", path = "/example/locales/es.json" }, + { id = "de", path = "/example/locales/de.json" }, + { id = "fr", path = "/example/locales/fr.json" }, + { id = "ja", path = "/example/locales/ja.json" }, + { id = "pt", path = "/example/locales/pt.json" }, + { id = "it", path = "/example/locales/it.json" }, + { id = "kr", path = "/example/locales/kr.json" }, + { id = "zh", path = "/example/locales/zh.json" }, + }, "en") druid.set_text_function(lang.txp) window.set_listener(function(_, event) diff --git a/example/examples/windows/window_confirmation/window_confirmation.gui_script b/example/examples/windows/window_confirmation/window_confirmation.gui_script index 82f2b0c..c2f406b 100644 --- a/example/examples/windows/window_confirmation/window_confirmation.gui_script +++ b/example/examples/windows/window_confirmation/window_confirmation.gui_script @@ -1,24 +1,9 @@ -local lang = require("lang.lang") local druid = require("druid.druid") local window_confirmation = require("example.examples.windows.window_confirmation.window_confirmation") -local function debug_stub(self) - if msg.url().socket ~= hash("window_confirmation") then - return - end - - lang.init() - druid.set_text_function(lang.txp) -end - - function init(self) - debug_stub(self) - - -- Using component instead put all inside gui_script to - -- allow use it as example and as separate collection self.druid = druid.new(self) self.druid:new(window_confirmation) end @@ -41,4 +26,4 @@ end function on_input(self, action_id, action) return self.druid:on_input(action_id, action) -end \ No newline at end of file +end diff --git a/example/examples/windows/window_info/window_info.gui_script b/example/examples/windows/window_info/window_info.gui_script index 9c4e5e9..cf77bb6 100644 --- a/example/examples/windows/window_info/window_info.gui_script +++ b/example/examples/windows/window_info/window_info.gui_script @@ -4,21 +4,7 @@ local druid = require("druid.druid") local window_info = require("example.examples.windows.window_info.window_info") -local function debug_stub(self) - if msg.url().socket ~= hash("window_info") then - return - end - - lang.init() - druid.set_text_function(lang.txp) -end - - function init(self) - debug_stub(self) - - -- Using component instead put all inside gui_script to - -- allow use it as example and as separate collection self.druid = druid.new(self) self.druid:new(window_info) end @@ -41,4 +27,4 @@ end function on_input(self, action_id, action) return self.druid:on_input(action_id, action) -end \ No newline at end of file +end diff --git a/example/examples/windows/window_language/window_language.gui_script b/example/examples/windows/window_language/window_language.gui_script index d213f31..63846f7 100644 --- a/example/examples/windows/window_language/window_language.gui_script +++ b/example/examples/windows/window_language/window_language.gui_script @@ -1,24 +1,8 @@ -local lang = require("lang.lang") local druid = require("druid.druid") local window_language = require("example.examples.windows.window_language.window_language") - -local function debug_stub(self) - if msg.url().socket ~= hash("window_language") then - return - end - - lang.init() - druid.set_text_function(lang.txp) -end - - function init(self) - debug_stub(self) - - -- Using component instead put all inside gui_script to - -- allow use it as example and as separate collection self.druid = druid.new(self) self.druid:new(window_language) end @@ -41,4 +25,4 @@ end function on_input(self, action_id, action) return self.druid:on_input(action_id, action) -end \ No newline at end of file +end diff --git a/game.project b/game.project index 3fe8149..8ce64b5 100644 --- a/game.project +++ b/game.project @@ -20,9 +20,9 @@ developer = Maksim Tuprikov custom_resources = /example/locales dependencies#0 = https://github.com/britzl/deftest/archive/refs/tags/2.8.0.zip dependencies#1 = https://github.com/Insality/defold-saver/archive/refs/tags/5.zip -dependencies#2 = https://github.com/Insality/defold-tweener/archive/refs/tags/3.zip -dependencies#3 = https://github.com/Insality/panthera/archive/refs/tags/runtime.4.zip -dependencies#4 = https://github.com/Insality/defold-lang/archive/refs/tags/3.zip +dependencies#2 = https://github.com/Insality/defold-tweener/archive/refs/tags/6.zip +dependencies#3 = https://github.com/Insality/panthera/archive/refs/tags/runtime.5.zip +dependencies#4 = https://github.com/Insality/defold-lang/archive/refs/tags/4.zip dependencies#5 = https://github.com/Insality/defold-event/archive/refs/tags/13.zip dependencies#6 = https://github.com/subsoap/defos/archive/refs/tags/v2.8.0.zip dependencies#7 = https://github.com/Insality/asset-store/archive/refs/tags/1.zip @@ -59,7 +59,7 @@ cssfile = /builtins/manifests/web/dark_theme.css show_console_banner = 0 [native_extension] -app_manifest = +app_manifest = [graphics] texture_profiles = /builtins/graphics/default.texture_profiles @@ -103,11 +103,6 @@ max_instances = 128 [saver] autosave_timer = 2 -[lang] -path = /example/locales -langs = en,ru,es,de,fr,ja,pt,it,kr,zh -default = es - [event] use_xpcall = 1