Add automatic cleanup (fixes #25)
This commit is contained in:
parent
12aebc5dd9
commit
b05d1428a5
3 changed files with 12 additions and 0 deletions
|
@ -17,6 +17,8 @@ Puts the framework into development mode. \
|
|||
Unlocks experimental features.
|
||||
### *bool* <u>custom_modules</u> = *false*
|
||||
Allows or disallows custom modules.
|
||||
### *bool* <u>automatic_shutdown</u> = *true*
|
||||
If `quit_safely` (and by extension `Core.cleanup`) should be called when pressing the X.
|
||||
|
||||
## Logger
|
||||
### *CoreTypes.LoggerLevel* <u>logger_level</u> = *CoreTypes.LoggerLevel.INFO*
|
||||
|
|
|
@ -17,6 +17,8 @@ class_name CoreConfiguration
|
|||
@export var development: bool
|
||||
## Allows or disallows custom modules.
|
||||
@export var custom_modules: bool
|
||||
## If [method Core.quit_safely] (and by extension [method Core.cleanup]) should be called when pressing the X.
|
||||
@export var automatic_shutdown: bool
|
||||
@export_category("Logger")
|
||||
## The minimum log level you want to be displayed.
|
||||
@export var logger_level: CoreTypes.LoggerLevel
|
||||
|
@ -46,6 +48,7 @@ func _init() -> void:
|
|||
headless = false
|
||||
development = false
|
||||
custom_modules = false
|
||||
automatic_shutdown = true
|
||||
|
||||
# Logger
|
||||
logger_level = CoreTypes.LoggerLevel.INFO
|
||||
|
|
|
@ -87,6 +87,7 @@ func _ready() -> void:
|
|||
add_child(custom_modules_node)
|
||||
loggeri = logger.get_instance(basepath.replace("res://", "") + "src/core.gd", self)
|
||||
add_child(scheduler)
|
||||
get_tree().auto_accept_quit = false
|
||||
|
||||
## Initializes all built-in modules during the preinitialization phase.[br]
|
||||
## [b]Danger: [i]Don't call this.[/i][/b]
|
||||
|
@ -338,3 +339,9 @@ func quit_safely(exitcode: int = 0) -> void:
|
|||
await get_tree().create_timer(0.25).timeout
|
||||
await cleanup()
|
||||
get_tree().quit(exitcode)
|
||||
|
||||
func _notification(what) -> void:
|
||||
match(what):
|
||||
NOTIFICATION_WM_CLOSE_REQUEST:
|
||||
if config.automatic_shutdown:
|
||||
await quit_safely(0)
|
||||
|
|
Loading…
Reference in a new issue