From 0e96c582c9380c25dbee4df3c07b2c6762b28ac1 Mon Sep 17 00:00:00 2001 From: Insality Date: Mon, 28 Sep 2020 02:33:47 +0300 Subject: [PATCH] Better grid example hints --- example/gui/main/main.gui | 259 ++++++++++++------------------------ example/page/grid_page.lua | 14 +- example/page/texts_page.lua | 2 +- 3 files changed, 91 insertions(+), 184 deletions(-) diff --git a/example/gui/main/main.gui b/example/gui/main/main.gui index 3e91200..79d53f6 100644 --- a/example/gui/main/main.gui +++ b/example/gui/main/main.gui @@ -9696,7 +9696,7 @@ nodes { nodes { position { x: 0.0 - y: -190.0 + y: -354.0 z: 0.0 w: 1.0 } @@ -9805,8 +9805,8 @@ nodes { } nodes { position { - x: -150.0 - y: -140.0 + x: -80.0 + y: -304.0 z: 0.0 w: 1.0 } @@ -9964,167 +9964,8 @@ nodes { } nodes { position { - x: 0.0 - y: -140.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: "grid_page_content" - 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" - 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: 150.0 - y: -140.0 + x: 80.0 + y: -304.0 z: 0.0 w: 1.0 } @@ -10283,7 +10124,7 @@ nodes { nodes { position { x: -160.0 - y: -230.0 + y: -394.0 z: 0.0 w: 1.0 } @@ -10456,7 +10297,7 @@ nodes { nodes { position { x: 0.0 - y: -650.0 + y: -814.0 z: 0.0 w: 1.0 } @@ -10566,7 +10407,7 @@ nodes { nodes { position { x: 0.0 - y: -700.0 + y: -864.0 z: 0.0 w: 1.0 } @@ -10621,7 +10462,7 @@ nodes { nodes { position { x: -250.0 - y: -1300.0 + y: -1464.0 z: 0.0 w: 1.0 } @@ -10731,7 +10572,7 @@ nodes { nodes { position { x: 0.0 - y: -1309.0 + y: -1473.0 z: 0.0 w: 1.0 } @@ -10786,7 +10627,7 @@ nodes { nodes { position { x: -60.0 - y: -620.0 + y: -784.0 z: 0.0 w: 1.0 } @@ -10911,7 +10752,7 @@ nodes { } type: TYPE_TEXT blend_mode: BLEND_MODE_ALPHA - text: "Add Start" + text: "Add First" font: "game" id: "button_add_start_dynamic/text" xanchor: XANCHOR_NONE @@ -10945,7 +10786,7 @@ nodes { nodes { position { x: 60.0 - y: -620.0 + y: -784.0 z: 0.0 w: 1.0 } @@ -11070,7 +10911,7 @@ nodes { } type: TYPE_TEXT blend_mode: BLEND_MODE_ALPHA - text: "Add End" + text: "Add Last" font: "game" id: "button_add_end_dynamic/text" xanchor: XANCHOR_NONE @@ -11104,7 +10945,7 @@ nodes { nodes { position { x: -60.0 - y: -1211.0 + y: -1375.0 z: 0.0 w: 1.0 } @@ -11229,7 +11070,7 @@ nodes { } type: TYPE_TEXT blend_mode: BLEND_MODE_ALPHA - text: "Add Start" + text: "Add First" font: "game" id: "button_add_start_dynamic_hor/text" xanchor: XANCHOR_NONE @@ -11263,7 +11104,7 @@ nodes { nodes { position { x: 60.0 - y: -1211.0 + y: -1375.0 z: 0.0 w: 1.0 } @@ -11388,7 +11229,7 @@ nodes { } type: TYPE_TEXT blend_mode: BLEND_MODE_ALPHA - text: "Add End" + text: "Add Last" font: "game" id: "button_add_end_dynamic_hor/text" xanchor: XANCHOR_NONE @@ -11419,6 +11260,70 @@ nodes { text_leading: 1.0 text_tracking: 0.0 } +nodes { + position { + x: -200.0 + y: -180.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: 533.33 + y: 200.0 + z: 0.0 + w: 1.0 + } + color { + x: 0.0 + y: 0.0 + z: 0.0 + w: 1.0 + } + type: TYPE_TEXT + blend_mode: BLEND_MODE_ALPHA + text: "Tap on node for remove\n" + "Long tap on node for remove without node shift" + font: "game" + id: "text_grid_hint" + xanchor: XANCHOR_NONE + yanchor: YANCHOR_NONE + pivot: PIVOT_W + outline { + x: 1.0 + y: 1.0 + z: 1.0 + w: 1.0 + } + shadow { + x: 1.0 + y: 1.0 + z: 1.0 + w: 1.0 + } + adjust_mode: ADJUST_MODE_FIT + line_break: true + parent: "grid_page_content" + layer: "" + inherit_alpha: true + alpha: 1.0 + outline_alpha: 0.0 + shadow_alpha: 0.0 + template_node_child: false + text_leading: 1.0 + text_tracking: 0.0 +} nodes { position { x: 0.0 diff --git a/example/page/grid_page.lua b/example/page/grid_page.lua index e2aff6d..4a0f9b3 100644 --- a/example/page/grid_page.lua +++ b/example/page/grid_page.lua @@ -66,19 +66,18 @@ local function init_static_grid(self) self.druid:new_button("button_add/button", function() add_node(self) end) - self.druid:new_button("button_clear/button", clear_nodes) - - local remove_button = self.druid:new_button("button_remove/button", remove_node) - gui.set_enabled(remove_button.node, false) + self.druid:new_button("button_clear/button", function() + clear_nodes(self) + end) end -local function remove_dynamic_node(self, button) +local function remove_dynamic_node(self, button, is_shift_left) 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) + self.grid_dynamic_grid:remove(index, is_shift_left) for i = 1, #self.dynamic_node_buttons do if self.dynamic_node_buttons[i] == button then table.remove(self.dynamic_node_buttons, i) @@ -97,6 +96,9 @@ local function add_node_dynamic(self, index, is_shift_left) local button = self.druid:new_button(node, function(_, params, button) remove_dynamic_node(self, button) end) + button.on_long_click:subscribe(function() + remove_dynamic_node(self, button, true) + end) button:set_click_zone(self.grid_dynamic_scroll.view_node) table.insert(self.dynamic_node_buttons, button) end diff --git a/example/page/texts_page.lua b/example/page/texts_page.lua index b77da1e..bb64294 100644 --- a/example/page/texts_page.lua +++ b/example/page/texts_page.lua @@ -27,7 +27,7 @@ local function setup_texts(self) timer.delay(0.3, true, function() anchoring:set_pivot(pivots[pivot_index]) - pivot_index = pivot_index + 1 + pivot_index = pivot_index + 1 if pivot_index > #pivots then pivot_index = 1 end