This commit is contained in:
Insality
2025-09-15 00:56:05 +03:00
parent b6a7df5ff2
commit 9ee084c502
6 changed files with 13 additions and 11 deletions

View File

@@ -1,3 +1,5 @@
---@alias color vector4|vector3|string
local PALETTE_DATA = {} local PALETTE_DATA = {}
local COLOR_WHITE = vmath.vector4(1, 1, 1, 1) local COLOR_WHITE = vmath.vector4(1, 1, 1, 1)
local COLOR_X = hash("color.x") local COLOR_X = hash("color.x")

View File

@@ -147,7 +147,7 @@ function M.get_widget(widget_class, gui_url, params)
for index = 1, #registered_druids do for index = 1, #registered_druids do
local druid = registered_druids[index] local druid = registered_druids[index]
if druid.fragment == gui_url.fragment and druid.path == gui_url.path then if druid.fragment == gui_url.fragment and druid.path == gui_url.path then
return druid.new_widget:trigger(widget_class, nil, nil, params) return druid.new_widget(widget_class, nil, nil, params)
end end
end end

View File

@@ -1,7 +1,7 @@
--- Module for assigning layers to GUI nodes based on textures and fonts --- Module for assigning layers to GUI nodes based on textures and fonts
local defold_parser = require("druid.editor_scripts.defold_parser.defold_parser") local defold_parser = require("druid.editor_scripts.defold_parser.defold_parser")
local system = require("druid.editor_scripts.defold_parser.system.system") local system = require("druid.editor_scripts.defold_parser.system.parser_internal")
local M = {} local M = {}

View File

@@ -65,7 +65,7 @@ end
---@param widget_resource_path string The path to the GUI script to link ---@param widget_resource_path string The path to the GUI script to link
function M.link_gui_script(selection, widget_resource_path) function M.link_gui_script(selection, widget_resource_path)
local defold_parser = require("druid.editor_scripts.defold_parser.defold_parser") local defold_parser = require("druid.editor_scripts.defold_parser.defold_parser")
local system = require("druid.editor_scripts.defold_parser.system.system") local system = require("druid.editor_scripts.defold_parser.system.parser_internal")
local gui_filepath = editor.get(selection, "path") local gui_filepath = editor.get(selection, "path")
print("Linking GUI script to", gui_filepath) print("Linking GUI script to", gui_filepath)

View File

@@ -1,7 +1,7 @@
--- Defold Text Proto format encoder/decoder to lua table --- Defold Text Proto format encoder/decoder to lua table
local config = require("druid.editor_scripts.defold_parser.system.config") local config = require("druid.editor_scripts.defold_parser.system.config")
local system = require("druid.editor_scripts.defold_parser.system.system") local parser_internal = require("druid.editor_scripts.defold_parser.system.parser_internal")
local M = {} local M = {}
@@ -17,7 +17,7 @@ function M.decode_defold_object(text)
-- For each line in the text, we go through the following steps: -- For each line in the text, we go through the following steps:
for raw_line in text:gmatch("[^\r\n]+") do for raw_line in text:gmatch("[^\r\n]+") do
system.parse_line(raw_line, stack) parser_internal.parse_line(raw_line, stack)
end end
return root return root
@@ -39,8 +39,8 @@ function M.encode_defold_object(obj, spaces, data_level, extension)
end end
table.sort(keys, function(a, b) table.sort(keys, function(a, b)
local index_a = system.contains(key_order, a) or 0 local index_a = parser_internal.contains(key_order, a) or 0
local index_b = system.contains(key_order, b) or 0 local index_b = parser_internal.contains(key_order, b) or 0
return index_a < index_b return index_a < index_b
end) end)
@@ -63,7 +63,7 @@ function M.encode_defold_object(obj, spaces, data_level, extension)
result = result .. tabString .. key .. ': "' .. encodedChild .. '"\n' result = result .. tabString .. key .. ': "' .. encodedChild .. '"\n'
elseif item_type == "number" or item_type == "boolean" then elseif item_type == "number" or item_type == "boolean" then
local is_contains_dot = string.find(key, "%.") local is_contains_dot = string.find(key, "%.")
if item_type == "number" and (system.contains(config.with_dot_params, key) and not is_contains_dot) then if item_type == "number" and (parser_internal.contains(config.with_dot_params, key) and not is_contains_dot) then
result = result .. tabString .. key .. ': ' .. string.format("%.1f", array_item) .. '\n' result = result .. tabString .. key .. ': ' .. string.format("%.1f", array_item) .. '\n'
else else
result = result .. tabString .. key .. ': ' .. tostring(array_item) .. '\n' result = result .. tabString .. key .. ': ' .. tostring(array_item) .. '\n'
@@ -94,7 +94,7 @@ function M.encode_defold_object(obj, spaces, data_level, extension)
-- Handle scalar values (string, number, boolean) -- Handle scalar values (string, number, boolean)
if value_type == "number" or value_type == "boolean" then if value_type == "number" or value_type == "boolean" then
local is_contains_dot = string.find(key, "%.") local is_contains_dot = string.find(key, "%.")
if value_type == "number" and (system.contains(config.with_dot_params, key) and not is_contains_dot) then if value_type == "number" and (parser_internal.contains(config.with_dot_params, key) and not is_contains_dot) then
result = result .. tabString .. key .. ': ' .. string.format("%.1f", value) .. '\n' result = result .. tabString .. key .. ': ' .. string.format("%.1f", value) .. '\n'
else else
result = result .. tabString .. key .. ': ' .. tostring(value) .. '\n' result = result .. tabString .. key .. ': ' .. tostring(value) .. '\n'
@@ -125,7 +125,7 @@ end
---@param file_path string ---@param file_path string
---@return table|nil, string|nil ---@return table|nil, string|nil
function M.load_from_file(file_path) function M.load_from_file(file_path)
local content, reason = system.read_file(file_path) local content, reason = parser_internal.read_file(file_path)
if not content then if not content then
return nil, reason return nil, reason
end end
@@ -146,7 +146,7 @@ function M.save_to_file(file_path, lua_table)
local encoded_object = M.encode_defold_object(lua_table, nil, nil, defold_format_name) local encoded_object = M.encode_defold_object(lua_table, nil, nil, defold_format_name)
return system.write_file(file_path, encoded_object) return parser_internal.write_file(file_path, encoded_object)
end end