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) DisplayServer.window_set_title(title)
window_title = title window_title = title
func set_windowed() -> void: func set_mode(mode:String) -> bool:
Logger.info("wmgr","Applying new window mode (windowed)") Logger.info("wmgr","Applying new window mode (" + mode + ")")
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED) match(mode):
"WINDOWED": DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
func set_minimized() -> void: "MINIMIZED": DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_MINIMIZED)
Logger.info("wmgr","Applying new window mode (minimized)") "MAXIMIZED": DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_MAXIMIZED)
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_MINIMIZED) "FULLSCREEN": DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
"EXCLUSIVE_FULLSCREEN": DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_EXCLUSIVE_FULLSCREEN)
func set_maximized() -> void: _:
Logger.info("wmgr","Applying new window mode (maximized)") Logger.error("wmgr","Invalid window mode \"" + mode + "\".")
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_MAXIMIZED) return false
return true
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 get_size() -> Vector2i: func get_size() -> Vector2i:
return DisplayServer.window_get_size() return DisplayServer.window_get_size()
@ -60,8 +53,16 @@ func get_position() -> Vector2i:
func get_title() -> String: func get_title() -> String:
return window_title return window_title
func get_mode() -> int: func get_mode() -> String:
return DisplayServer.window_get_mode() 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: func _ready() -> void:
Logger.info("wmgr","Configuring window") Logger.info("wmgr","Configuring window")