mirror of
https://github.com/Relintai/material-maker.git
synced 2024-11-13 06:27:18 +01:00
Added types to ios nodes
This commit is contained in:
parent
f0a22b593f
commit
97e923e781
@ -37,12 +37,14 @@ var parameters = {}
|
||||
var seed_locked : bool = false
|
||||
var seed_value : int = 0
|
||||
|
||||
const PORT_TYPE_NAMES : Array = [ "f", "rgb", "rgba", "sdf2d", "sdf3d" ]
|
||||
|
||||
const PORT_TYPES : Dictionary = {
|
||||
rgba = { type="vec4", paramdefs="vec2 uv", params="uv" },
|
||||
rgb = { type="vec3", paramdefs="vec2 uv", params="uv" },
|
||||
f = { type="float", paramdefs="vec2 uv", params="uv" },
|
||||
sdf2d = { type="float", paramdefs="vec2 uv", params="uv" },
|
||||
sdf3d = { type="float", paramdefs="vec3 p", params="p" }
|
||||
f = { type="float", paramdefs="vec2 uv", params="uv", slot_type=0, color=Color(0.5, 0.5, 0.5) },
|
||||
rgb = { type="vec3", paramdefs="vec2 uv", params="uv", slot_type=0, color=Color(0.5, 0.5, 1.0) },
|
||||
rgba = { type="vec4", paramdefs="vec2 uv", params="uv", slot_type=0, color=Color(0.0, 0.5, 0.0, 0.5) },
|
||||
sdf2d = { type="float", paramdefs="vec2 uv", params="uv", slot_type=1, color=Color(1.0, 0.5, 0.0) },
|
||||
sdf3d = { type="float", paramdefs="vec3 p", params="p", slot_type=2, color=Color(1.0, 0.0, 0.0) }
|
||||
}
|
||||
|
||||
func _ready() -> void:
|
||||
|
@ -284,8 +284,8 @@ func create_subgraph(gens : Array) -> MMGenGraph:
|
||||
if port_index == -1:
|
||||
port_index = outputs.size()
|
||||
outputs.push_back(src_name)
|
||||
gen_outputs.ports.push_back( { name="port"+str(port_index), type="rgba" } )
|
||||
print(gen_outputs.ports)
|
||||
var type = new_graph.get_node(c.from).get_output_defs()[c.from_port].type
|
||||
gen_outputs.ports.push_back( { name="port"+str(port_index), type=type } )
|
||||
my_new_connections.push_back( { from=new_graph.name, from_port=port_index, to=c.to, to_port=c.to_port } )
|
||||
new_graph_connections.push_back( { from=c.from, from_port=c.from_port, to="gen_outputs", to_port=port_index } )
|
||||
elif names.find(c.to) != -1:
|
||||
@ -293,7 +293,8 @@ func create_subgraph(gens : Array) -> MMGenGraph:
|
||||
if port_index == -1:
|
||||
port_index = inputs.size()
|
||||
inputs.push_back(src_name)
|
||||
gen_inputs.ports.push_back( { name="port"+str(port_index), type="rgba" } )
|
||||
var type = get_node(c.from).get_output_defs()[c.from_port].type
|
||||
gen_inputs.ports.push_back( { name="port"+str(port_index), type=type } )
|
||||
my_new_connections.push_back( { from=c.from, from_port=c.from_port, to=new_graph.name, to_port=port_index } )
|
||||
new_graph_connections.push_back( { from="gen_inputs", from_port=port_index, to=c.to, to_port=c.to_port } )
|
||||
else:
|
||||
|
@ -27,7 +27,7 @@ func get_type_name() -> String:
|
||||
func get_io_defs() -> Array:
|
||||
var rv : Array = []
|
||||
for p in ports:
|
||||
rv.push_back({ name=p.name, type="rgba" })
|
||||
rv.push_back({ name=p.name, type=p.type })
|
||||
return rv
|
||||
|
||||
func get_input_defs() -> Array:
|
||||
@ -54,6 +54,11 @@ func add_port() -> void:
|
||||
func set_port_name(i : int, n : String) -> void:
|
||||
ports[i].name = n
|
||||
|
||||
func set_port_type(i : int, t : String) -> void:
|
||||
print(t)
|
||||
ports[i].type = t
|
||||
emit_signal("parameter_changed", "__update_all__", null)
|
||||
|
||||
func delete_port(i : int) -> void:
|
||||
ports.remove(i)
|
||||
var input_gen = get_parent() if name == "gen_inputs" else self
|
||||
|
@ -174,14 +174,12 @@ func update_node() -> void:
|
||||
var input = inputs[i]
|
||||
var enable_left = false
|
||||
var color_left = Color(0.5, 0.5, 0.5)
|
||||
var type_left = 0
|
||||
if typeof(input) == TYPE_DICTIONARY:
|
||||
enable_left = true
|
||||
match input.type:
|
||||
"rgb": color_left = Color(0.5, 0.5, 1.0)
|
||||
"rgba": color_left = Color(0.0, 0.5, 0.0, 0.5)
|
||||
"sdf2d": color_left = Color(1.0, 0.5, 0.0, 1.0)
|
||||
"sdf3d": color_left = Color(1.0, 0.0, 0.0, 1.0)
|
||||
set_slot(i, enable_left, 0, color_left, false, 0, Color())
|
||||
color_left = MMGenBase.PORT_TYPES[input.type].color
|
||||
type_left = MMGenBase.PORT_TYPES[input.type].slot_type
|
||||
set_slot(i, enable_left, type_left, color_left, false, 0, Color())
|
||||
var hsizer : HBoxContainer = HBoxContainer.new()
|
||||
hsizer.size_flags_horizontal = SIZE_EXPAND | SIZE_FILL
|
||||
if input.has("label") and input.label != "":
|
||||
@ -247,17 +245,15 @@ func update_node() -> void:
|
||||
output_count = outputs.size()
|
||||
for i in range(output_count):
|
||||
var output = outputs[i]
|
||||
var enable_right = true
|
||||
var color_right = Color(0.5, 0.5, 0.5)
|
||||
var enable_right : bool = true
|
||||
var color_right : Color = Color(0.5, 0.5, 0.5)
|
||||
var type_right : int = 0
|
||||
assert(typeof(output) == TYPE_DICTIONARY)
|
||||
assert(output.has("type"))
|
||||
enable_right = true
|
||||
match output.type:
|
||||
"rgb": color_right = Color(0.5, 0.5, 1.0)
|
||||
"rgba": color_right = Color(0.0, 0.5, 0.0, 0.5)
|
||||
"sdf2d": color_right = Color(1.0, 0.5, 0.0, 1.0)
|
||||
"sdf3d": color_right = Color(1.0, 0.0, 0.0, 1.0)
|
||||
set_slot(i, is_slot_enabled_left(i), get_slot_type_left(i), get_slot_color_left(i), enable_right, 0, color_right)
|
||||
color_right = MMGenBase.PORT_TYPES[output.type].color
|
||||
type_right = MMGenBase.PORT_TYPES[output.type].slot_type
|
||||
set_slot(i, is_slot_enabled_left(i), get_slot_type_left(i), get_slot_color_left(i), enable_right, type_right, color_right)
|
||||
var hsizer : HBoxContainer
|
||||
while i >= get_child_count():
|
||||
hsizer = HBoxContainer.new()
|
||||
|
@ -22,12 +22,14 @@ func update_node() -> void:
|
||||
title = generator.get_type_name()
|
||||
var color = Color(0.0, 0.5, 0.0, 0.5)
|
||||
for p in generator.get_io_defs():
|
||||
color = MMGenBase.PORT_TYPES[p.type].color
|
||||
set_slot(get_child_count(), generator.name != "gen_inputs", 0, color, generator.name != "gen_outputs", 0, color)
|
||||
var port : Control
|
||||
if generator.is_editable():
|
||||
port = preload("res://addons/material_maker/nodes/ios/port.tscn").instance()
|
||||
if p.has("name"):
|
||||
port.set_label(p.name)
|
||||
port.set_type(p.type)
|
||||
else:
|
||||
port = Label.new()
|
||||
port.text = p.name
|
||||
|
@ -3,6 +3,9 @@ extends HBoxContainer
|
||||
func set_label(l : String) -> void:
|
||||
$Name.set_text(l)
|
||||
|
||||
func set_type(t : String) -> void:
|
||||
$Type.selected = MMGenBase.PORT_TYPE_NAMES.find(t)
|
||||
|
||||
func update_up_down_button() -> void:
|
||||
var parent = get_parent()
|
||||
if parent == null:
|
||||
@ -13,6 +16,9 @@ func update_up_down_button() -> void:
|
||||
func _on_Name_label_changed(new_label) -> void:
|
||||
get_parent().generator.set_port_name(get_index(), new_label)
|
||||
|
||||
func _on_Type_item_selected(ID) -> void:
|
||||
get_parent().generator.set_port_type(get_index(), MMGenBase.PORT_TYPE_NAMES[ID])
|
||||
|
||||
func _on_Delete_pressed() -> void:
|
||||
get_parent().generator.delete_port(get_index())
|
||||
|
||||
|
@ -48,7 +48,18 @@ margin_left = 84.0
|
||||
margin_right = 114.0
|
||||
margin_bottom = 20.0
|
||||
rect_min_size = Vector2( 30, 0 )
|
||||
|
||||
[node name="Type" type="OptionButton" parent="."]
|
||||
margin_left = 118.0
|
||||
margin_right = 222.0
|
||||
margin_bottom = 20.0
|
||||
rect_min_size = Vector2( 102, 0 )
|
||||
hint_tooltip = "Input flag"
|
||||
text = "Greyscale"
|
||||
items = [ "Greyscale", null, false, 0, null, "Color", null, false, 1, null, "RGBA", null, false, 2, null, "SDF2D", null, false, 3, null, "SDF3D", null, false, 4, null ]
|
||||
selected = 0
|
||||
[connection signal="pressed" from="Delete" to="." method="_on_Delete_pressed"]
|
||||
[connection signal="pressed" from="Up" to="." method="_on_Up_pressed"]
|
||||
[connection signal="pressed" from="Down" to="." method="_on_Down_pressed"]
|
||||
[connection signal="label_changed" from="Name" to="." method="_on_Name_label_changed"]
|
||||
[connection signal="item_selected" from="Type" to="." method="_on_Type_item_selected"]
|
||||
|
Loading…
Reference in New Issue
Block a user