Added comment nodes

This commit is contained in:
RodZill4 2019-10-12 08:30:46 +02:00
parent 8006f07e04
commit 4dbfd6be75
8 changed files with 131 additions and 101 deletions

View File

@ -0,0 +1,35 @@
tool
extends MMGenTexture
class_name MMGenComment
"""
Comments to put in the graph
"""
var text : String = "Double-click to write a comment"
var size : Vector2 = Vector2(0, 0)
func _ready():
if !parameters.has("size"):
parameters.size = 4
func get_type():
return "comment"
func get_type_name():
return "Comment"
func get_parameter_defs():
return []
func get_input_defs():
return []
func get_output_defs():
return []
func _serialize(data):
data.type = "comment"
data.text = text
data.size = { x=size.x, y=size.y }
return data

View File

@ -73,6 +73,12 @@ static func create_gen(data) -> MMGenBase:
generator = MMGenMaterial.new()
elif data.type == "buffer":
generator = MMGenBuffer.new()
elif data.type == "comment":
generator = MMGenComment.new()
if data.has("text"):
generator.text = data.text
if data.has("size"):
generator.size = Vector2(data.size.x, data.size.y)
elif data.type == "image":
generator = MMGenImage.new()
elif data.type == "ios":

View File

@ -0,0 +1,31 @@
tool
extends "res://addons/material_maker/node_base.gd"
var generator = null setget set_generator
onready var label = $VBox/Label
onready var editor = $VBox/TextEdit
func set_generator(g):
generator = g
label.text = generator.text
rect_size = generator.size
func _on_resize_request(new_size):
rect_size = new_size
generator.size = new_size
func _on_Label_gui_input(ev):
if ev is InputEventMouseButton and ev.doubleclick and ev.button_index == BUTTON_LEFT:
editor.rect_min_size = label.rect_size + Vector2(0, rect_size.y - get_minimum_size().y)
editor.text = label.text
label.visible = false
editor.visible = true
editor.select_all()
editor.grab_focus()
func _on_TextEdit_focus_exited():
label.text = editor.text
generator.text = editor.text
label.visible = true
editor.visible = false

View File

@ -0,0 +1,50 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://addons/material_maker/nodes/comment.gd" type="Script" id=1]
[sub_resource type="StyleBoxFlat" id=1]
bg_color = Color( 1, 1, 1, 0.0627451 )
[node name="GraphNode" type="GraphNode"]
margin_left = 1.0
margin_top = 1.0
margin_right = 250.0
margin_bottom = 44.0
size_flags_horizontal = 3
size_flags_vertical = 3
title = "Comment"
show_close = true
resizable = true
comment = true
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 )
[node name="VBox" type="VBoxContainer" parent="."]
margin_left = 16.0
margin_top = 24.0
margin_right = 233.0
margin_bottom = 38.0
[node name="Label" type="Label" parent="VBox"]
margin_right = 217.0
margin_bottom = 14.0
mouse_filter = 0
text = "Double-click to write a comment"
autowrap = true
[node name="TextEdit" type="TextEdit" parent="VBox"]
visible = false
margin_top = 18.0
margin_right = 221.0
margin_bottom = 18.0
custom_styles/focus = SubResource( 1 )
custom_styles/normal = SubResource( 1 )
wrap_enabled = true
[connection signal="resize_request" from="." to="." method="_on_resize_request"]
[connection signal="gui_input" from="VBox/Label" to="." method="_on_Label_gui_input"]
[connection signal="focus_exited" from="VBox/TextEdit" to="." method="_on_TextEdit_focus_exited"]

View File

@ -1,32 +0,0 @@
tool
extends "res://addons/material_maker/node_base.gd"
func _get_shader_code(uv, slot = 0):
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

View File

@ -1,66 +0,0 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://addons/material_maker/nodes/comment/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"]

File diff suppressed because one or more lines are too long

View File

@ -19,6 +19,11 @@ _global_script_classes=[ {
"language": "GDScript",
"path": "res://addons/material_maker/engine/gen_buffer.gd"
}, {
"base": "MMGenTexture",
"class": "MMGenComment",
"language": "GDScript",
"path": "res://addons/material_maker/engine/gen_comment.gd"
}, {
"base": "Object",
"class": "MMGenContext",
"language": "GDScript",
@ -117,6 +122,7 @@ _global_script_classes=[ {
_global_script_class_icons={
"MMGenBase": "",
"MMGenBuffer": "",
"MMGenComment": "",
"MMGenContext": "",
"MMGenConvolution": "",
"MMGenGraph": "",