42 lines
785 B
GDScript
42 lines
785 B
GDScript
extends Node
|
|
|
|
signal loaded()
|
|
|
|
var messages: MessageData
|
|
var topics: TopicData
|
|
var miscellaneous: MiscellaneousData
|
|
|
|
|
|
func _ready():
|
|
var autosave_timer = Timer.new()
|
|
autosave_timer.wait_time = 600.0 # Every ten minutes.
|
|
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()
|
|
|
|
|
|
func setup():
|
|
messages = MessageData.new()
|
|
topics = TopicData.new()
|
|
miscellaneous = MiscellaneousData.new()
|
|
yield(get_tree(), "idle_frame")
|
|
_load_data()
|
|
|
|
|
|
func _load_data():
|
|
messages.load_data()
|
|
topics.load_data()
|
|
miscellaneous.load_data()
|
|
emit_signal("loaded")
|
|
|
|
|
|
func _save_data():
|
|
messages.save_data()
|
|
topics.save_data()
|
|
miscellaneous.save_data()
|