mirror of
https://github.com/Relintai/material-maker.git
synced 2024-11-13 06:27:18 +01:00
Added control link check and editable labels
Now linking new controls to a linked_control will check compatibility (same control type and parameters). Linked control labels are now editable. Modified the Switch node layout so it is easier to understand. Updated the bricks example to use the switch and remote nodes.
This commit is contained in:
parent
f116aa0e22
commit
cb03131b85
File diff suppressed because one or more lines are too long
@ -5,7 +5,7 @@
|
|||||||
[sub_resource type="Theme" id=1]
|
[sub_resource type="Theme" id=1]
|
||||||
|
|
||||||
|
|
||||||
[node name="Combine" type="GraphNode" index="0"]
|
[node name="Combine" type="GraphNode"]
|
||||||
|
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
|
@ -108,7 +108,6 @@ selected = 1
|
|||||||
|
|
||||||
[node name="Albedo" type="HBoxContainer" parent="." index="1"]
|
[node name="Albedo" type="HBoxContainer" parent="." index="1"]
|
||||||
|
|
||||||
editor/display_folded = true
|
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
@ -170,7 +169,7 @@ group = null
|
|||||||
flat = false
|
flat = false
|
||||||
align = 1
|
align = 1
|
||||||
color = Color( 1, 1, 1, 1 )
|
color = Color( 1, 1, 1, 1 )
|
||||||
edit_alpha = true
|
edit_alpha = false
|
||||||
_sections_unfolded = [ "Rect", "Size Flags" ]
|
_sections_unfolded = [ "Rect", "Size Flags" ]
|
||||||
|
|
||||||
[node name="Metallic" type="HBoxContainer" parent="." index="2"]
|
[node name="Metallic" type="HBoxContainer" parent="." index="2"]
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
[sub_resource type="Theme" id=1]
|
[sub_resource type="Theme" id=1]
|
||||||
|
|
||||||
|
|
||||||
[node name="Remote" type="GraphNode" index="0"]
|
[node name="Remote" type="GraphNode"]
|
||||||
|
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
|
@ -12,7 +12,7 @@ func reset():
|
|||||||
|
|
||||||
func _get_shader_code(uv, index = 0):
|
func _get_shader_code(uv, index = 0):
|
||||||
var rv = { defs="", code="" }
|
var rv = { defs="", code="" }
|
||||||
var src = get_source(source+2*index)
|
var src = get_source(2*source+index)
|
||||||
var src_code = { defs="", code="", rgb="0.0" }
|
var src_code = { defs="", code="", rgb="0.0" }
|
||||||
if src != null:
|
if src != null:
|
||||||
src_code = src.get_shader_code(uv)
|
src_code = src.get_shader_code(uv)
|
||||||
|
@ -38,13 +38,13 @@ slot/0/right_color = Color( 0.498039, 0.498039, 1, 1 )
|
|||||||
slot/1/left_enabled = true
|
slot/1/left_enabled = true
|
||||||
slot/1/left_type = 0
|
slot/1/left_type = 0
|
||||||
slot/1/left_color = Color( 0.498039, 0.498039, 1, 1 )
|
slot/1/left_color = Color( 0.498039, 0.498039, 1, 1 )
|
||||||
slot/1/right_enabled = true
|
slot/1/right_enabled = false
|
||||||
slot/1/right_type = 0
|
slot/1/right_type = 0
|
||||||
slot/1/right_color = Color( 0.498039, 0.498039, 1, 1 )
|
slot/1/right_color = Color( 0.498039, 0.498039, 1, 1 )
|
||||||
slot/2/left_enabled = true
|
slot/2/left_enabled = true
|
||||||
slot/2/left_type = 0
|
slot/2/left_type = 0
|
||||||
slot/2/left_color = Color( 0.498039, 0.498039, 1, 1 )
|
slot/2/left_color = Color( 0.498039, 0.498039, 1, 1 )
|
||||||
slot/2/right_enabled = false
|
slot/2/right_enabled = true
|
||||||
slot/2/right_type = 0
|
slot/2/right_type = 0
|
||||||
slot/2/right_color = Color( 0.498039, 0.498039, 1, 1 )
|
slot/2/right_color = Color( 0.498039, 0.498039, 1, 1 )
|
||||||
slot/3/left_enabled = true
|
slot/3/left_enabled = true
|
||||||
@ -70,7 +70,7 @@ anchor_right = 0.0
|
|||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
margin_left = 16.0
|
margin_left = 16.0
|
||||||
margin_top = 24.0
|
margin_top = 24.0
|
||||||
margin_right = 103.0
|
margin_right = 70.0
|
||||||
margin_bottom = 44.0
|
margin_bottom = 44.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = false
|
rect_clip_content = false
|
||||||
@ -84,13 +84,13 @@ action_mode = 0
|
|||||||
enabled_focus_mode = 2
|
enabled_focus_mode = 2
|
||||||
shortcut = null
|
shortcut = null
|
||||||
group = null
|
group = null
|
||||||
text = "Objet 0"
|
text = "1"
|
||||||
flat = false
|
flat = false
|
||||||
align = 0
|
align = 0
|
||||||
items = [ "1", null, false, 0, null, "2", null, false, 1, null ]
|
items = [ "1", null, false, 0, null, "2", null, false, 1, null ]
|
||||||
selected = 0
|
selected = 0
|
||||||
|
|
||||||
[node name="HBoxContainer1" type="HBoxContainer" parent="." index="1"]
|
[node name="Label1" type="Label" parent="." index="1"]
|
||||||
|
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
@ -98,10 +98,31 @@ anchor_right = 0.0
|
|||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
margin_left = 16.0
|
margin_left = 16.0
|
||||||
margin_top = 44.0
|
margin_top = 44.0
|
||||||
margin_right = 103.0
|
margin_right = 70.0
|
||||||
margin_bottom = 58.0
|
margin_bottom = 58.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = false
|
rect_clip_content = false
|
||||||
|
mouse_filter = 2
|
||||||
|
mouse_default_cursor_shape = 0
|
||||||
|
size_flags_horizontal = 1
|
||||||
|
size_flags_vertical = 4
|
||||||
|
text = "A1"
|
||||||
|
percent_visible = 1.0
|
||||||
|
lines_skipped = 0
|
||||||
|
max_lines_visible = -1
|
||||||
|
|
||||||
|
[node name="HBoxContainer1" type="HBoxContainer" parent="." index="2"]
|
||||||
|
|
||||||
|
anchor_left = 0.0
|
||||||
|
anchor_top = 0.0
|
||||||
|
anchor_right = 0.0
|
||||||
|
anchor_bottom = 0.0
|
||||||
|
margin_left = 16.0
|
||||||
|
margin_top = 59.0
|
||||||
|
margin_right = 70.0
|
||||||
|
margin_bottom = 73.0
|
||||||
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
|
rect_clip_content = false
|
||||||
mouse_filter = 1
|
mouse_filter = 1
|
||||||
mouse_default_cursor_shape = 0
|
mouse_default_cursor_shape = 0
|
||||||
size_flags_horizontal = 1
|
size_flags_horizontal = 1
|
||||||
@ -114,7 +135,7 @@ anchor_left = 0.0
|
|||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
margin_right = 74.0
|
margin_right = 41.0
|
||||||
margin_bottom = 14.0
|
margin_bottom = 14.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = false
|
rect_clip_content = false
|
||||||
@ -122,7 +143,7 @@ mouse_filter = 2
|
|||||||
mouse_default_cursor_shape = 0
|
mouse_default_cursor_shape = 0
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
size_flags_vertical = 4
|
size_flags_vertical = 4
|
||||||
text = "A1"
|
text = "B1"
|
||||||
percent_visible = 1.0
|
percent_visible = 1.0
|
||||||
lines_skipped = 0
|
lines_skipped = 0
|
||||||
max_lines_visible = -1
|
max_lines_visible = -1
|
||||||
@ -133,8 +154,8 @@ anchor_left = 0.0
|
|||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
margin_left = 78.0
|
margin_left = 45.0
|
||||||
margin_right = 87.0
|
margin_right = 54.0
|
||||||
margin_bottom = 14.0
|
margin_bottom = 14.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = false
|
rect_clip_content = false
|
||||||
@ -147,27 +168,6 @@ percent_visible = 1.0
|
|||||||
lines_skipped = 0
|
lines_skipped = 0
|
||||||
max_lines_visible = -1
|
max_lines_visible = -1
|
||||||
|
|
||||||
[node name="Label2" type="Label" parent="." index="2"]
|
|
||||||
|
|
||||||
anchor_left = 0.0
|
|
||||||
anchor_top = 0.0
|
|
||||||
anchor_right = 0.0
|
|
||||||
anchor_bottom = 0.0
|
|
||||||
margin_left = 16.0
|
|
||||||
margin_top = 59.0
|
|
||||||
margin_right = 103.0
|
|
||||||
margin_bottom = 73.0
|
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
|
||||||
rect_clip_content = false
|
|
||||||
mouse_filter = 2
|
|
||||||
mouse_default_cursor_shape = 0
|
|
||||||
size_flags_horizontal = 1
|
|
||||||
size_flags_vertical = 4
|
|
||||||
text = "A2"
|
|
||||||
percent_visible = 1.0
|
|
||||||
lines_skipped = 0
|
|
||||||
max_lines_visible = -1
|
|
||||||
|
|
||||||
[node name="HBoxContainer2" type="HBoxContainer" parent="." index="3"]
|
[node name="HBoxContainer2" type="HBoxContainer" parent="." index="3"]
|
||||||
|
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
@ -176,7 +176,7 @@ anchor_right = 0.0
|
|||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
margin_left = 16.0
|
margin_left = 16.0
|
||||||
margin_top = 74.0
|
margin_top = 74.0
|
||||||
margin_right = 103.0
|
margin_right = 70.0
|
||||||
margin_bottom = 88.0
|
margin_bottom = 88.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = false
|
rect_clip_content = false
|
||||||
@ -192,7 +192,7 @@ anchor_left = 0.0
|
|||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
margin_right = 74.0
|
margin_right = 41.0
|
||||||
margin_bottom = 14.0
|
margin_bottom = 14.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = false
|
rect_clip_content = false
|
||||||
@ -200,7 +200,7 @@ mouse_filter = 2
|
|||||||
mouse_default_cursor_shape = 0
|
mouse_default_cursor_shape = 0
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
size_flags_vertical = 4
|
size_flags_vertical = 4
|
||||||
text = "B1"
|
text = "A2"
|
||||||
percent_visible = 1.0
|
percent_visible = 1.0
|
||||||
lines_skipped = 0
|
lines_skipped = 0
|
||||||
max_lines_visible = -1
|
max_lines_visible = -1
|
||||||
@ -211,8 +211,8 @@ anchor_left = 0.0
|
|||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
anchor_right = 0.0
|
anchor_right = 0.0
|
||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
margin_left = 78.0
|
margin_left = 45.0
|
||||||
margin_right = 87.0
|
margin_right = 54.0
|
||||||
margin_bottom = 14.0
|
margin_bottom = 14.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = false
|
rect_clip_content = false
|
||||||
@ -225,7 +225,7 @@ percent_visible = 1.0
|
|||||||
lines_skipped = 0
|
lines_skipped = 0
|
||||||
max_lines_visible = -1
|
max_lines_visible = -1
|
||||||
|
|
||||||
[node name="Label4" type="Label" parent="." index="4"]
|
[node name="Label2" type="Label" parent="." index="4"]
|
||||||
|
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
@ -233,7 +233,7 @@ anchor_right = 0.0
|
|||||||
anchor_bottom = 0.0
|
anchor_bottom = 0.0
|
||||||
margin_left = 16.0
|
margin_left = 16.0
|
||||||
margin_top = 89.0
|
margin_top = 89.0
|
||||||
margin_right = 103.0
|
margin_right = 70.0
|
||||||
margin_bottom = 103.0
|
margin_bottom = 103.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = false
|
rect_clip_content = false
|
||||||
|
@ -0,0 +1,12 @@
|
|||||||
|
extends Label
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
pass
|
||||||
|
|
||||||
|
func _on_gui_input(ev):
|
||||||
|
if ev is InputEventMouseButton and ev.doubleclick and ev.button_index == BUTTON_LEFT:
|
||||||
|
var dialog = preload("res://addons/material_maker/widgets/line_dialog.tscn").instance()
|
||||||
|
add_child(dialog)
|
||||||
|
dialog.set_texts("Remote", "Enter a name this control")
|
||||||
|
dialog.connect("ok", self, "set_text", [])
|
||||||
|
dialog.popup_centered()
|
@ -0,0 +1,27 @@
|
|||||||
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://addons/material_maker/widgets/linked_widgets/editable_label.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
[node name="Label" type="Label"]
|
||||||
|
|
||||||
|
anchor_left = 0.0
|
||||||
|
anchor_top = 0.0
|
||||||
|
anchor_right = 0.0
|
||||||
|
anchor_bottom = 0.0
|
||||||
|
margin_right = 40.0
|
||||||
|
margin_bottom = 14.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
|
||||||
|
percent_visible = 1.0
|
||||||
|
lines_skipped = 0
|
||||||
|
max_lines_visible = -1
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
_sections_unfolded = [ "Mouse" ]
|
||||||
|
|
||||||
|
[connection signal="gui_input" from="." to="." method="_on_gui_input"]
|
||||||
|
|
||||||
|
|
@ -1,38 +1,63 @@
|
|||||||
tool
|
tool
|
||||||
extends "res://addons/material_maker/widgets/linked_widgets/linked_control_base.gd"
|
extends "res://addons/material_maker/widgets/linked_widgets/linked_control_base.gd"
|
||||||
|
|
||||||
|
var control = null
|
||||||
|
|
||||||
func add_linked(node, widget):
|
func add_linked(node, widget):
|
||||||
if linked_widgets.empty():
|
if linked_widgets.empty():
|
||||||
var new_widget = null
|
control = null
|
||||||
var type
|
var type
|
||||||
if widget is SpinBox:
|
if widget is SpinBox:
|
||||||
new_widget = SpinBox.new()
|
control = SpinBox.new()
|
||||||
type = "SpinBox"
|
type = "SpinBox"
|
||||||
elif widget is ColorPickerButton:
|
elif widget is ColorPickerButton:
|
||||||
new_widget = ColorPickerButton.new()
|
control = ColorPickerButton.new()
|
||||||
type = "ColorPickerButton"
|
type = "ColorPickerButton"
|
||||||
elif widget is Control && widget.filename == "res://addons/material_maker/widgets/gradient_editor.tscn":
|
elif widget is Control && widget.filename == "res://addons/material_maker/widgets/gradient_editor.tscn":
|
||||||
new_widget = preload("res://addons/material_maker/widgets/gradient_editor.tscn").instance()
|
control = preload("res://addons/material_maker/widgets/gradient_editor.tscn").instance()
|
||||||
type = "GradientEditor"
|
type = "GradientEditor"
|
||||||
elif widget is HSlider:
|
elif widget is HSlider:
|
||||||
new_widget = HSlider.new()
|
control = HSlider.new()
|
||||||
type = "HSlider"
|
type = "HSlider"
|
||||||
elif widget is OptionButton:
|
elif widget is OptionButton:
|
||||||
new_widget = OptionButton.new()
|
control = OptionButton.new()
|
||||||
type = "OptionButton"
|
type = "OptionButton"
|
||||||
for i in range(widget.get_item_count()):
|
for i in range(widget.get_item_count()):
|
||||||
new_widget.add_item(widget.get_item_text(i), widget.get_item_id(i))
|
control.add_item(widget.get_item_text(i), widget.get_item_id(i))
|
||||||
if new_widget != null:
|
if control != null:
|
||||||
add_child(new_widget)
|
add_child(control)
|
||||||
mirror(new_widget, widget, type)
|
mirror(control, widget, type)
|
||||||
new_widget.connect("mouse_entered", self, "_on_mouse_entered")
|
control.connect("mouse_entered", self, "_on_mouse_entered")
|
||||||
new_widget.connect("mouse_exited", self, "_on_mouse_exited")
|
control.connect("mouse_exited", self, "_on_mouse_exited")
|
||||||
new_widget.connect(WIDGETS[type].sig, self, WIDGETS[type].sig_handler)
|
control.connect(WIDGETS[type].sig, self, WIDGETS[type].sig_handler)
|
||||||
|
else:
|
||||||
|
if !can_link_to(widget):
|
||||||
|
return
|
||||||
linked_widgets.append({ node=node, widget=widget })
|
linked_widgets.append({ node=node, widget=widget })
|
||||||
|
|
||||||
|
func can_link_to(c):
|
||||||
|
if c == null:
|
||||||
|
return false
|
||||||
|
var widget_type = get_widget_type(c)
|
||||||
|
if control == null:
|
||||||
|
return widget_type != null
|
||||||
|
elif widget_type != get_widget_type(control):
|
||||||
|
return false
|
||||||
|
else:
|
||||||
|
for l in linked_widgets:
|
||||||
|
if l.widget == c:
|
||||||
|
return false
|
||||||
|
var winfo = WIDGETS[widget_type]
|
||||||
|
for a in winfo.attrs:
|
||||||
|
if c.get(a) != control.get(a):
|
||||||
|
return false
|
||||||
|
return true
|
||||||
|
|
||||||
func mirror(to, from, type):
|
func mirror(to, from, type):
|
||||||
for a in WIDGETS[type].attrs:
|
var winfo = WIDGETS[type]
|
||||||
|
for a in winfo.attrs:
|
||||||
to.set(a, from.get(a))
|
to.set(a, from.get(a))
|
||||||
|
to.set(winfo.value_attr, from.get(winfo.value_attr))
|
||||||
|
|
||||||
func update_shaders():
|
func update_shaders():
|
||||||
var graph_edit = get_parent()
|
var graph_edit = get_parent()
|
||||||
|
@ -10,11 +10,11 @@ var links = null
|
|||||||
const Link = preload("res://addons/material_maker/widgets/linked_widgets/link.gd")
|
const Link = preload("res://addons/material_maker/widgets/linked_widgets/link.gd")
|
||||||
|
|
||||||
const WIDGETS = {
|
const WIDGETS = {
|
||||||
SpinBox={ attrs=[ "min_value", "max_value", "step", "value" ], value_attr="value", sig="value_changed", sig_handler="_on_value_changed" },
|
SpinBox={ attrs=[ "min_value", "max_value", "step" ], value_attr="value", sig="value_changed", sig_handler="_on_value_changed" },
|
||||||
HSlider={ attrs=[ "min_value", "max_value", "step", "value" ], value_attr="value", sig="value_changed", sig_handler="_on_value_changed" },
|
HSlider={ attrs=[ "min_value", "max_value", "step" ], value_attr="value", sig="value_changed", sig_handler="_on_value_changed" },
|
||||||
ColorPickerButton={ attrs=[ "edit_alpha", "color" ], value_attr="color", sig="color_changed", sig_handler="_on_color_changed" },
|
ColorPickerButton={ attrs=[ "edit_alpha", ], value_attr="color", sig="color_changed", sig_handler="_on_color_changed" },
|
||||||
OptionButton={ attrs=[ "selected" ], value_attr="selected", sig="item_selected", sig_handler="_on_item_selected" },
|
OptionButton={ attrs=[ ], value_attr="selected", sig="item_selected", sig_handler="_on_item_selected" },
|
||||||
GradientEditor={ attrs=[ "value" ], value_attr="value", sig="updated", sig_handler="_on_gradient_updated" }
|
GradientEditor={ attrs=[ ], value_attr="value", sig="updated", sig_handler="_on_gradient_updated" }
|
||||||
}
|
}
|
||||||
|
|
||||||
func get_widget_type(widget):
|
func get_widget_type(widget):
|
||||||
@ -34,8 +34,11 @@ func get_widget_type(widget):
|
|||||||
func _ready():
|
func _ready():
|
||||||
set_process_input(false)
|
set_process_input(false)
|
||||||
|
|
||||||
|
func can_link_to(c):
|
||||||
|
return c != null
|
||||||
|
|
||||||
func get_associated_controls():
|
func get_associated_controls():
|
||||||
label = Label.new()
|
label = preload("res://addons/material_maker/widgets/linked_widgets/editable_label.tscn").instance()
|
||||||
label.set_text("Unnamed")
|
label.set_text("Unnamed")
|
||||||
buttons = preload("res://addons/material_maker/widgets/linked_widgets/linked_control_buttons.tscn").instance()
|
buttons = preload("res://addons/material_maker/widgets/linked_widgets/linked_control_buttons.tscn").instance()
|
||||||
buttons.control = self
|
buttons.control = self
|
||||||
@ -90,7 +93,7 @@ func _input(event):
|
|||||||
elif event is InputEventMouseMotion:
|
elif event is InputEventMouseMotion:
|
||||||
var control = find_control(event.global_position)
|
var control = find_control(event.global_position)
|
||||||
link.end = event.global_position
|
link.end = event.global_position
|
||||||
link.target = control.widget if control != null else null
|
link.target = control.widget if control != null && can_link_to(control.widget) else null
|
||||||
link.update()
|
link.update()
|
||||||
elif event is InputEventMouseButton:
|
elif event is InputEventMouseButton:
|
||||||
if event.pressed:
|
if event.pressed:
|
||||||
@ -120,12 +123,14 @@ func pick_linked():
|
|||||||
pointed_control = null
|
pointed_control = null
|
||||||
|
|
||||||
func serialize():
|
func serialize():
|
||||||
var data = { linked_widgets=[] }
|
var data = { label=label.text, linked_widgets=[] }
|
||||||
for w in linked_widgets:
|
for w in linked_widgets:
|
||||||
data.linked_widgets.append( { node=w.node.name, widget=w.widget.name } )
|
data.linked_widgets.append( { node=w.node.name, widget=w.widget.name } )
|
||||||
return data
|
return data
|
||||||
|
|
||||||
func deserialize(data):
|
func deserialize(data):
|
||||||
|
if data.has("label"):
|
||||||
|
label.text = data.label
|
||||||
if !data.has("linked_widgets"):
|
if !data.has("linked_widgets"):
|
||||||
return
|
return
|
||||||
var graph_edit = get_parent()
|
var graph_edit = get_parent()
|
||||||
|
@ -3,11 +3,6 @@ extends HBoxContainer
|
|||||||
|
|
||||||
var control = null
|
var control = null
|
||||||
|
|
||||||
func _ready():
|
|
||||||
# Called when the node is added to the scene for the first time.
|
|
||||||
# Initialization here
|
|
||||||
pass
|
|
||||||
|
|
||||||
func _on_Link_pressed():
|
func _on_Link_pressed():
|
||||||
control.pick_linked()
|
control.pick_linked()
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
[ext_resource path="res://addons/material_maker/icons/link.png" type="Texture" id=2]
|
[ext_resource path="res://addons/material_maker/icons/link.png" type="Texture" id=2]
|
||||||
[ext_resource path="res://addons/material_maker/icons/remove.png" type="Texture" id=3]
|
[ext_resource path="res://addons/material_maker/icons/remove.png" type="Texture" id=3]
|
||||||
|
|
||||||
[node name="Buttons" type="HBoxContainer"]
|
[node name="Buttons" type="HBoxContainer" index="0"]
|
||||||
|
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
anchor_top = 0.0
|
anchor_top = 0.0
|
||||||
@ -31,6 +31,7 @@ margin_right = 28.0
|
|||||||
margin_bottom = 22.0
|
margin_bottom = 22.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = false
|
rect_clip_content = false
|
||||||
|
hint_tooltip = "Link new parameter"
|
||||||
focus_mode = 2
|
focus_mode = 2
|
||||||
mouse_filter = 0
|
mouse_filter = 0
|
||||||
mouse_default_cursor_shape = 0
|
mouse_default_cursor_shape = 0
|
||||||
@ -43,6 +44,7 @@ group = null
|
|||||||
icon = ExtResource( 2 )
|
icon = ExtResource( 2 )
|
||||||
flat = false
|
flat = false
|
||||||
align = 1
|
align = 1
|
||||||
|
_sections_unfolded = [ "Hint" ]
|
||||||
|
|
||||||
[node name="Remove" type="Button" parent="." index="1"]
|
[node name="Remove" type="Button" parent="." index="1"]
|
||||||
|
|
||||||
@ -55,6 +57,7 @@ margin_right = 60.0
|
|||||||
margin_bottom = 22.0
|
margin_bottom = 22.0
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
rect_clip_content = false
|
rect_clip_content = false
|
||||||
|
hint_tooltip = "Delete this control"
|
||||||
focus_mode = 2
|
focus_mode = 2
|
||||||
mouse_filter = 0
|
mouse_filter = 0
|
||||||
mouse_default_cursor_shape = 0
|
mouse_default_cursor_shape = 0
|
||||||
@ -67,6 +70,7 @@ group = null
|
|||||||
icon = ExtResource( 3 )
|
icon = ExtResource( 3 )
|
||||||
flat = false
|
flat = false
|
||||||
align = 1
|
align = 1
|
||||||
|
_sections_unfolded = [ "Hint" ]
|
||||||
|
|
||||||
[connection signal="pressed" from="Link" to="." method="_on_Link_pressed"]
|
[connection signal="pressed" from="Link" to="." method="_on_Link_pressed"]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user