2022-05-14 20:51:48 +02:00
extends Node
2022-06-04 13:33:00 +02:00
signal loaded ( )
2022-05-14 20:51:48 +02:00
var messages : MessageData
var topics : TopicData
2022-06-05 14:22:08 +02:00
var miscellaneous : MiscellaneousData
2022-05-14 20:51:48 +02:00
func _ready ( ) :
var autosave_timer = Timer . new ( )
2022-05-24 21:31:30 +02:00
autosave_timer . wait_time = 600.0 # Every ten minutes.
2022-05-14 20:51:48 +02:00
autosave_timer . autostart = true
autosave_timer . connect ( " timeout " , self , " _save_data " )
add_child ( autosave_timer )
func _notification ( what ) :
if what == NOTIFICATION_WM_QUIT_REQUEST :
_save_data ( )
2022-06-04 13:33:00 +02:00
func setup ( ) :
messages = MessageData . new ( )
topics = TopicData . new ( )
2022-06-05 14:22:08 +02:00
miscellaneous = MiscellaneousData . new ( )
2022-06-04 13:33:00 +02:00
yield ( get_tree ( ) , " idle_frame " )
_load_data ( )
2022-05-14 20:51:48 +02:00
func _load_data ( ) :
messages . load_data ( )
topics . load_data ( )
2022-06-05 14:22:08 +02:00
miscellaneous . load_data ( )
2022-06-04 13:33:00 +02:00
emit_signal ( " loaded " )
2022-05-14 20:51:48 +02:00
func _save_data ( ) :
messages . save_data ( )
topics . save_data ( )
2022-06-05 14:22:08 +02:00
miscellaneous . save_data ( )