Added autoloader and welcome() function
This commit is contained in:
parent
c988261688
commit
9cba437ee2
3 changed files with 36 additions and 0 deletions
25
autoload.gd
Normal file
25
autoload.gd
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
# autoload.gd
|
||||||
|
# CORE Autoloader
|
||||||
|
#
|
||||||
|
# This file is part of StarOpenSource CORE (SOSCORE)
|
||||||
|
# Made by the StarOpenSource Project and Contributers
|
||||||
|
# Licensed under GNU GPLv3
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
func singleton(singleton_name:String,singleton_path:String) -> void:
|
||||||
|
var node = Control.new()
|
||||||
|
node.name = singleton_name
|
||||||
|
node.set_script(ResourceLoader.load(singleton_path))
|
||||||
|
get_tree().root.add_child(node)
|
||||||
|
|
||||||
|
func preset(plugin_id:String) -> bool:
|
||||||
|
var node = Control.new()
|
||||||
|
match(plugin_id):
|
||||||
|
"dialogmgr":
|
||||||
|
node.name = "DialogueManager"
|
||||||
|
node.set_script(ResourceLoader.load("res://addons/dialogue_manager/dialogue_manager.gd"))
|
||||||
|
_:
|
||||||
|
Logger.error("autoload","Failed adding preset \"" + plugin_id + "\": Invalid preset.")
|
||||||
|
return false
|
||||||
|
get_tree().root.add_child(node)
|
||||||
|
return true
|
8
core.gd
8
core.gd
|
@ -6,10 +6,12 @@
|
||||||
# Licensed under GNU GPLv3
|
# Licensed under GNU GPLv3
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
|
const version = "git-develop"
|
||||||
var locked = false
|
var locked = false
|
||||||
var config = null
|
var config = null
|
||||||
var wmgr = null
|
var wmgr = null
|
||||||
var smgr = null
|
var smgr = null
|
||||||
|
var autoload = null
|
||||||
|
|
||||||
func attach(type:String,component:Script) -> void:
|
func attach(type:String,component:Script) -> void:
|
||||||
if locked:
|
if locked:
|
||||||
|
@ -28,6 +30,9 @@ func attach(type:String,component:Script) -> void:
|
||||||
"smgr":
|
"smgr":
|
||||||
add_child(comp)
|
add_child(comp)
|
||||||
smgr = comp
|
smgr = comp
|
||||||
|
"autoload":
|
||||||
|
add_child(comp)
|
||||||
|
autoload = comp
|
||||||
_:
|
_:
|
||||||
Logger.error("core","Failed attaching " + type + " to CORE: Invalid component")
|
Logger.error("core","Failed attaching " + type + " to CORE: Invalid component")
|
||||||
comp.free()
|
comp.free()
|
||||||
|
@ -37,3 +42,6 @@ func attach(type:String,component:Script) -> void:
|
||||||
func lock() -> void:
|
func lock() -> void:
|
||||||
locked = true
|
locked = true
|
||||||
Logger.diag("core","CORE is now locked. No new attachments can be made.")
|
Logger.diag("core","CORE is now locked. No new attachments can be made.")
|
||||||
|
|
||||||
|
func welcome() -> void:
|
||||||
|
Logger.info("core","CORE " + version + " welcomes you!<nl>It seems like everything is working :)")
|
||||||
|
|
|
@ -15,6 +15,7 @@ func _ready() -> void:
|
||||||
var scr_core = ResourceLoader.load("res://CORE/core.gd")
|
var scr_core = ResourceLoader.load("res://CORE/core.gd")
|
||||||
var scr_wmgr = ResourceLoader.load("res://CORE/wmgr.gd")
|
var scr_wmgr = ResourceLoader.load("res://CORE/wmgr.gd")
|
||||||
var scr_smgr = ResourceLoader.load("res://CORE/smgr.gd")
|
var scr_smgr = ResourceLoader.load("res://CORE/smgr.gd")
|
||||||
|
var scr_autoload = ResourceLoader.load("res://CORE/autoload.gd")
|
||||||
Logger.info("coreloader","Constructing CORE")
|
Logger.info("coreloader","Constructing CORE")
|
||||||
var core = Control.new()
|
var core = Control.new()
|
||||||
core.name = "core"
|
core.name = "core"
|
||||||
|
@ -29,6 +30,8 @@ func _ready() -> void:
|
||||||
core.attach("wmgr",scr_wmgr)
|
core.attach("wmgr",scr_wmgr)
|
||||||
Logger.info("coreloader","Attaching smgr to CORE")
|
Logger.info("coreloader","Attaching smgr to CORE")
|
||||||
core.attach("smgr",scr_smgr)
|
core.attach("smgr",scr_smgr)
|
||||||
|
Logger.info("coreloader","Attaching autoload to CORE")
|
||||||
|
core.attach("autoload",scr_autoload)
|
||||||
Logger.info("coreloader","Locking CORE")
|
Logger.info("coreloader","Locking CORE")
|
||||||
core.lock()
|
core.lock()
|
||||||
Logger.info("coreloader","Waiting for CORE to fully initialize")
|
Logger.info("coreloader","Waiting for CORE to fully initialize")
|
||||||
|
|
Loading…
Reference in a new issue