From 066a81f5f344163cf3026f975ef14e3b0f9c4f68 Mon Sep 17 00:00:00 2001 From: vlaaad Date: Fri, 22 Aug 2025 14:36:54 +0200 Subject: [PATCH 1/4] Create ext.properties --- druid/ext.properties | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 druid/ext.properties diff --git a/druid/ext.properties b/druid/ext.properties new file mode 100644 index 0000000..09f44dd --- /dev/null +++ b/druid/ext.properties @@ -0,0 +1,35 @@ +[druid] +help = Settings for Druid extension +group = Runtime + +input_text.default = text + +input_touch.default = touch + +input_marked_text.default = marked_text + +input_key_esc.default = key_esc + +input_key_back.default = key_back + +input_key_enter.default = key_enter + +input_key_backspace.default = key_backspace + +input_multitouch.default = touch_multi + +input_scroll_up.default = mouse_wheel_up + +input_scroll_down.default = mouse_wheel_down + +input_key_left.default = key_left + +input_key_right.default = key_right + +input_key_lshift.default = key_lshift + +input_key_lctrl.default = key_lctrl + +input_key_lsuper.default = key_lsuper + +no_auto_input.type = bool From 46b7d828f01cf71550a073e61fb4c3c153888f3a Mon Sep 17 00:00:00 2001 From: Insality Date: Sat, 27 Sep 2025 13:58:32 +0300 Subject: [PATCH 2/4] Use editor script to set gui script path --- .../create_druid_gui_script.lua | 79 ++----------------- 1 file changed, 5 insertions(+), 74 deletions(-) diff --git a/druid/editor_scripts/create_druid_gui_script.lua b/druid/editor_scripts/create_druid_gui_script.lua index 1807bbb..718694f 100644 --- a/druid/editor_scripts/create_druid_gui_script.lua +++ b/druid/editor_scripts/create_druid_gui_script.lua @@ -61,83 +61,14 @@ end ---Links a GUI script to a GUI file by updating the script property ----@param selection string The GUI resource to modify +---@param selection string The local GUI resource to modify ---@param widget_resource_path string The path to the GUI script to link function M.link_gui_script(selection, widget_resource_path) - local defold_parser = require("druid.editor_scripts.defold_parser.defold_parser") - local system = require("druid.editor_scripts.defold_parser.system.system") - local gui_filepath = editor.get(selection, "path") - print("Linking GUI script to", gui_filepath) - - -- Get the absolute path to the file - local absolute_project_path = editor.external_file_attributes(".").path - if not absolute_project_path:match("[\\/]$") then - absolute_project_path = absolute_project_path .. "/" - end - local clean_gui_path = gui_filepath - if clean_gui_path:sub(1, 1) == "/" then - clean_gui_path = clean_gui_path:sub(2) - end - local gui_absolute_path = absolute_project_path .. clean_gui_path - - -- Create a backup - local backup_path = gui_absolute_path .. ".backup" - print("Creating backup at:", backup_path) - - -- Read and write backup - local content, err_read = system.read_file(gui_absolute_path) - if not content then - print("Error reading original file for backup:", err_read) - return - end - - local success, err_write = system.write_file(backup_path, content) - if not success then - print("Error creating backup file:", err_write) - return - end - - -- Parse the GUI file - print("Parsing GUI file...") - local gui_data = defold_parser.load_from_file(gui_absolute_path) - if not gui_data then - print("Error: Failed to parse GUI file") - return - end - - -- Update the script property - print("Setting script property to:", widget_resource_path) - gui_data.script = widget_resource_path - - -- Write the updated GUI file - print("Writing updated GUI file...") - local save_success = defold_parser.save_to_file(gui_absolute_path, gui_data) - - if not save_success then - print("Error: Failed to save GUI file") - print("Attempting to restore from backup...") - - -- Restore from backup on failure - local backup_content, backup_err_read = system.read_file(backup_path) - if not backup_content then - print("Error reading backup file:", backup_err_read) - return - end - - local restore_success, restore_err_write = system.write_file(gui_absolute_path, backup_content) - if not restore_success then - print("Critical: Failed to restore from backup:", restore_err_write) - return - end - - print("Restored successfully from backup") - return - end - - -- Remove backup on success - os.remove(backup_path) - print("Successfully linked GUI script to:", gui_filepath) + print("Linking ", gui_filepath, "to", widget_resource_path) + editor.transact({ + editor.tx.set(selection, "script", widget_resource_path) + }) end From 872af8fb8edf01e9507a0db5210aeb54c0966b3a Mon Sep 17 00:00:00 2001 From: Insality Date: Sat, 27 Sep 2025 13:58:38 +0300 Subject: [PATCH 3/4] Update editor script linking messages --- .../create_druid_gui_script.lua | 23 ++++++------------- druid/editor_scripts/create_druid_widget.lua | 4 ++-- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/druid/editor_scripts/create_druid_gui_script.lua b/druid/editor_scripts/create_druid_gui_script.lua index 718694f..92aec47 100644 --- a/druid/editor_scripts/create_druid_gui_script.lua +++ b/druid/editor_scripts/create_druid_gui_script.lua @@ -12,7 +12,7 @@ end function M.create_druid_gui_script(selection) local gui_filepath = editor.get(selection, "path") local filename = gui_filepath:match("([^/]+)%.gui$") - print("Create Druid GUI Script for", gui_filepath) + print("Create GUI script for", gui_filepath) local absolute_project_path = editor.external_file_attributes(".").path local widget_resource_path = gui_filepath:gsub("%.gui$", ".gui_script") @@ -25,8 +25,8 @@ function M.create_druid_gui_script(selection) local f = io.open(new_widget_absolute_path, "r") if f then f:close() - print("Widget file already exists at " .. new_widget_absolute_path) - print("Creation aborted to prevent overwriting") + print("GUI script file already exists at " .. new_widget_absolute_path) + error("Creation aborted to prevent overwriting") return end @@ -37,7 +37,7 @@ function M.create_druid_gui_script(selection) local template_content = editor.get(template_path, "text") if not template_content then print("Error: Could not load template from", template_path) - print("Check the template path in [Druid] Settings") + error("Check the template path in [Druid] Settings") return end @@ -54,21 +54,12 @@ function M.create_druid_gui_script(selection) file:write(template_content) file:close() - print("Widget created at " .. widget_resource_path) - - M.link_gui_script(selection, widget_resource_path) -end - - ----Links a GUI script to a GUI file by updating the script property ----@param selection string The local GUI resource to modify ----@param widget_resource_path string The path to the GUI script to link -function M.link_gui_script(selection, widget_resource_path) - local gui_filepath = editor.get(selection, "path") - print("Linking ", gui_filepath, "to", widget_resource_path) + print("Widget created: " .. widget_resource_path) editor.transact({ editor.tx.set(selection, "script", widget_resource_path) }) + editor.save() + end diff --git a/druid/editor_scripts/create_druid_widget.lua b/druid/editor_scripts/create_druid_widget.lua index 75b2116..10b61bb 100644 --- a/druid/editor_scripts/create_druid_widget.lua +++ b/druid/editor_scripts/create_druid_widget.lua @@ -26,7 +26,7 @@ function M.create_druid_widget(selection) if f then f:close() print("Widget file already exists at " .. new_widget_absolute_path) - print("Creation aborted to prevent overwriting") + error("Creation aborted to prevent overwriting") return end @@ -37,7 +37,7 @@ function M.create_druid_widget(selection) local template_content = editor.get(template_path, "text") if not template_content then print("Error: Could not load template from", template_path) - print("Check the template path in [Druid] Settings") + error("Check the template path in [Druid] Settings") return end From b2d73bafa4d61e0c5d95f0f80c24c9c59f6d091a Mon Sep 17 00:00:00 2001 From: Insality Date: Sat, 27 Sep 2025 14:01:54 +0300 Subject: [PATCH 4/4] Release 1.1.6 --- README.md | 2 +- wiki/changelog.md | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5be60ca..9b9e7bd 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ Open your `game.project` file and add the following lines to the dependencies fi **[Druid](https://github.com/Insality/druid/)** ``` -https://github.com/Insality/druid/archive/refs/tags/1.1.5.zip +https://github.com/Insality/druid/archive/refs/tags/1.1.6.zip ``` **[Defold Event](https://github.com/Insality/defold-event)** diff --git a/wiki/changelog.md b/wiki/changelog.md index faaa41e..29e9640 100644 --- a/wiki/changelog.md +++ b/wiki/changelog.md @@ -718,3 +718,6 @@ Please support me if you like this project! It will help me keep engaged to upda #### Druid 1.1.5 - Update for using `defold-event` library v12 + +#### Druid 1.1.6 +- [#326] Fix for Editor Scripts corrupt file issue