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

37 lines
1.4 KiB
GDScript

# corelog.gd
# CORE Log
#
# This file is part of StarOpenSource CORE (SOSCORE)
# Made by the StarOpenSource Project and Contributers
# Licensed under GNU GPLv3
extends RichTextLabel
var log_first = true
var log_prefix = ""
var log_suffix = ""
func _ready():
# Enable recieving of log messages
Logger.connect("logevent",Callable(self,"logevent"))
# Disable VScrollBar functionality & visibility
get_child(0,true).add_theme_stylebox_override("grabber",StyleBoxEmpty.new())
get_child(0,true).add_theme_stylebox_override("grabber_highlight",StyleBoxEmpty.new())
get_child(0,true).add_theme_stylebox_override("grabber_pressed",StyleBoxEmpty.new())
get_child(0,true).add_theme_stylebox_override("scroll",StyleBoxEmpty.new())
get_child(0,true).add_theme_stylebox_override("scroll_focus",StyleBoxEmpty.new())
get_child(0,true).size = Vector2i(0,0)
get_child(0,true).mouse_filter = Control.MOUSE_FILTER_IGNORE
# Make RichTextLabel ignore all mouse events (to disable scrolling)
mouse_filter = Control.MOUSE_FILTER_IGNORE
func logevent(_type:String,_script:String,_message:String,logcomp:String) -> void:
# Appends log to RichTextLabel
if log_first:
log_first = false
text = text + log_prefix + logcomp + log_suffix
else:
text = text + "\n" + log_prefix + logcomp + log_suffix
func rmconnect() -> void:
# Disables recieving of log messages
Logger.disconnect("logevent",Callable(self,"logevent"))