Add initial progress on dynamic grid

This commit is contained in:
Insality
2020-09-21 23:00:51 +03:00
parent 6ce14a7a1c
commit f8731b2640
5 changed files with 379 additions and 72 deletions

View File

@@ -9713,8 +9713,8 @@ nodes {
w: 1.0
}
size {
x: 1.0
y: 1.0
x: 600.0
y: 900.0
z: 0.0
w: 1.0
}
@@ -9746,12 +9746,67 @@ nodes {
clipping_inverted: false
alpha: 1.0
template_node_child: false
size_mode: SIZE_MODE_AUTO
size_mode: SIZE_MODE_MANUAL
}
nodes {
position {
x: 0.0
y: 200.0
y: 450.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: 1800.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_page_content"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_N
adjust_mode: ADJUST_MODE_FIT
parent: "grid_page"
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: -190.0
z: 0.0
w: 1.0
}
@@ -9787,7 +9842,7 @@ nodes {
yanchor: YANCHOR_NONE
pivot: PIVOT_N
adjust_mode: ADJUST_MODE_FIT
parent: "grid_page"
parent: "grid_page_content"
layer: ""
inherit_alpha: true
slice9 {
@@ -9806,7 +9861,7 @@ nodes {
nodes {
position {
x: -150.0
y: 250.0
y: -140.0
z: 0.0
w: 1.0
}
@@ -9836,7 +9891,7 @@ nodes {
}
type: TYPE_TEMPLATE
id: "button_add"
parent: "grid_page"
parent: "grid_page_content"
layer: ""
inherit_alpha: true
alpha: 1.0
@@ -9965,7 +10020,7 @@ nodes {
nodes {
position {
x: 0.0
y: 250.0
y: -140.0
z: 0.0
w: 1.0
}
@@ -9995,7 +10050,7 @@ nodes {
}
type: TYPE_TEMPLATE
id: "button_remove"
parent: "grid_page"
parent: "grid_page_content"
layer: ""
inherit_alpha: true
alpha: 1.0
@@ -10124,7 +10179,7 @@ nodes {
nodes {
position {
x: 150.0
y: 250.0
y: -140.0
z: 0.0
w: 1.0
}
@@ -10154,7 +10209,7 @@ nodes {
}
type: TYPE_TEMPLATE
id: "button_clear"
parent: "grid_page"
parent: "grid_page_content"
layer: ""
inherit_alpha: true
alpha: 1.0
@@ -10283,7 +10338,7 @@ nodes {
nodes {
position {
x: -160.0
y: 160.0
y: -230.0
z: 0.0
w: 1.0
}
@@ -10319,7 +10374,7 @@ nodes {
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
adjust_mode: ADJUST_MODE_FIT
parent: "grid_page"
parent: "grid_page_content"
layer: ""
inherit_alpha: true
slice9 {
@@ -10453,6 +10508,171 @@ nodes {
text_leading: 1.0
text_tracking: 0.0
}
nodes {
position {
x: 0.0
y: -650.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: 300.0
y: 400.0
z: 0.0
w: 1.0
}
color {
x: 0.9019608
y: 0.9019608
z: 0.7019608
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: ""
id: "grid_dynamic_nodes"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_N
adjust_mode: ADJUST_MODE_FIT
parent: "grid_page_content"
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: -700.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: 250.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_red"
id: "grid_dynamic_prefab"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
adjust_mode: ADJUST_MODE_FIT
parent: "grid_page_content"
layer: ""
inherit_alpha: true
slice9 {
x: 20.0
y: 20.0
z: 20.0
w: 20.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: -650.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: 300.0
y: 400.0
z: 0.0
w: 1.0
}
color {
x: 0.5019608
y: 0.3019608
z: 0.5019608
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: ""
id: "grid_area"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
adjust_mode: ADJUST_MODE_FIT
parent: "grid_page_content"
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: 0.5
template_node_child: false
size_mode: SIZE_MODE_MANUAL
}
nodes {
position {
x: 0.0

View File

@@ -45,7 +45,7 @@ local function clear_nodes(self)
end
function M.setup_page(self)
local function init_static_grid(self)
self.grid_nodes = self.druid:new_static_grid("grid_nodes", "grid_nodes_prefab", 5)
self.grid_nodes:set_position_function(function(node, pos)
gui.animate(node, "position", pos, gui.EASING_OUTSINE, 0.2)
@@ -65,4 +65,37 @@ function M.setup_page(self)
end
local function add_node_dynamic(self, index)
local node = gui.clone(self.prefab_dynamic)
gui.set_enabled(node, true)
gui.set_size(node, vmath.vector3(250, math.random(60, 150), 0))
self.dynamic_grid:add(node)
end
local function init_dynamic_grid(self)
self.dynamic_grid = self.druid:new_dynamic_grid("grid_dynamic_nodes", "vertical")
self.prefab_dynamic = gui.get_node("grid_dynamic_prefab")
gui.set_enabled(self.prefab_dynamic, false)
for i = 1, 15 do
add_node_dynamic(self, i)
end
local area = gui.get_node("grid_area")
gui.set_size(area, self.dynamic_grid:get_size())
gui.set_position(area, self.dynamic_grid:get_center_position())
print(self.dynamic_grid:get_center_position())
end
function M.setup_page(self)
self.grid_page_scroll = self.druid:new_scroll("grid_page", "grid_page_content")
init_static_grid(self)
init_dynamic_grid(self)
end
return M

View File

@@ -5,7 +5,7 @@ local function init_scroll_with_grid(self)
local prefab = gui.get_node("grid_prefab")
local grid_scroll = self.druid:new_scroll("scroll_with_grid_size", "grid_content")
local grid = self.druid:new_grid("grid_content", "grid_prefab", 20)
local grid = self.druid:new_static_grid("grid_content", "grid_prefab", 20)
for i = 1, 40 do
local clone_prefab = gui.clone_tree(prefab)