CORE/events.gd

64 lines
2.5 KiB
GDScript3
Raw Normal View History

extends Node
@onready
var core = get_node(NodePath("/root/core"))
var window_title_prev = ""
var window_size_x_prev = 0
var window_size_y_prev = 0
var window_pos_x_prev = 0
var window_pos_y_prev = 0
signal window_title
signal window_size
signal window_pos
signal logger_all
signal logger_diag
signal logger_info
signal logger_warn
signal logger_error
func _ready() -> void:
Logger.connect("logevent",Callable(self,"logger_update"))
core.setready()
func logger_update(type:String,script:String,message:String,_logmessage:String) -> void:
emit_signal("logger_all",type,script,message)
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)
elif type == "ERROR":
emit_signal("logger_error",script,message)
func _process(_delta:float) -> void:
var window_title_var = core.wmgr.get_title()
var window_size_x = core.wmgr.get_size().x
var window_size_y = core.wmgr.get_size().y
var window_pos_x = core.wmgr.get_position().x
var window_pos_y = core.wmgr.get_position().y
if window_title_prev != window_title_var:
emit_signal("window_title",window_title_var,window_title_prev)
window_title_prev = window_title_var
if window_size_x != window_size_x_prev and window_size_y != window_size_y_prev:
emit_signal("window_size","BOTH",Vector2i(window_size_x,window_size_y),Vector2i(window_size_x_prev,window_size_y_prev))
window_size_x_prev = window_size_x
window_size_y_prev = window_size_y
elif window_size_x != window_size_x_prev:
emit_signal("window_size","X",Vector2i(window_size_x,window_size_y),Vector2i(window_size_x_prev,window_size_y_prev))
window_size_x_prev = window_size_x
elif window_size_y != window_size_y_prev:
emit_signal("window_size","Y",Vector2i(window_size_x,window_size_y),Vector2i(window_size_x_prev,window_size_y_prev))
window_size_y_prev = window_size_y
if window_pos_x != window_pos_x_prev and window_pos_y != window_pos_y_prev:
emit_signal("window_pos","BOTH",Vector2i(window_pos_x,window_pos_y),Vector2i(window_pos_x_prev,window_pos_y_prev))
window_pos_x_prev = window_pos_x
window_pos_y_prev = window_pos_y
elif window_pos_x != window_pos_x_prev:
emit_signal("window_pos","X",Vector2i(window_pos_x,window_pos_y),Vector2i(window_pos_x_prev,window_pos_y_prev))
window_pos_x_prev = window_pos_x
elif window_pos_y != window_pos_y_prev:
emit_signal("window_pos","Y",Vector2i(window_pos_x,window_pos_y),Vector2i(window_pos_x_prev,window_pos_y_prev))
window_pos_y_prev = window_pos_y