mirror of
https://github.com/Relintai/material-maker.git
synced 2025-01-25 18:59:18 +01:00
Added missing initialization of cursor positions in the Tones node
This commit is contained in:
parent
d3a3fabc31
commit
3627470239
@ -16,9 +16,10 @@ class Cursor:
|
|||||||
top = t
|
top = t
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
rect_position = Vector2(position * get_parent().rect_size.x - 0.5*WIDTH, -2 if top else get_parent().rect_size.y+2-HEIGHT)
|
rect_position.y = -2 if top else get_parent().rect_size.y+2-HEIGHT
|
||||||
|
set_value(position)
|
||||||
rect_size = Vector2(WIDTH, HEIGHT)
|
rect_size = Vector2(WIDTH, HEIGHT)
|
||||||
|
|
||||||
func _draw() -> void:
|
func _draw() -> void:
|
||||||
var polygon : PoolVector2Array
|
var polygon : PoolVector2Array
|
||||||
if top:
|
if top:
|
||||||
@ -30,7 +31,7 @@ class Cursor:
|
|||||||
draw_colored_polygon(polygon, c)
|
draw_colored_polygon(polygon, c)
|
||||||
var outline_color = 0.0 if position > 0.5 else 1.0
|
var outline_color = 0.0 if position > 0.5 else 1.0
|
||||||
draw_polyline(polygon, Color(outline_color, outline_color, outline_color), 1.0, true)
|
draw_polyline(polygon, Color(outline_color, outline_color, outline_color), 1.0, true)
|
||||||
|
|
||||||
func _gui_input(ev) -> void:
|
func _gui_input(ev) -> void:
|
||||||
if ev is InputEventMouseMotion && (ev.button_mask & 1) != 0:
|
if ev is InputEventMouseMotion && (ev.button_mask & 1) != 0:
|
||||||
rect_position.x += ev.relative.x
|
rect_position.x += ev.relative.x
|
||||||
@ -40,9 +41,10 @@ class Cursor:
|
|||||||
position = new_position
|
position = new_position
|
||||||
get_parent().get_parent().update_value(self, position)
|
get_parent().get_parent().update_value(self, position)
|
||||||
update()
|
update()
|
||||||
|
|
||||||
func get_position() -> Vector2:
|
func set_value(v : float):
|
||||||
return rect_position.x / (get_parent().rect_size.x - WIDTH)
|
position = v
|
||||||
|
rect_position.x = position * get_parent().rect_size.x - 0.5*WIDTH
|
||||||
|
|
||||||
var cursor_in_min : Cursor
|
var cursor_in_min : Cursor
|
||||||
var cursor_in_mid : Cursor
|
var cursor_in_mid : Cursor
|
||||||
@ -69,18 +71,7 @@ func set_generator(g) -> void:
|
|||||||
.set_generator(g)
|
.set_generator(g)
|
||||||
generator.connect("parameter_changed", self, "on_parameter_changed")
|
generator.connect("parameter_changed", self, "on_parameter_changed")
|
||||||
update_node()
|
update_node()
|
||||||
|
_on_Mode_item_selected(0)
|
||||||
func update_node() -> void:
|
|
||||||
if has_node("NodeEditButtons"):
|
|
||||||
var r = $NodeEditButtons
|
|
||||||
remove_child(r)
|
|
||||||
r.free()
|
|
||||||
rect_size = Vector2(0, 0)
|
|
||||||
if generator.is_editable():
|
|
||||||
var edit_buttons = preload("res://material_maker/nodes/edit_buttons.tscn").instance()
|
|
||||||
add_child(edit_buttons)
|
|
||||||
edit_buttons.connect_buttons(self, "edit_generator", "load_generator", "save_generator")
|
|
||||||
set_slot(edit_buttons.get_index(), false, 0, Color(0.0, 0.0, 0.0), false, 0, Color(0.0, 0.0, 0.0))
|
|
||||||
|
|
||||||
func on_parameter_changed(p, v) -> void:
|
func on_parameter_changed(p, v) -> void:
|
||||||
if p == "__input_changed__":
|
if p == "__input_changed__":
|
||||||
@ -91,6 +82,26 @@ func on_parameter_changed(p, v) -> void:
|
|||||||
result.copy_to_texture($Histogram.get_image_texture())
|
result.copy_to_texture($Histogram.get_image_texture())
|
||||||
result.release()
|
result.release()
|
||||||
|
|
||||||
|
func get_parameter(n : String) -> float:
|
||||||
|
var value = generator.get_parameter(n)
|
||||||
|
match $Mode.selected:
|
||||||
|
1:
|
||||||
|
return value.r
|
||||||
|
2:
|
||||||
|
return value.g
|
||||||
|
3:
|
||||||
|
return value.b
|
||||||
|
4:
|
||||||
|
return value.a
|
||||||
|
return (value.r+value.g+value.b)/3.0
|
||||||
|
|
||||||
|
func _on_Mode_item_selected(_id):
|
||||||
|
cursor_in_min.set_value(get_parameter("in_min"))
|
||||||
|
cursor_in_mid.set_value(get_parameter("in_mid"))
|
||||||
|
cursor_in_max.set_value(get_parameter("in_max"))
|
||||||
|
cursor_out_min.set_value(get_parameter("out_min"))
|
||||||
|
cursor_out_max.set_value(get_parameter("out_max"))
|
||||||
|
|
||||||
func set_parameter(n : String, v : float, d : float) -> void:
|
func set_parameter(n : String, v : float, d : float) -> void:
|
||||||
var value = generator.get_parameter(n)
|
var value = generator.get_parameter(n)
|
||||||
match $Mode.selected:
|
match $Mode.selected:
|
||||||
@ -123,6 +134,20 @@ func update_value(control : Cursor, value : float) -> void:
|
|||||||
set_parameter("out_max", value, 1)
|
set_parameter("out_max", value, 1)
|
||||||
get_parent().send_changed_signal()
|
get_parent().send_changed_signal()
|
||||||
|
|
||||||
|
# Everything below is only meant for editing the shader
|
||||||
|
|
||||||
|
func update_node() -> void:
|
||||||
|
if has_node("NodeEditButtons"):
|
||||||
|
var r = $NodeEditButtons
|
||||||
|
remove_child(r)
|
||||||
|
r.free()
|
||||||
|
rect_size = Vector2(0, 0)
|
||||||
|
if generator.is_editable():
|
||||||
|
var edit_buttons = preload("res://material_maker/nodes/edit_buttons.tscn").instance()
|
||||||
|
add_child(edit_buttons)
|
||||||
|
edit_buttons.connect_buttons(self, "edit_generator", "load_generator", "save_generator")
|
||||||
|
set_slot(edit_buttons.get_index(), false, 0, Color(0.0, 0.0, 0.0), false, 0, Color(0.0, 0.0, 0.0))
|
||||||
|
|
||||||
func edit_generator() -> void:
|
func edit_generator() -> void:
|
||||||
if generator.has_method("edit"):
|
if generator.has_method("edit"):
|
||||||
generator.edit(self)
|
generator.edit(self)
|
||||||
|
@ -76,3 +76,4 @@ rect_min_size = Vector2( 0, 4 )
|
|||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
}
|
}
|
||||||
|
[connection signal="item_selected" from="Mode" to="." method="_on_Mode_item_selected"]
|
||||||
|
Loading…
Reference in New Issue
Block a user