Added slot color support.

This commit is contained in:
Relintai 2021-10-04 13:28:00 +02:00
parent 2eb6f789dd
commit 634d28b713
4 changed files with 12 additions and 7 deletions

View File

@ -3,6 +3,8 @@ extends MarginContainer
var MMGraphNode = preload("res://addons/mat_maker_gd/editor/mm_graph_node.gd")
export(PoolColorArray) var slot_colors : PoolColorArray
export(NodePath) var graph_edit_path : NodePath = "VBoxContainer/GraphEdit"
export(NodePath) var add_popup_path : NodePath = "Popups/AddPopup"
@ -30,6 +32,7 @@ func recreate() -> void:
for n in _material.nodes:
var gn : GraphNode = MMGraphNode.new()
gn.slot_colors = slot_colors
gn.set_node(_material, n)
_graph_edit.add_child(gn)
@ -59,6 +62,7 @@ func _on_AddPopup_ok_pressed(script_path : String):
_material.add_node(nnode)
var gn : GraphNode = MMGraphNode.new()
gn.slot_colors = slot_colors
gn.set_node(_material, nnode)
_graph_edit.add_child(gn)

View File

@ -13,6 +13,7 @@ script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
slot_colors = PoolColorArray( 0.905882, 0.0627451, 0.0627451, 1, 0.431373, 0.0352941, 0.0352941, 1, 0.827451, 0.376471, 0.376471, 1, 0.0431373, 0.478431, 0.427451, 1, 0.352941, 0.0352941, 0.341176, 1 )
[node name="VBoxContainer" type="VBoxContainer" parent="."]
margin_right = 1024.0

View File

@ -1,7 +1,7 @@
tool
extends GraphNode
export(PoolColorArray) var slot_colors : PoolColorArray
var slot_colors : PoolColorArray
var _material : MMMateial = null
var _node : MMNode = null
@ -10,7 +10,7 @@ var properties : Array = Array()
func _init():
show_close = true
connect("offset_changed", self, "on_offset_changed")
func add_slot_texture(input_type : int, output_type : int, getter : String, setter : String) -> void:
var t : TextureRect = TextureRect.new()
@ -50,12 +50,12 @@ func add_slot(input_type : int, output_type : int, getter : String, setter : Str
if output_type != -1:
set_slot_type_left(slot_idx, output_type)
if slot_colors.size() > input_type:
if input_type != -1 && slot_colors.size() > input_type:
set_slot_color_left(slot_idx, slot_colors[input_type])
if slot_colors.size() > output_type:
set_slot_color_left(slot_idx, slot_colors[output_type])
if output_type != -1 && slot_colors.size() > output_type:
set_slot_color_right(slot_idx, slot_colors[output_type])
return slot_idx
func set_node(material : MMMateial, node : MMNode) -> void:

View File

@ -14,5 +14,5 @@ func get_value_for(uv : Vector2, slot_idx : int, pseed : int) -> Color:
return NoisePerlin.perlinc(uv, scale, iterations, persistence, pseed)
func register_methods(mm_graph_node) -> void:
mm_graph_node.add_slot_texture(0, 0, "recalculate_image", "")
mm_graph_node.add_slot_texture(SlotTypes.SLOT_TYPE_NONE, SlotTypes.SLOT_TYPE_IMAGE, "recalculate_image", "")