8 Commits
1.1.4 ... 1.1.6

Author SHA1 Message Date
Insality
b2d73bafa4 Release 1.1.6 2025-09-27 14:02:11 +03:00
Insality
872af8fb8e Update editor script linking messages 2025-09-27 14:02:11 +03:00
Insality
46b7d828f0 Use editor script to set gui script path 2025-09-27 14:02:11 +03:00
Maksim Tuprikov
044eec50b2 Merge pull request #322 from vlaaad/patch-1 2025-08-22 14:43:05 +02:00
vlaaad
066a81f5f3 Create ext.properties 2025-08-22 14:36:54 +02:00
Insality
ba7ee40510 Release 1.1.5 2025-07-02 21:51:43 +03:00
Insality
d019247ae4 Update for event v12 2025-07-02 21:50:48 +03:00
Insality
616c513fbd Use tagged releases of dependencies 2025-06-19 20:28:45 +03:00
9 changed files with 66 additions and 102 deletions

View File

@@ -33,7 +33,8 @@
"Lua.runtime.version": "Lua 5.1", "Lua.runtime.version": "Lua 5.1",
"Lua.workspace.library": [ "Lua.workspace.library": [
"~/Library/Application Support/Cursor/User/globalStorage/astronachos.defold", "~/Library/Application Support/Cursor/User/globalStorage/astronachos.defold",
"~/Library/Application Support/Cursor/User/workspaceStorage/1446075a23c89451a63f0e82b2291def/astronachos.defold" "~/Library/Application Support/Cursor/User/workspaceStorage/1446075a23c89451a63f0e82b2291def/astronachos.defold",
"~/Library/Application Support/Cursor/User/workspaceStorage/7975bec62a9fa9724d190779fa01ec63/astronachos.defold"
], ],
"files.exclude": { "files.exclude": {
"**/*.gui": true "**/*.gui": true

View File

@@ -39,13 +39,13 @@ Open your `game.project` file and add the following lines to the dependencies fi
**[Druid](https://github.com/Insality/druid/)** **[Druid](https://github.com/Insality/druid/)**
``` ```
https://github.com/Insality/druid/archive/refs/tags/1.1.4.zip https://github.com/Insality/druid/archive/refs/tags/1.1.6.zip
``` ```
**[Defold Event](https://github.com/Insality/defold-event)** **[Defold Event](https://github.com/Insality/defold-event)**
``` ```
https://github.com/Insality/defold-event/archive/refs/tags/11.zip https://github.com/Insality/defold-event/archive/refs/tags/12.zip
``` ```
After that, select `Project ▸ Fetch Libraries` to update [library dependencies]((https://defold.com/manuals/libraries/#setting-up-library-dependencies)). This happens automatically whenever you open a project so you will only need to do this if the dependencies change without re-opening the project. After that, select `Project ▸ Fetch Libraries` to update [library dependencies]((https://defold.com/manuals/libraries/#setting-up-library-dependencies)). This happens automatically whenever you open a project so you will only need to do this if the dependencies change without re-opening the project.

View File

@@ -1,6 +1,6 @@
local component = require("druid.component") local component = require("druid.component")
local helper = require("druid.helper") local helper = require("druid.helper")
local defer = require("event.defer") local queues = require("event.queues")
---@class druid.tiling_node: druid.component ---@class druid.tiling_node: druid.component
---@field animation table ---@field animation table
@@ -28,7 +28,7 @@ function M:init(node)
print("The druid.script is not found, please add it nearby to the GUI collection", msg.url()) print("The druid.script is not found, please add it nearby to the GUI collection", msg.url())
end) end)
defer.push("druid.get_atlas_path", { queues.push("druid.get_atlas_path", {
texture_name = gui.get_texture(self.node), texture_name = gui.get_texture(self.node),
sender = msg.url(), sender = msg.url(),
}, self.on_get_atlas_path, self) }, self.on_get_atlas_path, self)

View File

@@ -3,9 +3,9 @@
-- This one is a required to make a unified "Shaders" pipeline in the GUI scripts -- This one is a required to make a unified "Shaders" pipeline in the GUI scripts
-- This required to grab a texture data with `go.get` function -- This required to grab a texture data with `go.get` function
local defer = require("event.defer") local queues = require("event.queues")
---Usage: defer.push("druid.get_atlas_path", { ---Usage: queues.push("druid.get_atlas_path", {
--- texture_name = gui.get_texture(self.node), --- texture_name = gui.get_texture(self.node),
--- sender = msg.url(), --- sender = msg.url(),
---}, callback, [context]) ---}, callback, [context])
@@ -35,10 +35,10 @@ end
function init(self) function init(self)
defer.subscribe(MESSAGE_GET_ATLAS_PATH, get_atlas_path, self) queues.subscribe(MESSAGE_GET_ATLAS_PATH, get_atlas_path, self)
end end
function final(self) function final(self)
defer.unsubscribe(MESSAGE_GET_ATLAS_PATH, get_atlas_path, self) queues.unsubscribe(MESSAGE_GET_ATLAS_PATH, get_atlas_path, self)
end end

View File

@@ -12,7 +12,7 @@ end
function M.create_druid_gui_script(selection) function M.create_druid_gui_script(selection)
local gui_filepath = editor.get(selection, "path") local gui_filepath = editor.get(selection, "path")
local filename = gui_filepath:match("([^/]+)%.gui$") 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 absolute_project_path = editor.external_file_attributes(".").path
local widget_resource_path = gui_filepath:gsub("%.gui$", ".gui_script") 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") local f = io.open(new_widget_absolute_path, "r")
if f then if f then
f:close() f:close()
print("Widget file already exists at " .. new_widget_absolute_path) print("GUI script file already exists at " .. new_widget_absolute_path)
print("Creation aborted to prevent overwriting") error("Creation aborted to prevent overwriting")
return return
end end
@@ -37,7 +37,7 @@ function M.create_druid_gui_script(selection)
local template_content = editor.get(template_path, "text") local template_content = editor.get(template_path, "text")
if not template_content then if not template_content then
print("Error: Could not load template from", template_path) 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 return
end end
@@ -54,90 +54,12 @@ function M.create_druid_gui_script(selection)
file:write(template_content) file:write(template_content)
file:close() file:close()
print("Widget created at " .. widget_resource_path) print("Widget created: " .. widget_resource_path)
editor.transact({
editor.tx.set(selection, "script", widget_resource_path)
})
editor.save()
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 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)
end end

View File

@@ -26,7 +26,7 @@ function M.create_druid_widget(selection)
if f then if f then
f:close() f:close()
print("Widget file already exists at " .. new_widget_absolute_path) print("Widget file already exists at " .. new_widget_absolute_path)
print("Creation aborted to prevent overwriting") error("Creation aborted to prevent overwriting")
return return
end end
@@ -37,7 +37,7 @@ function M.create_druid_widget(selection)
local template_content = editor.get(template_path, "text") local template_content = editor.get(template_path, "text")
if not template_content then if not template_content then
print("Error: Could not load template from", template_path) 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 return
end end

35
druid/ext.properties Normal file
View File

@@ -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

View File

@@ -14,16 +14,16 @@ update_frequency = 60
[project] [project]
title = Druid title = Druid
version = 1.1.4 version = 1.1.5
publisher = Insality publisher = Insality
developer = Maksim Tuprikov developer = Maksim Tuprikov
custom_resources = /example/locales custom_resources = /example/locales
dependencies#0 = https://github.com/britzl/deftest/archive/refs/tags/2.8.0.zip dependencies#0 = https://github.com/britzl/deftest/archive/refs/tags/2.8.0.zip
dependencies#1 = https://github.com/Insality/defold-saver/archive/refs/heads/develop.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#2 = https://github.com/Insality/defold-tweener/archive/refs/tags/3.zip
dependencies#3 = https://github.com/Insality/panthera/archive/refs/heads/develop.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#4 = https://github.com/Insality/defold-lang/archive/refs/tags/3.zip
dependencies#5 = https://github.com/Insality/defold-event/archive/refs/heads/develop.zip dependencies#5 = https://github.com/Insality/defold-event/archive/refs/tags/12.zip
dependencies#6 = https://github.com/subsoap/defos/archive/refs/tags/v2.8.0.zip dependencies#6 = https://github.com/subsoap/defos/archive/refs/tags/v2.8.0.zip
[library] [library]

View File

@@ -715,3 +715,9 @@ Please support me if you like this project! It will help me keep engaged to upda
#### Druid 1.1.4 #### Druid 1.1.4
- [#312] Fix for text metrics issue if returned height is 0 sometimes - [#312] Fix for text metrics issue if returned height is 0 sometimes
#### Druid 1.1.5
- Update for using `defold-event` library v12
#### Druid 1.1.6
- [#326] Fix for Editor Scripts corrupt file issue