summaryrefslogtreecommitdiffstats
path: root/screens/Schedule/Header.gd
blob: 3cf6e01e42b91782c7f830d452761504fab37ea1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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])