CORE/wmgr.gd
2023-03-18 16:34:12 +01:00

72 lines
2.3 KiB
GDScript

# 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
var available = false
@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
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
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 get_size() -> Vector2i:
return DisplayServer.window_get_size()
func get_position() -> Vector2i:
return DisplayServer.window_get_position()
func get_title() -> String:
return window_title
func get_mode() -> int:
return DisplayServer.window_get_mode()
func _ready() -> void:
Logger.info("wmgr","Configuring window")
DisplayServer.window_set_size(Vector2i(960,540))
DisplayServer.window_set_min_size(Vector2i(960,540))
DisplayServer.window_set_title(window_title)
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
available = true