mirror of
https://github.com/Insality/druid
synced 2025-06-27 10:27:48 +02:00
Update
This commit is contained in:
parent
4cb16de782
commit
c7b11562d5
19
CONTRIBUTING
19
CONTRIBUTING
@ -18,7 +18,7 @@ Please, open PR against the `develop` branch. Very nice to have an issue, which
|
|||||||
|
|
||||||
You fix should contains only changes, which are related to the issue. Also please keep the code style the same!
|
You fix should contains only changes, which are related to the issue. Also please keep the code style the same!
|
||||||
|
|
||||||
Thanks <3
|
❤️ Thanks ❤️
|
||||||
|
|
||||||
## Update Documentation
|
## Update Documentation
|
||||||
|
|
||||||
@ -48,3 +48,20 @@ On your repo fork:
|
|||||||
- Test the example by running the game
|
- Test the example by running the game
|
||||||
- Create a pull request to the `develop` branch
|
- Create a pull request to the `develop` branch
|
||||||
|
|
||||||
|
|
||||||
|
## Add or Update Unit Tests
|
||||||
|
|
||||||
|
The unit tests was updated to cover more Druid's source code. So now I have more examples how to run and check some parts of the code.
|
||||||
|
|
||||||
|
In case you face issue and want to reproduce it, you also can starts from the unit tests:
|
||||||
|
|
||||||
|
All tests placed in the `/test/tests` directory.
|
||||||
|
|
||||||
|
To run tests you need to set the bootstrap collection to `/test/test.collection` and run it.
|
||||||
|
|
||||||
|
So the flow will be the similar:
|
||||||
|
|
||||||
|
- Create a new branch for your changes
|
||||||
|
- Make your changes and commit them
|
||||||
|
- Push your changes to your fork
|
||||||
|
- Create a pull request to the Druid repository `develop` branch
|
||||||
|
@ -107,9 +107,16 @@ end
|
|||||||
|
|
||||||
|
|
||||||
---Set current component nodes, returned from `gui.clone_tree` function.
|
---Set current component nodes, returned from `gui.clone_tree` function.
|
||||||
---@param nodes table<hash, node>
|
---@param nodes table<hash, node>|node|string|nil The nodes table from gui.clone_tree or prefab node to use for clone or node id to clone
|
||||||
---@return druid.component
|
---@return druid.component
|
||||||
function M:set_nodes(nodes)
|
function M:set_nodes(nodes)
|
||||||
|
if type(nodes) == "string" then
|
||||||
|
nodes = self:get_node(nodes)
|
||||||
|
end
|
||||||
|
if type(nodes) == "userdata" then
|
||||||
|
nodes = gui.clone_tree(nodes) --[[@as table<hash, node>]]
|
||||||
|
end
|
||||||
|
|
||||||
self._meta.nodes = nodes
|
self._meta.nodes = nodes
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -132,7 +139,7 @@ end
|
|||||||
|
|
||||||
---Get Druid instance for inner component creation.
|
---Get Druid instance for inner component creation.
|
||||||
---@param template string|nil
|
---@param template string|nil
|
||||||
---@param nodes table<hash, node>|nil
|
---@param nodes table<hash, node>|node|string|nil The nodes table from gui.clone_tree or prefab node to use for clone or node id to clone
|
||||||
---@return druid.instance
|
---@return druid.instance
|
||||||
function M:get_druid(template, nodes)
|
function M:get_druid(template, nodes)
|
||||||
local druid_instance = setmetatable({
|
local druid_instance = setmetatable({
|
||||||
@ -396,7 +403,11 @@ function M.create_widget(self, widget_class, context)
|
|||||||
default_input_priority = const.PRIORITY_INPUT,
|
default_input_priority = const.PRIORITY_INPUT,
|
||||||
_is_input_priority_changed = true, -- Default true for sort once time after GUI init
|
_is_input_priority_changed = true, -- Default true for sort once time after GUI init
|
||||||
}
|
}
|
||||||
instance._meta = {
|
|
||||||
|
-- I'll hide a meta fields under metatable to hide this tables from pprint output
|
||||||
|
-- cause it's leads to recursive pprint's from (druid = self)
|
||||||
|
-- Wish this to be better, since it can reduce a memory usage
|
||||||
|
instance._meta = setmetatable({}, { __index = {
|
||||||
druid = self,
|
druid = self,
|
||||||
template = "",
|
template = "",
|
||||||
nodes = nil,
|
nodes = nil,
|
||||||
@ -406,7 +417,7 @@ function M.create_widget(self, widget_class, context)
|
|||||||
children = {},
|
children = {},
|
||||||
parent = type(context) ~= "userdata" and context or nil,
|
parent = type(context) ~= "userdata" and context or nil,
|
||||||
instance_class = widget_class
|
instance_class = widget_class
|
||||||
}
|
}})
|
||||||
|
|
||||||
-- Register
|
-- Register
|
||||||
if instance._meta.parent then
|
if instance._meta.parent then
|
||||||
|
@ -33,9 +33,17 @@ end
|
|||||||
---@param name string Module name
|
---@param name string Module name
|
||||||
---@param module table Lua table with component
|
---@param module table Lua table with component
|
||||||
function M.register(name, module)
|
function M.register(name, module)
|
||||||
|
local is_custom_component = getmetatable(module) ~= nil
|
||||||
|
if is_custom_component then
|
||||||
druid_instance["new_" .. name] = function(self, ...)
|
druid_instance["new_" .. name] = function(self, ...)
|
||||||
return druid_instance.new(self, module, ...)
|
return druid_instance.new(self, module, ...)
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
-- Just for some compatability. But better to use direct druid_instance:new_widget(module, ...) function
|
||||||
|
druid_instance["new_" .. name] = function(self, template, nodes, ...)
|
||||||
|
return druid_instance.new_widget(self, module, template, nodes, ...)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -494,13 +494,6 @@ end
|
|||||||
function M:new_widget(widget, template, nodes, ...)
|
function M:new_widget(widget, template, nodes, ...)
|
||||||
local instance = create_widget(self, widget)
|
local instance = create_widget(self, widget)
|
||||||
|
|
||||||
if type(nodes) == "string" then
|
|
||||||
nodes = gui.get_node(nodes)
|
|
||||||
end
|
|
||||||
if type(nodes) == "userdata" then
|
|
||||||
nodes = gui.clone_tree(nodes) --[[@as table<hash, node>]]
|
|
||||||
end
|
|
||||||
|
|
||||||
instance.druid = instance:get_druid(template, nodes)
|
instance.druid = instance:get_druid(template, nodes)
|
||||||
|
|
||||||
if instance.init then
|
if instance.init then
|
||||||
|
@ -16,7 +16,7 @@ function M.get_examples()
|
|||||||
information_text_id = "ui_example_widget_properties_panel_description",
|
information_text_id = "ui_example_widget_properties_panel_description",
|
||||||
template = "properties_panel",
|
template = "properties_panel",
|
||||||
root = "properties_panel/root",
|
root = "properties_panel/root",
|
||||||
code_url = "example/examples/widgets/properties_panel/properties_panel.lua",
|
code_url = "example/examples/widgets/examples_list.lua",
|
||||||
widget_class = require("druid.widget.properties_panel.properties_panel"),
|
widget_class = require("druid.widget.properties_panel.properties_panel"),
|
||||||
on_create = function(instance, output_list)
|
on_create = function(instance, output_list)
|
||||||
---@cast instance druid.widget.properties_panel
|
---@cast instance druid.widget.properties_panel
|
||||||
@ -96,7 +96,7 @@ function M.get_examples()
|
|||||||
information_text_id = "ui_example_widget_property_input_description",
|
information_text_id = "ui_example_widget_property_input_description",
|
||||||
template = "property_input",
|
template = "property_input",
|
||||||
root = "property_input/root",
|
root = "property_input/root",
|
||||||
code_url = "druid/widget/properties_panel/properties/property_input.lua",
|
code_url = "example/examples/widgets/examples_list.lua",
|
||||||
widget_class = require("druid.widget.properties_panel.properties.property_input"),
|
widget_class = require("druid.widget.properties_panel.properties.property_input"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -7,12 +7,8 @@ embedded_instances {
|
|||||||
" component: \"/example/examples/widgets/go_widgets/go_widget.gui\"\n"
|
" component: \"/example/examples/widgets/go_widgets/go_widget.gui\"\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"components {\n"
|
"components {\n"
|
||||||
" id: \"go_bindings\"\n"
|
" id: \"go_with_widget\"\n"
|
||||||
" component: \"/example/examples/widgets/go_widgets/go_widget.script\"\n"
|
" component: \"/example/examples/widgets/go_widgets/go_with_widget.script\"\n"
|
||||||
"}\n"
|
|
||||||
"components {\n"
|
|
||||||
" id: \"druid\"\n"
|
|
||||||
" component: \"/druid/druid.script\"\n"
|
|
||||||
"}\n"
|
"}\n"
|
||||||
"embedded_components {\n"
|
"embedded_components {\n"
|
||||||
" id: \"sprite\"\n"
|
" id: \"sprite\"\n"
|
@ -1,6 +1,6 @@
|
|||||||
local panthera = require("panthera.panthera")
|
local panthera = require("panthera.panthera")
|
||||||
|
|
||||||
local animation = require("example.examples.widgets.go_widgets.go_bindings_panthera")
|
local animation = require("example.examples.widgets.go_widgets.go_with_widget_panthera")
|
||||||
|
|
||||||
local druid = require("druid.druid")
|
local druid = require("druid.druid")
|
||||||
local widget = require("example.examples.widgets.go_widgets.go_widget")
|
local widget = require("example.examples.widgets.go_widgets.go_widget")
|
||||||
@ -8,6 +8,7 @@ local widget = require("example.examples.widgets.go_widgets.go_widget")
|
|||||||
function init(self)
|
function init(self)
|
||||||
local gui_url = msg.url(nil, nil, "go_widget")
|
local gui_url = msg.url(nil, nil, "go_widget")
|
||||||
self.go_widget = druid.get_widget(widget, gui_url)
|
self.go_widget = druid.get_widget(widget, gui_url)
|
||||||
|
|
||||||
self.go_widget:play_animation()
|
self.go_widget:play_animation()
|
||||||
self.go_widget:set_position(go.get_position())
|
self.go_widget:set_position(go.get_position())
|
||||||
|
|
@ -89,7 +89,7 @@ return {
|
|||||||
fps = 60,
|
fps = 60,
|
||||||
gizmo_steps = {
|
gizmo_steps = {
|
||||||
},
|
},
|
||||||
gui_path = "/example/examples/widgets/go_widgets/go_widget.collection",
|
gui_path = "/example/examples/widgets/go_widgets/go_with_widget.collection",
|
||||||
layers = {
|
layers = {
|
||||||
},
|
},
|
||||||
settings = {
|
settings = {
|
Loading…
x
Reference in New Issue
Block a user