a game about throwing hammers made for the github game off
Diffstat (limited to 'ui/components/caretoptionbutton/caretoptionbutton.gd')
| -rw-r--r-- | ui/components/caretoptionbutton/caretoptionbutton.gd | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/ui/components/caretoptionbutton/caretoptionbutton.gd b/ui/components/caretoptionbutton/caretoptionbutton.gd new file mode 100644 index 0000000..b46ef1b --- /dev/null +++ b/ui/components/caretoptionbutton/caretoptionbutton.gd @@ -0,0 +1,22 @@ +extends HBoxContainer +class_name CaretOptionButton + +signal changed(current_option: int) + +@onready var button: Button = $button as Button +@export var options: PackedStringArray = [] +@export var current_option: int = 0: + set(val): + current_option = wrapi(val, 0, len(options)) + if not button: return + button.text = options[current_option] + changed.emit(current_option) + +func _ready() -> void: + current_option = current_option + +func sub() -> void: + current_option -= 1 + +func add() -> void: + current_option += 1 |