cooking options, start refactor process

This commit is contained in:
Tabby 2026-05-31 21:28:25 +10:00
parent c083791b9a
commit 2322ae9ec2
6 changed files with 106 additions and 35 deletions

View file

@ -4,11 +4,13 @@
- [ ] pick time for the clock to end, and how long before that it should start (in duration - ie 2 hours) - [ ] pick time for the clock to end, and how long before that it should start (in duration - ie 2 hours)
- [x] support for varied monitor size - [x] support for varied monitor size
- [x] app / toolbar icons - [x] app / toolbar icons
- [ ] app name - [x] app name
- Sleepyclock - Sleepyclock
- [ ] toolbar menu - [x] toolbar menu
- [ ] customisation/settings - [x] customisation/settings
- [ ] scale on high resolution displays - [ ] scale on high resolution displays
- [ ] remove leftover files from focus and payphone watcher - [ ] remove leftover files from focus and payphone watcher
- [ ] fade/flash when time rouns out - [ ] fade/flash when time rouns out
- [ ] options save and load - [x] options save and load
- [ ] select display style (which side)
- [ ] hide clock outside active hours

View file

@ -3,6 +3,8 @@ extends Control
var taskbar_height : int = 50 var taskbar_height : int = 50
@export var bar: TextureProgressBar @export var bar: TextureProgressBar
@export var label: Label @export var label: Label
@export var options_window: Window
@export var bar_position : Position @export var bar_position : Position
@ -36,7 +38,10 @@ func setup_window():
# Called every frame. 'delta' is the elapsed time since the previous frame. # Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void: func _process(delta: float) -> void:
var days : float = (Time.get_unix_time_from_system() + (60*60*10)) / 86400 var unix : float = Time.get_unix_time_from_system()
var days : float = (Time.get_unix_time_from_system() + (60*60*10)) / 86400 # days since unix
var offset : float = 0.5 # 0 = midday, 12 = midnight var offset : float = 0.5 # 0 = midday, 12 = midnight
# bar should fill from 11:30pm (11.5) -> 1:30am (13.5) # bar should fill from 11:30pm (11.5) -> 1:30am (13.5)
var current_day : float = fmod(days + offset,1) var current_day : float = fmod(days + offset,1)
@ -57,3 +62,10 @@ func _process(delta: float) -> void:
#DisplayServer.window_set_size(Vector2i(screen_size.x, 10)) #DisplayServer.window_set_size(Vector2i(screen_size.x, 10))
#get_window().size = Vector2i(screen_size.x, 10) #get_window().size = Vector2i(screen_size.x, 10)
pass pass
func _on_popup_menu_id_pressed(id: int) -> void:
if id == 0:
get_tree().quit()
if id == 1:
options_window.show()

View file

@ -3,6 +3,7 @@
[ext_resource type="Script" uid="uid://dp4nvppf3b0gj" path="res://clock.gd" id="1_h2yge"] [ext_resource type="Script" uid="uid://dp4nvppf3b0gj" path="res://clock.gd" id="1_h2yge"]
[ext_resource type="Script" uid="uid://njpp5gvmxi7f" path="res://TitleBar.gd" id="1_ig7tw"] [ext_resource type="Script" uid="uid://njpp5gvmxi7f" path="res://TitleBar.gd" id="1_ig7tw"]
[ext_resource type="Texture2D" uid="uid://j8lswk62w1d3" path="res://Logo/logo taskbar.png" id="3_h2yge"] [ext_resource type="Texture2D" uid="uid://j8lswk62w1d3" path="res://Logo/logo taskbar.png" id="3_h2yge"]
[ext_resource type="Script" uid="uid://dg7m1s0i4ud5m" path="res://options_window.gd" id="4_1bvp3"]
[sub_resource type="Gradient" id="Gradient_h2yge"] [sub_resource type="Gradient" id="Gradient_h2yge"]
offsets = PackedFloat32Array(1) offsets = PackedFloat32Array(1)
@ -17,7 +18,7 @@ font_size = 11
[sub_resource type="LabelSettings" id="LabelSettings_1bvp3"] [sub_resource type="LabelSettings" id="LabelSettings_1bvp3"]
font_color = Color(0.63375676, 0.6337568, 0.63375676, 1) font_color = Color(0.63375676, 0.6337568, 0.63375676, 1)
[node name="Control" type="Control" unique_id=577067945 node_paths=PackedStringArray("bar", "label")] [node name="SleepyClock" type="Control" unique_id=577067945 node_paths=PackedStringArray("bar", "label", "options_window")]
modulate = Color(1, 1, 1, 0.42745098) modulate = Color(1, 1, 1, 0.42745098)
top_level = true top_level = true
layout_mode = 3 layout_mode = 3
@ -31,6 +32,7 @@ grow_vertical = 0
script = ExtResource("1_h2yge") script = ExtResource("1_h2yge")
bar = NodePath("VBoxContainer/MainContent/bar") bar = NodePath("VBoxContainer/MainContent/bar")
label = NodePath("VBoxContainer/MainContent/Label") label = NodePath("VBoxContainer/MainContent/Label")
options_window = NodePath("Options Window")
[node name="Bar" type="Window" parent="." unique_id=714499816] [node name="Bar" type="Window" parent="." unique_id=714499816]
transparent_bg = true transparent_bg = true
@ -46,24 +48,15 @@ icon = ExtResource("3_h2yge")
menu = NodePath("PopupMenu") menu = NodePath("PopupMenu")
[node name="PopupMenu" type="PopupMenu" parent="StatusIndicator" unique_id=1255435033] [node name="PopupMenu" type="PopupMenu" parent="StatusIndicator" unique_id=1255435033]
item_count = 6 item_count = 3
item_0/text = "Exit" item_0/text = "Sleepyclock"
item_0/id = 0 item_0/icon = ExtResource("3_h2yge")
item_0/id = 2
item_0/disabled = true
item_1/text = "Options"
item_1/id = 1 item_1/id = 1
item_1/separator = true item_2/text = "Exit"
item_2/text = "Smaller" item_2/id = 0
item_2/checkable = 2
item_2/id = 5
item_3/text = "Small"
item_3/checkable = 2
item_3/checked = true
item_3/id = 2
item_4/text = "Medium"
item_4/checkable = 2
item_4/id = 3
item_5/text = "Large"
item_5/checkable = 2
item_5/id = 4
[node name="Background" type="ColorRect" parent="." unique_id=641703216] [node name="Background" type="ColorRect" parent="." unique_id=641703216]
layout_mode = 1 layout_mode = 1
@ -136,7 +129,7 @@ grow_vertical = 2
text = "12:34 Remaining Until Sleepy time, there is alot of space for text you can work with here meow meow meow meow" text = "12:34 Remaining Until Sleepy time, there is alot of space for text you can work with here meow meow meow meow"
label_settings = SubResource("LabelSettings_h2yge") label_settings = SubResource("LabelSettings_h2yge")
[node name="Options Window" type="Window" parent="." unique_id=1651073981] [node name="Options Window" type="Window" parent="." unique_id=1651073981 node_paths=PackedStringArray("sleep_h", "sleep_m", "duration_h", "duration_m")]
oversampling_override = 1.0 oversampling_override = 1.0
title = "SleepClock Options" title = "SleepClock Options"
initial_position = 1 initial_position = 1
@ -146,6 +139,11 @@ unresizable = true
always_on_top = true always_on_top = true
minimize_disabled = true minimize_disabled = true
maximize_disabled = true maximize_disabled = true
script = ExtResource("4_1bvp3")
sleep_h = NodePath("MarginContainer/VBoxContainer/GridContainer/HBoxContainer/sleepH")
sleep_m = NodePath("MarginContainer/VBoxContainer/GridContainer/HBoxContainer/sleepM")
duration_h = NodePath("MarginContainer/VBoxContainer/GridContainer/HBoxContainer2/durationH")
duration_m = NodePath("MarginContainer/VBoxContainer/GridContainer/HBoxContainer2/durationM")
[node name="MarginContainer" type="MarginContainer" parent="Options Window" unique_id=426909220] [node name="MarginContainer" type="MarginContainer" parent="Options Window" unique_id=426909220]
anchors_preset = 15 anchors_preset = 15
@ -169,19 +167,21 @@ columns = 2
[node name="Label" type="Label" parent="Options Window/MarginContainer/VBoxContainer/GridContainer" unique_id=2012826546] [node name="Label" type="Label" parent="Options Window/MarginContainer/VBoxContainer/GridContainer" unique_id=2012826546]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
text = "Sleep Time (24 hour time):" tooltip_text = "This is the time at which the bar should completely fill up"
mouse_filter = 1
text = "Sleep Time (24 hour time): 🛈"
[node name="HBoxContainer" type="HBoxContainer" parent="Options Window/MarginContainer/VBoxContainer/GridContainer" unique_id=34542284] [node name="HBoxContainer" type="HBoxContainer" parent="Options Window/MarginContainer/VBoxContainer/GridContainer" unique_id=34542284]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
[node name="SpinBox" type="SpinBox" parent="Options Window/MarginContainer/VBoxContainer/GridContainer/HBoxContainer" unique_id=53115223] [node name="sleepH" type="SpinBox" parent="Options Window/MarginContainer/VBoxContainer/GridContainer/HBoxContainer" unique_id=53115223]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
max_value = 23.0 max_value = 23.0
suffix = "h" suffix = "h"
[node name="SpinBox2" type="SpinBox" parent="Options Window/MarginContainer/VBoxContainer/GridContainer/HBoxContainer" unique_id=1582897710] [node name="sleepM" type="SpinBox" parent="Options Window/MarginContainer/VBoxContainer/GridContainer/HBoxContainer" unique_id=1582897710]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
max_value = 59.0 max_value = 59.0
@ -190,19 +190,21 @@ suffix = "m"
[node name="Label3" type="Label" parent="Options Window/MarginContainer/VBoxContainer/GridContainer" unique_id=1956355233] [node name="Label3" type="Label" parent="Options Window/MarginContainer/VBoxContainer/GridContainer" unique_id=1956355233]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
text = "Bar/Clock Duration:" tooltip_text = "How long it should take for the bar to fill"
mouse_filter = 1
text = "Bar/Clock Duration: 🛈"
[node name="HBoxContainer2" type="HBoxContainer" parent="Options Window/MarginContainer/VBoxContainer/GridContainer" unique_id=650035341] [node name="HBoxContainer2" type="HBoxContainer" parent="Options Window/MarginContainer/VBoxContainer/GridContainer" unique_id=650035341]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
[node name="SpinBox" type="SpinBox" parent="Options Window/MarginContainer/VBoxContainer/GridContainer/HBoxContainer2" unique_id=1511471443] [node name="durationH" type="SpinBox" parent="Options Window/MarginContainer/VBoxContainer/GridContainer/HBoxContainer2" unique_id=1511471443]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
max_value = 23.0 max_value = 23.0
suffix = "h" suffix = "h"
[node name="SpinBox2" type="SpinBox" parent="Options Window/MarginContainer/VBoxContainer/GridContainer/HBoxContainer2" unique_id=1155242421] [node name="durationM" type="SpinBox" parent="Options Window/MarginContainer/VBoxContainer/GridContainer/HBoxContainer2" unique_id=1155242421]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
max_value = 59.0 max_value = 59.0
@ -219,16 +221,19 @@ label_settings = SubResource("LabelSettings_1bvp3")
[node name="HBoxContainer" type="HBoxContainer" parent="Options Window/MarginContainer/VBoxContainer" unique_id=2066769118] [node name="HBoxContainer" type="HBoxContainer" parent="Options Window/MarginContainer/VBoxContainer" unique_id=2066769118]
layout_mode = 2 layout_mode = 2
[node name="Button" type="Button" parent="Options Window/MarginContainer/VBoxContainer/HBoxContainer" unique_id=1764524981] [node name="cancelButton" type="Button" parent="Options Window/MarginContainer/VBoxContainer/HBoxContainer" unique_id=1764524981]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
text = "Cancel" text = "Cancel"
[node name="Button2" type="Button" parent="Options Window/MarginContainer/VBoxContainer/HBoxContainer" unique_id=1904551975] [node name="saveButton" type="Button" parent="Options Window/MarginContainer/VBoxContainer/HBoxContainer" unique_id=1904551975]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
text = "Save" text = "Save"
[connection signal="id_pressed" from="StatusIndicator/PopupMenu" to="." method="_on_popup_menu_id_pressed"] [connection signal="id_pressed" from="StatusIndicator/PopupMenu" to="." method="_on_popup_menu_id_pressed"]
[connection signal="id_pressed" from="StatusIndicator/PopupMenu" to="VBoxContainer/TitleBar" method="_on_popup_menu_id_pressed"]
[connection signal="gui_input" from="VBoxContainer/TitleBar" to="VBoxContainer/TitleBar" method="_on_TitleBar_gui_input"] [connection signal="gui_input" from="VBoxContainer/TitleBar" to="VBoxContainer/TitleBar" method="_on_TitleBar_gui_input"]
[connection signal="close_requested" from="Options Window" to="Options Window" method="_on_close_requested"]
[connection signal="visibility_changed" from="Options Window" to="Options Window" method="_on_visibility_changed"]
[connection signal="pressed" from="Options Window/MarginContainer/VBoxContainer/HBoxContainer/cancelButton" to="Options Window" method="_on_cancel_button_pressed"]
[connection signal="pressed" from="Options Window/MarginContainer/VBoxContainer/HBoxContainer/saveButton" to="Options Window" method="_on_save_button_pressed"]

51
options_window.gd Normal file
View file

@ -0,0 +1,51 @@
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.

1
options_window.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://dg7m1s0i4ud5m

View file

@ -1,5 +1,5 @@
extends Resource extends Resource
class_name SleepyclockSave class_name SleepyclockSave
@export var end_time : int = 0 # number of seconds past midnight the clock bar should fill up @export var end_time : float = 0 # number of seconds past midnight the clock bar should fill up
@export var duration : int = 7200 # number of seconds the clock bar should progress for (end_time - duration = "start_time") @export var duration : float = 7200 # number of seconds the clock bar should progress for (end_time - duration = "start_time")