material-maker/addons/material_maker/widgets/size_option_button.gd
RodZill4 4fc7c11a29 Updated size parameter handling and resized all examples to 2048x2048
Also added a base class for all graph nodes, fixed issues with graph/remote interactions.
2019-10-21 23:58:14 +02:00

35 lines
785 B
GDScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

extends OptionButton
class_name SizeOptionButton
var min_size : int = 4 setget set_min_size
var max_size : int = 12 setget set_max_size
var size_value : int = 10 setget set_size_value
signal size_value_changed(s)
func _ready() -> void:
connect("item_selected", self, "_on_item_selected")
func set_min_size(m : int) -> void:
min_size = m
update_options()
func set_max_size(m : int) -> void:
max_size = m
update_options()
func set_size_value(v : int) -> void:
size_value = v
update_options()
func update_options() -> void:
clear()
for i in range(min_size, max_size+1):
var s = pow(2, i)
add_item("%d×%d" % [ s, s ])
selected = size_value-min_size
func _on_item_selected(id : int) -> void:
size_value = id + min_size
emit_signal("size_value_changed", size_value)