From 733a8fd6c06047b38976e5d571ef3ec8a9523e75 Mon Sep 17 00:00:00 2001 From: Tabby <41929769+tabby-cat-nya@users.noreply.github.com> Date: Mon, 1 Jun 2026 12:21:11 +1000 Subject: [PATCH] lots of progress --- Data.gd | 16 +++++- Logo/tiny.png | Bin 0 -> 472 bytes Logo/tiny.png.import | 40 +++++++++++++ clock.gd | 50 ++++++++-------- main.tscn | 134 +++++++++++++++++++++++++++++++++++++------ options_window.gd | 48 +++++++++++++--- sleepyclockSave.gd | 3 +- 7 files changed, 240 insertions(+), 51 deletions(-) create mode 100644 Logo/tiny.png create mode 100644 Logo/tiny.png.import diff --git a/Data.gd b/Data.gd index 21c88f8..a5c004b 100644 --- a/Data.gd +++ b/Data.gd @@ -3,6 +3,13 @@ extends Node @export var save : SleepyclockSave @export var path : String = "user://sleepyclockSave.tres" +enum Position { + Bottom, + Right, + Top, + Left, +} + # Called when the node enters the scene tree for the first time. func _ready() -> void: print("looking for save...") @@ -24,6 +31,13 @@ func _process(delta: float) -> void: # returns true if new data created and saved func new_data() -> bool: save = SleepyclockSave.new() + + var screen_size : Vector2i = DisplayServer.screen_get_size() # get current screen size + if screen_size.x > 2560 or screen_size.y > 1440: + save.size = 20 + if OS.has_feature("macos"): + save.position = Data.Position.Right + var error = ResourceSaver.save(save,path) if error != OK: print(error) @@ -35,7 +49,7 @@ func load_data() -> bool: if not FileAccess.file_exists(path): return false else: - save = ResourceLoader.load(path) + save = ResourceLoader.load(path,"",ResourceLoader.CACHE_MODE_IGNORE) return true # returns true if data successfully saved diff --git a/Logo/tiny.png b/Logo/tiny.png new file mode 100644 index 0000000000000000000000000000000000000000..d4449ed8200f3fabc305832888af2c53742c9b9e GIT binary patch literal 472 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc3?z4jzqJQajKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$1AIbUf%LWd|3LClbGj^$VlD~t3;zF~;rc0Fpjrmb0*}aI1_r*vAk26? ze?yz&ooa@Ed~xC zhm}E!k(GfF$npYWX($`yWDQ1Uus9QtZOF*PAPA(RfHjH>b(|~LcU;>)N1XdYjX#r$Gbr~8MfMnTBuM}_U zFR}(Q6FglULo|X*`#AX+6gik1|Jzr2uY6JE8(pvIi9|A!SQhMJ)yQgA19P{9DC}$Wv}XkZ@;o+6=$y7AiF}P^v_9G Zx0)lbn0Pd+@=t;6^>p=fS?83{1OW4+a5Vq` literal 0 HcmV?d00001 diff --git a/Logo/tiny.png.import b/Logo/tiny.png.import new file mode 100644 index 0000000..59ec645 --- /dev/null +++ b/Logo/tiny.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dbrin3qlfjdas" +path="res://.godot/imported/tiny.png-7075772b29e1a77872ae6087fda4f47f.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Logo/tiny.png" +dest_files=["res://.godot/imported/tiny.png-7075772b29e1a77872ae6087fda4f47f.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/clock.gd b/clock.gd index 7f8e19e..55698ad 100644 --- a/clock.gd +++ b/clock.gd @@ -1,20 +1,20 @@ extends Control var taskbar_height : int = 50 -@export var bar_size : int = 10 +#@export var bar_size : int = 10 @export var bar: TextureProgressBar @export var label: Label @export var options_window: Window - -@export var bar_position : Position - -enum Position { - Bottom, - Right, - Top, - Left, -} +# +#@export var bar_position : Position +# +#enum Position { + #Bottom, + #Right, + #Top, + #Left, +#} # Called when the node enters the scene tree for the first time. func _ready() -> void: @@ -26,26 +26,26 @@ func setup_window(): var screen_size : Vector2i = DisplayServer.screen_get_size() # get current screen size var screen_pos : Vector2i = DisplayServer.screen_get_position(DisplayServer.SCREEN_OF_MAIN_WINDOW) # get the posiiton of the window on the virtual display get_window().min_size = Vector2i(1,1) # weird godot bug where the min screen size is 64x64 unless set in code - if bar_position == Position.Bottom: - if screen_size.x > 2560: - bar_size = 20 + if Data.save.position == Data.Position.Bottom: - get_window().size = Vector2i(screen_size.x, bar_size) # set window size to be 10 high and screen width wide - size = Vector2i(screen_size.x, bar_size) - DisplayServer.window_set_position(screen_pos + Vector2i(0,screen_size.y-bar_size-taskbar_height)) # set position of window to be just above the taskbar + + get_window().size = Vector2i(screen_size.x, Data.save.size) # set window size to be 10 high and screen width wide + size = Vector2i(screen_size.x, Data.save.size) + DisplayServer.window_set_position(screen_pos + Vector2i(0,screen_size.y-Data.save.size-taskbar_height)) # set position of window to be just above the taskbar position.y = 0 # set position of bar to be where it should be (moves when we change the window size) - label.label_settings.font_size = (bar_size/10)*10 - if bar_position == Position.Right: - if screen_size.y > 1440: - bar_size = 20 + position.x = 0 + rotation_degrees = 0 + label.label_settings.font_size = (float(Data.save.size)/10)*10 + if Data.save.position == Data.Position.Right: - get_window().size = Vector2i(bar_size, screen_size.y) # set window size to be 10 high and screen width wide + + get_window().size = Vector2i(Data.save.size, screen_size.y) # set window size to be 10 high and screen width wide size.x = screen_size.y - taskbar_height - size.y = bar_size - label.label_settings.font_size = (bar_size/10)*10 - DisplayServer.window_set_position(screen_pos + Vector2i(screen_size.x-bar_size,0)) # set position of window to be just above the taskbar + size.y = Data.save.size + label.label_settings.font_size = (float(Data.save.size)/10)*10 + DisplayServer.window_set_position(screen_pos + Vector2i(screen_size.x-Data.save.size,0)) # set position of window to be just above the taskbar position.y = 0 # set position of bar to be where it should be (moves when we change the window size) - position.x = bar_size + position.x = Data.save.size rotation_degrees = 90 # Called every frame. 'delta' is the elapsed time since the previous frame. diff --git a/main.tscn b/main.tscn index 7b36750..ebafe2e 100644 --- a/main.tscn +++ b/main.tscn @@ -33,7 +33,6 @@ script = ExtResource("1_h2yge") bar = NodePath("VBoxContainer/MainContent/bar") label = NodePath("VBoxContainer/MainContent/Label") options_window = NodePath("Options Window") -bar_position = 1 [node name="Bar" type="Window" parent="." unique_id=714499816] transparent_bg = true @@ -128,12 +127,11 @@ 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" label_settings = SubResource("LabelSettings_h2yge") -[node name="Options Window" type="Window" parent="." unique_id=1651073981 node_paths=PackedStringArray("sleep_h", "sleep_m", "duration_h", "duration_m")] +[node name="Options Window" type="Window" parent="." unique_id=1651073981 node_paths=PackedStringArray("sleep_h", "sleep_m", "duration_h", "duration_m", "size_label", "size_slider")] oversampling_override = 1.0 -title = "SleepClock Options" +title = "SleepyClock Options" initial_position = 1 -size = Vector2i(450, 300) -visible = false +size = Vector2i(450, 600) unresizable = true always_on_top = true minimize_disabled = true @@ -143,6 +141,8 @@ sleep_h = NodePath("MarginContainer/VBoxContainer/GridContainer/HBoxContainer/sl sleep_m = NodePath("MarginContainer/VBoxContainer/GridContainer/HBoxContainer/sleepM") duration_h = NodePath("MarginContainer/VBoxContainer/GridContainer/HBoxContainer2/durationH") duration_m = NodePath("MarginContainer/VBoxContainer/GridContainer/HBoxContainer2/durationM") +size_label = NodePath("MarginContainer/VBoxContainer/GridContainer/HBoxContainer3/sizeLabel") +size_slider = NodePath("MarginContainer/VBoxContainer/GridContainer/HBoxContainer3/sizeSlider") [node name="MarginContainer" type="MarginContainer" parent="Options Window" unique_id=426909220] anchors_preset = 15 @@ -168,7 +168,7 @@ layout_mode = 2 size_flags_horizontal = 3 tooltip_text = "This is the time at which the bar should completely fill up" mouse_filter = 1 -text = "Sleep Time (24 hour time): 🛈" +text = "Sleep Time (24 hour time) 🛈" [node name="HBoxContainer" type="HBoxContainer" parent="Options Window/MarginContainer/VBoxContainer/GridContainer" unique_id=34542284] layout_mode = 2 @@ -193,7 +193,7 @@ layout_mode = 2 size_flags_horizontal = 3 tooltip_text = "How long it should take for the bar to fill" mouse_filter = 1 -text = "Bar/Clock Duration: 🛈" +text = "Bar/Clock Duration 🛈" [node name="HBoxContainer2" type="HBoxContainer" parent="Options Window/MarginContainer/VBoxContainer/GridContainer" unique_id=650035341] layout_mode = 2 @@ -215,11 +215,12 @@ select_all_on_focus = true [node name="Label4" type="Label" parent="Options Window/MarginContainer/VBoxContainer/GridContainer" unique_id=1856476808] layout_mode = 2 -text = "Bar Position" +tooltip_text = "Which edge of the screen should the bar be placed on" +mouse_filter = 1 +text = "Bar Position 🛈" -[node name="OptionButton" type="OptionButton" parent="Options Window/MarginContainer/VBoxContainer/GridContainer" unique_id=1955200779] +[node name="positionDropdown" type="OptionButton" parent="Options Window/MarginContainer/VBoxContainer/GridContainer" unique_id=1955200779] layout_mode = 2 -disabled = true selected = 0 item_count = 2 popup/item_0/text = "Bottom" @@ -229,31 +230,121 @@ popup/item_1/id = 1 [node name="Label2" type="Label" parent="Options Window/MarginContainer/VBoxContainer/GridContainer" unique_id=1597493397] layout_mode = 2 -text = "Bar Size" +tooltip_text = "How much space should the bar take up" +mouse_filter = 1 +text = "Bar Size 🛈" [node name="HBoxContainer3" type="HBoxContainer" parent="Options Window/MarginContainer/VBoxContainer/GridContainer" unique_id=1274134494] layout_mode = 2 -[node name="Label" type="Label" parent="Options Window/MarginContainer/VBoxContainer/GridContainer/HBoxContainer3" unique_id=531473775] +[node name="sizeLabel" type="Label" parent="Options Window/MarginContainer/VBoxContainer/GridContainer/HBoxContainer3" unique_id=531473775] layout_mode = 2 text = "10px" -[node name="HSlider" type="HSlider" parent="Options Window/MarginContainer/VBoxContainer/GridContainer/HBoxContainer3" unique_id=271540690] +[node name="sizeSlider" type="HSlider" parent="Options Window/MarginContainer/VBoxContainer/GridContainer/HBoxContainer3" unique_id=271540690] layout_mode = 2 size_flags_horizontal = 3 size_flags_vertical = 4 min_value = 10.0 max_value = 50.0 -step = 10.0 value = 10.0 -editable = false tick_count = 5 ticks_on_borders = true +[node name="Label6" type="Label" parent="Options Window/MarginContainer/VBoxContainer/GridContainer" unique_id=1332307585] +layout_mode = 2 +tooltip_text = "Color that the bar should be under normal conditions" +mouse_filter = 1 +text = "Bar Color 🛈" + +[node name="barColor" type="ColorPickerButton" parent="Options Window/MarginContainer/VBoxContainer/GridContainer" unique_id=114688172] +layout_mode = 2 + +[node name="Label7" type="Label" parent="Options Window/MarginContainer/VBoxContainer/GridContainer" unique_id=1857238089] +layout_mode = 2 +tooltip_text = "Color that the background of the bar should be" +mouse_filter = 1 +text = "Background Color 🛈" + +[node name="backgroundColor" type="ColorPickerButton" parent="Options Window/MarginContainer/VBoxContainer/GridContainer" unique_id=468934955] +layout_mode = 2 + +[node name="Label5" type="Label" parent="Options Window/MarginContainer/VBoxContainer/GridContainer" unique_id=665826413] +layout_mode = 2 +tooltip_text = "Make the bar change color when the time left is below a certain threshold" +mouse_filter = 1 +text = "Warning 🛈" + +[node name="HBoxContainer4" type="HBoxContainer" parent="Options Window/MarginContainer/VBoxContainer/GridContainer" unique_id=936118584] +layout_mode = 2 + +[node name="warningColor" type="ColorPickerButton" parent="Options Window/MarginContainer/VBoxContainer/GridContainer/HBoxContainer4" unique_id=925432958] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="warningH" type="SpinBox" parent="Options Window/MarginContainer/VBoxContainer/GridContainer/HBoxContainer4" unique_id=232298746] +layout_mode = 2 +size_flags_horizontal = 3 +max_value = 23.0 +suffix = "h" +select_all_on_focus = true + +[node name="warningM" type="SpinBox" parent="Options Window/MarginContainer/VBoxContainer/GridContainer/HBoxContainer4" unique_id=604816514] +layout_mode = 2 +size_flags_horizontal = 3 +max_value = 59.0 +suffix = "m" +select_all_on_focus = true + +[node name="Label10" type="Label" parent="Options Window/MarginContainer/VBoxContainer/GridContainer" unique_id=207682712] +layout_mode = 2 +tooltip_text = "Play a flashing effect when time expires" +mouse_filter = 1 +text = "flash bar when time ends 🛈" + +[node name="flashCheck" type="CheckButton" parent="Options Window/MarginContainer/VBoxContainer/GridContainer" unique_id=1168112585] +layout_mode = 2 +size_flags_horizontal = 4 + +[node name="Label8" type="Label" parent="Options Window/MarginContainer/VBoxContainer/GridContainer" unique_id=280072151] +layout_mode = 2 +tooltip_text = "How long should the bar be visible before the time starts" +mouse_filter = 1 +text = "Display before time starts 🛈" + +[node name="HBoxContainer5" type="HBoxContainer" parent="Options Window/MarginContainer/VBoxContainer/GridContainer" unique_id=2104802150] +layout_mode = 2 + +[node name="beforeM" type="SpinBox" parent="Options Window/MarginContainer/VBoxContainer/GridContainer/HBoxContainer5" unique_id=157077084] +layout_mode = 2 +size_flags_horizontal = 3 +max_value = 59.0 +editable = false +suffix = "m" +select_all_on_focus = true + +[node name="Label9" type="Label" parent="Options Window/MarginContainer/VBoxContainer/GridContainer" unique_id=703302168] +layout_mode = 2 +tooltip_text = "How long should the bar be visible for after the time ends" +mouse_filter = 1 +text = "Display after time ends 🛈" + +[node name="HBoxContainer6" type="HBoxContainer" parent="Options Window/MarginContainer/VBoxContainer/GridContainer" unique_id=1503325100] +layout_mode = 2 + +[node name="afterM" type="SpinBox" parent="Options Window/MarginContainer/VBoxContainer/GridContainer/HBoxContainer6" unique_id=1517063919] +layout_mode = 2 +size_flags_horizontal = 3 +max_value = 59.0 +editable = false +suffix = "m" +select_all_on_focus = true + [node name="Label2" type="Label" parent="Options Window/MarginContainer/VBoxContainer" unique_id=201796106] layout_mode = 2 text = "todo: -- position and size +- red threshold +- display before/after time - text to display inside bar" label_settings = SubResource("LabelSettings_1bvp3") @@ -273,6 +364,17 @@ text = "Save" [connection signal="id_pressed" from="StatusIndicator/PopupMenu" to="." method="_on_popup_menu_id_pressed"] [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="options_changed" from="Options Window" to="." method="setup_window"] [connection signal="visibility_changed" from="Options Window" to="Options Window" method="_on_visibility_changed"] +[connection signal="value_changed" from="Options Window/MarginContainer/VBoxContainer/GridContainer/HBoxContainer/sleepH" to="Options Window" method="_on_sleep_value_changed"] +[connection signal="value_changed" from="Options Window/MarginContainer/VBoxContainer/GridContainer/HBoxContainer/sleepM" to="Options Window" method="_on_sleep_value_changed"] +[connection signal="value_changed" from="Options Window/MarginContainer/VBoxContainer/GridContainer/HBoxContainer2/durationH" to="Options Window" method="_on_duration_value_changed"] +[connection signal="value_changed" from="Options Window/MarginContainer/VBoxContainer/GridContainer/HBoxContainer2/durationM" to="Options Window" method="_on_duration_value_changed"] +[connection signal="item_selected" from="Options Window/MarginContainer/VBoxContainer/GridContainer/positionDropdown" to="Options Window" method="_on_position_dropdown_item_selected"] +[connection signal="value_changed" from="Options Window/MarginContainer/VBoxContainer/GridContainer/HBoxContainer3/sizeSlider" to="Options Window" method="_on_size_slider_value_changed"] +[connection signal="value_changed" from="Options Window/MarginContainer/VBoxContainer/GridContainer/HBoxContainer4/warningH" to="Options Window" method="_on_duration_value_changed"] +[connection signal="value_changed" from="Options Window/MarginContainer/VBoxContainer/GridContainer/HBoxContainer4/warningM" to="Options Window" method="_on_duration_value_changed"] +[connection signal="value_changed" from="Options Window/MarginContainer/VBoxContainer/GridContainer/HBoxContainer5/beforeM" to="Options Window" method="_on_duration_value_changed"] +[connection signal="value_changed" from="Options Window/MarginContainer/VBoxContainer/GridContainer/HBoxContainer6/afterM" to="Options Window" method="_on_duration_value_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"] diff --git a/options_window.gd b/options_window.gd index c5704be..7613e84 100644 --- a/options_window.gd +++ b/options_window.gd @@ -1,9 +1,13 @@ extends Window +signal options_changed + @export var sleep_h: SpinBox @export var sleep_m: SpinBox @export var duration_h: SpinBox @export var duration_m: SpinBox +@export var size_label: Label +@export var size_slider: HSlider # Called when the node enters the scene tree for the first time. func _ready() -> void: @@ -13,6 +17,8 @@ func _ready() -> void: # 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? + if visible: + size_label.text = str(Data.save.size)+"px" pass @@ -24,18 +30,14 @@ func _on_close_requested() -> void: func _on_cancel_button_pressed() -> void: + Data.load_data() 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. @@ -48,4 +50,34 @@ func _on_visibility_changed() -> void: 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) + size_slider.value = Data.save.size pass # Replace with function body. + + +func _on_duration_value_changed(value: float) -> void: + var duration_seconds : float = 0 + duration_seconds += duration_h.value * 60 * 60 + duration_seconds += duration_m.value * 60 + Data.save.duration = duration_seconds + pass # Replace with function body. + + +func _on_sleep_value_changed(value: float) -> void: + var end_seconds : float = 0 + end_seconds += sleep_h.value * 60 * 60 + end_seconds += sleep_m.value * 60 + Data.save.end_time = end_seconds + pass # Replace with function body. + + +func _on_size_slider_value_changed(value: float) -> void: + Data.save.size = int(value) + options_changed.emit() + + +func _on_position_dropdown_item_selected(index: int) -> void: + if index == 0: + Data.save.position = Data.Position.Bottom + elif index == 1: + Data.save.position = Data.Position.Right + options_changed.emit() diff --git a/sleepyclockSave.gd b/sleepyclockSave.gd index f4d44b7..f4b0f81 100644 --- a/sleepyclockSave.gd +++ b/sleepyclockSave.gd @@ -4,4 +4,5 @@ class_name SleepyclockSave @export var end_time : float = 0 # number of seconds past midnight the clock bar should fill up @export var duration : float = 7200 # number of seconds the clock bar should progress for (end_time - duration = "start_time") #@export var position : int = 0 -#@export var size : int = 10 +@export var size : int = 10 +@export var position : Data.Position = Data.Position.Bottom