Fix static poses calculation

This commit is contained in:
Insality
2020-11-09 01:11:22 +03:00
parent e038d70039
commit 834d0714e0
4 changed files with 358 additions and 105 deletions

View File

@@ -11793,7 +11793,7 @@ nodes {
}
nodes {
position {
x: 0.0
x: -150.0
y: -644.0
z: 0.0
w: 1.0
@@ -11811,7 +11811,7 @@ nodes {
w: 1.0
}
size {
x: 400.0
x: 250.0
y: 250.0
z: 0.0
w: 1.0
@@ -11866,7 +11866,7 @@ nodes {
w: 1.0
}
size {
x: 400.0
x: 250.0
y: 250.0
z: 0.0
w: 1.0
@@ -11879,7 +11879,7 @@ nodes {
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: "kenney/empty"
texture: ""
id: "infinity_scroll_content"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
@@ -11903,8 +11903,8 @@ nodes {
}
nodes {
position {
x: 0.0
y: -684.0
x: 150.0
y: -644.0
z: 0.0
w: 1.0
}
@@ -11921,35 +11921,35 @@ nodes {
w: 1.0
}
size {
x: 300.0
y: 60.0
x: 250.0
y: 100.0
z: 0.0
w: 1.0
}
color {
x: 1.0
x: 0.8
y: 1.0
z: 1.0
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: "kenney/button_blue"
id: "infinity_prefab"
texture: ""
id: "infinity_scroll_stencil_hor"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
pivot: PIVOT_N
adjust_mode: ADJUST_MODE_FIT
parent: "infinity_page_content"
layer: ""
inherit_alpha: true
slice9 {
x: 20.0
x: 0.0
y: 0.0
z: 20.0
z: 0.0
w: 0.0
}
clipping_mode: CLIPPING_MODE_NONE
clipping_mode: CLIPPING_MODE_STENCIL
clipping_visible: true
clipping_inverted: false
alpha: 1.0
@@ -11958,8 +11958,8 @@ nodes {
}
nodes {
position {
x: 0.0
y: 4.0
x: -125.0
y: -50.0
z: 0.0
w: 1.0
}
@@ -11970,54 +11970,46 @@ nodes {
w: 1.0
}
scale {
x: 0.75
y: 0.75
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
size {
x: 380.0
y: 50.0
x: 250.0
y: 100.0
z: 0.0
w: 1.0
}
color {
x: 1.0
x: 0.8
y: 1.0
z: 1.0
w: 1.0
}
type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA
text: "Infinity element 1"
font: "game"
id: "infinity_text"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
outline {
x: 0.3019608
y: 0.4
z: 0.8
w: 1.0
}
shadow {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: ""
id: "infinity_scroll_content_hor"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_W
adjust_mode: ADJUST_MODE_FIT
line_break: false
parent: "infinity_prefab"
parent: "infinity_scroll_stencil_hor"
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
outline_alpha: 1.0
shadow_alpha: 0.0
template_node_child: false
text_leading: 1.0
text_tracking: 0.0
size_mode: SIZE_MODE_MANUAL
}
nodes {
position {
@@ -12204,7 +12196,7 @@ nodes {
w: 1.0
}
size {
x: 380.0
x: 60.0
y: 50.0
z: 0.0
w: 1.0
@@ -12249,7 +12241,7 @@ nodes {
}
nodes {
position {
x: 0.0
x: -150.0
y: -176.0
z: 0.0
w: 1.0
@@ -12267,8 +12259,8 @@ nodes {
w: 1.0
}
size {
x: 400.0
y: 400.0
x: 250.0
y: 350.0
z: 0.0
w: 1.0
}
@@ -12322,8 +12314,8 @@ nodes {
w: 1.0
}
size {
x: 400.0
y: 400.0
x: 250.0
y: 350.0
z: 0.0
w: 1.0
}
@@ -12359,8 +12351,8 @@ nodes {
}
nodes {
position {
x: 0.0
y: -216.0
x: 150.0
y: -176.0
z: 0.0
w: 1.0
}
@@ -12377,7 +12369,117 @@ nodes {
w: 1.0
}
size {
x: 300.0
x: 250.0
y: 100.0
z: 0.0
w: 1.0
}
color {
x: 0.8
y: 1.0
z: 1.0
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: ""
id: "infinity_scroll_stencil_dynamic_hor"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_N
adjust_mode: ADJUST_MODE_FIT
parent: "infinity_page_content"
layer: ""
inherit_alpha: true
slice9 {
x: 0.0
y: 0.0
z: 0.0
w: 0.0
}
clipping_mode: CLIPPING_MODE_STENCIL
clipping_visible: true
clipping_inverted: false
alpha: 1.0
template_node_child: false
size_mode: SIZE_MODE_MANUAL
}
nodes {
position {
x: -125.0
y: -50.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: 100.0
z: 0.0
w: 1.0
}
color {
x: 0.8
y: 1.0
z: 0.8
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: "kenney/empty"
id: "infinity_scroll_content_dynamic_hor"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_W
adjust_mode: ADJUST_MODE_FIT
parent: "infinity_scroll_stencil_dynamic_hor"
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: 150.0
y: -820.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: 60.0
z: 0.0
w: 1.0
@@ -12391,7 +12493,7 @@ nodes {
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: "kenney/button_blue"
id: "infinity_prefab_dynamic"
id: "infinity_prefab"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
@@ -12432,7 +12534,7 @@ nodes {
w: 1.0
}
size {
x: 380.0
x: 200.0
y: 50.0
z: 0.0
w: 1.0
@@ -12445,7 +12547,125 @@ nodes {
}
type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA
text: "Dynamic element 1"
text: "Record 1"
font: "game"
id: "infinity_text"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
outline {
x: 0.3019608
y: 0.4
z: 0.8
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: "infinity_prefab"
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
}
nodes {
position {
x: 151.0
y: -356.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: 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: "infinity_prefab_dynamic"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
adjust_mode: ADJUST_MODE_FIT
parent: "infinity_page_content"
layer: ""
inherit_alpha: true
slice9 {
x: 20.0
y: 10.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: 4.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 0.75
y: 0.75
z: 1.0
w: 1.0
}
size {
x: 200.0
y: 50.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: "Dynamic 1"
font: "game"
id: "infinity_text_dynamic"
xanchor: XANCHOR_NONE

View File

@@ -1,3 +1,5 @@
local const = require("druid.const")
local M = {}
@@ -6,12 +8,12 @@ local function simple_animate(node, pos)
end
local function remove_node(self, button, is_shift)
local function remove_node(self, button, no_shift)
gui.delete_node(button.node)
self.druid:remove(button)
local index = self.grid_static_grid:get_index_by_node(button.node)
self.grid_static_grid:remove(index, is_shift)
self.grid_static_grid:remove(index, no_shift and const.SHIFT.NO_SHIFT or const.SHIFT.RIGHT)
for i = 1, #self.grid_node_buttons do
if self.grid_node_buttons[i] == button then
table.remove(self.grid_node_buttons, i)
@@ -27,10 +29,10 @@ local function add_node(self, index)
gui.set_enabled(cloned["grid_nodes_prefab"], true)
local button = self.druid:new_button(cloned["grid_nodes_prefab"], function(_, params, button)
remove_node(self, button, true)
remove_node(self, button)
end)
button.on_long_click:subscribe(function()
remove_node(self, button)
remove_node(self, button, true)
end)
button:set_click_zone(self.grid_static_scroll.view_node)
@@ -72,12 +74,12 @@ local function init_static_grid(self)
end
local function remove_dynamic_node(self, button, is_shift_left)
local function remove_dynamic_node(self, button, shift_policy)
gui.delete_node(button.node)
self.druid:remove(button)
local index = self.grid_dynamic_grid:get_index_by_node(button.node)
self.grid_dynamic_grid:remove(index, is_shift_left)
self.grid_dynamic_grid:remove(index, shift_policy)
for i = 1, #self.dynamic_node_buttons do
if self.dynamic_node_buttons[i] == button then
table.remove(self.dynamic_node_buttons, i)
@@ -97,7 +99,7 @@ local function add_node_dynamic(self, index, is_shift_left)
remove_dynamic_node(self, button)
end)
button.on_long_click:subscribe(function()
remove_dynamic_node(self, button, true)
remove_dynamic_node(self, button, const.SHIFT.lEFT)
end)
button:set_click_zone(self.grid_dynamic_scroll.view_node)
table.insert(self.dynamic_node_buttons, button)

View File

@@ -4,7 +4,7 @@
local function create_infinity_instance(self, record, index)
local instance = gui.clone_tree(self.infinity_prefab)
gui.set_enabled(instance["infinity_prefab"], true)
gui.set_text(instance["infinity_text"], "Infinity record " .. index)
gui.set_text(instance["infinity_text"], "Record " .. index)
local button = self.druid:new_button(instance["infinity_prefab"], function()
print("Infinity click on", index)
@@ -27,13 +27,26 @@ local function create_infinity_instance_small(self, record, index)
end
local function create_infinity_instance_dynamic(self, record, index)
local instance = gui.clone_tree(self.infinity_prefab_dynamic)
gui.set_enabled(instance["infinity_prefab_dynamic"], true)
gui.set_text(instance["infinity_text_dynamic"], "Dynamic record " .. index)
gui.set_text(instance["infinity_text_dynamic"], "Record " .. index)
gui.set_size(instance["infinity_prefab_dynamic"], vmath.vector3(300, 60 + index * 5, 0))
gui.set_size(instance["infinity_prefab_dynamic"], vmath.vector3(200, 60 + index * 3, 0))
local button = self.druid:new_button(instance["infinity_prefab_dynamic"], function()
print("Dynamic click on", index)
end)
return instance["infinity_prefab_dynamic"], button
end
local function create_infinity_instance_dynamic_hor(self, record, index)
local instance = gui.clone_tree(self.infinity_prefab_dynamic)
gui.set_enabled(instance["infinity_prefab_dynamic"], true)
gui.set_text(instance["infinity_text_dynamic"], "Record " .. index)
gui.set_size(instance["infinity_prefab_dynamic"], vmath.vector3(150 + 2 * index, 60, 0))
local button = self.druid:new_button(instance["infinity_prefab_dynamic"], function()
print("Dynamic click on", index)
end)
@@ -53,9 +66,17 @@ local function setup_infinity_list(self)
return create_infinity_instance(self, record, index)
end)
self.infinity_list_hor = self.druid:new_infinity_list(data, self.infinity_scroll_hor, self.infinity_grid_hor, function(record, index)
-- function should return gui_node, [druid_component]
return create_infinity_instance(self, record, index)
end)
-- scroll to some index
-- local pos = self.infinity_grid:get_pos(25)
-- self.infinity_scroll:scroll_to(pos, true)
-- timer.delay(1, false, function()
-- self.infinity_list:scroll_to_index(1)
-- end)
self.infinity_list_small = self.druid:new_infinity_list(data, self.infinity_scroll_3, self.infinity_grid_3, function(record, index)
@@ -67,29 +88,44 @@ local function setup_infinity_list(self)
-- function should return gui_node, [druid_component]
return create_infinity_instance_dynamic(self, record, index)
end)
self.infinity_list_dynamic_hor = self.druid:new_infinity_list(data, self.infinity_scroll_dynamic_hor, self.infinity_grid_dynamic_hor, function(record, index)
-- function should return gui_node, [druid_component]
return create_infinity_instance_dynamic_hor(self, record, index)
end)
end
function M.setup_page(self)
self.druid:new_scroll("infinity_page", "infinity_page_content")
self.infinity_prefab = gui.get_node("infinity_prefab")
self.infinity_prefab_small = gui.get_node("infinity_prefab_small")
self.infinity_prefab_dynamic = gui.get_node("infinity_prefab_dynamic")
gui.set_enabled(self.infinity_prefab, false)
gui.set_enabled(self.infinity_prefab_small, false)
gui.set_enabled(self.infinity_prefab_dynamic, false)
self.infinity_scroll = self.druid:new_scroll("infinity_scroll_stencil", "infinity_scroll_content")
:set_horizontal_scroll(false)
self.infinity_grid = self.druid:new_static_grid("infinity_scroll_content", "infinity_prefab", 1)
self.infinity_prefab = gui.get_node("infinity_prefab")
gui.set_enabled(self.infinity_prefab, false)
self.infinity_scroll_hor = self.druid:new_scroll("infinity_scroll_stencil_hor", "infinity_scroll_content_hor")
:set_vertical_scroll(false)
self.infinity_grid_hor = self.druid:new_static_grid("infinity_scroll_content_hor", "infinity_prefab", 999)
self.infinity_scroll_3 = self.druid:new_scroll("infinity_scroll_3_stencil", "infinity_scroll_3_content")
:set_horizontal_scroll(false)
self.infinity_grid_3 = self.druid:new_static_grid("infinity_scroll_3_content", "infinity_prefab_small", 3)
self.infinity_prefab_small = gui.get_node("infinity_prefab_small")
gui.set_enabled(self.infinity_prefab_small, false)
self.infinity_scroll_dynamic = self.druid:new_scroll("infinity_scroll_stencil_dynamic", "infinity_scroll_content_dynamic")
:set_horizontal_scroll(false)
self.infinity_grid_dynamic = self.druid:new_dynamic_grid("infinity_scroll_content_dynamic", "infinity_prefab", 1)
self.infinity_prefab_dynamic = gui.get_node("infinity_prefab_dynamic")
gui.set_enabled(self.infinity_prefab_dynamic, false)
self.infinity_grid_dynamic = self.druid:new_dynamic_grid("infinity_scroll_content_dynamic")
self.infinity_scroll_dynamic_hor = self.druid:new_scroll("infinity_scroll_stencil_dynamic_hor", "infinity_scroll_content_dynamic_hor")
:set_vertical_scroll(false)
self.infinity_grid_dynamic_hor = self.druid:new_dynamic_grid("infinity_scroll_content_dynamic_hor")
setup_infinity_list(self)
end