Update docs, add Editor script: Create Druid GUI Script, add simple using widgets example

This commit is contained in:
Insality
2025-04-25 20:37:00 +03:00
parent 749666a4a5
commit 6795934a1f
19 changed files with 466 additions and 77 deletions

View File

@@ -6,8 +6,6 @@ function M.open_settings()
local dialog_component = editor.ui.component(function(props)
local template_path, set_template_path = editor.ui.use_state(editor.prefs.get("druid.widget_template_path"))
-- Check if the template path is valid
local path_valid = editor.ui.use_memo(function(path)
-- Use resource_exists to check if the resource exists
local exists = false
@@ -19,6 +17,16 @@ function M.open_settings()
return exists
end, template_path)
local gui_script_template_path, set_gui_script_template_path = editor.ui.use_state(editor.prefs.get("druid.gui_script_template_path"))
local gui_script_template_path_valid = editor.ui.use_memo(function(path)
local exists = false
pcall(function()
local content = editor.get(path, "text")
exists = content ~= nil
end)
return exists
end, gui_script_template_path)
return editor.ui.dialog({
title = "Druid Settings",
content = editor.ui.vertical({
@@ -39,6 +47,20 @@ function M.open_settings()
color = editor.ui.COLOR.WARNING
}) or nil,
editor.ui.label({
text = "GUI Script Template Path:"
}),
editor.ui.resource_field({
value = gui_script_template_path,
on_value_changed = set_gui_script_template_path,
extensions = {"lua", "template"},
padding = editor.ui.PADDING.SMALL
}),
not gui_script_template_path_valid and editor.ui.label({
text = "Warning: Path not found!",
color = editor.ui.COLOR.WARNING
}) or nil,
-- Links section title
editor.ui.label({
text = "Documentation:",