Add ability to hide the window on shutdown
This commit is contained in:
parent
971b15adfc
commit
5a02c10080
3 changed files with 20 additions and 0 deletions
|
@ -19,6 +19,8 @@ Unlocks experimental features.
|
||||||
Allows or disallows custom modules.
|
Allows or disallows custom modules.
|
||||||
### *bool* <u>automatic_shutdown</u> = *true*
|
### *bool* <u>automatic_shutdown</u> = *true*
|
||||||
If `quit_safely` (and by extension `Core.cleanup`) should be called when pressing the X.
|
If `quit_safely` (and by extension `Core.cleanup`) should be called when pressing the X.
|
||||||
|
### *bool* <u>hide_window_on_shutdown</u> = *true*
|
||||||
|
Hides the window during engine shutdown. Useful when your game and the framework will take longer to cleanup.
|
||||||
|
|
||||||
## Logger
|
## Logger
|
||||||
### *CoreTypes.LoggerLevel* <u>logger_level</u> = *CoreTypes.LoggerLevel.INFO*
|
### *CoreTypes.LoggerLevel* <u>logger_level</u> = *CoreTypes.LoggerLevel.INFO*
|
||||||
|
|
|
@ -19,6 +19,8 @@ class_name CoreConfiguration
|
||||||
@export var custom_modules: bool
|
@export var custom_modules: bool
|
||||||
## If [method Core.quit_safely] (and by extension [method Core.cleanup]) should be called when pressing the X.
|
## If [method Core.quit_safely] (and by extension [method Core.cleanup]) should be called when pressing the X.
|
||||||
@export var automatic_shutdown: bool
|
@export var automatic_shutdown: bool
|
||||||
|
## Hides the window during engine shutdown. Useful when your game and the framework will take longer to cleanup.
|
||||||
|
@export var hide_window_on_shutdown: bool
|
||||||
|
|
||||||
@export_category("Logger")
|
@export_category("Logger")
|
||||||
## The minimum log level you want to be displayed.
|
## The minimum log level you want to be displayed.
|
||||||
|
@ -67,6 +69,7 @@ func _init() -> void:
|
||||||
development = false
|
development = false
|
||||||
custom_modules = false
|
custom_modules = false
|
||||||
automatic_shutdown = true
|
automatic_shutdown = true
|
||||||
|
hide_window_on_shutdown = true
|
||||||
|
|
||||||
# Logger
|
# Logger
|
||||||
logger_level = CoreTypes.LoggerLevel.INFO
|
logger_level = CoreTypes.LoggerLevel.INFO
|
||||||
|
|
15
src/core.gd
15
src/core.gd
|
@ -415,6 +415,21 @@ func check_godot_version() -> bool:
|
||||||
## [b]Note: [i]Using the [code]await[/code] keyword is required for this function.[/i][/b]
|
## [b]Note: [i]Using the [code]await[/code] keyword is required for this function.[/i][/b]
|
||||||
func quit_safely(exitcode: int = 0) -> void:
|
func quit_safely(exitcode: int = 0) -> void:
|
||||||
loggeri.info("Shutting down (code " + str(exitcode) + ")")
|
loggeri.info("Shutting down (code " + str(exitcode) + ")")
|
||||||
|
if config.hide_window_on_shutdown:
|
||||||
|
loggeri.verb("Hiding window")
|
||||||
|
Engine.max_fps = -1 # a higher framerate seems to make the shutdown process muuuuch faster
|
||||||
|
DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_ENABLED) # we don't want to cook the cpu tho
|
||||||
|
DisplayServer.window_set_exclusive(0, false)
|
||||||
|
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_MINIMIZED)
|
||||||
|
DisplayServer.window_set_min_size(Vector2.ZERO)
|
||||||
|
DisplayServer.window_set_size(Vector2i.ZERO)
|
||||||
|
DisplayServer.window_set_max_size(Vector2.ZERO)
|
||||||
|
DisplayServer.window_set_position(Vector2i(9999999, 9999999))
|
||||||
|
DisplayServer.window_set_flag(DisplayServer.WINDOW_FLAG_BORDERLESS, true)
|
||||||
|
DisplayServer.window_set_flag(DisplayServer.WINDOW_FLAG_ALWAYS_ON_TOP, false)
|
||||||
|
DisplayServer.window_set_flag(DisplayServer.WINDOW_FLAG_MOUSE_PASSTHROUGH, false)
|
||||||
|
DisplayServer.window_set_flag(DisplayServer.WINDOW_FLAG_NO_FOCUS, true)
|
||||||
|
DisplayServer.window_set_flag(DisplayServer.WINDOW_FLAG_RESIZE_DISABLED, true)
|
||||||
await get_tree().create_timer(0.25).timeout
|
await get_tree().create_timer(0.25).timeout
|
||||||
await cleanup()
|
await cleanup()
|
||||||
get_tree().quit(exitcode)
|
get_tree().quit(exitcode)
|
||||||
|
|
Loading…
Reference in a new issue