Update to 00368a14e5e4325f46ecc0ff9462275df067899a
This commit is contained in:
parent
864af56021
commit
fe4a160631
3 changed files with 34 additions and 2 deletions
|
@ -46,6 +46,8 @@ class_name CoreConfiguration
|
|||
@export var logui_background_color: Color
|
||||
## What font size the graphical log should have.
|
||||
@export var logui_font_size: int
|
||||
## How many lines can be visible on the screen at any given time. [b]Never[/b] set this higher than 100 or it will cause tremendous amounts of lag for no real benefit. Instead [i]lowering[/i] that amount helps performance.
|
||||
@export var logui_max_lines: int
|
||||
|
||||
@export_category("Miscellaneous")
|
||||
## Shows or hides the type when calling [code]stringify_variables[/code].
|
||||
|
@ -83,6 +85,7 @@ func _init() -> void:
|
|||
logui_enabled = true
|
||||
logui_background_color = Color.BLACK # To disable the background, use Color.TRANSPARENT
|
||||
logui_font_size = 14
|
||||
logui_max_lines = 100
|
||||
|
||||
# Misc
|
||||
misc_stringify_show_type = false
|
||||
|
|
30
src/logui.gd
30
src/logui.gd
|
@ -28,12 +28,21 @@ var logrtl: RichTextLabel
|
|||
var font_normal: Font
|
||||
var font_bold: Font
|
||||
|
||||
# Configuration
|
||||
var config_max_lines: int
|
||||
|
||||
# +++ module +++
|
||||
func _pull_config() -> void:
|
||||
background.visible = !core.config.headless and core.config.logui_enabled
|
||||
if !core.config.logui_enabled:
|
||||
background.visible = false
|
||||
logrtl.text = ""
|
||||
else:
|
||||
background.visible = !core.config.headless
|
||||
background.color = core.config.logui_background_color
|
||||
logrtl.add_theme_font_size_override("normal_font_size", core.config.logui_font_size)
|
||||
logrtl.add_theme_font_size_override("bold_font_size", core.config.logui_font_size)
|
||||
|
||||
config_max_lines = core.config.logui_max_lines
|
||||
|
||||
func _cleanup() -> void:
|
||||
background.remove_child(logrtl)
|
||||
|
@ -90,7 +99,9 @@ func _ready() -> void:
|
|||
vsbar.add_theme_stylebox_override("grabber_pressed", StyleBoxEmpty.new())
|
||||
|
||||
# Connect log_event
|
||||
core.logger.connect("log_event", func(allowed: bool, _level: CoreTypes.LoggerLevel, _origin: String, _message: String, format: String) -> void: if allowed: logrtl.text = logrtl.text + format + "\n")
|
||||
core.logger.connect("log_event", func(allowed: bool, _level: CoreTypes.LoggerLevel, _origin: String, _message: String, format: String) -> void:
|
||||
if allowed and core.config.logui_enabled: logrtl.text = logrtl.text + format + "\n"
|
||||
)
|
||||
|
||||
# +++ process +++
|
||||
func _process(_delta: float) -> void:
|
||||
|
@ -98,3 +109,18 @@ func _process(_delta: float) -> void:
|
|||
var window_size: Vector2i = DisplayServer.window_get_size()
|
||||
background.size = window_size
|
||||
logrtl.size = window_size
|
||||
|
||||
var stripped_text: String = ""
|
||||
if logrtl.text.count("\n") > config_max_lines:
|
||||
printerr("Stripping text")
|
||||
var lines: PackedStringArray = logrtl.text.split("\n")
|
||||
|
||||
var index: int = 0
|
||||
for line in lines:
|
||||
if index >= lines.size()-config_max_lines:
|
||||
if stripped_text == "": stripped_text = line
|
||||
else: stripped_text += "\n" + line
|
||||
|
||||
index += 1
|
||||
|
||||
logrtl.text = stripped_text
|
||||
|
|
|
@ -62,17 +62,20 @@ func _schedule() -> void:
|
|||
## Returns a new [CoreValidationSingle].
|
||||
func get_single(data, parent: Node) -> CoreValidationSingle:
|
||||
var single: CoreValidationSingle = CoreValidationSingle.new(core, data, parent)
|
||||
single.name = core.stringify_variables("CoreValidationSingle -> %parent% (type=%type% bytes=%bytes%)", { "parent": parent, "type": type_string(typeof(data)), "bytes": var_to_bytes_with_objects(data).size() })
|
||||
singles.append(single)
|
||||
return single
|
||||
|
||||
## Returns a new [CoreValidationSingle] for use in [CoreValidationSchema]s.
|
||||
func get_single_schema(parent: Node) -> CoreValidationSingle:
|
||||
var single: CoreValidationSingle = CoreValidationSingle.new(core, null, parent)
|
||||
single.name = core.stringify_variables("CoreValidationSingle -> %parent% (no data, for schema)", { "parent": parent })
|
||||
singles.append(single)
|
||||
return single
|
||||
|
||||
## Returns a new [CoreValidationSchema].
|
||||
func get_schema(schema_new: Dictionary, data_new: Dictionary, parent: Node) -> CoreValidationSchema:
|
||||
var schema: CoreValidationSchema = CoreValidationSchema.new(core, schema_new, data_new, parent)
|
||||
schema.name = core.stringify_variables("CoreValidationSchema -> %parent% (keys_schema=%keys_schema% keys_data=%keys_data% bytes_schema=%bytes_schema% bytes_data=%bytes_data%)", { "parent": parent, "keys_schema": schema_new.size(), "keys_data": data_new.size(), "bytes_schema": var_to_bytes_with_objects(schema_new).size(), "bytes_data": var_to_bytes_with_objects(data_new).size() })
|
||||
schemas.append(schema)
|
||||
return schema
|
||||
|
|
Loading…
Reference in a new issue