options screen functionality :):):):):)

This commit is contained in:
Haze Weathers 2023-03-08 16:46:23 -05:00
parent 89b4bc045e
commit 1fc44271f1
10 changed files with 271 additions and 36 deletions

View file

@ -1,15 +1,33 @@
extends HBoxContainer
signal selection_changed(selection)
export (ButtonGroup) var group
var _selection = 0
func _ready():
focus_mode = FOCUS_ALL
connect("focus_entered", self, "_focused")
for child in get_children():
if child is BaseButton:
child.focus_neighbour_top = "../%s" % focus_neighbour_top
child.focus_neighbour_bottom = "../%s" % focus_neighbour_bottom
child.connect("focus_entered", child, "set_pressed", [true])
connect("focus_entered", self, "_focused")
child.connect("focus_entered", self, "_button_selected", [], CONNECT_DEFERRED)
func _focused():
_selection = get_selection()
group.get_pressed_button().grab_focus()
func _button_selected():
var new_selection = get_selection()
if _selection != new_selection:
_selection = new_selection
emit_signal("selection_changed", _selection)
func get_selection():
return group.get_buttons().find(group.get_pressed_button())
func select(selection):
group.get_buttons()[selection].pressed = true