From b9d5940fac443c34083b437445eaceaea04c192c Mon Sep 17 00:00:00 2001 From: Tabby <41929769+tabby-cat-nya@users.noreply.github.com> Date: Sun, 31 May 2026 23:34:29 +1000 Subject: [PATCH] ok i think i figured out the horrible code --- clock.gd | 52 +++++++++++++++++++++++++++++++++++++++++++--------- main.tscn | 12 ++++++++---- 2 files changed, 51 insertions(+), 13 deletions(-) diff --git a/clock.gd b/clock.gd index f1a3ac6..e092a22 100644 --- a/clock.gd +++ b/clock.gd @@ -39,21 +39,55 @@ func setup_window(): # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta: float) -> void: 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 timezone_minutes = Time.get_time_zone_from_system().bias + var timezone_seconds = timezone_minutes * 60 + var aus_unix : float = unix + (timezone_seconds) + var aus_days : float = (aus_unix / 86400) # days since unix + #print("curr: " + Time.get_datetime_string_from_unix_time(aus_unix)) + + ## need to do different behaviour depending on if target time has passed for the particular day + var next_end : float = 0 + + # compare todays seconds to end time + var todays_seconds = aus_unix - (int(aus_days)*86400) + #print("todays secs:" + str(todays_seconds)) + + #print("left: " + str(int(aus_days+1)*86400)) + #print("righ: " + str(aus_unix + Data.save.end_time) ) + if (todays_seconds > Data.save.end_time): + #print("running if") + #target passed for the current day, use the next day + next_end = (int(aus_days+1)*86400) + (Data.save.end_time) + pass + else: + #print("running else") + # target NOT passed for the current day, use current day + next_end = (int(aus_days)*86400) + (Data.save.end_time) + pass - var offset : float = 0.5 # 0 = midday, 12 = midnight - # bar should fill from 11:30pm (11.5) -> 1:30am (13.5) - var current_day : float = fmod(days + offset,1) - var mini_hour : float = 1.0/24.0 - bar.max_value = mini_hour * 13.5 - bar.min_value = mini_hour * 11.5 - bar.value = current_day + # need to find next timestamp of the clock end, int(days) * end_time + #var next_end : float = (int(aus_days)*86400) + (Data.save.end_time) + #var next_end : float = int(aus_unix)%86400 + Data.save.end_time + #print("next: " + Time.get_datetime_string_from_unix_time(next_end)) + + #print(str(unix) + " --> " + str(next_end)) + var seconds_left : float = next_end - aus_unix + + #print("seconds until end: " + str(seconds_left)) + + ## dont worry about anything below here yet + + + bar.max_value = Data.save.duration + bar.min_value = 0 + bar.value = Data.save.duration - seconds_left + #print("bar value: " + str(bar.value)) #label.text = Time.get_datetime_string_from_system() #Time. #print(current_day) - if (bar.value >= 0.50): + if (seconds_left <= 3600): bar.modulate = Color.RED else: bar.modulate = Color.DODGER_BLUE diff --git a/main.tscn b/main.tscn index 1c32be2..1de927d 100644 --- a/main.tscn +++ b/main.tscn @@ -112,10 +112,9 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 -min_value = 11.5 -max_value = 13.5 +min_value = 100.0 step = 0.0 -value = 11.81 +value = 100.0 nine_patch_stretch = true texture_progress = SubResource("GradientTexture1D_1bvp3") @@ -180,12 +179,14 @@ layout_mode = 2 size_flags_horizontal = 3 max_value = 23.0 suffix = "h" +select_all_on_focus = true [node name="sleepM" type="SpinBox" parent="Options Window/MarginContainer/VBoxContainer/GridContainer/HBoxContainer" unique_id=1582897710] layout_mode = 2 size_flags_horizontal = 3 max_value = 59.0 suffix = "m" +select_all_on_focus = true [node name="Label3" type="Label" parent="Options Window/MarginContainer/VBoxContainer/GridContainer" unique_id=1956355233] layout_mode = 2 @@ -203,19 +204,22 @@ layout_mode = 2 size_flags_horizontal = 3 max_value = 23.0 suffix = "h" +select_all_on_focus = true [node name="durationM" type="SpinBox" parent="Options Window/MarginContainer/VBoxContainer/GridContainer/HBoxContainer2" unique_id=1155242421] layout_mode = 2 size_flags_horizontal = 3 max_value = 59.0 suffix = "m" +select_all_on_focus = true [node name="Label2" type="Label" parent="Options Window/MarginContainer/VBoxContainer/GridContainer" unique_id=201796106] layout_mode = 2 text = "Things that will go here: - bar end time - bar duration -- text to display inside bar" +- text to display inside bar +- where to display bar" label_settings = SubResource("LabelSettings_1bvp3") [node name="HBoxContainer" type="HBoxContainer" parent="Options Window/MarginContainer/VBoxContainer" unique_id=2066769118]