2019-09-17 08:12:53 +02:00
|
|
|
tool
|
|
|
|
extends MMGenBase
|
|
|
|
class_name MMGenIOs
|
|
|
|
|
|
|
|
"""
|
|
|
|
IOs just forward their inputs to their outputs and are used to specify graph interfaces
|
|
|
|
"""
|
|
|
|
|
|
|
|
var ports : Array = []
|
|
|
|
|
2019-10-20 16:22:06 +02:00
|
|
|
func get_type() -> String:
|
2019-10-05 11:04:50 +02:00
|
|
|
return "ios"
|
2019-09-17 08:12:53 +02:00
|
|
|
|
2019-10-20 16:22:06 +02:00
|
|
|
func get_type_name() -> String:
|
2019-09-29 10:07:32 +02:00
|
|
|
match name:
|
|
|
|
"gen_inputs": return "Inputs"
|
|
|
|
"gen_outputs": return "Outputs"
|
2019-09-17 08:12:53 +02:00
|
|
|
_: return "IOs"
|
|
|
|
|
2019-10-20 16:22:06 +02:00
|
|
|
func get_io_defs() -> Array:
|
2019-09-17 08:12:53 +02:00
|
|
|
var rv : Array = []
|
2019-10-05 11:04:50 +02:00
|
|
|
for p in ports:
|
|
|
|
rv.push_back({ name=p.name, type="rgba" })
|
2019-09-17 08:12:53 +02:00
|
|
|
return rv
|
2019-10-02 23:06:20 +02:00
|
|
|
|
2019-10-20 16:22:06 +02:00
|
|
|
func get_input_defs() -> Array:
|
2019-10-02 23:06:20 +02:00
|
|
|
return [] if name == "gen_inputs" else get_io_defs()
|
|
|
|
|
2019-10-20 16:22:06 +02:00
|
|
|
func get_output_defs() -> Array:
|
2019-10-02 23:06:20 +02:00
|
|
|
return [] if name == "gen_outputs" else get_io_defs()
|
2019-09-17 08:12:53 +02:00
|
|
|
|
2019-10-20 16:22:06 +02:00
|
|
|
func source_changed(input_index : int) -> void:
|
2019-09-22 22:17:26 +02:00
|
|
|
if name == "gen_outputs":
|
|
|
|
get_parent().notify_output_change(input_index)
|
|
|
|
else:
|
|
|
|
notify_output_change(input_index)
|
|
|
|
|
2019-10-20 16:22:06 +02:00
|
|
|
func _get_shader_code(uv : String, output_index : int, context : MMGenContext) -> Dictionary:
|
2019-10-05 11:04:50 +02:00
|
|
|
var source = get_source(output_index)
|
|
|
|
if source != null:
|
|
|
|
var rv = source.generator._get_shader_code(uv, source.output_index, context)
|
|
|
|
while rv is GDScriptFunctionState:
|
|
|
|
rv = yield(rv, "completed")
|
|
|
|
return rv
|
2019-09-17 08:12:53 +02:00
|
|
|
return { defs="", code="", textures={} }
|
|
|
|
|
2019-10-20 16:22:06 +02:00
|
|
|
func _serialize(data: Dictionary) -> Dictionary:
|
2019-09-22 22:17:26 +02:00
|
|
|
data.type = "ios"
|
|
|
|
data.ports = ports
|
2019-09-17 08:12:53 +02:00
|
|
|
return data
|