SleepyClock/options_window.gd
2026-05-31 21:28:25 +10:00

51 lines
1.3 KiB
GDScript

extends Window
@export var sleep_h: SpinBox
@export var sleep_m: SpinBox
@export var duration_h: SpinBox
@export var duration_m: SpinBox
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
#validate inputs?, disable save button if somehow invalid?
pass
func _on_close_requested() -> void:
hide()
pass # Replace with function body.
func _on_cancel_button_pressed() -> void:
hide()
func _on_save_button_pressed() -> void:
var end_seconds : float = 0
end_seconds += sleep_h.value * 60 * 60
end_seconds += sleep_m.value * 60
var duration_seconds : float = 0
duration_seconds += duration_h.value * 60 * 60
duration_seconds += duration_m.value * 60
Data.save.duration = duration_seconds
Data.save.end_time = end_seconds
if Data.save_data():
hide()
pass # Replace with function body.
func _on_visibility_changed() -> void:
#populate form
#print(Data.save.end_time)
sleep_h.value = int(Data.save.end_time/(60*60))
sleep_m.value = int((Data.save.end_time-sleep_h.value*60*60)/60)
duration_h.value = int(Data.save.duration/(60*60))
duration_m.value = int((Data.save.duration-duration_h.value*60*60)/60)
pass # Replace with function body.