gpml/script/day.gd

49 lines
869 B
GDScript3
Raw Normal View History

2024-05-25 18:50:50 +02:00
class_name Day
extends Button
signal day_toggled(date)
signal fill_days(date)
var date = {}
func _ready():
2024-05-25 21:14:03 +02:00
set_toggle_mode(true)
2024-05-25 18:50:50 +02:00
toggled.connect(self._on_day_toggled)
func _gui_input(event):
if event.is_action_pressed("shift_click"):
fill_days.emit(self)
accept_event()
func _on_day_toggled(_toggled_on):
day_toggled.emit(date)
func set_date(year, month, day):
date = {"year": year, "month": month, "day": day}
func is_before(other_day):
var day_unix_time = Time.get_unix_time_from_datetime_dict(date)
var other_day_unix_time = Time.get_unix_time_from_datetime_dict(other_day.date)
2024-05-25 21:14:03 +02:00
2024-05-25 18:50:50 +02:00
if day_unix_time < other_day_unix_time:
return true
return false
2024-05-25 21:14:03 +02:00
2024-05-28 02:58:12 +02:00
func save():
return {
"year": date.year,
"month": date.month,
"day": date.day,
"is_pressed": is_pressed()
}
2024-05-25 18:50:50 +02:00
func dump():
print("%s - %s - %s" % [date.year, date.month, date.day])