mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-12-21 13:16:49 +01:00
Now the editor loads and created nodes from MMNodes, and also implemented MMNode and graphnode creating logic for the add button/dialog.
This commit is contained in:
parent
1374df2b59
commit
537d44bc63
@ -1,13 +1,63 @@
|
||||
tool
|
||||
extends MarginContainer
|
||||
|
||||
var MMGraphNode = preload("res://addons/mat_maker_gd/editor/mm_graph_node.gd")
|
||||
|
||||
export(NodePath) var graph_edit_path : NodePath = "VBoxContainer/GraphEdit"
|
||||
export(NodePath) var add_popup_path : NodePath = "Popups/AddPopup"
|
||||
|
||||
var _graph_edit : GraphEdit = null
|
||||
|
||||
var _material : MMMateial
|
||||
|
||||
func _enter_tree():
|
||||
ensure_objs()
|
||||
|
||||
func ensure_objs() -> void:
|
||||
if !_graph_edit:
|
||||
_graph_edit = get_node(graph_edit_path)
|
||||
|
||||
func recreate() -> void:
|
||||
ensure_objs()
|
||||
|
||||
for c in _graph_edit.get_children():
|
||||
if c is GraphNode:
|
||||
_graph_edit.remove_child(c)
|
||||
c.queue_free()
|
||||
|
||||
if !_material:
|
||||
return
|
||||
|
||||
for n in _material.nodes:
|
||||
var gn : GraphNode = MMGraphNode.new()
|
||||
gn.set_node(n)
|
||||
_graph_edit.add_child(gn)
|
||||
|
||||
#connect them
|
||||
|
||||
func set_mmmaterial(object : MMMateial):
|
||||
_material = object
|
||||
|
||||
recreate()
|
||||
|
||||
func _on_AddButton_pressed():
|
||||
get_node(add_popup_path).popup_centered()
|
||||
|
||||
func _on_AddPopup_ok_pressed(script_path : String):
|
||||
#print(script_path)
|
||||
pass
|
||||
if !_material:
|
||||
return
|
||||
|
||||
ensure_objs()
|
||||
|
||||
var sc = load(script_path)
|
||||
var nnode : MMNode = sc.new()
|
||||
|
||||
if !nnode:
|
||||
print("_on_AddPopup_ok_pressed: Error !nnode! script: " + script_path)
|
||||
return
|
||||
|
||||
_material.nodes.append(nnode)
|
||||
|
||||
var gn : GraphNode = MMGraphNode.new()
|
||||
gn.set_node(nnode)
|
||||
_graph_edit.add_child(gn)
|
||||
|
@ -1,3 +1,7 @@
|
||||
tool
|
||||
extends GraphNode
|
||||
|
||||
var _node : MMNode = null
|
||||
|
||||
func set_node(node : MMNode) -> void:
|
||||
_node = node
|
||||
|
@ -36,7 +36,9 @@ func handles(object):
|
||||
func edit(object):
|
||||
#if editor_scene:
|
||||
# make_bottom_panel_item_visible(editor_scene)
|
||||
pass
|
||||
|
||||
if object is MMMateial:
|
||||
editor_scene.set_mmmaterial(object as MMMateial)
|
||||
|
||||
func make_visible(visible):
|
||||
if tool_button:
|
||||
|
Loading…
Reference in New Issue
Block a user