a game about throwing hammers made for the github game off
Diffstat (limited to 'ui/popup.gd')
| -rw-r--r-- | ui/popup.gd | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/ui/popup.gd b/ui/popup.gd new file mode 100644 index 0000000..4fc583f --- /dev/null +++ b/ui/popup.gd @@ -0,0 +1,24 @@ +extends Control +class_name Popuppable + +const RemapButton := preload("res://addons/remap/RemapButton.gd") + +signal close + +@export var focus: Control + +func open() -> void: + show() + if focus is RemapButton: + focus.button.grab_focus() + else: + focus.grab_focus() + +func _unhandled_key_input(event: InputEvent) -> void: + if visible and event is InputEventKey and event.keycode == KEY_ESCAPE: + accept_event() + exit() + +func exit() -> void: + close.emit() + hide() |