mirror of
https://github.com/Relintai/material-maker.git
synced 2024-11-13 06:27:18 +01:00
Added subgraph navigation popup
This commit is contained in:
parent
66790ed86d
commit
159ee7678b
@ -12,6 +12,10 @@ var need_save = false
|
|||||||
var top_generator = null
|
var top_generator = null
|
||||||
var generator = null
|
var generator = null
|
||||||
|
|
||||||
|
onready var timer : Timer = $Timer
|
||||||
|
|
||||||
|
onready var subgraph_ui : HBoxContainer = $GraphUI/SubGraphUI
|
||||||
|
|
||||||
signal save_path_changed
|
signal save_path_changed
|
||||||
signal graph_changed
|
signal graph_changed
|
||||||
|
|
||||||
@ -110,8 +114,8 @@ func update_view(g):
|
|||||||
clear_view()
|
clear_view()
|
||||||
generator = g
|
generator = g
|
||||||
update_graph(generator.get_children(), generator.connections)
|
update_graph(generator.get_children(), generator.connections)
|
||||||
$SubGraphUI.visible = generator != top_generator
|
subgraph_ui.visible = generator != top_generator
|
||||||
$SubGraphUI/Label.text = generator.label
|
subgraph_ui.get_node("Label").text = generator.label
|
||||||
center_view()
|
center_view()
|
||||||
|
|
||||||
func clear_material():
|
func clear_material():
|
||||||
@ -263,7 +267,7 @@ func paste(pos = Vector2(0, 0)):
|
|||||||
|
|
||||||
func send_changed_signal():
|
func send_changed_signal():
|
||||||
set_need_save(true)
|
set_need_save(true)
|
||||||
$Timer.start(0.1)
|
timer.start(0.1)
|
||||||
|
|
||||||
func do_send_changed_signal():
|
func do_send_changed_signal():
|
||||||
emit_signal("graph_changed")
|
emit_signal("graph_changed")
|
||||||
@ -296,4 +300,9 @@ func create_subgraph():
|
|||||||
generator.create_subgraph(generators)
|
generator.create_subgraph(generators)
|
||||||
update_view(generator)
|
update_view(generator)
|
||||||
|
|
||||||
|
func _on_ButtonShowTree_pressed():
|
||||||
|
var graph_tree : Popup = preload("res://addons/material_maker/widgets/graph_tree/graph_tree.tscn").instance()
|
||||||
|
graph_tree.init("Top", top_generator)
|
||||||
|
add_child(graph_tree)
|
||||||
|
graph_tree.connect("item_double_clicked", self, "update_view")
|
||||||
|
graph_tree.popup_centered()
|
||||||
|
@ -1,6 +1,17 @@
|
|||||||
[gd_scene load_steps=2 format=2]
|
[gd_scene load_steps=5 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://addons/material_maker/graph_edit.gd" type="Script" id=1]
|
[ext_resource path="res://addons/material_maker/graph_edit.gd" type="Script" id=1]
|
||||||
|
[ext_resource path="res://addons/material_maker/icons/icons.svg" type="Texture" id=2]
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id=1]
|
||||||
|
flags = 4
|
||||||
|
atlas = ExtResource( 2 )
|
||||||
|
region = Rect2( 15.4016, 47.1451, 16.7512, 17.8319 )
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id=2]
|
||||||
|
flags = 4
|
||||||
|
atlas = ExtResource( 2 )
|
||||||
|
region = Rect2( 0, 48, 16, 16 )
|
||||||
|
|
||||||
[node name="GraphEdit" type="GraphEdit"]
|
[node name="GraphEdit" type="GraphEdit"]
|
||||||
self_modulate = Color( 1, 1, 1, 0 )
|
self_modulate = Color( 1, 1, 1, 0 )
|
||||||
@ -14,25 +25,41 @@ script = ExtResource( 1 )
|
|||||||
wait_time = 0.2
|
wait_time = 0.2
|
||||||
one_shot = true
|
one_shot = true
|
||||||
|
|
||||||
[node name="SubGraphUI" type="HBoxContainer" parent="."]
|
[node name="GraphUI" type="HBoxContainer" parent="."]
|
||||||
anchor_left = 1.0
|
anchor_left = 1.0
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
margin_left = -197.0
|
margin_left = -592.0
|
||||||
margin_right = -13.0
|
margin_right = -16.0
|
||||||
margin_bottom = 24.0
|
margin_bottom = 40.0
|
||||||
|
alignment = 2
|
||||||
|
|
||||||
[node name="Label" type="LineEdit" parent="SubGraphUI"]
|
[node name="SubGraphUI" type="HBoxContainer" parent="GraphUI"]
|
||||||
|
margin_left = 362.0
|
||||||
|
margin_right = 544.0
|
||||||
|
margin_bottom = 40.0
|
||||||
|
size_flags_horizontal = 9
|
||||||
|
|
||||||
|
[node name="Label" type="LineEdit" parent="GraphUI/SubGraphUI"]
|
||||||
margin_right = 150.0
|
margin_right = 150.0
|
||||||
margin_bottom = 24.0
|
margin_bottom = 40.0
|
||||||
rect_min_size = Vector2( 150, 0 )
|
rect_min_size = Vector2( 150, 0 )
|
||||||
|
size_flags_horizontal = 9
|
||||||
|
|
||||||
[node name="ButtonUp" type="Button" parent="SubGraphUI"]
|
[node name="ButtonUp" type="Button" parent="GraphUI/SubGraphUI"]
|
||||||
margin_left = 154.0
|
margin_left = 154.0
|
||||||
margin_right = 184.0
|
margin_right = 182.0
|
||||||
margin_bottom = 24.0
|
margin_bottom = 40.0
|
||||||
text = "Up"
|
size_flags_horizontal = 9
|
||||||
|
icon = SubResource( 1 )
|
||||||
|
|
||||||
|
[node name="ButtonShowTree" type="Button" parent="GraphUI"]
|
||||||
|
margin_left = 548.0
|
||||||
|
margin_right = 576.0
|
||||||
|
margin_bottom = 40.0
|
||||||
|
icon = SubResource( 2 )
|
||||||
[connection signal="connection_request" from="." to="." method="connect_node"]
|
[connection signal="connection_request" from="." to="." method="connect_node"]
|
||||||
[connection signal="disconnection_request" from="." to="." method="disconnect_node"]
|
[connection signal="disconnection_request" from="." to="." method="disconnect_node"]
|
||||||
[connection signal="timeout" from="Timer" to="." method="do_send_changed_signal"]
|
[connection signal="timeout" from="Timer" to="." method="do_send_changed_signal"]
|
||||||
[connection signal="text_changed" from="SubGraphUI/Label" to="." method="_on_Label_text_changed"]
|
[connection signal="text_changed" from="GraphUI/SubGraphUI/Label" to="." method="_on_Label_text_changed"]
|
||||||
[connection signal="pressed" from="SubGraphUI/ButtonUp" to="." method="on_ButtonUp_pressed"]
|
[connection signal="pressed" from="GraphUI/SubGraphUI/ButtonUp" to="." method="on_ButtonUp_pressed"]
|
||||||
|
[connection signal="pressed" from="GraphUI/ButtonShowTree" to="." method="_on_ButtonShowTree_pressed"]
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
viewBox="0 0 64 64"
|
viewBox="0 0 64 64"
|
||||||
version="1.1"
|
version="1.1"
|
||||||
id="svg8"
|
id="svg8"
|
||||||
inkscape:version="0.92.3 (2405546, 2018-03-11)"
|
inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
|
||||||
sodipodi:docname="icons.svg">
|
sodipodi:docname="icons.svg">
|
||||||
<defs
|
<defs
|
||||||
id="defs2">
|
id="defs2">
|
||||||
@ -48,9 +48,9 @@
|
|||||||
borderopacity="1.0"
|
borderopacity="1.0"
|
||||||
inkscape:pageopacity="0.0"
|
inkscape:pageopacity="0.0"
|
||||||
inkscape:pageshadow="2"
|
inkscape:pageshadow="2"
|
||||||
inkscape:zoom="14.304427"
|
inkscape:zoom="40.459029"
|
||||||
inkscape:cx="33.274902"
|
inkscape:cx="17.695886"
|
||||||
inkscape:cy="41.347265"
|
inkscape:cy="7.9897925"
|
||||||
inkscape:document-units="px"
|
inkscape:document-units="px"
|
||||||
inkscape:current-layer="layer1"
|
inkscape:current-layer="layer1"
|
||||||
showgrid="true"
|
showgrid="true"
|
||||||
@ -324,5 +324,33 @@
|
|||||||
d="m 23.783078,44.110649 -4.508983,4.648736 -3.980261,-5.27284 a 12.770835,12.770835 0 0 0 -2.631282,1.045173 l 0.825522,6.441784 -6.571368,-0.17469 a 12.770835,12.770835 0 0 0 -0.7896172,2.557631 12.770835,12.770835 0 0 0 -0.027504,0.173796 l 5.5120272,3.347264 -4.1861363,4.972095 a 12.770835,12.770835 0 0 0 1.6563998,2.37002 l 5.9760855,-2.194035 1.267643,6.324612 a 12.770835,12.770835 0 0 0 2.907828,0.192046 l 1.997862,-6.001057 5.727797,2.948399 a 12.770835,12.770835 0 0 0 1.98019,-2.135962 l -3.455675,-5.317616 5.926699,-2.662342 a 12.770835,12.770835 0 0 0 -0.414249,-2.850168 l -6.383635,-0.620945 1.631047,-6.361785 a 12.770835,12.770835 0 0 0 -2.46039,-1.430116 z m -4.472442,8.529047 a 3.1927084,3.1927084 0 0 1 2.523332,3.744269 3.1927084,3.1927084 0 0 1 -3.744267,2.523336 3.1927084,3.1927084 0 0 1 -2.523335,-3.744269 3.1927084,3.1927084 0 0 1 3.74427,-2.523336 z"
|
d="m 23.783078,44.110649 -4.508983,4.648736 -3.980261,-5.27284 a 12.770835,12.770835 0 0 0 -2.631282,1.045173 l 0.825522,6.441784 -6.571368,-0.17469 a 12.770835,12.770835 0 0 0 -0.7896172,2.557631 12.770835,12.770835 0 0 0 -0.027504,0.173796 l 5.5120272,3.347264 -4.1861363,4.972095 a 12.770835,12.770835 0 0 0 1.6563998,2.37002 l 5.9760855,-2.194035 1.267643,6.324612 a 12.770835,12.770835 0 0 0 2.907828,0.192046 l 1.997862,-6.001057 5.727797,2.948399 a 12.770835,12.770835 0 0 0 1.98019,-2.135962 l -3.455675,-5.317616 5.926699,-2.662342 a 12.770835,12.770835 0 0 0 -0.414249,-2.850168 l -6.383635,-0.620945 1.631047,-6.361785 a 12.770835,12.770835 0 0 0 -2.46039,-1.430116 z m -4.472442,8.529047 a 3.1927084,3.1927084 0 0 1 2.523332,3.744269 3.1927084,3.1927084 0 0 1 -3.744267,2.523336 3.1927084,3.1927084 0 0 1 -2.523335,-3.744269 3.1927084,3.1927084 0 0 1 3.74427,-2.523336 z"
|
||||||
style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.80446196;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:fill markers stroke" />
|
style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.80446196;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:fill markers stroke" />
|
||||||
</g>
|
</g>
|
||||||
|
<path
|
||||||
|
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="m 2.9383367,329.45579 0.1398168,13.14278"
|
||||||
|
id="path1469"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<path
|
||||||
|
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="m 3.5097233,333.01844 4.9679886,-0.0742"
|
||||||
|
id="path1471"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="cc" />
|
||||||
|
<path
|
||||||
|
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="m 7.4643412,333.1173 0.024716,3.95462 7.1924608,-0.0247 v 0"
|
||||||
|
id="path1473"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<path
|
||||||
|
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="m 7.4890575,337.83813 -0.024716,3.68273 h 5.8083445"
|
||||||
|
id="path1475"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<path
|
||||||
|
style="fill:#ffffff;fill-opacity:0.84322037;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||||
|
d="m 17.351562,55.695312 4.34961,0.04883 0.123047,6.822265 h 4.27539 l 0.125,-6.822265 4.34961,-0.04883 -6.611328,-6.845703 z"
|
||||||
|
transform="translate(0,280.06665)"
|
||||||
|
id="path1477"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="cccccccc" />
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 20 KiB |
@ -8,13 +8,13 @@
|
|||||||
[ext_resource path="res://addons/material_maker/engine/renderer.tscn" type="PackedScene" id=6]
|
[ext_resource path="res://addons/material_maker/engine/renderer.tscn" type="PackedScene" id=6]
|
||||||
[ext_resource path="res://addons/material_maker/node_factory.gd" type="Script" id=7]
|
[ext_resource path="res://addons/material_maker/node_factory.gd" type="Script" id=7]
|
||||||
|
|
||||||
[sub_resource type="PanoramaSky" id=4]
|
[sub_resource type="PanoramaSky" id=1]
|
||||||
resource_local_to_scene = true
|
resource_local_to_scene = true
|
||||||
panorama = ExtResource( 4 )
|
panorama = ExtResource( 4 )
|
||||||
|
|
||||||
[sub_resource type="Environment" id=5]
|
[sub_resource type="Environment" id=2]
|
||||||
background_mode = 2
|
background_mode = 2
|
||||||
background_sky = SubResource( 4 )
|
background_sky = SubResource( 1 )
|
||||||
background_energy = 1.5
|
background_energy = 1.5
|
||||||
ambient_light_color = Color( 1, 1, 1, 1 )
|
ambient_light_color = Color( 1, 1, 1, 1 )
|
||||||
ambient_light_energy = 0.32
|
ambient_light_energy = 0.32
|
||||||
@ -124,7 +124,7 @@ render_target_update_mode = 0
|
|||||||
|
|
||||||
[node name="Camera" type="Camera" parent="VBoxContainer/HBoxContainer/ProjectsPane/BackgroundPreview/Viewport"]
|
[node name="Camera" type="Camera" parent="VBoxContainer/HBoxContainer/ProjectsPane/BackgroundPreview/Viewport"]
|
||||||
transform = Transform( 1, 0, 0, 0, 0.766044, 0.642788, 0, -0.642788, 0.766044, 0, 2.24976, 2.68115 )
|
transform = Transform( 1, 0, 0, 0, 0.766044, 0.642788, 0, -0.642788, 0.766044, 0, 2.24976, 2.68115 )
|
||||||
environment = SubResource( 5 )
|
environment = SubResource( 2 )
|
||||||
current = true
|
current = true
|
||||||
|
|
||||||
[node name="Projects" type="Panel" parent="VBoxContainer/HBoxContainer/ProjectsPane"]
|
[node name="Projects" type="Panel" parent="VBoxContainer/HBoxContainer/ProjectsPane"]
|
||||||
|
22
addons/material_maker/widgets/graph_tree/graph_tree.gd
Normal file
22
addons/material_maker/widgets/graph_tree/graph_tree.gd
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
extends Popup
|
||||||
|
|
||||||
|
signal item_double_clicked(generator)
|
||||||
|
|
||||||
|
func init(graph_name : String, generator : MMGenGraph):
|
||||||
|
$Tree.clear()
|
||||||
|
var root : TreeItem = $Tree.create_item(null)
|
||||||
|
root.set_text(0, graph_name)
|
||||||
|
root.set_metadata(0, generator)
|
||||||
|
fill_item(root, generator)
|
||||||
|
|
||||||
|
func fill_item(parent : TreeItem, generator : MMGenGraph):
|
||||||
|
for c in generator.get_children():
|
||||||
|
if c is MMGenGraph:
|
||||||
|
var item : TreeItem = $Tree.create_item(parent)
|
||||||
|
item.set_text(0, c.get_type_name())
|
||||||
|
item.set_metadata(0, c)
|
||||||
|
fill_item(item, c)
|
||||||
|
|
||||||
|
func _on_Tree_item_double_clicked():
|
||||||
|
emit_signal("item_double_clicked", $Tree.get_selected().get_metadata(0))
|
||||||
|
queue_free()
|
14
addons/material_maker/widgets/graph_tree/graph_tree.tscn
Normal file
14
addons/material_maker/widgets/graph_tree/graph_tree.tscn
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://addons/material_maker/widgets/graph_tree/graph_tree.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
[node name="GraphTree" type="Popup"]
|
||||||
|
margin_right = 335.0
|
||||||
|
margin_bottom = 339.0
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="Tree" type="Tree" parent="."]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
[connection signal="item_activated" from="Tree" to="." method="_on_Tree_item_double_clicked"]
|
||||||
|
[connection signal="item_double_clicked" from="Tree" to="." method="_on_Tree_item_double_clicked"]
|
Loading…
Reference in New Issue
Block a user