diff --git a/addons/material_maker/engine/gen_base.gd b/addons/material_maker/engine/gen_base.gd index d40da58..80fc16a 100644 --- a/addons/material_maker/engine/gen_base.gd +++ b/addons/material_maker/engine/gen_base.gd @@ -49,6 +49,9 @@ func toggle_editable() -> bool: func is_editable() -> bool: return false +func has_randomness(): + return false + func init_parameters() -> void: for p in get_parameter_defs(): if !parameters.has(p.name): diff --git a/addons/material_maker/icons/icons.svg b/addons/material_maker/icons/icons.svg index 1cc7e5f..c493618 100644 --- a/addons/material_maker/icons/icons.svg +++ b/addons/material_maker/icons/icons.svg @@ -15,7 +15,7 @@ viewBox="0 0 128 64" version="1.1" id="svg8" - inkscape:version="0.92.3 (2405546, 2018-03-11)" + inkscape:version="0.92.4 (5da689c313, 2019-01-14)" sodipodi:docname="icons.svg"> @@ -48,9 +48,9 @@ borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" - inkscape:zoom="14.304427" - inkscape:cx="79.150133" - inkscape:cy="47.863625" + inkscape:zoom="28.608854" + inkscape:cx="86.841515" + inkscape:cy="21.061007" inkscape:document-units="px" inkscape:current-layer="layer1" showgrid="true" @@ -393,5 +393,62 @@ id="path4576-0" inkscape:connector-curvature="0" sodipodi:nodetypes="czsc" /> + + + + + + + + + + + + diff --git a/addons/material_maker/icons/randomness_locked.tres b/addons/material_maker/icons/randomness_locked.tres new file mode 100644 index 0000000..2381e64 --- /dev/null +++ b/addons/material_maker/icons/randomness_locked.tres @@ -0,0 +1,8 @@ +[gd_resource type="AtlasTexture" load_steps=2 format=2] + +[ext_resource path="res://addons/material_maker/icons/icons.svg" type="Texture" id=1] + +[resource] +flags = 4 +atlas = ExtResource( 1 ) +region = Rect2( 80, 32, 16, 16 ) diff --git a/addons/material_maker/icons/randomness_unlocked.tres b/addons/material_maker/icons/randomness_unlocked.tres new file mode 100644 index 0000000..bd87a21 --- /dev/null +++ b/addons/material_maker/icons/randomness_unlocked.tres @@ -0,0 +1,8 @@ +[gd_resource type="AtlasTexture" load_steps=2 format=2] + +[ext_resource path="res://addons/material_maker/icons/icons.svg" type="Texture" id=1] + +[resource] +flags = 4 +atlas = ExtResource( 1 ) +region = Rect2( 64, 32, 16, 16 ) diff --git a/addons/material_maker/nodes/base.gd b/addons/material_maker/nodes/base.gd index fa17a08..f7603bc 100644 --- a/addons/material_maker/nodes/base.gd +++ b/addons/material_maker/nodes/base.gd @@ -3,12 +3,23 @@ extends GraphNode class_name MMGraphNodeBase var generator : MMGenBase = null setget set_generator +var fixed_seed = false func _ready() -> void: connect("offset_changed", self, "_on_offset_changed") +func _draw(): + if generator.has_randomness(): + var icon = preload("res://addons/material_maker/icons/randomness_unlocked.tres") if fixed_seed else preload("res://addons/material_maker/icons/randomness_locked.tres") + draw_texture_rect(icon, Rect2(rect_size.x-48, 4, 16, 16), false) + func set_generator(g) -> void: generator = g func _on_offset_changed() -> void: generator.set_position(offset) + +func _on_gui_input(event): + if event is InputEventMouseButton and event.pressed and event.button_index == BUTTON_LEFT and Rect2(rect_size.x-48, 4, 16, 16).has_point(event.position): + fixed_seed = !fixed_seed + update()