Renamed output.gd to output_image.gd and implemented it's logic.

This commit is contained in:
Relintai 2021-10-09 14:47:55 +02:00
parent 52858a6970
commit 8758111bf6
3 changed files with 43 additions and 15 deletions

View File

@ -40,7 +40,7 @@ default_color = Color( 0, 0, 0, 1 )
[sub_resource type="Resource" id=5]
script = ExtResource( 4 )
graph_position = Vector2( -260, -340 )
graph_position = Vector2( -340, -360 )
shape_type = 1
sides = 4
radius = SubResource( 4 )

View File

@ -1,14 +0,0 @@
tool
extends MMNode
var image : Resource
func _init_properties():
image = MMNodeUniversalProperty.new()
image.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
image.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
image.slot_name = "radius"
image.value_step = 0.05
func _register_methods(mm_graph_node) -> void:
mm_graph_node.add_slot_texture_universal(image)

View File

@ -0,0 +1,42 @@
tool
extends MMNode
var image : Resource
var postfix : String = ""
func _init_properties():
image = MMNodeUniversalProperty.new()
image.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
image.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
image.slot_name = "image"
register_input_property(image)
func _register_methods(mm_graph_node) -> void:
mm_graph_node.add_slot_texture_universal(image)
mm_graph_node.add_slot_line_edit(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_NONE, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_NONE, "get_postfix", "set_postfix", "postfix")
func _render(material) -> void:
var img : Image = image.get_active_image()
if !img:
return
var matpath : String = material.get_path()
if matpath == "":
return
var matbn : String = matpath.get_basename()
var final_file_name : String = matbn + postfix + ".png"
img.save_png(final_file_name)
func get_postfix() -> String:
return postfix
func set_postfix(pf : String) -> void:
postfix = pf
set_dirty(true)