summaryrefslogtreecommitdiffstats
path: root/screens/Schedule/Header.gd
diff options
context:
space:
mode:
Diffstat (limited to 'screens/Schedule/Header.gd')
-rw-r--r--screens/Schedule/Header.gd26
1 files changed, 26 insertions, 0 deletions
diff --git a/screens/Schedule/Header.gd b/screens/Schedule/Header.gd
new file mode 100644
index 0000000..3cf6e01
--- /dev/null
+++ b/screens/Schedule/Header.gd
@@ -0,0 +1,26 @@
+extends Button
+
+var timeslots = []
+var current_timeslot = null
+var last_minute = -1
+
+func populate(data):
+ timeslots = data
+
+func _process(_delta):
+ var time = Time.get_unix_time_from_system()
+ var time_dict = Time.get_time_dict_from_unix_time(time)
+ if time_dict.minute != last_minute:
+ last_minute = time_dict.minute
+ $"%Time".text = DataHelpers.timeofday(time)
+ time = Time.get_unix_time_from_datetime_dict(time_dict)
+ current_timeslot = null
+ for timeslot in timeslots:
+ if time >= timeslot.start_time && time <= timeslot.end_time:
+ current_timeslot = timeslot
+ break
+ $"%Name".text = "Free Time" if current_timeslot == null else current_timeslot.name
+
+func _on_ScheduleHeader_button_up():
+ if current_timeslot != null:
+ $"/root/Main".nav_screen("TimeSlot", TimeSlot, "get_by_id", [current_timeslot.id])