add state machine draft
This commit is contained in:
parent
a7c7fb0b6f
commit
810a3aa9b5
|
@ -1,11 +1,16 @@
|
||||||
extends Node
|
extends Node
|
||||||
# https://docs.godotengine.org/en/stable/tutorials/scripting/singletons_autoload.html
|
# 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"
|
const config_path = "user://logue.cfg"
|
||||||
|
|
||||||
var config = ConfigFile.new()
|
var config = ConfigFile.new()
|
||||||
var db : SQLite = SQLite.new()
|
var db = SQLite.new()
|
||||||
var current_scene = null
|
var current_scene = null
|
||||||
|
var current_state = State.UNLOADED
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
var root = get_tree().root
|
var root = get_tree().root
|
||||||
|
@ -17,6 +22,15 @@ func _ready():
|
||||||
if err == OK:
|
if err == OK:
|
||||||
var db_path = config.get_value("general", "db_path")
|
var db_path = config.get_value("general", "db_path")
|
||||||
load_db(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):
|
func load_db(path: String):
|
||||||
db.path = path
|
db.path = path
|
||||||
|
|
Loading…
Reference in a new issue