diff --git a/godot/global.gd b/godot/global.gd index 35e56e4..4c1e83b 100644 --- a/godot/global.gd +++ b/godot/global.gd @@ -1,11 +1,16 @@ extends Node # https://docs.godotengine.org/en/stable/tutorials/scripting/singletons_autoload.html +signal state_changed(previous, new) + +enum State {UNLOADED, LOADED} + const config_path = "user://logue.cfg" var config = ConfigFile.new() -var db : SQLite = SQLite.new() +var db = SQLite.new() var current_scene = null +var current_state = State.UNLOADED func _ready(): var root = get_tree().root @@ -17,6 +22,15 @@ func _ready(): if err == OK: var db_path = config.get_value("general", "db_path") load_db(db_path) + + +func switch_state(new: State): + var old = current_state + if old == new: + return + + current_state = new + #signal state_changed(old, new) func load_db(path: String): db.path = path