mirror of
https://github.com/Insality/druid
synced 2025-06-27 18:37:45 +02:00
Merge pull request #128 from Insality/117-update-examples
117 update examples
This commit is contained in:
commit
c27ba03a77
@ -26,10 +26,11 @@ local DataList = component.create("data_list")
|
|||||||
|
|
||||||
|
|
||||||
--- Data list constructor
|
--- Data list constructor
|
||||||
-- @tparam Scroll self
|
-- @tparam DataList self
|
||||||
-- @tparam node view_node GUI view scroll node
|
-- @tparam druid.scroll The Scroll instance for Data List component
|
||||||
-- @tparam node content_node GUI content scroll node
|
-- @tparam druid.grid The Grid instance for Data List component
|
||||||
function DataList.init(self, data, scroll, grid, create_function)
|
-- @tparam function create_function The create function callback(data, index). Function should return (node, [component])
|
||||||
|
function DataList.init(self, scroll, grid, create_function)
|
||||||
self.druid = self:get_druid()
|
self.druid = self:get_druid()
|
||||||
self.scroll = scroll
|
self.scroll = scroll
|
||||||
self.grid = grid
|
self.grid = grid
|
||||||
@ -47,8 +48,6 @@ function DataList.init(self, data, scroll, grid, create_function)
|
|||||||
self._data_visual = {}
|
self._data_visual = {}
|
||||||
|
|
||||||
self.scroll.on_scroll:subscribe(self._check_elements, self)
|
self.scroll.on_scroll:subscribe(self._check_elements, self)
|
||||||
|
|
||||||
self:set_data(data)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -62,10 +61,13 @@ end
|
|||||||
--- Set new data set for DataList component
|
--- Set new data set for DataList component
|
||||||
-- @tparam DataList self
|
-- @tparam DataList self
|
||||||
-- @tparam table data The new data array
|
-- @tparam table data The new data array
|
||||||
|
-- @treturn druid.data_list Current DataList instance
|
||||||
function DataList.set_data(self, data)
|
function DataList.set_data(self, data)
|
||||||
self._data = data
|
self._data = data or {}
|
||||||
self:_update_data_info()
|
self:_update_data_info()
|
||||||
self:_refresh()
|
self:_refresh()
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
619
example/example.collection
Normal file
619
example/example.collection
Normal file
@ -0,0 +1,619 @@
|
|||||||
|
name: "example"
|
||||||
|
scale_along_z: 0
|
||||||
|
embedded_instances {
|
||||||
|
id: "gui"
|
||||||
|
data: "components {\n"
|
||||||
|
" id: \"main\"\n"
|
||||||
|
" component: \"/example/example.gui\"\n"
|
||||||
|
" position {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" }\n"
|
||||||
|
" rotation {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" w: 1.0\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n"
|
||||||
|
""
|
||||||
|
position {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
}
|
||||||
|
rotation {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
w: 1.0
|
||||||
|
}
|
||||||
|
scale3 {
|
||||||
|
x: 1.0
|
||||||
|
y: 1.0
|
||||||
|
z: 1.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
embedded_instances {
|
||||||
|
id: "system"
|
||||||
|
data: "components {\n"
|
||||||
|
" id: \"init\"\n"
|
||||||
|
" component: \"/example/init.script\"\n"
|
||||||
|
" position {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" }\n"
|
||||||
|
" rotation {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" w: 1.0\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n"
|
||||||
|
""
|
||||||
|
position {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
}
|
||||||
|
rotation {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
w: 1.0
|
||||||
|
}
|
||||||
|
scale3 {
|
||||||
|
x: 1.0
|
||||||
|
y: 1.0
|
||||||
|
z: 1.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
embedded_instances {
|
||||||
|
id: "sound"
|
||||||
|
data: "embedded_components {\n"
|
||||||
|
" id: \"click\"\n"
|
||||||
|
" type: \"sound\"\n"
|
||||||
|
" data: \"sound: \\\"/example/assets/sounds/click.ogg\\\"\\n"
|
||||||
|
"looping: 0\\n"
|
||||||
|
"group: \\\"master\\\"\\n"
|
||||||
|
"gain: 1.0\\n"
|
||||||
|
"pan: 0.0\\n"
|
||||||
|
"speed: 1.0\\n"
|
||||||
|
"loopcount: 0\\n"
|
||||||
|
"\"\n"
|
||||||
|
" position {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" }\n"
|
||||||
|
" rotation {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" w: 1.0\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n"
|
||||||
|
""
|
||||||
|
position {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
}
|
||||||
|
rotation {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
w: 1.0
|
||||||
|
}
|
||||||
|
scale3 {
|
||||||
|
x: 1.0
|
||||||
|
y: 1.0
|
||||||
|
z: 1.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
embedded_instances {
|
||||||
|
id: "general_overview"
|
||||||
|
data: "components {\n"
|
||||||
|
" id: \"screen_factory\"\n"
|
||||||
|
" component: \"/monarch/screen_factory.script\"\n"
|
||||||
|
" position {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" }\n"
|
||||||
|
" rotation {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" w: 1.0\n"
|
||||||
|
" }\n"
|
||||||
|
" properties {\n"
|
||||||
|
" id: \"screen_id\"\n"
|
||||||
|
" value: \"general_overview\"\n"
|
||||||
|
" type: PROPERTY_TYPE_HASH\n"
|
||||||
|
" }\n"
|
||||||
|
" properties {\n"
|
||||||
|
" id: \"popup\"\n"
|
||||||
|
" value: \"true\"\n"
|
||||||
|
" type: PROPERTY_TYPE_BOOLEAN\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n"
|
||||||
|
"embedded_components {\n"
|
||||||
|
" id: \"collectionfactory\"\n"
|
||||||
|
" type: \"collectionfactory\"\n"
|
||||||
|
" data: \"prototype: \\\"/example/examples/general/overview/overview.collection\\\"\\n"
|
||||||
|
"load_dynamically: false\\n"
|
||||||
|
"\"\n"
|
||||||
|
" position {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" }\n"
|
||||||
|
" rotation {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" w: 1.0\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n"
|
||||||
|
""
|
||||||
|
position {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
}
|
||||||
|
rotation {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
w: 1.0
|
||||||
|
}
|
||||||
|
scale3 {
|
||||||
|
x: 1.0
|
||||||
|
y: 1.0
|
||||||
|
z: 1.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
embedded_instances {
|
||||||
|
id: "general_buttons"
|
||||||
|
data: "components {\n"
|
||||||
|
" id: \"screen_factory\"\n"
|
||||||
|
" component: \"/monarch/screen_factory.script\"\n"
|
||||||
|
" position {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" }\n"
|
||||||
|
" rotation {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" w: 1.0\n"
|
||||||
|
" }\n"
|
||||||
|
" properties {\n"
|
||||||
|
" id: \"screen_id\"\n"
|
||||||
|
" value: \"general_buttons\"\n"
|
||||||
|
" type: PROPERTY_TYPE_HASH\n"
|
||||||
|
" }\n"
|
||||||
|
" properties {\n"
|
||||||
|
" id: \"popup\"\n"
|
||||||
|
" value: \"true\"\n"
|
||||||
|
" type: PROPERTY_TYPE_BOOLEAN\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n"
|
||||||
|
"embedded_components {\n"
|
||||||
|
" id: \"collectionfactory\"\n"
|
||||||
|
" type: \"collectionfactory\"\n"
|
||||||
|
" data: \"prototype: \\\"/example/examples/general/buttons/buttons.collection\\\"\\n"
|
||||||
|
"load_dynamically: false\\n"
|
||||||
|
"\"\n"
|
||||||
|
" position {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" }\n"
|
||||||
|
" rotation {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" w: 1.0\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n"
|
||||||
|
""
|
||||||
|
position {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
}
|
||||||
|
rotation {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
w: 1.0
|
||||||
|
}
|
||||||
|
scale3 {
|
||||||
|
x: 1.0
|
||||||
|
y: 1.0
|
||||||
|
z: 1.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
embedded_instances {
|
||||||
|
id: "general_texts"
|
||||||
|
data: "components {\n"
|
||||||
|
" id: \"screen_factory\"\n"
|
||||||
|
" component: \"/monarch/screen_factory.script\"\n"
|
||||||
|
" position {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" }\n"
|
||||||
|
" rotation {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" w: 1.0\n"
|
||||||
|
" }\n"
|
||||||
|
" properties {\n"
|
||||||
|
" id: \"screen_id\"\n"
|
||||||
|
" value: \"general_texts\"\n"
|
||||||
|
" type: PROPERTY_TYPE_HASH\n"
|
||||||
|
" }\n"
|
||||||
|
" properties {\n"
|
||||||
|
" id: \"popup\"\n"
|
||||||
|
" value: \"true\"\n"
|
||||||
|
" type: PROPERTY_TYPE_BOOLEAN\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n"
|
||||||
|
"embedded_components {\n"
|
||||||
|
" id: \"collectionfactory\"\n"
|
||||||
|
" type: \"collectionfactory\"\n"
|
||||||
|
" data: \"prototype: \\\"/example/examples/general/texts/texts.collection\\\"\\n"
|
||||||
|
"load_dynamically: false\\n"
|
||||||
|
"\"\n"
|
||||||
|
" position {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" }\n"
|
||||||
|
" rotation {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" w: 1.0\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n"
|
||||||
|
""
|
||||||
|
position {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
}
|
||||||
|
rotation {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
w: 1.0
|
||||||
|
}
|
||||||
|
scale3 {
|
||||||
|
x: 1.0
|
||||||
|
y: 1.0
|
||||||
|
z: 1.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
embedded_instances {
|
||||||
|
id: "general_sliders"
|
||||||
|
data: "components {\n"
|
||||||
|
" id: \"screen_factory\"\n"
|
||||||
|
" component: \"/monarch/screen_factory.script\"\n"
|
||||||
|
" position {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" }\n"
|
||||||
|
" rotation {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" w: 1.0\n"
|
||||||
|
" }\n"
|
||||||
|
" properties {\n"
|
||||||
|
" id: \"screen_id\"\n"
|
||||||
|
" value: \"general_sliders\"\n"
|
||||||
|
" type: PROPERTY_TYPE_HASH\n"
|
||||||
|
" }\n"
|
||||||
|
" properties {\n"
|
||||||
|
" id: \"popup\"\n"
|
||||||
|
" value: \"true\"\n"
|
||||||
|
" type: PROPERTY_TYPE_BOOLEAN\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n"
|
||||||
|
"embedded_components {\n"
|
||||||
|
" id: \"collectionfactory\"\n"
|
||||||
|
" type: \"collectionfactory\"\n"
|
||||||
|
" data: \"prototype: \\\"/example/examples/general/sliders/sliders.collection\\\"\\n"
|
||||||
|
"load_dynamically: false\\n"
|
||||||
|
"\"\n"
|
||||||
|
" position {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" }\n"
|
||||||
|
" rotation {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" w: 1.0\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n"
|
||||||
|
""
|
||||||
|
position {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
}
|
||||||
|
rotation {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
w: 1.0
|
||||||
|
}
|
||||||
|
scale3 {
|
||||||
|
x: 1.0
|
||||||
|
y: 1.0
|
||||||
|
z: 1.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
embedded_instances {
|
||||||
|
id: "general_grid"
|
||||||
|
data: "components {\n"
|
||||||
|
" id: \"screen_factory\"\n"
|
||||||
|
" component: \"/monarch/screen_factory.script\"\n"
|
||||||
|
" position {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" }\n"
|
||||||
|
" rotation {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" w: 1.0\n"
|
||||||
|
" }\n"
|
||||||
|
" properties {\n"
|
||||||
|
" id: \"screen_id\"\n"
|
||||||
|
" value: \"general_grid\"\n"
|
||||||
|
" type: PROPERTY_TYPE_HASH\n"
|
||||||
|
" }\n"
|
||||||
|
" properties {\n"
|
||||||
|
" id: \"popup\"\n"
|
||||||
|
" value: \"true\"\n"
|
||||||
|
" type: PROPERTY_TYPE_BOOLEAN\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n"
|
||||||
|
"embedded_components {\n"
|
||||||
|
" id: \"collectionfactory\"\n"
|
||||||
|
" type: \"collectionfactory\"\n"
|
||||||
|
" data: \"prototype: \\\"/example/examples/general/grid/grid.collection\\\"\\n"
|
||||||
|
"load_dynamically: false\\n"
|
||||||
|
"\"\n"
|
||||||
|
" position {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" }\n"
|
||||||
|
" rotation {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" w: 1.0\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n"
|
||||||
|
""
|
||||||
|
position {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
}
|
||||||
|
rotation {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
w: 1.0
|
||||||
|
}
|
||||||
|
scale3 {
|
||||||
|
x: 1.0
|
||||||
|
y: 1.0
|
||||||
|
z: 1.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
embedded_instances {
|
||||||
|
id: "general_input"
|
||||||
|
data: "components {\n"
|
||||||
|
" id: \"screen_factory\"\n"
|
||||||
|
" component: \"/monarch/screen_factory.script\"\n"
|
||||||
|
" position {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" }\n"
|
||||||
|
" rotation {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" w: 1.0\n"
|
||||||
|
" }\n"
|
||||||
|
" properties {\n"
|
||||||
|
" id: \"screen_id\"\n"
|
||||||
|
" value: \"general_input\"\n"
|
||||||
|
" type: PROPERTY_TYPE_HASH\n"
|
||||||
|
" }\n"
|
||||||
|
" properties {\n"
|
||||||
|
" id: \"popup\"\n"
|
||||||
|
" value: \"true\"\n"
|
||||||
|
" type: PROPERTY_TYPE_BOOLEAN\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n"
|
||||||
|
"embedded_components {\n"
|
||||||
|
" id: \"collectionfactory\"\n"
|
||||||
|
" type: \"collectionfactory\"\n"
|
||||||
|
" data: \"prototype: \\\"/example/examples/general/input/input.collection\\\"\\n"
|
||||||
|
"load_dynamically: false\\n"
|
||||||
|
"\"\n"
|
||||||
|
" position {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" }\n"
|
||||||
|
" rotation {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" w: 1.0\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n"
|
||||||
|
""
|
||||||
|
position {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
}
|
||||||
|
rotation {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
w: 1.0
|
||||||
|
}
|
||||||
|
scale3 {
|
||||||
|
x: 1.0
|
||||||
|
y: 1.0
|
||||||
|
z: 1.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
embedded_instances {
|
||||||
|
id: "general_scroll"
|
||||||
|
data: "components {\n"
|
||||||
|
" id: \"screen_factory\"\n"
|
||||||
|
" component: \"/monarch/screen_factory.script\"\n"
|
||||||
|
" position {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" }\n"
|
||||||
|
" rotation {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" w: 1.0\n"
|
||||||
|
" }\n"
|
||||||
|
" properties {\n"
|
||||||
|
" id: \"screen_id\"\n"
|
||||||
|
" value: \"general_scroll\"\n"
|
||||||
|
" type: PROPERTY_TYPE_HASH\n"
|
||||||
|
" }\n"
|
||||||
|
" properties {\n"
|
||||||
|
" id: \"popup\"\n"
|
||||||
|
" value: \"true\"\n"
|
||||||
|
" type: PROPERTY_TYPE_BOOLEAN\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n"
|
||||||
|
"embedded_components {\n"
|
||||||
|
" id: \"collectionfactory\"\n"
|
||||||
|
" type: \"collectionfactory\"\n"
|
||||||
|
" data: \"prototype: \\\"/example/examples/general/scroll/scroll.collection\\\"\\n"
|
||||||
|
"load_dynamically: false\\n"
|
||||||
|
"\"\n"
|
||||||
|
" position {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" }\n"
|
||||||
|
" rotation {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" w: 1.0\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n"
|
||||||
|
""
|
||||||
|
position {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
}
|
||||||
|
rotation {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
w: 1.0
|
||||||
|
}
|
||||||
|
scale3 {
|
||||||
|
x: 1.0
|
||||||
|
y: 1.0
|
||||||
|
z: 1.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
embedded_instances {
|
||||||
|
id: "general_data_list"
|
||||||
|
data: "components {\n"
|
||||||
|
" id: \"screen_factory\"\n"
|
||||||
|
" component: \"/monarch/screen_factory.script\"\n"
|
||||||
|
" position {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" }\n"
|
||||||
|
" rotation {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" w: 1.0\n"
|
||||||
|
" }\n"
|
||||||
|
" properties {\n"
|
||||||
|
" id: \"screen_id\"\n"
|
||||||
|
" value: \"general_data_list\"\n"
|
||||||
|
" type: PROPERTY_TYPE_HASH\n"
|
||||||
|
" }\n"
|
||||||
|
" properties {\n"
|
||||||
|
" id: \"popup\"\n"
|
||||||
|
" value: \"true\"\n"
|
||||||
|
" type: PROPERTY_TYPE_BOOLEAN\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n"
|
||||||
|
"embedded_components {\n"
|
||||||
|
" id: \"collectionfactory\"\n"
|
||||||
|
" type: \"collectionfactory\"\n"
|
||||||
|
" data: \"prototype: \\\"/example/examples/general/data_list/data_list.collection\\\"\\n"
|
||||||
|
"load_dynamically: false\\n"
|
||||||
|
"\"\n"
|
||||||
|
" position {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" }\n"
|
||||||
|
" rotation {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" w: 1.0\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n"
|
||||||
|
""
|
||||||
|
position {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
}
|
||||||
|
rotation {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
w: 1.0
|
||||||
|
}
|
||||||
|
scale3 {
|
||||||
|
x: 1.0
|
||||||
|
y: 1.0
|
||||||
|
z: 1.0
|
||||||
|
}
|
||||||
|
}
|
1153
example/example.gui
Normal file
1153
example/example.gui
Normal file
File diff suppressed because it is too large
Load Diff
155
example/example.gui_script
Normal file
155
example/example.gui_script
Normal file
@ -0,0 +1,155 @@
|
|||||||
|
---@type druid
|
||||||
|
local druid = require("druid.druid")
|
||||||
|
local monarch = require("monarch.monarch")
|
||||||
|
local default_style = require("druid.styles.default.style")
|
||||||
|
|
||||||
|
local function back_to_lobby(self)
|
||||||
|
if gui.set_enabled(self.button_menu.node) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
monarch.back()
|
||||||
|
gui.set_enabled(gui.get_node("C_Anchor"), true)
|
||||||
|
gui.set_enabled(self.button_menu.node, false)
|
||||||
|
|
||||||
|
self.text_header:set_to("Druid")
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function show_scene(self, scene_name, text_header)
|
||||||
|
monarch.show(scene_name)
|
||||||
|
gui.set_enabled(gui.get_node("C_Anchor"), false)
|
||||||
|
gui.set_enabled(self.button_menu.node, true)
|
||||||
|
|
||||||
|
self.text_header:set_to(text_header)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function init_top_panel(self)
|
||||||
|
self.druid:new_blocker("panel_top")
|
||||||
|
|
||||||
|
self.button_menu = self.druid:new_button("button_menu/button", back_to_lobby)
|
||||||
|
self.druid:new_back_handler(back_to_lobby)
|
||||||
|
gui.set_enabled(self.button_menu.node, false)
|
||||||
|
|
||||||
|
self.button_api = self.druid:new_button("button_api/button", sys.open_url, "https://insality.github.io/druid/")
|
||||||
|
|
||||||
|
self.text_header = self.druid:new_text("text_header", "Druid")
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function on_window_callback(self, event, data)
|
||||||
|
druid.on_window_callback(event, data)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function get_title(self, text)
|
||||||
|
local prefab = gui.get_node("prefab_header")
|
||||||
|
local nodes = gui.clone_tree(prefab)
|
||||||
|
local root = nodes["prefab_header"]
|
||||||
|
gui.set_enabled(root, true)
|
||||||
|
gui.set_text(nodes["prefab_text"], text)
|
||||||
|
return root
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function get_button(self, text, scene_name)
|
||||||
|
local prefab = gui.get_node("prefab_button")
|
||||||
|
local nodes = gui.clone_tree(prefab)
|
||||||
|
local root = nodes["prefab_button"]
|
||||||
|
gui.set_enabled(root, true)
|
||||||
|
self.druid:new_button(root, function()
|
||||||
|
show_scene(self, scene_name, text)
|
||||||
|
end)
|
||||||
|
:set_click_zone(self.lobby_scroll.view_node)
|
||||||
|
gui.set_text(nodes["text_button_lobby"], text)
|
||||||
|
|
||||||
|
return root
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function get_button_disabled(self, text)
|
||||||
|
local prefab = gui.get_node("prefab_button")
|
||||||
|
local nodes = gui.clone_tree(prefab)
|
||||||
|
local root = nodes["prefab_button"]
|
||||||
|
gui.play_flipbook(nodes["icon_button"], "back_gray")
|
||||||
|
gui.set_enabled(root, true)
|
||||||
|
gui.set_text(nodes["text_button_lobby"], text)
|
||||||
|
|
||||||
|
return root
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function init_lobby(self)
|
||||||
|
gui.set_enabled(gui.get_node("prefabs"), false)
|
||||||
|
|
||||||
|
self.lobby_scroll = self.druid:new_scroll("lobby_view", "lobby_content")
|
||||||
|
self.lobby_grid = self.druid:new_dynamic_grid("lobby_content")
|
||||||
|
self.lobby_scroll:bind_grid(self.lobby_grid)
|
||||||
|
|
||||||
|
self.lobby_grid:add(get_title(self, "General examples"))
|
||||||
|
self.lobby_grid:add(get_button(self, "Overview", "general_overview"))
|
||||||
|
self.lobby_grid:add(get_button(self, "Buttons", "general_buttons"))
|
||||||
|
self.lobby_grid:add(get_button(self, "Texts", "general_texts"))
|
||||||
|
self.lobby_grid:add(get_button_disabled(self, "Lang Text", "scene_name"))
|
||||||
|
self.lobby_grid:add(get_button(self, "Sliders", "general_sliders"))
|
||||||
|
self.lobby_grid:add(get_button(self, "Scrolls", "general_scroll"))
|
||||||
|
self.lobby_grid:add(get_button(self, "Grids", "general_grid"))
|
||||||
|
self.lobby_grid:add(get_button_disabled(self, "Progress Bar", "scene_name"))
|
||||||
|
self.lobby_grid:add(get_button(self, "Data List", "general_data_list"))
|
||||||
|
self.lobby_grid:add(get_button_disabled(self, "Checkboxes", "scene_name"))
|
||||||
|
self.lobby_grid:add(get_button(self, "Input text", "general_input"))
|
||||||
|
self.lobby_grid:add(get_button_disabled(self, "Swipe", "scene_name"))
|
||||||
|
self.lobby_grid:add(get_button_disabled(self, "Drag", "scene_name"))
|
||||||
|
|
||||||
|
self.lobby_grid:add(get_title(self, "Scrolls"))
|
||||||
|
self.lobby_grid:add(get_button_disabled(self, "Nested scrolls", "scroll_scene"))
|
||||||
|
self.lobby_grid:add(get_button_disabled(self, "With points of interest", "scroll_scene"))
|
||||||
|
self.lobby_grid:add(get_button_disabled(self, "Without inertion", "scroll_scene"))
|
||||||
|
|
||||||
|
self.lobby_grid:add(get_title(self, "Grids"))
|
||||||
|
self.lobby_grid:add(get_button_disabled(self, "Static grid", "scroll_scene"))
|
||||||
|
self.lobby_grid:add(get_button_disabled(self, "Dynamic grid", "scroll_scene"))
|
||||||
|
self.lobby_grid:add(get_button_disabled(self, "Scroll binding", "scroll_scene"))
|
||||||
|
|
||||||
|
self.lobby_grid:add(get_title(self, "Data list / Infinity scroll"))
|
||||||
|
self.lobby_grid:add(get_button_disabled(self, "With static grid", "scroll_scene"))
|
||||||
|
self.lobby_grid:add(get_button_disabled(self, "With dynamic grid", "scroll_scene"))
|
||||||
|
self.lobby_grid:add(get_button_disabled(self, "Add/remove elements", "scroll_scene"))
|
||||||
|
self.lobby_grid:add(get_button_disabled(self, "Navigate over elements", "scroll_scene"))
|
||||||
|
|
||||||
|
self.lobby_grid:add(get_title(self, "System"))
|
||||||
|
self.lobby_grid:add(get_button_disabled(self, "Styles"))
|
||||||
|
self.lobby_grid:add(get_button_disabled(self, "Custom components"))
|
||||||
|
self.lobby_grid:add(get_button_disabled(self, "Component interests"))
|
||||||
|
self.lobby_grid:add(get_button_disabled(self, "Nested Druids"))
|
||||||
|
self.lobby_grid:add(get_button_disabled(self, "Input priority"))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function init(self)
|
||||||
|
-- Main lobby have more render priority (top panel)
|
||||||
|
gui.set_render_order(10)
|
||||||
|
|
||||||
|
window.set_listener(on_window_callback)
|
||||||
|
druid.set_default_style(default_style)
|
||||||
|
self.druid = druid.new(self)
|
||||||
|
|
||||||
|
init_top_panel(self)
|
||||||
|
init_lobby(self)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function update(self, dt)
|
||||||
|
self.druid:update(dt)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function on_message(self, message_id, message, sender)
|
||||||
|
self.druid:on_message(message_id, message, sender)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function on_input(self, action_id, action)
|
||||||
|
self.druid:on_input(action_id, action)
|
||||||
|
end
|
37
example/examples/general/buttons/buttons.collection
Normal file
37
example/examples/general/buttons/buttons.collection
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
name: "buttons"
|
||||||
|
scale_along_z: 0
|
||||||
|
embedded_instances {
|
||||||
|
id: "go"
|
||||||
|
data: "components {\n"
|
||||||
|
" id: \"buttons\"\n"
|
||||||
|
" component: \"/example/examples/general/buttons/buttons.gui\"\n"
|
||||||
|
" position {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" }\n"
|
||||||
|
" rotation {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" w: 1.0\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n"
|
||||||
|
""
|
||||||
|
position {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
}
|
||||||
|
rotation {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
w: 1.0
|
||||||
|
}
|
||||||
|
scale3 {
|
||||||
|
x: 1.0
|
||||||
|
y: 1.0
|
||||||
|
z: 1.0
|
||||||
|
}
|
||||||
|
}
|
1315
example/examples/general/buttons/buttons.gui
Normal file
1315
example/examples/general/buttons/buttons.gui
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,24 +1,27 @@
|
|||||||
|
local druid = require("druid.druid")
|
||||||
local sprite_style = require("druid.styles.sprites.style")
|
local sprite_style = require("druid.styles.sprites.style")
|
||||||
|
|
||||||
local M = {}
|
|
||||||
|
|
||||||
|
|
||||||
local function usual_callback()
|
local function usual_callback()
|
||||||
print("Usual callback")
|
print("Usual callback")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function long_tap_callback(self, params, button, hold_time)
|
local function long_tap_callback(self, params, button, hold_time)
|
||||||
print("Long tap callback", hold_time)
|
print("Long tap callback", hold_time)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function hold_callback(self, params, button, hold_time)
|
local function hold_callback(self, params, button, hold_time)
|
||||||
print("On hold callback", hold_time)
|
print("On hold callback", hold_time)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function repeated_callback(self, params, button, click_in_row)
|
local function repeated_callback(self, params, button, click_in_row)
|
||||||
print("Repeated callback", click_in_row)
|
print("Repeated callback", click_in_row)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function double_tap_callback(self, params, button, click_in_row)
|
local function double_tap_callback(self, params, button, click_in_row)
|
||||||
print("Double tap callback", click_in_row)
|
print("Double tap callback", click_in_row)
|
||||||
end
|
end
|
||||||
@ -48,9 +51,27 @@ local function setup_buttons(self)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function M.setup_page(self)
|
function init(self)
|
||||||
|
self.druid = druid.new(self)
|
||||||
setup_buttons(self)
|
setup_buttons(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return M
|
function final(self)
|
||||||
|
self.druid:final()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function update(self, dt)
|
||||||
|
self.druid:update(dt)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function on_message(self, message_id, message, sender)
|
||||||
|
self.druid:on_message(message_id, message, sender)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function on_input(self, action_id, action)
|
||||||
|
return self.druid:on_input(action_id, action)
|
||||||
|
end
|
37
example/examples/general/data_list/data_list.collection
Normal file
37
example/examples/general/data_list/data_list.collection
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
name: "data_list"
|
||||||
|
scale_along_z: 0
|
||||||
|
embedded_instances {
|
||||||
|
id: "go"
|
||||||
|
data: "components {\n"
|
||||||
|
" id: \"data_list\"\n"
|
||||||
|
" component: \"/example/examples/general/data_list/data_list.gui\"\n"
|
||||||
|
" position {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" }\n"
|
||||||
|
" rotation {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" w: 1.0\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n"
|
||||||
|
""
|
||||||
|
position {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
}
|
||||||
|
rotation {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
w: 1.0
|
||||||
|
}
|
||||||
|
scale3 {
|
||||||
|
x: 1.0
|
||||||
|
y: 1.0
|
||||||
|
z: 1.0
|
||||||
|
}
|
||||||
|
}
|
1260
example/examples/general/data_list/data_list.gui
Normal file
1260
example/examples/general/data_list/data_list.gui
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
|||||||
local M = {}
|
local druid = require("druid.druid")
|
||||||
|
|
||||||
|
|
||||||
local function create_infinity_instance(self, record, index)
|
local function create_infinity_instance(self, record, index)
|
||||||
@ -86,46 +86,46 @@ local function setup_infinity_list(self)
|
|||||||
table.insert(data, i)
|
table.insert(data, i)
|
||||||
end
|
end
|
||||||
|
|
||||||
self.infinity_list = self.druid:new_data_list(data, self.infinity_scroll, self.infinity_grid, function(record, index)
|
self.infinity_list = self.druid:new_data_list(self.infinity_scroll, self.infinity_grid, function(record, index)
|
||||||
-- function should return gui_node, [druid_component]
|
-- function should return gui_node, [druid_component]
|
||||||
local root, button = create_infinity_instance(self, record, index)
|
local root, button = create_infinity_instance(self, record, index)
|
||||||
button:set_click_zone(self.infinity_scroll.view_node)
|
button:set_click_zone(self.infinity_scroll.view_node)
|
||||||
return root, button
|
return root, button
|
||||||
end)
|
end):set_data(data)
|
||||||
|
|
||||||
self.infinity_list_hor = self.druid:new_data_list(data, self.infinity_scroll_hor, self.infinity_grid_hor, function(record, index)
|
self.infinity_list_hor = self.druid:new_data_list(self.infinity_scroll_hor, self.infinity_grid_hor, function(record, index)
|
||||||
-- function should return gui_node, [druid_component]
|
-- function should return gui_node, [druid_component]
|
||||||
local root, button = create_infinity_instance_hor(self, record, index)
|
local root, button = create_infinity_instance_hor(self, record, index)
|
||||||
button:set_click_zone(self.infinity_scroll_hor.view_node)
|
button:set_click_zone(self.infinity_scroll_hor.view_node)
|
||||||
return root, button
|
return root, button
|
||||||
end)
|
end):set_data(data)
|
||||||
|
|
||||||
-- scroll to some index
|
-- scroll to some index
|
||||||
-- local pos = self.infinity_grid:get_pos(25)
|
-- local pos = self.infinity_grid:get_pos(25)
|
||||||
-- self.infinity_scroll:scroll_to(pos, true)
|
-- self.infinity_scroll:scroll_to(pos, true)
|
||||||
timer.delay(1, false, function()
|
timer.delay(1, false, function()
|
||||||
self.infinity_list:scroll_to_index(25)
|
-- self.infinity_list:scroll_to_index(25)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
self.infinity_list_small = self.druid:new_data_list(data, self.infinity_scroll_3, self.infinity_grid_3, function(record, index)
|
self.infinity_list_small = self.druid:new_data_list(self.infinity_scroll_3, self.infinity_grid_3, function(record, index)
|
||||||
-- function should return gui_node, [druid_component]
|
-- function should return gui_node, [druid_component]
|
||||||
return create_infinity_instance_small(self, record, index)
|
return create_infinity_instance_small(self, record, index)
|
||||||
end)
|
end):set_data(data)
|
||||||
|
|
||||||
self.infinity_list_dynamic = self.druid:new_data_list(data, self.infinity_scroll_dynamic, self.infinity_grid_dynamic, function(record, index)
|
self.infinity_list_dynamic = self.druid:new_data_list(self.infinity_scroll_dynamic, self.infinity_grid_dynamic, function(record, index)
|
||||||
-- function should return gui_node, [druid_component]
|
-- function should return gui_node, [druid_component]
|
||||||
return create_infinity_instance_dynamic(self, record, index)
|
return create_infinity_instance_dynamic(self, record, index)
|
||||||
end)
|
end):set_data(data)
|
||||||
|
|
||||||
timer.delay(1, false, function()
|
timer.delay(1, false, function()
|
||||||
self.infinity_list_dynamic:scroll_to_index(25)
|
-- self.infinity_list_dynamic:scroll_to_index(25)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
self.infinity_list_dynamic_hor = self.druid:new_data_list(data, self.infinity_scroll_dynamic_hor, self.infinity_grid_dynamic_hor, function(record, index)
|
self.infinity_list_dynamic_hor = self.druid:new_data_list(self.infinity_scroll_dynamic_hor, self.infinity_grid_dynamic_hor, function(record, index)
|
||||||
-- function should return gui_node, [druid_component]
|
-- function should return gui_node, [druid_component]
|
||||||
return create_infinity_instance_dynamic_hor(self, record, index)
|
return create_infinity_instance_dynamic_hor(self, record, index)
|
||||||
end)
|
end):set_data(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -140,8 +140,9 @@ local function toggle_stencil(self)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function M.setup_page(self)
|
function init(self)
|
||||||
self.druid:new_scroll("infinity_page", "infinity_page_content")
|
self.druid = druid.new(self)
|
||||||
|
self.druid:new_scroll("root", "infinity_page_content")
|
||||||
|
|
||||||
self.infinity_prefab = gui.get_node("infinity_prefab")
|
self.infinity_prefab = gui.get_node("infinity_prefab")
|
||||||
self.infinity_prefab_small = gui.get_node("infinity_prefab_small")
|
self.infinity_prefab_small = gui.get_node("infinity_prefab_small")
|
||||||
@ -177,4 +178,21 @@ function M.setup_page(self)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return M
|
function final(self)
|
||||||
|
self.druid:final()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function update(self, dt)
|
||||||
|
self.druid:update(dt)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function on_message(self, message_id, message, sender)
|
||||||
|
self.druid:on_message(message_id, message, sender)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function on_input(self, action_id, action)
|
||||||
|
return self.druid:on_input(action_id, action)
|
||||||
|
end
|
37
example/examples/general/grid/grid.collection
Normal file
37
example/examples/general/grid/grid.collection
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
name: "grid"
|
||||||
|
scale_along_z: 0
|
||||||
|
embedded_instances {
|
||||||
|
id: "go"
|
||||||
|
data: "components {\n"
|
||||||
|
" id: \"overview\"\n"
|
||||||
|
" component: \"/example/examples/general/grid/grid.gui\"\n"
|
||||||
|
" position {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" }\n"
|
||||||
|
" rotation {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" w: 1.0\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n"
|
||||||
|
""
|
||||||
|
position {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
}
|
||||||
|
rotation {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
w: 1.0
|
||||||
|
}
|
||||||
|
scale3 {
|
||||||
|
x: 1.0
|
||||||
|
y: 1.0
|
||||||
|
z: 1.0
|
||||||
|
}
|
||||||
|
}
|
2058
example/examples/general/grid/grid.gui
Normal file
2058
example/examples/general/grid/grid.gui
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,8 +1,6 @@
|
|||||||
|
local druid = require("druid.druid")
|
||||||
local const = require("druid.const")
|
local const = require("druid.const")
|
||||||
|
|
||||||
local M = {}
|
|
||||||
|
|
||||||
|
|
||||||
local function simple_animate(node, pos)
|
local function simple_animate(node, pos)
|
||||||
gui.animate(node, "position", pos, gui.EASING_OUTSINE, 0.2)
|
gui.animate(node, "position", pos, gui.EASING_OUTSINE, 0.2)
|
||||||
end
|
end
|
||||||
@ -178,8 +176,10 @@ local function init_dynamic_grid(self)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function M.setup_page(self)
|
function init(self)
|
||||||
self.druid:new_scroll("grid_page", "grid_page_content")
|
self.druid = druid.new(self)
|
||||||
|
|
||||||
|
self.druid:new_scroll("root", "grid_page_content")
|
||||||
|
|
||||||
self.grid_static_grid = self.druid:new_static_grid("grid_nodes", "grid_nodes_prefab", 5)
|
self.grid_static_grid = self.druid:new_static_grid("grid_nodes", "grid_nodes_prefab", 5)
|
||||||
:set_position_function(simple_animate)
|
:set_position_function(simple_animate)
|
||||||
@ -204,4 +204,21 @@ function M.setup_page(self)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return M
|
function final(self)
|
||||||
|
self.druid:final()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function update(self, dt)
|
||||||
|
self.druid:update(dt)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function on_message(self, message_id, message, sender)
|
||||||
|
self.druid:on_message(message_id, message, sender)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function on_input(self, action_id, action)
|
||||||
|
return self.druid:on_input(action_id, action)
|
||||||
|
end
|
37
example/examples/general/input/input.collection
Normal file
37
example/examples/general/input/input.collection
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
name: "input"
|
||||||
|
scale_along_z: 0
|
||||||
|
embedded_instances {
|
||||||
|
id: "go"
|
||||||
|
data: "components {\n"
|
||||||
|
" id: \"overview\"\n"
|
||||||
|
" component: \"/example/examples/general/input/input.gui\"\n"
|
||||||
|
" position {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" }\n"
|
||||||
|
" rotation {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" w: 1.0\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n"
|
||||||
|
""
|
||||||
|
position {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
}
|
||||||
|
rotation {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
w: 1.0
|
||||||
|
}
|
||||||
|
scale3 {
|
||||||
|
x: 1.0
|
||||||
|
y: 1.0
|
||||||
|
z: 1.0
|
||||||
|
}
|
||||||
|
}
|
1022
example/examples/general/input/input.gui
Normal file
1022
example/examples/general/input/input.gui
Normal file
File diff suppressed because it is too large
Load Diff
31
example/examples/general/input/input.gui_script
Normal file
31
example/examples/general/input/input.gui_script
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
local druid = require("druid.druid")
|
||||||
|
|
||||||
|
function init(self)
|
||||||
|
self.druid = druid.new(self)
|
||||||
|
|
||||||
|
self.druid:new_input("input_box_usual", "input_text_usual")
|
||||||
|
self.druid:new_input("input_box_password", "input_text_password", gui.KEYBOARD_TYPE_PASSWORD)
|
||||||
|
self.druid:new_input("input_box_email", "input_text_email", gui.KEYBOARD_TYPE_EMAIL)
|
||||||
|
self.druid:new_input("input_box_numpad", "input_text_numpad", gui.KEYBOARD_TYPE_NUMBER_PAD)
|
||||||
|
:set_allowed_characters("[%d,.]")
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function final(self)
|
||||||
|
self.druid:final()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function update(self, dt)
|
||||||
|
self.druid:update(dt)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function on_message(self, message_id, message, sender)
|
||||||
|
self.druid:on_message(message_id, message, sender)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function on_input(self, action_id, action)
|
||||||
|
return self.druid:on_input(action_id, action)
|
||||||
|
end
|
37
example/examples/general/overview/overview.collection
Normal file
37
example/examples/general/overview/overview.collection
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
name: "overview"
|
||||||
|
scale_along_z: 0
|
||||||
|
embedded_instances {
|
||||||
|
id: "go"
|
||||||
|
data: "components {\n"
|
||||||
|
" id: \"overview\"\n"
|
||||||
|
" component: \"/example/examples/general/overview/overview.gui\"\n"
|
||||||
|
" position {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" }\n"
|
||||||
|
" rotation {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" w: 1.0\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n"
|
||||||
|
""
|
||||||
|
position {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
}
|
||||||
|
rotation {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
w: 1.0
|
||||||
|
}
|
||||||
|
scale3 {
|
||||||
|
x: 1.0
|
||||||
|
y: 1.0
|
||||||
|
z: 1.0
|
||||||
|
}
|
||||||
|
}
|
3016
example/examples/general/overview/overview.gui
Normal file
3016
example/examples/general/overview/overview.gui
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,5 @@
|
|||||||
local lang = require("example.lang")
|
local lang = require("example.lang")
|
||||||
|
local druid = require("druid.druid")
|
||||||
local M = {}
|
|
||||||
|
|
||||||
|
|
||||||
local function empty_callback(self, param)
|
local function empty_callback(self, param)
|
||||||
print("Empty callback. Param", param)
|
print("Empty callback. Param", param)
|
||||||
@ -34,6 +32,7 @@ local function setup_texts(self)
|
|||||||
self.druid:new_lang_text("text_slider", "ui_section_slider")
|
self.druid:new_lang_text("text_slider", "ui_section_slider")
|
||||||
self.druid:new_lang_text("text_radio", "ui_section_radio")
|
self.druid:new_lang_text("text_radio", "ui_section_radio")
|
||||||
self.druid:new_lang_text("text_checkbox", "ui_section_checkbox")
|
self.druid:new_lang_text("text_checkbox", "ui_section_checkbox")
|
||||||
|
self.druid:new_lang_text("text_input", "ui_section_input")
|
||||||
|
|
||||||
self.druid:new_lang_text("text_translated", "ui_text_example")
|
self.druid:new_lang_text("text_translated", "ui_text_example")
|
||||||
self.druid:new_lang_text("text_button_lang", "ui_text_change_lang")
|
self.druid:new_lang_text("text_button_lang", "ui_text_change_lang")
|
||||||
@ -80,28 +79,39 @@ local function setup_timer(self)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function setup_back_handler(self)
|
|
||||||
self.druid:new_back_handler(empty_callback, "back button")
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
local function setup_input(self)
|
local function setup_input(self)
|
||||||
local input = self.druid:new_input("input_box", "input_text")
|
local input = self.druid:new_input("input_box", "input_text")
|
||||||
input:set_text("hello!")
|
input:set_text("hello!")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function M.setup_page(self)
|
function init(self)
|
||||||
|
self.druid = druid.new(self)
|
||||||
setup_texts(self)
|
setup_texts(self)
|
||||||
|
|
||||||
setup_button(self)
|
setup_button(self)
|
||||||
setup_progress(self)
|
setup_progress(self)
|
||||||
setup_timer(self)
|
setup_timer(self)
|
||||||
setup_checkbox(self)
|
setup_checkbox(self)
|
||||||
setup_slider(self)
|
setup_slider(self)
|
||||||
setup_back_handler(self)
|
|
||||||
setup_input(self)
|
setup_input(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return M
|
function final(self)
|
||||||
|
self.druid:final()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function update(self, dt)
|
||||||
|
self.druid:update(dt)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function on_message(self, message_id, message, sender)
|
||||||
|
self.druid:on_message(message_id, message, sender)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function on_input(self, action_id, action)
|
||||||
|
return self.druid:on_input(action_id, action)
|
||||||
|
end
|
37
example/examples/general/scroll/scroll.collection
Normal file
37
example/examples/general/scroll/scroll.collection
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
name: "scroll"
|
||||||
|
scale_along_z: 0
|
||||||
|
embedded_instances {
|
||||||
|
id: "go"
|
||||||
|
data: "components {\n"
|
||||||
|
" id: \"scroll\"\n"
|
||||||
|
" component: \"/example/examples/general/scroll/scroll.gui\"\n"
|
||||||
|
" position {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" }\n"
|
||||||
|
" rotation {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" w: 1.0\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n"
|
||||||
|
""
|
||||||
|
position {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
}
|
||||||
|
rotation {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
w: 1.0
|
||||||
|
}
|
||||||
|
scale3 {
|
||||||
|
x: 1.0
|
||||||
|
y: 1.0
|
||||||
|
z: 1.0
|
||||||
|
}
|
||||||
|
}
|
2092
example/examples/general/scroll/scroll.gui
Normal file
2092
example/examples/general/scroll/scroll.gui
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
|||||||
local M = {}
|
local druid = require("druid.druid")
|
||||||
|
|
||||||
|
|
||||||
local function init_scroll_with_grid(self)
|
local function init_scroll_with_grid(self)
|
||||||
@ -34,9 +34,11 @@ local function init_scroll_with_grid(self)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function M.setup_page(self)
|
function init(self)
|
||||||
-- Usual scroll for whole page
|
self.druid = druid.new(self)
|
||||||
self.druid:new_scroll("scroll_page", "scroll_page_content")
|
|
||||||
|
-- Usual scroll for whole page
|
||||||
|
self.druid:new_scroll("root", "scroll_page_content")
|
||||||
|
|
||||||
-- Simple scroll with no adjust
|
-- Simple scroll with no adjust
|
||||||
self.druid:new_scroll("simple_scroll_input", "simple_scroll_content")
|
self.druid:new_scroll("simple_scroll_input", "simple_scroll_content")
|
||||||
@ -68,4 +70,21 @@ function M.setup_page(self)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return M
|
function final(self)
|
||||||
|
self.druid:final()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function update(self, dt)
|
||||||
|
self.druid:update(dt)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function on_message(self, message_id, message, sender)
|
||||||
|
self.druid:on_message(message_id, message, sender)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function on_input(self, action_id, action)
|
||||||
|
return self.druid:on_input(action_id, action)
|
||||||
|
end
|
37
example/examples/general/sliders/sliders.collection
Normal file
37
example/examples/general/sliders/sliders.collection
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
name: "sliders"
|
||||||
|
scale_along_z: 0
|
||||||
|
embedded_instances {
|
||||||
|
id: "go"
|
||||||
|
data: "components {\n"
|
||||||
|
" id: \"sliders\"\n"
|
||||||
|
" component: \"/example/examples/general/sliders/sliders.gui\"\n"
|
||||||
|
" position {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" }\n"
|
||||||
|
" rotation {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" w: 1.0\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n"
|
||||||
|
""
|
||||||
|
position {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
}
|
||||||
|
rotation {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
w: 1.0
|
||||||
|
}
|
||||||
|
scale3 {
|
||||||
|
x: 1.0
|
||||||
|
y: 1.0
|
||||||
|
z: 1.0
|
||||||
|
}
|
||||||
|
}
|
1084
example/examples/general/sliders/sliders.gui
Normal file
1084
example/examples/general/sliders/sliders.gui
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,9 @@
|
|||||||
local M = {}
|
local druid = require("druid.druid")
|
||||||
|
|
||||||
|
|
||||||
function M.setup_page(self)
|
function init(self)
|
||||||
|
self.druid = druid.new(self)
|
||||||
|
|
||||||
local slider = self.druid:new_slider("slider_simple_pin", vmath.vector3(95, 0, 0), function(_, value)
|
local slider = self.druid:new_slider("slider_simple_pin", vmath.vector3(95, 0, 0), function(_, value)
|
||||||
gui.set_text(gui.get_node("slider_simple_text"), math.ceil(value * 100) .. "%")
|
gui.set_text(gui.get_node("slider_simple_text"), math.ceil(value * 100) .. "%")
|
||||||
end)
|
end)
|
||||||
@ -17,4 +19,21 @@ function M.setup_page(self)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return M
|
function final(self)
|
||||||
|
self.druid:final()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function update(self, dt)
|
||||||
|
self.druid:update(dt)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function on_message(self, message_id, message, sender)
|
||||||
|
self.druid:on_message(message_id, message, sender)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function on_input(self, action_id, action)
|
||||||
|
return self.druid:on_input(action_id, action)
|
||||||
|
end
|
37
example/examples/general/texts/texts.collection
Normal file
37
example/examples/general/texts/texts.collection
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
name: "texts"
|
||||||
|
scale_along_z: 0
|
||||||
|
embedded_instances {
|
||||||
|
id: "go"
|
||||||
|
data: "components {\n"
|
||||||
|
" id: \"texts\"\n"
|
||||||
|
" component: \"/example/examples/general/texts/texts.gui\"\n"
|
||||||
|
" position {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" }\n"
|
||||||
|
" rotation {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" w: 1.0\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n"
|
||||||
|
""
|
||||||
|
position {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
}
|
||||||
|
rotation {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
w: 1.0
|
||||||
|
}
|
||||||
|
scale3 {
|
||||||
|
x: 1.0
|
||||||
|
y: 1.0
|
||||||
|
z: 1.0
|
||||||
|
}
|
||||||
|
}
|
1070
example/examples/general/texts/texts.gui
Normal file
1070
example/examples/general/texts/texts.gui
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
|||||||
local M = {}
|
local druid = require("druid.druid")
|
||||||
|
|
||||||
local pivots = {
|
local pivots = {
|
||||||
gui.PIVOT_CENTER,
|
gui.PIVOT_CENTER,
|
||||||
@ -12,6 +12,7 @@ local pivots = {
|
|||||||
gui.PIVOT_NW
|
gui.PIVOT_NW
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
local function setup_texts(self)
|
local function setup_texts(self)
|
||||||
self.druid:new_text("text_inline")
|
self.druid:new_text("text_inline")
|
||||||
self.druid:new_text("text_multiline")
|
self.druid:new_text("text_multiline")
|
||||||
@ -45,9 +46,27 @@ local function setup_texts(self)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function M.setup_page(self)
|
function init(self)
|
||||||
|
self.druid = druid.new(self)
|
||||||
setup_texts(self)
|
setup_texts(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return M
|
function final(self)
|
||||||
|
self.druid:final()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function update(self, dt)
|
||||||
|
self.druid:update(dt)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function on_message(self, message_id, message, sender)
|
||||||
|
self.druid:on_message(message_id, message, sender)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function on_input(self, action_id, action)
|
||||||
|
return self.druid:on_input(action_id, action)
|
||||||
|
end
|
37
example/examples/template/template.collection
Normal file
37
example/examples/template/template.collection
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
name: "template"
|
||||||
|
scale_along_z: 0
|
||||||
|
embedded_instances {
|
||||||
|
id: "go"
|
||||||
|
data: "components {\n"
|
||||||
|
" id: \"template\"\n"
|
||||||
|
" component: \"/example/examples/template/template.gui\"\n"
|
||||||
|
" position {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" }\n"
|
||||||
|
" rotation {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" w: 1.0\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n"
|
||||||
|
""
|
||||||
|
position {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
}
|
||||||
|
rotation {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
w: 1.0
|
||||||
|
}
|
||||||
|
scale3 {
|
||||||
|
x: 1.0
|
||||||
|
y: 1.0
|
||||||
|
z: 1.0
|
||||||
|
}
|
||||||
|
}
|
141
example/examples/template/template.gui
Normal file
141
example/examples/template/template.gui
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
script: "/example/examples/template/template.gui_script"
|
||||||
|
fonts {
|
||||||
|
name: "game"
|
||||||
|
font: "/example/assets/fonts/game.font"
|
||||||
|
}
|
||||||
|
textures {
|
||||||
|
name: "kenney"
|
||||||
|
texture: "/example/assets/images/kenney.atlas"
|
||||||
|
}
|
||||||
|
background_color {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
w: 0.0
|
||||||
|
}
|
||||||
|
nodes {
|
||||||
|
position {
|
||||||
|
x: 300.0
|
||||||
|
y: 415.0
|
||||||
|
z: 0.0
|
||||||
|
w: 1.0
|
||||||
|
}
|
||||||
|
rotation {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
w: 1.0
|
||||||
|
}
|
||||||
|
scale {
|
||||||
|
x: 1.0
|
||||||
|
y: 1.0
|
||||||
|
z: 1.0
|
||||||
|
w: 1.0
|
||||||
|
}
|
||||||
|
size {
|
||||||
|
x: 600.0
|
||||||
|
y: 830.0
|
||||||
|
z: 0.0
|
||||||
|
w: 1.0
|
||||||
|
}
|
||||||
|
color {
|
||||||
|
x: 1.0
|
||||||
|
y: 1.0
|
||||||
|
z: 1.0
|
||||||
|
w: 1.0
|
||||||
|
}
|
||||||
|
type: TYPE_BOX
|
||||||
|
blend_mode: BLEND_MODE_ALPHA
|
||||||
|
texture: "kenney/empty"
|
||||||
|
id: "root"
|
||||||
|
xanchor: XANCHOR_NONE
|
||||||
|
yanchor: YANCHOR_NONE
|
||||||
|
pivot: PIVOT_CENTER
|
||||||
|
adjust_mode: ADJUST_MODE_FIT
|
||||||
|
layer: ""
|
||||||
|
inherit_alpha: true
|
||||||
|
slice9 {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
w: 0.0
|
||||||
|
}
|
||||||
|
clipping_mode: CLIPPING_MODE_NONE
|
||||||
|
clipping_visible: true
|
||||||
|
clipping_inverted: false
|
||||||
|
alpha: 1.0
|
||||||
|
template_node_child: false
|
||||||
|
size_mode: SIZE_MODE_MANUAL
|
||||||
|
}
|
||||||
|
nodes {
|
||||||
|
position {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
w: 1.0
|
||||||
|
}
|
||||||
|
rotation {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
w: 1.0
|
||||||
|
}
|
||||||
|
scale {
|
||||||
|
x: 1.0
|
||||||
|
y: 1.0
|
||||||
|
z: 1.0
|
||||||
|
w: 1.0
|
||||||
|
}
|
||||||
|
size {
|
||||||
|
x: 200.0
|
||||||
|
y: 100.0
|
||||||
|
z: 0.0
|
||||||
|
w: 1.0
|
||||||
|
}
|
||||||
|
color {
|
||||||
|
x: 1.0
|
||||||
|
y: 1.0
|
||||||
|
z: 1.0
|
||||||
|
w: 1.0
|
||||||
|
}
|
||||||
|
type: TYPE_TEXT
|
||||||
|
blend_mode: BLEND_MODE_ALPHA
|
||||||
|
text: "Hello!"
|
||||||
|
font: "game"
|
||||||
|
id: "text_hint"
|
||||||
|
xanchor: XANCHOR_NONE
|
||||||
|
yanchor: YANCHOR_NONE
|
||||||
|
pivot: PIVOT_CENTER
|
||||||
|
outline {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
w: 1.0
|
||||||
|
}
|
||||||
|
shadow {
|
||||||
|
x: 1.0
|
||||||
|
y: 1.0
|
||||||
|
z: 1.0
|
||||||
|
w: 1.0
|
||||||
|
}
|
||||||
|
adjust_mode: ADJUST_MODE_FIT
|
||||||
|
line_break: false
|
||||||
|
parent: "root"
|
||||||
|
layer: ""
|
||||||
|
inherit_alpha: true
|
||||||
|
alpha: 1.0
|
||||||
|
outline_alpha: 1.0
|
||||||
|
shadow_alpha: 0.0
|
||||||
|
template_node_child: false
|
||||||
|
text_leading: 1.0
|
||||||
|
text_tracking: 0.0
|
||||||
|
}
|
||||||
|
layers {
|
||||||
|
name: "image"
|
||||||
|
}
|
||||||
|
layers {
|
||||||
|
name: "text"
|
||||||
|
}
|
||||||
|
material: "/builtins/materials/gui.material"
|
||||||
|
adjust_reference: ADJUST_REFERENCE_PARENT
|
||||||
|
max_nodes: 512
|
25
example/examples/template/template.gui_script
Normal file
25
example/examples/template/template.gui_script
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
local druid = require("druid.druid")
|
||||||
|
|
||||||
|
function init(self)
|
||||||
|
self.druid = druid.new(self)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function final(self)
|
||||||
|
self.druid:final()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function update(self, dt)
|
||||||
|
self.druid:update(dt)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function on_message(self, message_id, message, sender)
|
||||||
|
self.druid:on_message(message_id, message, sender)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function on_input(self, action_id, action)
|
||||||
|
return self.druid:on_input(action_id, action)
|
||||||
|
end
|
File diff suppressed because it is too large
Load Diff
@ -1,104 +0,0 @@
|
|||||||
---@type druid
|
|
||||||
local druid = require("druid.druid")
|
|
||||||
|
|
||||||
local empty_style = require("druid.styles.empty.style")
|
|
||||||
local default_style = require("druid.styles.default.style")
|
|
||||||
|
|
||||||
local main_page = require("example.page.main_page")
|
|
||||||
local text_page = require("example.page.texts_page")
|
|
||||||
local button_page = require("example.page.button_page")
|
|
||||||
local scroll_page = require("example.page.scroll_page")
|
|
||||||
local slider_page = require("example.page.slider_page")
|
|
||||||
local input_page = require("example.page.input_page")
|
|
||||||
local grid_page = require("example.page.grid_page")
|
|
||||||
local infinity_page = require("example.page.infinity_page")
|
|
||||||
|
|
||||||
local pages = {
|
|
||||||
"main_page",
|
|
||||||
"texts_page",
|
|
||||||
"button_page",
|
|
||||||
"scroll_page",
|
|
||||||
"slider_page",
|
|
||||||
"input_page",
|
|
||||||
"grid_page",
|
|
||||||
"infinity_page",
|
|
||||||
}
|
|
||||||
|
|
||||||
local function on_control_button(self, delta)
|
|
||||||
self.page = self.page + delta
|
|
||||||
self.page = math.max(1, self.page)
|
|
||||||
self.page = math.min(self.page, #pages)
|
|
||||||
|
|
||||||
self.header:translate(pages[self.page])
|
|
||||||
local node = gui.get_node("C_Anchor")
|
|
||||||
|
|
||||||
for i = 1, #pages do
|
|
||||||
gui.set_enabled(gui.get_node(pages[i]), i == self.page)
|
|
||||||
end
|
|
||||||
gui.animate(node, "position.x", (self.page-1) * -600, gui.EASING_OUTSINE, 0.2)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
local function init_top_panel(self)
|
|
||||||
self.druid:new_blocker("panel_top")
|
|
||||||
self.druid:new_button("button_left/button", on_control_button, -1)
|
|
||||||
self.druid:new_button("button_right/button", on_control_button, 1)
|
|
||||||
self.header = self.druid:new_lang_text("text_header", "main_page")
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
local function init_swipe_control(self)
|
|
||||||
self.druid:new_swipe("root", function(_, side)
|
|
||||||
if side == "left" then
|
|
||||||
on_control_button(self, 1)
|
|
||||||
end
|
|
||||||
if side == "right" then
|
|
||||||
on_control_button(self, -1)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
local function on_window_callback(self, event, data)
|
|
||||||
druid.on_window_callback(event, data)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function init(self)
|
|
||||||
druid.set_default_style(default_style)
|
|
||||||
self.druid = druid.new(self)
|
|
||||||
|
|
||||||
window.set_listener(on_window_callback)
|
|
||||||
|
|
||||||
init_swipe_control(self)
|
|
||||||
|
|
||||||
self.page = 1
|
|
||||||
main_page.setup_page(self)
|
|
||||||
text_page.setup_page(self)
|
|
||||||
button_page.setup_page(self)
|
|
||||||
scroll_page.setup_page(self)
|
|
||||||
slider_page.setup_page(self)
|
|
||||||
input_page.setup_page(self)
|
|
||||||
grid_page.setup_page(self)
|
|
||||||
infinity_page.setup_page(self)
|
|
||||||
|
|
||||||
init_top_panel(self)
|
|
||||||
|
|
||||||
-- Refresh state
|
|
||||||
on_control_button(self, 0)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function update(self, dt)
|
|
||||||
self.druid:update(dt)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function on_message(self, message_id, message, sender)
|
|
||||||
self.druid:on_message(message_id, message, sender)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function on_input(self, action_id, action)
|
|
||||||
self.druid:on_input(action_id, action)
|
|
||||||
end
|
|
@ -4,7 +4,7 @@ local lang = require("example.lang")
|
|||||||
|
|
||||||
local function setup_druid()
|
local function setup_druid()
|
||||||
druid.set_sound_function(function(name)
|
druid.set_sound_function(function(name)
|
||||||
sound.play("kenney:/sound#" .. name)
|
sound.play("example:/sound#" .. name)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
druid.set_text_function(function(lang_id, ...)
|
druid.set_text_function(function(lang_id, ...)
|
||||||
|
@ -1,115 +0,0 @@
|
|||||||
name: "kenney"
|
|
||||||
scale_along_z: 0
|
|
||||||
embedded_instances {
|
|
||||||
id: "gui"
|
|
||||||
data: "components {\n"
|
|
||||||
" id: \"main\"\n"
|
|
||||||
" component: \"/example/gui/main/main.gui\"\n"
|
|
||||||
" position {\n"
|
|
||||||
" x: 0.0\n"
|
|
||||||
" y: 0.0\n"
|
|
||||||
" z: 0.0\n"
|
|
||||||
" }\n"
|
|
||||||
" rotation {\n"
|
|
||||||
" x: 0.0\n"
|
|
||||||
" y: 0.0\n"
|
|
||||||
" z: 0.0\n"
|
|
||||||
" w: 1.0\n"
|
|
||||||
" }\n"
|
|
||||||
"}\n"
|
|
||||||
""
|
|
||||||
position {
|
|
||||||
x: 0.0
|
|
||||||
y: 0.0
|
|
||||||
z: 0.0
|
|
||||||
}
|
|
||||||
rotation {
|
|
||||||
x: 0.0
|
|
||||||
y: 0.0
|
|
||||||
z: 0.0
|
|
||||||
w: 1.0
|
|
||||||
}
|
|
||||||
scale3 {
|
|
||||||
x: 1.0
|
|
||||||
y: 1.0
|
|
||||||
z: 1.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
embedded_instances {
|
|
||||||
id: "system"
|
|
||||||
data: "components {\n"
|
|
||||||
" id: \"init\"\n"
|
|
||||||
" component: \"/example/init.script\"\n"
|
|
||||||
" position {\n"
|
|
||||||
" x: 0.0\n"
|
|
||||||
" y: 0.0\n"
|
|
||||||
" z: 0.0\n"
|
|
||||||
" }\n"
|
|
||||||
" rotation {\n"
|
|
||||||
" x: 0.0\n"
|
|
||||||
" y: 0.0\n"
|
|
||||||
" z: 0.0\n"
|
|
||||||
" w: 1.0\n"
|
|
||||||
" }\n"
|
|
||||||
"}\n"
|
|
||||||
""
|
|
||||||
position {
|
|
||||||
x: 0.0
|
|
||||||
y: 0.0
|
|
||||||
z: 0.0
|
|
||||||
}
|
|
||||||
rotation {
|
|
||||||
x: 0.0
|
|
||||||
y: 0.0
|
|
||||||
z: 0.0
|
|
||||||
w: 1.0
|
|
||||||
}
|
|
||||||
scale3 {
|
|
||||||
x: 1.0
|
|
||||||
y: 1.0
|
|
||||||
z: 1.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
embedded_instances {
|
|
||||||
id: "sound"
|
|
||||||
data: "embedded_components {\n"
|
|
||||||
" id: \"click\"\n"
|
|
||||||
" type: \"sound\"\n"
|
|
||||||
" data: \"sound: \\\"/example/assets/sounds/click.ogg\\\"\\n"
|
|
||||||
"looping: 0\\n"
|
|
||||||
"group: \\\"master\\\"\\n"
|
|
||||||
"gain: 1.0\\n"
|
|
||||||
"pan: 0.0\\n"
|
|
||||||
"speed: 1.0\\n"
|
|
||||||
"loopcount: 0\\n"
|
|
||||||
"\"\n"
|
|
||||||
" position {\n"
|
|
||||||
" x: 0.0\n"
|
|
||||||
" y: 0.0\n"
|
|
||||||
" z: 0.0\n"
|
|
||||||
" }\n"
|
|
||||||
" rotation {\n"
|
|
||||||
" x: 0.0\n"
|
|
||||||
" y: 0.0\n"
|
|
||||||
" z: 0.0\n"
|
|
||||||
" w: 1.0\n"
|
|
||||||
" }\n"
|
|
||||||
"}\n"
|
|
||||||
""
|
|
||||||
position {
|
|
||||||
x: 0.0
|
|
||||||
y: 0.0
|
|
||||||
z: 0.0
|
|
||||||
}
|
|
||||||
rotation {
|
|
||||||
x: 0.0
|
|
||||||
y: 0.0
|
|
||||||
z: 0.0
|
|
||||||
w: 1.0
|
|
||||||
}
|
|
||||||
scale3 {
|
|
||||||
x: 1.0
|
|
||||||
y: 1.0
|
|
||||||
z: 1.0
|
|
||||||
}
|
|
||||||
}
|
|
@ -18,6 +18,7 @@ local en = {
|
|||||||
ui_section_slider = "Slider",
|
ui_section_slider = "Slider",
|
||||||
ui_section_radio = "Radio",
|
ui_section_radio = "Radio",
|
||||||
ui_section_checkbox = "Checkbox",
|
ui_section_checkbox = "Checkbox",
|
||||||
|
ui_section_input = "Input",
|
||||||
ui_text_example = "Translated",
|
ui_text_example = "Translated",
|
||||||
ui_text_change_lang = "Change lang",
|
ui_text_change_lang = "Change lang",
|
||||||
}
|
}
|
||||||
@ -38,6 +39,7 @@ local ru = {
|
|||||||
ui_section_slider = "Слайдер",
|
ui_section_slider = "Слайдер",
|
||||||
ui_section_radio = "Выбор",
|
ui_section_radio = "Выбор",
|
||||||
ui_section_checkbox = "Мн. выбор",
|
ui_section_checkbox = "Мн. выбор",
|
||||||
|
ui_section_input = "Ввод текста",
|
||||||
ui_text_example = "Переведен",
|
ui_text_example = "Переведен",
|
||||||
ui_text_change_lang = "Сменить язык",
|
ui_text_change_lang = "Сменить язык",
|
||||||
}
|
}
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
local M = {}
|
|
||||||
|
|
||||||
|
|
||||||
function M.setup_page(self)
|
|
||||||
self.druid:new_input("input_box_usual", "input_text_usual")
|
|
||||||
self.druid:new_input("input_box_password", "input_text_password", gui.KEYBOARD_TYPE_PASSWORD)
|
|
||||||
self.druid:new_input("input_box_email", "input_text_email", gui.KEYBOARD_TYPE_EMAIL)
|
|
||||||
self.druid:new_input("input_box_numpad", "input_text_numpad", gui.KEYBOARD_TYPE_NUMBER_PAD)
|
|
||||||
:set_allowed_characters("[%d,.]")
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
return M
|
|
@ -1,5 +1,5 @@
|
|||||||
[bootstrap]
|
[bootstrap]
|
||||||
main_collection = /example/kenney.collectionc
|
main_collection = /example/example.collectionc
|
||||||
|
|
||||||
[script]
|
[script]
|
||||||
shared_state = 1
|
shared_state = 1
|
||||||
@ -11,7 +11,7 @@ height = 900
|
|||||||
[project]
|
[project]
|
||||||
title = druid
|
title = druid
|
||||||
version = 0.5.0
|
version = 0.5.0
|
||||||
dependencies = https://github.com/insalitygames/deftest/archive/master.zip
|
dependencies = https://github.com/insalitygames/deftest/archive/master.zip,https://github.com/britzl/monarch/archive/refs/tags/3.3.0.zip
|
||||||
|
|
||||||
[library]
|
[library]
|
||||||
include_dirs = druid
|
include_dirs = druid
|
||||||
|
Loading…
x
Reference in New Issue
Block a user