From 8651569f2bb8480336d424f346c81edcc5e1acd8 Mon Sep 17 00:00:00 2001 From: RodZill4 Date: Sat, 5 Oct 2019 19:50:44 +0200 Subject: [PATCH] Fixed problem with preview and generic node update --- addons/material_maker/main_window.tscn | 2 +- addons/material_maker/nodes/generic.gd | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/addons/material_maker/main_window.tscn b/addons/material_maker/main_window.tscn index 6c9dd0e..efbf5da 100644 --- a/addons/material_maker/main_window.tscn +++ b/addons/material_maker/main_window.tscn @@ -42,7 +42,7 @@ margin_left = 79.0 margin_right = 125.0 margin_bottom = 20.0 text = "Tools" -items = [ "Create subgraph", null, 0, false, false, 15, 268435527, null, "", false, "Make selected nodes editable", null, 0, false, false, 16, 268435526, null, "", false, "Add selected node to user library", null, 0, false, false, 17, 0, null, "", false, "Save user library", null, 0, false, false, 18, 0, null, "", false ] +items = [ "Create group", null, 0, false, false, 15, 268435527, null, "", false, "Make selected nodes editable", null, 0, false, false, 16, 268435526, null, "", false, "Add selected node to user library", null, 0, false, false, 17, 0, null, "", false, "Save user library", null, 0, false, false, 18, 0, null, "", false ] [node name="Help" type="MenuButton" parent="VBoxContainer/Menu"] margin_left = 129.0 diff --git a/addons/material_maker/nodes/generic.gd b/addons/material_maker/nodes/generic.gd index 194982d..5ddcf98 100644 --- a/addons/material_maker/nodes/generic.gd +++ b/addons/material_maker/nodes/generic.gd @@ -12,7 +12,7 @@ var preview : TextureRect var preview_index : int = -1 var preview_position : int var preview_size : int -var preview_timer : Timer +var preview_timer : Timer = null func set_generator(g): generator = g @@ -142,6 +142,10 @@ func create_parameter_control(p : Dictionary): func update_node(): # Clean node var custom_node_buttons = null + remove_child(preview) + if preview_timer != null: + preview_timer.stop() + remove_child(preview_timer) for c in get_children(): c.queue_free() yield(get_tree(), "idle_frame") @@ -256,6 +260,8 @@ func update_node(): var button = preload("res://addons/material_maker/widgets/preview_button.tscn").instance() button.size_flags_horizontal = SIZE_SHRINK_END button.size_flags_vertical = SIZE_SHRINK_CENTER + if i == preview_index: + button.pressed = true hsizer.add_child(button) button.connect("toggled", self, "on_preview_button", [ i ]) button_width = button.rect_size.x @@ -276,9 +282,10 @@ func update_node(): add_child(edit_buttons) edit_buttons.connect_buttons(self, "edit_generator", "load_generator", "save_generator") # Preview timer - preview_timer = Timer.new() - preview_timer.one_shot = true - preview_timer.connect("timeout", self, "do_update_preview") + if preview_timer == null: + preview_timer = Timer.new() + preview_timer.one_shot = true + preview_timer.connect("timeout", self, "do_update_preview") add_child(preview_timer)