diary/system/data/data_singleton.gd
mono 7d285bd607 - reworked Chat Panel system
- added user switching
- added Topic Panel functionality (features are missing)
- some basic refactoring
2022-05-14 20:51:48 +02:00

39 lines
654 B
GDScript

extends Node
var messages: MessageData
var topics: TopicData
func _ready():
messages = MessageData.new()
topics = TopicData.new()
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)
yield(get_tree(), "idle_frame")
_load_data()
func _notification(what):
if what == NOTIFICATION_WM_QUIT_REQUEST:
_save_data()
func _exit_tree():
messages.free()
topics.free()
func _load_data():
messages.load_data()
topics.load_data()
func _save_data():
messages.save_data()
topics.save_data()