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.
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