2023-08-25 14:34:57 +02:00
|
|
|
######################################
|
|
|
|
# THE CORE FRAMEWORK #
|
|
|
|
# MADE BY THE STAROPENSOURCE PROJECT #
|
|
|
|
# AND CONTRIBUTERS (THANK YOU!) #
|
|
|
|
# #
|
|
|
|
# COPYRIGHT 2023 THE STAROPENSOURCE #
|
|
|
|
# PROJECT AND CONTRIBUTERS #
|
|
|
|
# #
|
|
|
|
# LICENSED UNDER THE GNU GENERAL #
|
|
|
|
# PUBLIC LICENSE VERSION 3 (ONLY) #
|
|
|
|
######################################
|
2023-05-29 20:46:47 +02:00
|
|
|
extends Node
|
|
|
|
|
2023-08-25 14:34:57 +02:00
|
|
|
# CORE modules
|
|
|
|
var core: Node = null
|
|
|
|
var logger: Node = null
|
2023-05-29 20:46:47 +02:00
|
|
|
|
2023-08-25 14:34:57 +02:00
|
|
|
# Used for checking if any values have changed
|
|
|
|
var prev_window_title: String = ""
|
|
|
|
var prev_window_size_x: int = 0
|
|
|
|
var prev_window_size_y: int = 0
|
|
|
|
var prev_window_pos_x: int = 0
|
|
|
|
var prev_window_pos_y: int = 0
|
|
|
|
|
|
|
|
# Event signals
|
2023-05-29 20:46:47 +02:00
|
|
|
signal window_title
|
|
|
|
signal window_size
|
|
|
|
signal window_pos
|
|
|
|
signal logger_all
|
|
|
|
signal logger_diag
|
|
|
|
signal logger_info
|
|
|
|
signal logger_warn
|
|
|
|
signal logger_error
|
|
|
|
|
2023-08-25 14:34:57 +02:00
|
|
|
# Set up connection between logger's logevent and logger_update()
|
2023-08-07 14:49:12 +02:00
|
|
|
func initialize() -> void:
|
|
|
|
if core.protection_mode: return
|
2023-08-25 14:34:57 +02:00
|
|
|
# logevent (signal) -> logger_update()
|
|
|
|
logger.connect("logevent",Callable(self,"logger_update"))
|
2023-08-07 14:49:12 +02:00
|
|
|
|
|
|
|
func logger_update(type:String,script:String,message:String,_logmessage:String) -> void:
|
|
|
|
if core.protection_mode: return
|
2023-08-25 14:34:57 +02:00
|
|
|
# Emit signal logger_all for all log messages
|
2023-08-07 14:49:12 +02:00
|
|
|
emit_signal("logger_all",type,script,message)
|
2023-08-25 14:34:57 +02:00
|
|
|
# Check for log type and emit the right signal
|
2023-08-07 14:49:12 +02:00
|
|
|
if type == "DIAG":
|
|
|
|
emit_signal("logger_diag",script,message)
|
|
|
|
elif type == "INFO":
|
|
|
|
emit_signal("logger_info",script,message)
|
|
|
|
elif type == "WARN":
|
|
|
|
emit_signal("logger_warn",script,message)
|
2023-08-25 14:34:57 +02:00
|
|
|
elif type == "ERR!":
|
2023-08-07 14:49:12 +02:00
|
|
|
emit_signal("logger_error",script,message)
|
|
|
|
else:
|
|
|
|
core.exception("events","The log type \"" + type + "\" is not known to events.gd")
|
2023-08-25 14:34:57 +02:00
|
|
|
|
|
|
|
# Check various variables and emit signals if they changed
|
|
|
|
func _process(_delta:float) -> void:
|
|
|
|
process_window_title()
|
|
|
|
process_window_size()
|
|
|
|
process_window_pos()
|
|
|
|
|
|
|
|
func process_window_title() -> void:
|
|
|
|
var new_window_title: String = get_tree().root.title
|
|
|
|
if prev_window_title != new_window_title:
|
|
|
|
emit_signal("window_title",new_window_title,prev_window_title)
|
|
|
|
prev_window_title = new_window_title
|
|
|
|
|
|
|
|
func process_window_size() -> void:
|
|
|
|
var new_window_size_x: int = DisplayServer.window_get_size().x
|
|
|
|
var new_window_size_y: int = DisplayServer.window_get_size().y
|
|
|
|
if new_window_size_x != prev_window_size_x and new_window_size_y != prev_window_size_y:
|
|
|
|
emit_signal("window_size","BOTH",Vector2i(new_window_size_x,new_window_size_y),Vector2i(prev_window_size_x,prev_window_size_y))
|
|
|
|
prev_window_size_x = new_window_size_x
|
|
|
|
prev_window_size_y = new_window_size_y
|
|
|
|
elif new_window_size_x != prev_window_size_x:
|
|
|
|
emit_signal("window_size","X",Vector2i(new_window_size_x,new_window_size_y),Vector2i(prev_window_size_x,prev_window_size_y))
|
|
|
|
prev_window_size_x = new_window_size_x
|
|
|
|
elif new_window_size_y != prev_window_size_y:
|
|
|
|
emit_signal("window_size","Y",Vector2i(new_window_size_x,new_window_size_y),Vector2i(prev_window_size_x,prev_window_size_y))
|
|
|
|
prev_window_size_y = new_window_size_y
|
|
|
|
|
|
|
|
func process_window_pos() -> void:
|
|
|
|
var new_window_pos_x: int = DisplayServer.window_get_position().x
|
|
|
|
var new_window_pos_y: int = DisplayServer.window_get_position().y
|
|
|
|
if new_window_pos_x != prev_window_pos_x and new_window_pos_y != prev_window_pos_y:
|
|
|
|
emit_signal("window_pos","BOTH",Vector2i(new_window_pos_x,new_window_pos_y),Vector2i(prev_window_pos_x,prev_window_pos_y))
|
|
|
|
prev_window_pos_x = new_window_pos_x
|
|
|
|
prev_window_pos_y = new_window_pos_y
|
|
|
|
elif new_window_pos_x != prev_window_pos_x:
|
|
|
|
emit_signal("window_pos","X",Vector2i(new_window_pos_x,new_window_pos_y),Vector2i(prev_window_pos_x,prev_window_pos_y))
|
|
|
|
prev_window_pos_x = new_window_pos_x
|
|
|
|
elif new_window_pos_y != prev_window_pos_y:
|
|
|
|
emit_signal("window_pos","Y",Vector2i(new_window_pos_x,new_window_pos_y),Vector2i(prev_window_pos_x,prev_window_pos_y))
|
|
|
|
prev_window_pos_y = new_window_pos_y
|