diff options
| author | dam <dam@gudinoff> | 2022-02-09 00:21:59 +0000 |
|---|---|---|
| committer | dam <dam@gudinoff> | 2022-02-09 00:21:59 +0000 |
| commit | cc3f6e5ea29bfe006576a35b5fa24d029a07cf7c (patch) | |
| tree | 05a9671dde552fbebadd326df0fbc9d2b58b1b60 /main.gd | |
| parent | 9478682f845d5518ca1c6a4552a8b710d1a2b238 (diff) | |
| download | surgery-log-cc3f6e5ea29bfe006576a35b5fa24d029a07cf7c.tar.zst surgery-log-cc3f6e5ea29bfe006576a35b5fa24d029a07cf7c.zip | |
Add confirmation dialog to entry destructive actions.
Diffstat (limited to 'main.gd')
| -rw-r--r-- | main.gd | 32 |
1 files changed, 21 insertions, 11 deletions
@@ -1,11 +1,13 @@ extends Control -var timeout: float +var power_throttle_timeout: float -onready var controls_sensible_to_keyboard: Array = [ +onready var file_picker := get_node("/root/main/file_picker") as FileDialog +onready var confirm_action := get_node("/root/main/confirm_action") as ConfirmationDialog +onready var controls_sensible_to_keyboard := [ self, - get_node("/root/main/file_picker"), - get_node("/root/main/confirm_action"), + file_picker, + confirm_action, ] @@ -14,27 +16,35 @@ func _init(): PhysicsServer.set_active(false) +func _ready(): + confirm_action.get_cancel().connect("pressed", self, "dialog_cancelled", ["confirmed"]) + file_picker.get_cancel().connect("pressed", self, "dialog_cancelled", ["file_selected"]) + + func _process(delta: float): var keyboard_height: int = OS.get_virtual_keyboard_height() for it in controls_sensible_to_keyboard: it.margin_bottom = -keyboard_height - # @DAM Debug information. -# $debug.text = "%s" % Engine.get_frames_per_second() -# $debug.text = "%s" % timeout - if timeout > 0.0: - timeout -= delta + if power_throttle_timeout > 0.0: + power_throttle_timeout -= delta else: Engine.target_fps = 10 func _input(event: InputEvent): Engine.target_fps = 0 - timeout = 3.5 + power_throttle_timeout = 3.5 func _unhandled_input(event: InputEvent): Engine.target_fps = 0 - timeout = 3.5 + power_throttle_timeout = 3.5 + + +func dialog_cancelled(confirmation_signal_name: String): + var confirmation_handlers = confirm_action.get_signal_connection_list(confirmation_signal_name) + for it in confirmation_handlers: + confirm_action.disconnect(it.signal, it.target, it.method) |
