40 lines
751 B
GDScript3
40 lines
751 B
GDScript3
|
class_name Day
|
||
|
extends Button
|
||
|
|
||
|
|
||
|
signal day_toggled(date)
|
||
|
signal fill_days(date)
|
||
|
|
||
|
var date = {}
|
||
|
|
||
|
|
||
|
func _ready():
|
||
|
set_toggle_mode(true);
|
||
|
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)
|
||
|
|
||
|
if day_unix_time < other_day_unix_time:
|
||
|
return true
|
||
|
return false
|
||
|
|
||
|
func dump():
|
||
|
print("%s - %s - %s" % [date.year, date.month, date.day])
|