ok i think i figured out the horrible code

This commit is contained in:
Tabby 2026-05-31 23:34:29 +10:00
parent 2322ae9ec2
commit b9d5940fac
2 changed files with 51 additions and 13 deletions

View file

@ -39,21 +39,55 @@ 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 unix : float = Time.get_unix_time_from_system() 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 # need to find next timestamp of the clock end, int(days) * end_time
# bar should fill from 11:30pm (11.5) -> 1:30am (13.5) #var next_end : float = (int(aus_days)*86400) + (Data.save.end_time)
var current_day : float = fmod(days + offset,1) #var next_end : float = int(aus_unix)%86400 + Data.save.end_time
var mini_hour : float = 1.0/24.0 #print("next: " + Time.get_datetime_string_from_unix_time(next_end))
bar.max_value = mini_hour * 13.5
bar.min_value = mini_hour * 11.5 #print(str(unix) + " --> " + str(next_end))
bar.value = current_day 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() #label.text = Time.get_datetime_string_from_system()
#Time. #Time.
#print(current_day) #print(current_day)
if (bar.value >= 0.50): if (seconds_left <= 3600):
bar.modulate = Color.RED bar.modulate = Color.RED
else: else:
bar.modulate = Color.DODGER_BLUE bar.modulate = Color.DODGER_BLUE

View file

@ -112,10 +112,9 @@ anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
min_value = 11.5 min_value = 100.0
max_value = 13.5
step = 0.0 step = 0.0
value = 11.81 value = 100.0
nine_patch_stretch = true nine_patch_stretch = true
texture_progress = SubResource("GradientTexture1D_1bvp3") texture_progress = SubResource("GradientTexture1D_1bvp3")
@ -180,12 +179,14 @@ layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
max_value = 23.0 max_value = 23.0
suffix = "h" suffix = "h"
select_all_on_focus = true
[node name="sleepM" 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
suffix = "m" suffix = "m"
select_all_on_focus = true
[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
@ -203,19 +204,22 @@ layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
max_value = 23.0 max_value = 23.0
suffix = "h" suffix = "h"
select_all_on_focus = true
[node name="durationM" 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
suffix = "m" suffix = "m"
select_all_on_focus = true
[node name="Label2" type="Label" parent="Options Window/MarginContainer/VBoxContainer/GridContainer" unique_id=201796106] [node name="Label2" type="Label" parent="Options Window/MarginContainer/VBoxContainer/GridContainer" unique_id=201796106]
layout_mode = 2 layout_mode = 2
text = "Things that will go here: text = "Things that will go here:
- bar end time - bar end time
- bar duration - bar duration
- text to display inside bar" - text to display inside bar
- where to display bar"
label_settings = SubResource("LabelSettings_1bvp3") 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]