From 1a5ddae2267d8f3167fc5d09b2e7b8d59bc2ce61 Mon Sep 17 00:00:00 2001 From: RodZill4 Date: Mon, 10 Sep 2018 21:59:52 +0200 Subject: [PATCH] Added comment node --- addons/material_maker/graph_edit.tscn | 2 +- addons/material_maker/library/base.json | 4 + addons/material_maker/main_window.gd | 1 + addons/material_maker/nodes/comment.gd | 32 ++++ addons/material_maker/nodes/comment.tscn | 65 ++++++++ .../material_maker/widgets/line_dialog.tscn | 11 +- addons/material_maker/widgets/text_dialog.gd | 17 ++ .../material_maker/widgets/text_dialog.tscn | 146 ++++++++++++++++++ 8 files changed, 272 insertions(+), 6 deletions(-) create mode 100644 addons/material_maker/nodes/comment.gd create mode 100644 addons/material_maker/nodes/comment.tscn create mode 100644 addons/material_maker/widgets/text_dialog.gd create mode 100644 addons/material_maker/widgets/text_dialog.tscn diff --git a/addons/material_maker/graph_edit.tscn b/addons/material_maker/graph_edit.tscn index 362c89e..c36a474 100644 --- a/addons/material_maker/graph_edit.tscn +++ b/addons/material_maker/graph_edit.tscn @@ -6,7 +6,7 @@ [sub_resource type="Theme" id=1] -[node name="GraphEdit" type="GraphEdit" index="0"] +[node name="GraphEdit" type="GraphEdit"] self_modulate = Color( 1, 1, 1, 0 ) anchor_left = 0.0 diff --git a/addons/material_maker/library/base.json b/addons/material_maker/library/base.json index 2640bb8..5c3eb0d 100644 --- a/addons/material_maker/library/base.json +++ b/addons/material_maker/library/base.json @@ -205,5 +205,9 @@ { "tree_item":"Miscellaneous/Remote", "type":"remote" + }, + { + "tree_item":"Miscellaneous/Comment", + "type":"comment" } ]} \ No newline at end of file diff --git a/addons/material_maker/main_window.gd b/addons/material_maker/main_window.gd index bbd971b..39c07b9 100644 --- a/addons/material_maker/main_window.gd +++ b/addons/material_maker/main_window.gd @@ -184,6 +184,7 @@ func add_to_user_library(): selected_nodes.append(n) if !selected_nodes.empty(): var dialog = preload("res://addons/material_maker/widgets/line_dialog.tscn").instance() + dialog.set_texts("New library element", "Select a name for the new library element") add_child(dialog) dialog.connect("ok", self, "do_add_to_user_library", [ selected_nodes ]) dialog.popup_centered() diff --git a/addons/material_maker/nodes/comment.gd b/addons/material_maker/nodes/comment.gd new file mode 100644 index 0000000..c7745a5 --- /dev/null +++ b/addons/material_maker/nodes/comment.gd @@ -0,0 +1,32 @@ +tool +extends "res://addons/material_maker/node_base.gd" + +func _get_shader_code(uv): + var rv = { defs="", code="" } + rv.rgb = "vec3(1.0)" + return rv + +func serialize(): + var data = .serialize() + data.text = $Label.text + return data + +func deserialize(data): + .deserialize(data) + if data.has("text"): + $Label.text = data.text + +func _on_resize_request(new_minsize): + rect_min_size = new_minsize + +func _on_Label_gui_input(ev): + if ev is InputEventMouseButton and ev.doubleclick and ev.button_index == BUTTON_LEFT: + var dialog = preload("res://addons/material_maker/widgets/text_dialog.tscn").instance() + dialog.set_title("Write comment") + dialog.set_text($Label.text) + add_child(dialog) + dialog.connect("ok", self, "set_comment") + dialog.popup_centered() + +func set_comment(text): + $Label.text = text diff --git a/addons/material_maker/nodes/comment.tscn b/addons/material_maker/nodes/comment.tscn new file mode 100644 index 0000000..a1b29ee --- /dev/null +++ b/addons/material_maker/nodes/comment.tscn @@ -0,0 +1,65 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/material_maker/nodes/comment.gd" type="Script" id=1] + +[node name="GraphNode" type="GraphNode" index="0"] + +anchor_left = 0.0 +anchor_top = 0.0 +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_left = 1.0 +margin_top = 1.0 +margin_right = 109.0 +margin_bottom = 81.0 +rect_min_size = Vector2( 100, 80 ) +rect_pivot_offset = Vector2( 0, 0 ) +rect_clip_content = false +mouse_filter = 0 +mouse_default_cursor_shape = 0 +size_flags_horizontal = 3 +size_flags_vertical = 3 +title = "Comment" +offset = Vector2( 0, 0 ) +show_close = true +resizable = true +selected = false +comment = true +overlay = 0 +slot/0/left_enabled = false +slot/0/left_type = 0 +slot/0/left_color = Color( 1, 1, 1, 1 ) +slot/0/right_enabled = false +slot/0/right_type = 0 +slot/0/right_color = Color( 1, 1, 1, 1 ) +script = ExtResource( 1 ) +_sections_unfolded = [ "custom_styles" ] + +[node name="Label" type="Label" parent="." index="0"] + +anchor_left = 0.0 +anchor_top = 0.0 +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_left = 16.0 +margin_top = 24.0 +margin_right = 92.0 +margin_bottom = 72.0 +rect_pivot_offset = Vector2( 0, 0 ) +rect_clip_content = false +mouse_filter = 0 +mouse_default_cursor_shape = 0 +size_flags_horizontal = 1 +size_flags_vertical = 4 +text = "Double-click to write a comment" +autowrap = true +percent_visible = 1.0 +lines_skipped = 0 +max_lines_visible = -1 +_sections_unfolded = [ "Mouse" ] + +[connection signal="resize_request" from="." to="." method="_on_resize_request"] + +[connection signal="gui_input" from="Label" to="." method="_on_Label_gui_input"] + + diff --git a/addons/material_maker/widgets/line_dialog.tscn b/addons/material_maker/widgets/line_dialog.tscn index d008b5d..758ef9a 100644 --- a/addons/material_maker/widgets/line_dialog.tscn +++ b/addons/material_maker/widgets/line_dialog.tscn @@ -2,7 +2,7 @@ [ext_resource path="res://addons/material_maker/widgets/line_dialog.gd" type="Script" id=1] -[node name="LineDialog" type="WindowDialog" index="0"] +[node name="LineDialog" type="WindowDialog"] anchor_left = 0.0 anchor_top = 0.0 @@ -17,7 +17,7 @@ mouse_default_cursor_shape = 0 size_flags_horizontal = 1 size_flags_vertical = 1 popup_exclusive = false -window_title = "New library element" +window_title = "blah" resizable = false script = ExtResource( 1 ) @@ -49,7 +49,7 @@ mouse_filter = 2 mouse_default_cursor_shape = 0 size_flags_horizontal = 1 size_flags_vertical = 4 -text = "Select a name for the new library element" +text = "blah" percent_visible = 1.0 lines_skipped = 0 max_lines_visible = -1 @@ -83,14 +83,15 @@ anchor_left = 0.0 anchor_top = 0.0 anchor_right = 0.0 anchor_bottom = 0.0 +margin_left = 104.0 margin_top = 46.0 -margin_right = 124.0 +margin_right = 228.0 margin_bottom = 66.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false mouse_filter = 1 mouse_default_cursor_shape = 0 -size_flags_horizontal = 0 +size_flags_horizontal = 4 size_flags_vertical = 0 alignment = 0 _sections_unfolded = [ "Size Flags" ] diff --git a/addons/material_maker/widgets/text_dialog.gd b/addons/material_maker/widgets/text_dialog.gd new file mode 100644 index 0000000..635a186 --- /dev/null +++ b/addons/material_maker/widgets/text_dialog.gd @@ -0,0 +1,17 @@ +tool +extends WindowDialog + +signal ok + +func _ready(): + popup() + +func set_title(title): + window_title = title + +func set_text(text): + $VBoxContainer/TextEdit.text = text + +func _on_OK_pressed(): + emit_signal("ok", $VBoxContainer/TextEdit.text) + queue_free() diff --git a/addons/material_maker/widgets/text_dialog.tscn b/addons/material_maker/widgets/text_dialog.tscn new file mode 100644 index 0000000..d7dacb6 --- /dev/null +++ b/addons/material_maker/widgets/text_dialog.tscn @@ -0,0 +1,146 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/material_maker/widgets/text_dialog.gd" type="Script" id=1] + +[node name="TextDialog" type="WindowDialog"] + +anchor_left = 0.0 +anchor_top = 0.0 +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_right = 310.0 +margin_bottom = 178.0 +rect_pivot_offset = Vector2( 0, 0 ) +rect_clip_content = false +mouse_filter = 0 +mouse_default_cursor_shape = 0 +size_flags_horizontal = 1 +size_flags_vertical = 1 +popup_exclusive = false +window_title = "blah" +resizable = false +script = ExtResource( 1 ) + +[node name="VBoxContainer" type="VBoxContainer" parent="." index="1"] + +anchor_left = 0.0 +anchor_top = 0.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +rect_pivot_offset = Vector2( 0, 0 ) +rect_clip_content = false +mouse_filter = 1 +mouse_default_cursor_shape = 0 +size_flags_horizontal = 1 +size_flags_vertical = 1 +alignment = 0 + +[node name="TextEdit" type="TextEdit" parent="VBoxContainer" index="0"] + +anchor_left = 0.0 +anchor_top = 0.0 +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_right = 310.0 +margin_bottom = 150.0 +rect_min_size = Vector2( 0, 150 ) +rect_pivot_offset = Vector2( 0, 0 ) +rect_clip_content = false +focus_mode = 2 +mouse_filter = 0 +mouse_default_cursor_shape = 0 +size_flags_horizontal = 1 +size_flags_vertical = 1 +text = "" +readonly = false +highlight_current_line = false +syntax_highlighting = false +show_line_numbers = false +highlight_all_occurrences = false +override_selected_font_color = false +context_menu_enabled = true +smooth_scrolling = false +v_scroll_speed = 80.0 +hiding_enabled = 0 +wrap_lines = false +caret_block_mode = false +caret_blink = false +caret_blink_speed = 0.65 +caret_moving_by_right_click = true +_sections_unfolded = [ "Rect" ] + +[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer" index="1"] + +anchor_left = 0.0 +anchor_top = 0.0 +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_left = 93.0 +margin_top = 154.0 +margin_right = 217.0 +margin_bottom = 174.0 +rect_pivot_offset = Vector2( 0, 0 ) +rect_clip_content = false +mouse_filter = 1 +mouse_default_cursor_shape = 0 +size_flags_horizontal = 4 +size_flags_vertical = 0 +alignment = 0 +_sections_unfolded = [ "Size Flags" ] + +[node name="OK" type="Button" parent="VBoxContainer/HBoxContainer" index="0"] + +anchor_left = 0.0 +anchor_top = 0.0 +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_right = 60.0 +margin_bottom = 20.0 +rect_min_size = Vector2( 60, 0 ) +rect_pivot_offset = Vector2( 0, 0 ) +rect_clip_content = false +focus_mode = 2 +mouse_filter = 0 +mouse_default_cursor_shape = 0 +size_flags_horizontal = 1 +size_flags_vertical = 1 +toggle_mode = false +enabled_focus_mode = 2 +shortcut = null +group = null +text = "OK" +flat = false +align = 1 +_sections_unfolded = [ "Rect" ] + +[node name="Cancel" type="Button" parent="VBoxContainer/HBoxContainer" index="1"] + +anchor_left = 0.0 +anchor_top = 0.0 +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_left = 64.0 +margin_right = 124.0 +margin_bottom = 20.0 +rect_min_size = Vector2( 60, 0 ) +rect_pivot_offset = Vector2( 0, 0 ) +rect_clip_content = false +focus_mode = 2 +mouse_filter = 0 +mouse_default_cursor_shape = 0 +size_flags_horizontal = 1 +size_flags_vertical = 1 +toggle_mode = false +enabled_focus_mode = 2 +shortcut = null +group = null +text = "Cancel" +flat = false +align = 1 +_sections_unfolded = [ "Rect" ] + +[connection signal="pressed" from="VBoxContainer/HBoxContainer/OK" to="." method="_on_OK_pressed"] + +[connection signal="pressed" from="VBoxContainer/HBoxContainer/Cancel" to="." method="queue_free"] + +