2023-03-18 16:34:12 +01:00
|
|
|
# wgr.gd
|
|
|
|
# Window Manager
|
|
|
|
#
|
|
|
|
# This file is part of StarOpenSource CORE (SOSCORE)
|
|
|
|
# Made by the StarOpenSource Project and Contributers
|
|
|
|
# Licensed under GNU GPLv3
|
|
|
|
extends Node
|
|
|
|
|
|
|
|
@onready
|
|
|
|
var core = get_node(NodePath("/root/core"))
|
|
|
|
@onready
|
|
|
|
var window_size_x = core.config.wmgr_size_x
|
|
|
|
@onready
|
|
|
|
var window_size_y = core.config.wmgr_size_y
|
|
|
|
@onready
|
|
|
|
var window_title = core.config.wmgr_title
|
|
|
|
@onready
|
|
|
|
var window_mode = core.config.wmgr_mode
|
|
|
|
|
2023-06-26 20:07:19 +02:00
|
|
|
var delta = 0
|
|
|
|
|
|
|
|
func _process(deltap) -> void:
|
|
|
|
delta = deltap
|
|
|
|
|
2023-03-18 16:34:12 +01:00
|
|
|
func set_size(x:int,y:int) -> void:
|
|
|
|
Logger.info("wmgr","Applying new window size (" + str(x) + "x" + str(y) + ")")
|
|
|
|
DisplayServer.window_set_size(Vector2i(x,y))
|
|
|
|
|
|
|
|
func set_position(x:int,y:int) -> void:
|
|
|
|
Logger.info("wmgr","Applying new window position (X" + str(x) + " Y" + str(y) + ")")
|
|
|
|
DisplayServer.window_set_position(Vector2i(x,y))
|
|
|
|
|
|
|
|
func set_title(title:String) -> void:
|
|
|
|
Logger.info("wmgr","Applying new window title (" + title + ")")
|
|
|
|
DisplayServer.window_set_title(title)
|
|
|
|
window_title = title
|
|
|
|
|
2023-03-19 13:14:18 +01:00
|
|
|
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
|
2023-03-18 16:34:12 +01:00
|
|
|
|
|
|
|
func get_size() -> Vector2i:
|
|
|
|
return DisplayServer.window_get_size()
|
|
|
|
|
|
|
|
func get_position() -> Vector2i:
|
|
|
|
return DisplayServer.window_get_position()
|
|
|
|
|
|
|
|
func get_title() -> String:
|
|
|
|
return window_title
|
|
|
|
|
2023-03-19 13:14:18 +01:00
|
|
|
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"
|
2023-03-18 16:34:12 +01:00
|
|
|
|
2023-06-26 20:14:38 +02:00
|
|
|
func get_fps() -> float:
|
2023-06-26 20:07:19 +02:00
|
|
|
if str(delta) == "0":
|
2023-06-26 20:14:38 +02:00
|
|
|
return INF
|
2023-06-26 20:07:19 +02:00
|
|
|
else:
|
2023-06-26 20:14:38 +02:00
|
|
|
return 1/delta
|
2023-06-26 20:07:19 +02:00
|
|
|
|
|
|
|
func get_rendertime() -> float:
|
|
|
|
return Performance.get_monitor(Performance.TIME_PROCESS)
|
|
|
|
|
2023-06-26 20:27:22 +02:00
|
|
|
func get_delta() -> float:
|
2023-06-26 20:07:19 +02:00
|
|
|
return delta
|
|
|
|
|
2023-03-18 16:34:12 +01:00
|
|
|
func _ready() -> void:
|
|
|
|
Logger.info("wmgr","Configuring window")
|
2023-05-30 02:44:10 +02:00
|
|
|
DisplayServer.window_set_size(Vector2i(window_size_x,window_size_y))
|
2023-03-18 16:34:12 +01:00
|
|
|
DisplayServer.window_set_min_size(Vector2i(960,540))
|
|
|
|
DisplayServer.window_set_title(window_title)
|
2023-05-30 02:44:10 +02:00
|
|
|
DisplayServer.window_set_mode(window_mode)
|
2023-05-29 20:46:47 +02:00
|
|
|
core.setready()
|