Made setting/getting window mode easier

This commit is contained in:
JeremyStar™ 2023-03-19 13:14:18 +01:00
parent c6cfa28f96
commit 616afa9460

43
wmgr.gd
View file

@ -31,25 +31,18 @@ func set_title(title:String) -> void:
DisplayServer.window_set_title(title)
window_title = title
func set_windowed() -> void:
Logger.info("wmgr","Applying new window mode (windowed)")
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
func set_minimized() -> void:
Logger.info("wmgr","Applying new window mode (minimized)")
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_MINIMIZED)
func set_maximized() -> void:
Logger.info("wmgr","Applying new window mode (maximized)")
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_MAXIMIZED)
func set_fullscreen() -> void:
Logger.info("wmgr","Applying new window mode (fullscreen)")
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
func set_fullsceen_exclusive() -> void:
Logger.info("wmgr","Applying new window mode (exclusive fullscreen)")
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_EXCLUSIVE_FULLSCREEN)
func set_mode(mode:String) -> bool:
Logger.info("wmgr","Applying new window mode (" + mode + ")")
match(mode):
"WINDOWED": DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
"MINIMIZED": DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_MINIMIZED)
"MAXIMIZED": DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_MAXIMIZED)
"FULLSCREEN": DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
"EXCLUSIVE_FULLSCREEN": DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_EXCLUSIVE_FULLSCREEN)
_:
Logger.error("wmgr","Invalid window mode \"" + mode + "\".")
return false
return true
func get_size() -> Vector2i:
return DisplayServer.window_get_size()
@ -60,8 +53,16 @@ func get_position() -> Vector2i:
func get_title() -> String:
return window_title
func get_mode() -> int:
return DisplayServer.window_get_mode()
func get_mode() -> String:
match(DisplayServer.window_get_mode()):
0: return "WINDOWED"
1: return "MINIMIZED"
2: return "MAXIMIZED"
3: return "FULLSCREEN"
4: return "EXCLUSIVE_FULLSCREEN"
_:
Logger.error("wmgr","Failed to get window mode: The window mode id \"" + str(DisplayServer.window_get_mode()) + "\" is not known to CORE.")
return "INVALID_MODE"
func _ready() -> void:
Logger.info("wmgr","Configuring window")