parent
ed4647c750
commit
538ba01aec
4 changed files with 38 additions and 5 deletions
2
Test.gd
2
Test.gd
|
@ -43,6 +43,8 @@ Type (technical) = %type_technical%
|
|||
Typerelease = %release_type%
|
||||
Development mode = %devmode%
|
||||
Headless mode = %headless%"""))
|
||||
# Print hi
|
||||
core.logger.info("Hi there!")
|
||||
|
||||
# Update CORE configuration
|
||||
func configure_core() -> void:
|
||||
|
|
|
@ -16,4 +16,4 @@ If you want to use the CORE Framework in a new project, then your answer is **ye
|
|||
- [x] Logger implementation
|
||||
- [ ] HTTP Request helper
|
||||
- [ ] Mod Loader
|
||||
- [ ] Support for custom modules
|
||||
- [x] Support for custom modules
|
||||
|
|
|
@ -26,10 +26,14 @@ Stores the path to CORE's installation directory.
|
|||
|
||||
## Functions
|
||||
### *void* <u>_init</u>(*CoreConfiguration* <u>new_config</u>)
|
||||
:::note
|
||||
This function will be called when calling `CORE.new()`.
|
||||
:::
|
||||
Determines the base path, loads the configuration file and initializes all modules.
|
||||
### *void* <u>register_custom_module</u>(*String* <u>module_name</u>, *CoreBaseModule* <u>module_class</u>)
|
||||
Registers a custom module.
|
||||
### *void* <u>unregister_custom_module</u>(*String* <u>module_name</u>)
|
||||
Unregisters a custom module.
|
||||
### *CoreBaseModule* <u>get_custom_module</u>(*String* <u>module_name</u>)
|
||||
Returns a registered custom module. \
|
||||
Please note that you can't get CORE's builtin modules with this function.
|
||||
### *void* <u>reload_configuration</u>(*CoreConfiguration* <u>new_config</u>)
|
||||
Loads a new CoreConfiguration class and applies it's settings.
|
||||
### *bool* <u>is_devmode</u>()
|
||||
|
|
29
src/core.gd
29
src/core.gd
|
@ -30,13 +30,14 @@ const version_type: CoreTypes.VersionType = CoreTypes.VersionType.ALPHA
|
|||
const version_typerelease: int = 0
|
||||
|
||||
# Modules
|
||||
var config: CoreConfiguration
|
||||
var logger: CoreBaseModule
|
||||
var misc: CoreBaseModule
|
||||
var logui: CoreBaseModule
|
||||
|
||||
# Variables
|
||||
var basepath: String
|
||||
var config: CoreConfiguration
|
||||
var custom_modules: Dictionary = {}
|
||||
|
||||
# Preinitialization
|
||||
func _init(new_config: CoreConfiguration = CoreConfiguration.new()) -> void:
|
||||
|
@ -82,6 +83,32 @@ func inject_modules() -> void:
|
|||
add_child(misc)
|
||||
add_child(logui)
|
||||
|
||||
# Registers a custom module
|
||||
func register_custom_module(module_name: String, module_class: CoreBaseModule) -> void:
|
||||
logger.verb("Registering new custom module \"" + module_name + "\"")
|
||||
if custom_modules.has(module_name):
|
||||
logger.error("Registering module failed: A custom module with the name \"" + module_name + "\" already exists.")
|
||||
return
|
||||
custom_modules.merge({ module_name: module_class })
|
||||
module_class._initialize()
|
||||
module_class._pull_config()
|
||||
|
||||
# Unregisters a custom module
|
||||
func unregister_custom_module(module_name: String) -> void:
|
||||
logger.verb("Unregistering custom module \"" + module_name + "\"")
|
||||
if !custom_modules.has(module_name):
|
||||
logger.error("Unregistering module failed: A custom module with the name \"" + module_name + "\" does not exist.")
|
||||
return
|
||||
custom_modules.erase(module_name)
|
||||
|
||||
# Returns a custom module
|
||||
func get_custom_module(module_name: String) -> CoreBaseModule:
|
||||
logger.diag("Getting custom module \"" + module_name + "\"")
|
||||
if !custom_modules.has(module_name):
|
||||
logger.error("Getting module failed: A custom module with the name \"" + module_name + "\" does not exist.")
|
||||
return
|
||||
return custom_modules[module_name]
|
||||
|
||||
# (Re-)Load configuration
|
||||
func reload_configuration(new_config: CoreConfiguration = CoreConfiguration.new()) -> void:
|
||||
var initialized = config != null
|
||||
|
|
Loading…
Reference in a new issue