Now slot colors in mat makjer gd's ui is handled by a method instead of having a PoolColorArray.

This commit is contained in:
Relintai 2022-06-06 20:52:38 +02:00
parent eb7c514ee7
commit a82f5fafe4
3 changed files with 23 additions and 16 deletions

View File

@ -3,8 +3,6 @@ extends MarginContainer
var MMGraphNode = preload("res://addons/mat_maker_gd/editor/mm_graph_node.gd") 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 graph_edit_path : NodePath = "VBoxContainer/GraphEdit"
export(NodePath) var add_popup_path : NodePath = "Popups/AddPopup" export(NodePath) var add_popup_path : NodePath = "Popups/AddPopup"
@ -81,7 +79,6 @@ func recreate() -> void:
for n in _material.nodes: for n in _material.nodes:
var gn : GraphNode = MMGraphNode.new() var gn : GraphNode = MMGraphNode.new()
gn.slot_colors = slot_colors
gn.set_editor(self) gn.set_editor(self)
gn.set_node(_material, n) gn.set_node(_material, n)
_graph_edit.add_child(gn) _graph_edit.add_child(gn)
@ -213,7 +210,6 @@ func _on_AddPopup_ok_pressed(script_path : String):
_undo_redo.commit_action() _undo_redo.commit_action()
var gn : GraphNode = MMGraphNode.new() var gn : GraphNode = MMGraphNode.new()
gn.slot_colors = slot_colors
gn.set_editor(self) gn.set_editor(self)
gn.set_node(_material, nnode) gn.set_node(_material, nnode)
_graph_edit.add_child(gn) _graph_edit.add_child(gn)

View File

@ -10,10 +10,6 @@ rect_min_size = Vector2( 0, 200 )
size_flags_horizontal = 3 size_flags_horizontal = 3
size_flags_vertical = 3 size_flags_vertical = 3
script = ExtResource( 1 ) 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, 0.0352941, 0.0509804, 1, 1, 0.372549, 0.372549, 0.372549, 1 )
[node name="VBoxContainer" type="VBoxContainer" parent="."] [node name="VBoxContainer" type="VBoxContainer" parent="."]
margin_right = 1024.0 margin_right = 1024.0

View File

@ -5,8 +5,6 @@ var gradient_editor_scene : PackedScene = preload("res://addons/mat_maker_gd/wid
var polygon_edit_scene : PackedScene = preload("res://addons/mat_maker_gd/widgets/polygon_edit/polygon_edit.tscn") var polygon_edit_scene : PackedScene = preload("res://addons/mat_maker_gd/widgets/polygon_edit/polygon_edit.tscn")
var curve_edit_scene : PackedScene = preload("res://addons/mat_maker_gd/widgets/curve_edit/curve_edit.tscn") var curve_edit_scene : PackedScene = preload("res://addons/mat_maker_gd/widgets/curve_edit/curve_edit.tscn")
var slot_colors : PoolColorArray
var _material : MMMateial = null var _material : MMMateial = null
var _node : MMNode = null var _node : MMNode = null
var properties : Array = Array() var properties : Array = Array()
@ -431,15 +429,11 @@ func add_slot(input_type : int, output_type : int, getter : String, setter : Str
if input_type != -1: if input_type != -1:
set_slot_type_left(slot_idx, input_type) set_slot_type_left(slot_idx, input_type)
set_slot_color_left(slot_idx, get_slot_color(input_type))
if output_type != -1: if output_type != -1:
set_slot_type_left(slot_idx, output_type) set_slot_type_left(slot_idx, output_type)
set_slot_color_right(slot_idx, get_slot_color(output_type))
if input_type != -1 && slot_colors.size() > input_type:
set_slot_color_left(slot_idx, slot_colors[input_type])
if output_type != -1 && slot_colors.size() > output_type:
set_slot_color_right(slot_idx, slot_colors[output_type])
return slot_idx return slot_idx
@ -725,3 +719,24 @@ func on_close_request() -> void:
return return
n = n.get_parent() n = n.get_parent()
func get_slot_color(slot_type : int) -> Color:
return _get_slot_color(slot_type)
func _get_slot_color(slot_type : int) -> Color:
if slot_type == 0:
return Color(0.91, 0.06, 0.06)
elif slot_type == 1:
return Color(0.43, 0.04, 0.04)
elif slot_type == 2:
return Color(0.83, 0.38, 0.38)
elif slot_type == 3:
return Color(0.04, 0.48, 0.43)
elif slot_type == 4:
return Color(0.35, 0.04, 0.34)
elif slot_type == 5:
return Color(0.04, 0.05, 1)
elif slot_type == 6:
return Color(0.37, 0.37, 0.37)
return Color(1, 1, 1, 1)