diff --git a/druid/color.lua b/druid/color.lua index 3d9e660..f7567a2 100644 --- a/druid/color.lua +++ b/druid/color.lua @@ -1,3 +1,5 @@ +---@alias color vector4|vector3|string + local PALETTE_DATA = {} local COLOR_WHITE = vmath.vector4(1, 1, 1, 1) local COLOR_X = hash("color.x") diff --git a/druid/druid.lua b/druid/druid.lua index 1dde1b7..1fcf995 100644 --- a/druid/druid.lua +++ b/druid/druid.lua @@ -147,7 +147,7 @@ function M.get_widget(widget_class, gui_url, params) for index = 1, #registered_druids do local druid = registered_druids[index] 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 diff --git a/druid/editor_scripts/assign_layers.lua b/druid/editor_scripts/assign_layers.lua index 8fe59d9..2aedc48 100644 --- a/druid/editor_scripts/assign_layers.lua +++ b/druid/editor_scripts/assign_layers.lua @@ -1,7 +1,7 @@ --- Module for assigning layers to GUI nodes based on textures and fonts 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 = {} diff --git a/druid/editor_scripts/create_druid_gui_script.lua b/druid/editor_scripts/create_druid_gui_script.lua index 1807bbb..0bbb701 100644 --- a/druid/editor_scripts/create_druid_gui_script.lua +++ b/druid/editor_scripts/create_druid_gui_script.lua @@ -65,7 +65,7 @@ end ---@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 system = require("druid.editor_scripts.defold_parser.system.parser_internal") local gui_filepath = editor.get(selection, "path") print("Linking GUI script to", gui_filepath) diff --git a/druid/editor_scripts/defold_parser/defold_parser.lua b/druid/editor_scripts/defold_parser/defold_parser.lua index e0d257d..227d6ad 100644 --- a/druid/editor_scripts/defold_parser/defold_parser.lua +++ b/druid/editor_scripts/defold_parser/defold_parser.lua @@ -1,7 +1,7 @@ --- Defold Text Proto format encoder/decoder to lua table 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 = {} @@ -17,7 +17,7 @@ function M.decode_defold_object(text) -- For each line in the text, we go through the following steps: for raw_line in text:gmatch("[^\r\n]+") do - system.parse_line(raw_line, stack) + parser_internal.parse_line(raw_line, stack) end return root @@ -39,8 +39,8 @@ function M.encode_defold_object(obj, spaces, data_level, extension) end table.sort(keys, function(a, b) - local index_a = system.contains(key_order, a) or 0 - local index_b = system.contains(key_order, b) or 0 + local index_a = parser_internal.contains(key_order, a) or 0 + local index_b = parser_internal.contains(key_order, b) or 0 return index_a < index_b end) @@ -63,7 +63,7 @@ function M.encode_defold_object(obj, spaces, data_level, extension) result = result .. tabString .. key .. ': "' .. encodedChild .. '"\n' elseif item_type == "number" or item_type == "boolean" then 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' else 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) if value_type == "number" or value_type == "boolean" then 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' else result = result .. tabString .. key .. ': ' .. tostring(value) .. '\n' @@ -125,7 +125,7 @@ end ---@param file_path string ---@return table|nil, string|nil 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 return nil, reason 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) - return system.write_file(file_path, encoded_object) + return parser_internal.write_file(file_path, encoded_object) end diff --git a/druid/editor_scripts/defold_parser/system/system.lua b/druid/editor_scripts/defold_parser/system/parser_internal.lua similarity index 100% rename from druid/editor_scripts/defold_parser/system/system.lua rename to druid/editor_scripts/defold_parser/system/parser_internal.lua