mirror of
https://github.com/Insality/druid.git
synced 2025-06-27 18:37:44 +02:00
Merge branch 'develop': add example for grid animations
This commit is contained in:
commit
105f672676
@ -48,4 +48,5 @@ globals = {
|
||||
"buffer",
|
||||
"resource",
|
||||
"defos",
|
||||
"html5",
|
||||
}
|
||||
|
@ -101,6 +101,8 @@ druid.on_window_callback(event)
|
||||
|
||||
- **[Dynamic Grid](docs_md/01-components.md#dynamic-grid)** - Component to manage node positions with different sizes. Only in one row or column
|
||||
|
||||
- **[Data List](docs_md/01-components.md#data-list)** - Component to manage data for huge dataset in scroll
|
||||
|
||||
- **[Input](docs_md/01-components.md#input)** - User text input component
|
||||
|
||||
- **[Lang text](docs_md/01-components.md#lang-text)** - Wrap on Text component to handle localization
|
||||
|
@ -1 +1 @@
|
||||
{"content":[{"name":"game.projectc","size":3432,"pieces":[{"name":"game.projectc0","offset":0}]},{"name":"game.arci","size":10608,"pieces":[{"name":"game.arci0","offset":0}]},{"name":"game.arcd","size":384566,"pieces":[{"name":"game.arcd0","offset":0}]},{"name":"game.dmanifest","size":23386,"pieces":[{"name":"game.dmanifest0","offset":0}]},{"name":"game.public.der","size":162,"pieces":[{"name":"game.public.der0","offset":0}]}]}
|
||||
{"content":[{"name":"game.projectc","size":3432,"pieces":[{"name":"game.projectc0","offset":0}]},{"name":"game.arci","size":11568,"pieces":[{"name":"game.arci0","offset":0}]},{"name":"game.arcd","size":388522,"pieces":[{"name":"game.arcd0","offset":0}]},{"name":"game.dmanifest","size":25565,"pieces":[{"name":"game.dmanifest0","offset":0}]},{"name":"game.public.der","size":162,"pieces":[{"name":"game.public.der0","offset":0}]}]}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,12 +1,12 @@
|
||||
[project]
|
||||
title = druid
|
||||
version = 0.6.459
|
||||
version = 0.6.466
|
||||
write_log = 0
|
||||
compress_archive = 1
|
||||
publisher = Insality
|
||||
developer = Insality
|
||||
commit_sha = 015564f5b3e0d5e63e422056c69e53826ed689bf
|
||||
build_time = 2021-04-05T21:00:43Z
|
||||
commit_sha = ffa3bafa002c561f6f4a31e8bbca228c3606b1cc
|
||||
build_time = 2021-05-30T08:51:36Z
|
||||
|
||||
[display]
|
||||
width = 600
|
||||
@ -121,7 +121,7 @@ default_language = en
|
||||
localizations = en
|
||||
|
||||
[android]
|
||||
version_code = 459
|
||||
version_code = 466
|
||||
minimum_sdk_version = 16
|
||||
target_sdk_version = 29
|
||||
package = com.insality.druid
|
||||
|
Binary file not shown.
@ -7,7 +7,7 @@
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<!-- The above 4 meta tags *must* come first in the head; any other head content must come *after* these tags -->
|
||||
|
||||
<title>druid 0.6.459</title>
|
||||
<title>druid 0.6.466</title>
|
||||
<style type='text/css'>
|
||||
/* Disable user selection to avoid strange bug in Chrome on Windows:
|
||||
* Selecting a text outside the canvas, then clicking+draging would
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
|
||||
## Button
|
||||
[Button API here](https://insality.github.io/druid/modules/druid.button.html)
|
||||
[Button API here](https://insality.github.io/druid/modules/Button.html)
|
||||
|
||||
### Overview
|
||||
Basic Druid input component. Handle input on node and provide different callbacks on touch events.
|
||||
@ -36,7 +36,7 @@ _fill example usecases_
|
||||
|
||||
|
||||
## Text
|
||||
[Text API here](https://insality.github.io/druid/modules/druid.text.html)
|
||||
[Text API here](https://insality.github.io/druid/modules/Text.html)
|
||||
|
||||
### Overview
|
||||
Basic Druid text component. Text components by default have the text size adjusting.
|
||||
@ -55,7 +55,7 @@ Create text node with druid: `text = druid:new_text(node_name, [initial_value],
|
||||
|
||||
|
||||
## Blocker
|
||||
[Blocker API here](https://insality.github.io/druid/modules/druid.blocker.html)
|
||||
[Blocker API here](https://insality.github.io/druid/modules/Blocker.html)
|
||||
|
||||
### Overview
|
||||
Druid component for block input. Use it to block input in special zone.
|
||||
@ -75,7 +75,7 @@ So you can do the safe zones, when you have the big buttons
|
||||
|
||||
|
||||
## Back Handler
|
||||
[Back handler API here](https://insality.github.io/druid/modules/druid.back_handler.html)
|
||||
[Back handler API here](https://insality.github.io/druid/modules/BackHandler.html)
|
||||
|
||||
### Overview
|
||||
Component to handle back button. It handle Android back button and Backspace key. Key triggers in `input.binding` should be setup for correct working.
|
||||
@ -87,7 +87,7 @@ Setup callback with `druid:new_back_handler(callback)`
|
||||
|
||||
|
||||
## Lang text
|
||||
[Lang text API here](https://insality.github.io/druid/modules/druid.lang_text.html)
|
||||
[Lang text API here](https://insality.github.io/druid/modules/LangText.html)
|
||||
|
||||
### Overview
|
||||
Wrap on Text component to handle localization. It uses druid get_text_function to set text by it's id
|
||||
@ -99,7 +99,7 @@ Create lang text component with druid `text = druid:new_lang_text(node_name, loc
|
||||
|
||||
|
||||
## Scroll
|
||||
[Scroll API here](https://insality.github.io/druid/modules/druid.scroll.html)
|
||||
[Scroll API here](https://insality.github.io/druid/modules/Scroll.html)
|
||||
|
||||
### Overview
|
||||
Basic Druid scroll component. Handle all scrolling stuff in druid GUI
|
||||
@ -120,7 +120,7 @@ Usually, Place _view_node_ and as children add _content_node_:
|
||||
*Here content_node below view_node, in game content_node be able to scroll left until end*
|
||||
|
||||
### Notes
|
||||
- Scroll by default style have inertion and extra size for strecthing effect. It can be adjust via scroll [style settings](https://insality.github.io/druid/modules/druid.scroll.html#Style)
|
||||
- Scroll by default style have inertion and extra size for strecthing effect. It can be adjust via scroll [style settings](https://insality.github.io/druid/modules/Scroll.html#Style)
|
||||
- You can setup "points of interest". Scroll always will be centered on closes point of interest. It is able to create slider without inertion and points of interest on each scroll element.
|
||||
- Scroll have next events:
|
||||
- *on_scroll* (self, position) On scroll move callback
|
||||
@ -133,7 +133,7 @@ Usually, Place _view_node_ and as children add _content_node_:
|
||||
|
||||
|
||||
## Progress
|
||||
[Progress API here](https://insality.github.io/druid/modules/druid.progress.html)
|
||||
[Progress API here](https://insality.github.io/druid/modules/Progress.html)
|
||||
|
||||
### Overview
|
||||
Basic Druid progress bar component
|
||||
@ -151,7 +151,7 @@ Key is value from druid const: const.SIDE.X (or just "x") or const.SIDE.Y (or ju
|
||||
|
||||
|
||||
## Slider
|
||||
[Slider API here](https://insality.github.io/druid/modules/druid.slider.html)
|
||||
[Slider API here](https://insality.github.io/druid/modules/Slider.html)
|
||||
|
||||
### Overview
|
||||
Basic Druid slider component
|
||||
@ -167,7 +167,7 @@ Pin node (node_name in params) should be placed in zero position (initial). It w
|
||||
|
||||
|
||||
## Input
|
||||
[Input API here](https://insality.github.io/druid/modules/druid.input.html)
|
||||
[Input API here](https://insality.github.io/druid/modules/Input.html)
|
||||
|
||||
### Overview
|
||||
Basic Druid text input component
|
||||
@ -187,7 +187,7 @@ Create input component with druid: `input = druid:new_input(button_node_name, te
|
||||
|
||||
|
||||
## Checkbox
|
||||
[Checkbox API here](https://insality.github.io/druid/modules/druid.checkbox.html)
|
||||
[Checkbox API here](https://insality.github.io/druid/modules/Checkbox.html)
|
||||
|
||||
### Overview
|
||||
Basic Druid checkbox component.
|
||||
@ -201,7 +201,7 @@ Create checkbox component with druid: `checkbox = druid:new_checkbox(node, callb
|
||||
|
||||
|
||||
## Checkbox group
|
||||
[Checkbox group API here](https://insality.github.io/druid/modules/druid.checkbox_group.html)
|
||||
[Checkbox group API here](https://insality.github.io/druid/modules/CheckboxGroup.html)
|
||||
|
||||
### Overview
|
||||
Several checkboxes in one group
|
||||
@ -215,7 +215,7 @@ Create checkbox_group component with druid: `group = druid:new_checkbox_group(no
|
||||
|
||||
|
||||
## Radio group
|
||||
[Radio group API here](https://insality.github.io/druid/modules/druid.radio_group.html)
|
||||
[Radio group API here](https://insality.github.io/druid/modules/RadioGroup.html)
|
||||
|
||||
### Overview
|
||||
Several checkboxes in one group with single choice
|
||||
@ -230,7 +230,7 @@ Create radio_group component with druid: `group = druid:new_radio_group(nodes[],
|
||||
|
||||
|
||||
## Timer
|
||||
[Timer API here](https://insality.github.io/druid/modules/druid.timer.html)
|
||||
[Timer API here](https://insality.github.io/druid/modules/Timer.html)
|
||||
|
||||
### Overview
|
||||
Handle timer work on gui text node
|
||||
@ -245,7 +245,7 @@ Create timer component with druid: `timer = druid:new_timer(text_node, from_seco
|
||||
|
||||
|
||||
## Static Grid
|
||||
[Static Grid API here](https://insality.github.io/druid/modules/druid.static_grid.html)
|
||||
[Static Grid API here](https://insality.github.io/druid/modules/StaticGrid.html)
|
||||
|
||||
### Overview
|
||||
Component for manage node positions.
|
||||
@ -266,7 +266,7 @@ Create component with druid: `grid = druid:new_static_grid(parent_node, prefab_
|
||||
|
||||
|
||||
## Dynamic Grid
|
||||
[Dynamic Grid API here](https://insality.github.io/druid/modules/druid.dynamic_grid.html)
|
||||
[Dynamic Grid API here](https://insality.github.io/druid/modules/DynamicGrid.html)
|
||||
|
||||
### Overview
|
||||
Component for manage node positions with different node sizes.
|
||||
@ -276,7 +276,7 @@ Dynamic Grid can't have gaps between elements
|
||||
Dynamic Grid should have __West__, __East__, __South__ or __North__ pivot (vertical or horizontal element placement)
|
||||
|
||||
### Setup
|
||||
Create component with druid: `grid = druid:new_dynamic_grid(parent_node)`
|
||||
Create component with druid: `grid = druid:new_dynamic_grid(parent_node)`
|
||||
|
||||
Check the _parent_node_ have correct pivot point. You will get the error otherwise.
|
||||
|
||||
@ -290,8 +290,34 @@ Check the _parent_node_ have correct pivot point. You will get the error otherwi
|
||||
- First node placed at Grid pivot point. Other nodes placed nearby of other nodes.
|
||||
- On *add/remove* nodes always shifted. You can point the shift side in this functions (*is_shift_left* boolean argumentp
|
||||
|
||||
|
||||
## Data List
|
||||
[Data List API here](https://insality.github.io/druid/modules/DataList.html)
|
||||
|
||||
### Overview
|
||||
Component to manage data for huge dataset in scroll. DataList create elements only in scroll view.
|
||||
It requires Druid Scroll and Druid Grid (Static or Dynamic) components
|
||||
|
||||
|
||||
### Setup
|
||||
Create component with druid: `grid = druid:new_data_list(scroll, grid, create_callback)`
|
||||
- scroll - already created Scroll component
|
||||
- grid - already created StaticGrid or DynamicGrid component
|
||||
- create_function - your function to create node instances. This callback have next parameters: fun(self, data, index, data_list)
|
||||
- self - Script/Druid context
|
||||
- data- your element data
|
||||
- index - element index
|
||||
- data_list - current DataList component
|
||||
|
||||
Create function should return root node and optionaly, Druid component. It’s required to manage create/remove lifecycle.
|
||||
|
||||
### Notes
|
||||
- Set data with `data_list:set_data({...})` after component initialize
|
||||
- You can use `data_list:scroll_to_index()` function to show data element
|
||||
|
||||
|
||||
## Hover
|
||||
[Hover API here](https://insality.github.io/druid/modules/druid.hover.html)
|
||||
[Hover API here](https://insality.github.io/druid/modules/Hover.html)
|
||||
|
||||
### Overview
|
||||
System Druid component, handle hover node state.
|
||||
@ -306,7 +332,7 @@ Create hover component with druid: `hover = druid:new_hover(node, callback)`
|
||||
|
||||
|
||||
## Swipe
|
||||
[Swipe API here](https://insality.github.io/druid/modules/druid.swipe.html)
|
||||
[Swipe API here](https://insality.github.io/druid/modules/Swipe.html)
|
||||
|
||||
### Overview
|
||||
System Druid component, handle swipe actions on node
|
||||
@ -327,7 +353,7 @@ Create swipe component with druid: `hover = druid:new_swipe(node, swipe_callback
|
||||
|
||||
|
||||
## Drag
|
||||
[Drag API here](https://insality.github.io/druid/modules/druid.drag.html)
|
||||
[Drag API here](https://insality.github.io/druid/modules/Drag.html)
|
||||
|
||||
### Overview
|
||||
System Druid component, handle drag actions on node
|
||||
|
@ -136,7 +136,7 @@ Also check _component.template.lua_ what you can use for your own custom compone
|
||||
|
||||
Hey! Are you tired from **Druid** updates? _(It's a joke)_
|
||||
|
||||
Finally, got a time to release component to process huge amount of data. So introducing: **DataList** component. I can't say what it's "infinity" scroll, but it can help to solve your problem with `GUI nodes limit reached` and helps with scroll optimization. Give feedback about it!
|
||||
Finally, got a time to release component to process huge amount of data. So introducing: **DataList** component. It can help solve your problem with `GUI nodes limit reached` and helps with scroll optimization. Give feedback about it!
|
||||
|
||||
The next important stuff is **EmmyLua** docs. I'm implemented EmmyLua doc generator from LuaDoc and Protofiles, so now you can use EmmyLua annotations inside your IDE instead of website API looking or source code scanning.
|
||||
|
||||
@ -144,7 +144,7 @@ Also the **Druid examples** is reworked, so each example will be in separate col
|
||||
|
||||
Input priority got reworked too. Now instead of two input stacks: usual and high, Druid use simple input priority value.
|
||||
|
||||
And I should note here is several breaking changes, take a look in changelogs.
|
||||
And I should note here are several breaking changes, take a look in changelogs.
|
||||
|
||||
Wanna something more? [Add an issues!](https://github.com/Insality/druid/issues)
|
||||
Have a good day.
|
||||
|
@ -869,3 +869,66 @@ embedded_instances {
|
||||
z: 1.0
|
||||
}
|
||||
}
|
||||
embedded_instances {
|
||||
id: "grid_animations"
|
||||
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: \"grid_animations\"\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/grid/grid_animations/grid_animations.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
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,8 @@ end
|
||||
|
||||
|
||||
local function show_scene(self, scene_name, text_header)
|
||||
print("Show scene:", scene_name)
|
||||
|
||||
monarch.show(scene_name)
|
||||
gui.set_enabled(gui.get_node("C_Anchor"), false)
|
||||
gui.set_enabled(self.button_menu.node, true)
|
||||
@ -60,6 +62,9 @@ local function get_button(self, text, scene_name)
|
||||
local nodes = gui.clone_tree(prefab)
|
||||
local root = nodes["prefab_button"]
|
||||
gui.set_enabled(root, true)
|
||||
|
||||
self.scene_names[scene_name] = text
|
||||
|
||||
self.druid:new_button(root, function()
|
||||
show_scene(self, scene_name, text)
|
||||
end):set_click_zone(self.lobby_scroll.view_node)
|
||||
@ -84,6 +89,7 @@ end
|
||||
|
||||
local function init_lobby(self)
|
||||
gui.set_enabled(gui.get_node("prefabs"), false)
|
||||
self.scene_names = {}
|
||||
|
||||
self.lobby_scroll = self.druid:new_scroll("lobby_view", "lobby_content")
|
||||
self.lobby_grid = self.druid:new_dynamic_grid("lobby_content")
|
||||
@ -113,6 +119,7 @@ local function init_lobby(self)
|
||||
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_button(self, "Add/Remove animations", "grid_animations"))
|
||||
|
||||
self.lobby_grid:add(get_title(self, "Data list / Infinity scroll"))
|
||||
self.lobby_grid:add(get_button(self, "With static grid", "data_list_static_grid"))
|
||||
@ -129,6 +136,18 @@ local function init_lobby(self)
|
||||
end
|
||||
|
||||
|
||||
local function check_url(self)
|
||||
if not html5 then
|
||||
return
|
||||
end
|
||||
local example_arg = html5.run("new URLSearchParams(window.location.search).get('example')")
|
||||
if example_arg and self.scene_names[example_arg] then
|
||||
print("Start example: ", example_arg)
|
||||
show_scene(self, example_arg, self.scene_names[example_arg] or "unknown")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function init(self)
|
||||
-- Main lobby have more render priority (top panel)
|
||||
gui.set_render_order(10)
|
||||
@ -139,6 +158,8 @@ function init(self)
|
||||
|
||||
init_top_panel(self)
|
||||
init_lobby(self)
|
||||
|
||||
timer.delay(0, false, check_url)
|
||||
end
|
||||
|
||||
|
||||
|
@ -0,0 +1,37 @@
|
||||
name: "grid_animations"
|
||||
scale_along_z: 0
|
||||
embedded_instances {
|
||||
id: "go"
|
||||
data: "components {\n"
|
||||
" id: \"grid_animations\"\n"
|
||||
" component: \"/example/examples/grid/grid_animations/grid_animations.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
|
||||
}
|
||||
}
|
626
example/examples/grid/grid_animations/grid_animations.gui
Normal file
626
example/examples/grid/grid_animations/grid_animations.gui
Normal file
@ -0,0 +1,626 @@
|
||||
script: "/example/examples/grid/grid_animations/grid_animations.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: -100.0
|
||||
y: -200.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_TEMPLATE
|
||||
id: "button_add"
|
||||
parent: "root"
|
||||
layer: ""
|
||||
inherit_alpha: true
|
||||
alpha: 1.0
|
||||
template: "/example/templates/button.gui"
|
||||
template_node_child: false
|
||||
}
|
||||
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: 130.0
|
||||
y: 60.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/button_blue"
|
||||
id: "button_add/button"
|
||||
xanchor: XANCHOR_NONE
|
||||
yanchor: YANCHOR_NONE
|
||||
pivot: PIVOT_CENTER
|
||||
adjust_mode: ADJUST_MODE_FIT
|
||||
parent: "button_add"
|
||||
layer: "image"
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 15.0
|
||||
y: 15.0
|
||||
z: 15.0
|
||||
w: 15.0
|
||||
}
|
||||
clipping_mode: CLIPPING_MODE_NONE
|
||||
clipping_visible: true
|
||||
clipping_inverted: false
|
||||
alpha: 1.0
|
||||
template_node_child: true
|
||||
size_mode: SIZE_MODE_MANUAL
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: 0.0
|
||||
y: 7.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
rotation {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
scale {
|
||||
x: 0.7
|
||||
y: 0.7
|
||||
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: "Add\n"
|
||||
""
|
||||
font: "game"
|
||||
id: "button_add/text"
|
||||
xanchor: XANCHOR_NONE
|
||||
yanchor: YANCHOR_NONE
|
||||
pivot: PIVOT_CENTER
|
||||
outline {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
shadow {
|
||||
x: 0.101960786
|
||||
y: 0.2
|
||||
z: 0.6
|
||||
w: 1.0
|
||||
}
|
||||
adjust_mode: ADJUST_MODE_FIT
|
||||
line_break: false
|
||||
parent: "button_add/button"
|
||||
layer: "text"
|
||||
inherit_alpha: true
|
||||
alpha: 1.0
|
||||
outline_alpha: 0.0
|
||||
shadow_alpha: 0.78
|
||||
overridden_fields: 8
|
||||
template_node_child: true
|
||||
text_leading: 1.0
|
||||
text_tracking: 0.0
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: 100.0
|
||||
y: -200.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_TEMPLATE
|
||||
id: "button_remove"
|
||||
parent: "root"
|
||||
layer: ""
|
||||
inherit_alpha: true
|
||||
alpha: 1.0
|
||||
template: "/example/templates/button.gui"
|
||||
template_node_child: false
|
||||
}
|
||||
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: 130.0
|
||||
y: 60.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/button_blue"
|
||||
id: "button_remove/button"
|
||||
xanchor: XANCHOR_NONE
|
||||
yanchor: YANCHOR_NONE
|
||||
pivot: PIVOT_CENTER
|
||||
adjust_mode: ADJUST_MODE_FIT
|
||||
parent: "button_remove"
|
||||
layer: "image"
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 15.0
|
||||
y: 15.0
|
||||
z: 15.0
|
||||
w: 15.0
|
||||
}
|
||||
clipping_mode: CLIPPING_MODE_NONE
|
||||
clipping_visible: true
|
||||
clipping_inverted: false
|
||||
alpha: 1.0
|
||||
template_node_child: true
|
||||
size_mode: SIZE_MODE_MANUAL
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: 0.0
|
||||
y: 7.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
rotation {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
scale {
|
||||
x: 0.7
|
||||
y: 0.7
|
||||
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: "Remove\n"
|
||||
""
|
||||
font: "game"
|
||||
id: "button_remove/text"
|
||||
xanchor: XANCHOR_NONE
|
||||
yanchor: YANCHOR_NONE
|
||||
pivot: PIVOT_CENTER
|
||||
outline {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
shadow {
|
||||
x: 0.101960786
|
||||
y: 0.2
|
||||
z: 0.6
|
||||
w: 1.0
|
||||
}
|
||||
adjust_mode: ADJUST_MODE_FIT
|
||||
line_break: false
|
||||
parent: "button_remove/button"
|
||||
layer: "text"
|
||||
inherit_alpha: true
|
||||
alpha: 1.0
|
||||
outline_alpha: 0.0
|
||||
shadow_alpha: 0.78
|
||||
overridden_fields: 8
|
||||
template_node_child: true
|
||||
text_leading: 1.0
|
||||
text_tracking: 0.0
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: 0.0
|
||||
y: 108.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: 200.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: "grid"
|
||||
xanchor: XANCHOR_NONE
|
||||
yanchor: YANCHOR_NONE
|
||||
pivot: PIVOT_CENTER
|
||||
adjust_mode: ADJUST_MODE_FIT
|
||||
parent: "root"
|
||||
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: 80.0
|
||||
y: 110.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: "prefab"
|
||||
xanchor: XANCHOR_NONE
|
||||
yanchor: YANCHOR_NONE
|
||||
pivot: PIVOT_CENTER
|
||||
adjust_mode: ADJUST_MODE_FIT
|
||||
parent: "root"
|
||||
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: 80.0
|
||||
y: 110.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/button_green"
|
||||
id: "prefab_icon"
|
||||
xanchor: XANCHOR_NONE
|
||||
yanchor: YANCHOR_NONE
|
||||
pivot: PIVOT_CENTER
|
||||
adjust_mode: ADJUST_MODE_FIT
|
||||
parent: "prefab"
|
||||
layer: ""
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 10.0
|
||||
y: 10.0
|
||||
z: 10.0
|
||||
w: 10.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: -2.0
|
||||
y: 8.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
rotation {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
scale {
|
||||
x: 1.5
|
||||
y: 1.5
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
size {
|
||||
x: 30.0
|
||||
y: 30.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
color {
|
||||
x: 1.0
|
||||
y: 0.9019608
|
||||
z: 0.6
|
||||
w: 1.0
|
||||
}
|
||||
type: TYPE_TEXT
|
||||
blend_mode: BLEND_MODE_ALPHA
|
||||
text: "1"
|
||||
font: "game"
|
||||
id: "prefab_text"
|
||||
xanchor: XANCHOR_NONE
|
||||
yanchor: YANCHOR_NONE
|
||||
pivot: PIVOT_CENTER
|
||||
outline {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
shadow {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
adjust_mode: ADJUST_MODE_FIT
|
||||
line_break: false
|
||||
parent: "prefab_icon"
|
||||
layer: ""
|
||||
inherit_alpha: true
|
||||
alpha: 1.0
|
||||
outline_alpha: 0.0
|
||||
shadow_alpha: 0.5
|
||||
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
|
@ -0,0 +1,65 @@
|
||||
local druid = require("druid.druid")
|
||||
|
||||
|
||||
local function add_element(self)
|
||||
-- Limit up to 10 nodes in this example
|
||||
if #self.grid.nodes >= 10 then
|
||||
return
|
||||
end
|
||||
|
||||
-- Make new element to insert into the grid
|
||||
local nodes = gui.clone_tree(self.prefab)
|
||||
gui.set_enabled(nodes["prefab"], true)
|
||||
self.grid:add(nodes["prefab"])
|
||||
gui.set_text(nodes["prefab_text"], #self.grid.nodes)
|
||||
|
||||
-- Animate new element after _grid:add_
|
||||
-- Note, what Grid component take care of node position, so we can't
|
||||
-- animate position of the root node. We need insert one more anchor node to make
|
||||
-- it possible. In this example it is "prefab_icon"
|
||||
gui.animate(nodes["prefab_icon"], "position.y", 20, gui.EASING_OUTSINE, 0.4, 0, nil, gui.PLAYBACK_ONCE_BACKWARD)
|
||||
gui.animate(nodes["prefab_icon"], "color.w", 0, gui.EASING_OUTSINE, 0.3, 0, nil, gui.PLAYBACK_ONCE_BACKWARD)
|
||||
end
|
||||
|
||||
|
||||
local function remove_element(self)
|
||||
if #self.grid.nodes > 0 then
|
||||
local root = self.grid:remove(#self.grid.nodes)
|
||||
-- We should instant remove element from the grid, but node itself delete after the animation
|
||||
gui.animate(root, "color.w", 0, gui.EASING_OUTSINE, 0.2, 0, function()
|
||||
gui.delete_node(root)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function init(self)
|
||||
self.druid = druid.new(self)
|
||||
self.grid = self.druid:new_static_grid("grid", "prefab", 5)
|
||||
|
||||
self.prefab = gui.get_node("prefab")
|
||||
gui.set_enabled(self.prefab, false)
|
||||
|
||||
self.druid:new_button("button_add/button", add_element)
|
||||
self.druid:new_button("button_remove/button", remove_element)
|
||||
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
|
Loading…
x
Reference in New Issue
Block a user