Refactored debug labels in the overlay, now supports bbcode
This commit is contained in:
parent
d834ee2c4e
commit
27d08c567a
|
@ -7,6 +7,8 @@ extends CanvasLayer
|
||||||
@onready var scroll_bar = $Root/LogScroll.get_v_scroll_bar()
|
@onready var scroll_bar = $Root/LogScroll.get_v_scroll_bar()
|
||||||
@onready var log_title = $Root/LogTitle
|
@onready var log_title = $Root/LogTitle
|
||||||
|
|
||||||
|
@onready var default_label = preload("res://debug/DebugLabel.tscn")
|
||||||
|
|
||||||
var show_gizmos = false
|
var show_gizmos = false
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
|
@ -17,12 +19,12 @@ func _on_scroll_bar_update():
|
||||||
scroll_bar.value = scroll_bar.max_value
|
scroll_bar.value = scroll_bar.max_value
|
||||||
|
|
||||||
func put_log(value: Dictionary):
|
func put_log(value: Dictionary):
|
||||||
var new_label = Label.new()
|
var new_label = default_label.instantiate()
|
||||||
#new_label.bbcode_enabled = true
|
#new_label.bbcode_enabled = true
|
||||||
#new_label.fit_content = true
|
#new_label.fit_content = true
|
||||||
new_label.text = value["description"] + " | " + value["text"]
|
new_label.text = value["description"] + " | " + value["text"]
|
||||||
|
new_label.custom_minimum_size = Vector2(1920, 24)
|
||||||
logs.add_child(new_label)
|
logs.add_child(new_label)
|
||||||
new_label.use_parent_material = true
|
|
||||||
log_title.text = "Log +"
|
log_title.text = "Log +"
|
||||||
get_tree().create_timer(0.1).connect("timeout", _on_log_update_timeout)
|
get_tree().create_timer(0.1).connect("timeout", _on_log_update_timeout)
|
||||||
|
|
||||||
|
@ -44,10 +46,9 @@ func stat_set(stat: Dictionary):
|
||||||
set_text(child, stat)
|
set_text(child, stat)
|
||||||
found_key = true
|
found_key = true
|
||||||
if not found_key:
|
if not found_key:
|
||||||
var new_label = RichTextLabel.new()
|
var new_label = default_label.instantiate()
|
||||||
new_label.name = stat["key"]
|
new_label.name = stat["key"]
|
||||||
categories.add_child(new_label)
|
categories.add_child(new_label)
|
||||||
new_label.use_parent_material = true
|
|
||||||
set_text(new_label, stat)
|
set_text(new_label, stat)
|
||||||
|
|
||||||
func set_text(node, stat):
|
func set_text(node, stat):
|
||||||
|
@ -93,7 +94,7 @@ func _process(_delta):
|
||||||
clear_log()
|
clear_log()
|
||||||
|
|
||||||
# Debug properties of things in the world
|
# Debug properties of things in the world
|
||||||
process_debug_property("debug_state", func(): return Label.new(), func(item):
|
process_debug_property("debug_state", func(): return default_label.instantiate(), func(item):
|
||||||
item.text = item.get_parent().get_node("StateMachine").state.name
|
item.text = item.get_parent().get_node("StateMachine").state.name
|
||||||
)
|
)
|
||||||
process_debug_property("debug_trail",
|
process_debug_property("debug_trail",
|
||||||
|
|
|
@ -1,18 +1,14 @@
|
||||||
[gd_scene load_steps=4 format=3 uid="uid://c7e1ndysa4vmu"]
|
[gd_scene load_steps=4 format=3 uid="uid://c7e1ndysa4vmu"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://debug/Debug.gd" id="1_ek618"]
|
[ext_resource type="Script" path="res://debug/Debug.gd" id="1_ek618"]
|
||||||
[ext_resource type="Shader" path="res://assets/shaders/2d_outline.gdshader" id="2_mahlg"]
|
[ext_resource type="Material" uid="uid://ctrfy55ljeflp" path="res://debug/DebugTextOutline.tres" id="2_alpen"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://c311q88kbpxrf" path="res://debug/DebugLabel.tscn" id="3_axf08"]
|
||||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_5fpqx"]
|
|
||||||
shader = ExtResource("2_mahlg")
|
|
||||||
shader_parameter/line_color = Color(0.353696, 0.18623, 0.405237, 1)
|
|
||||||
shader_parameter/line_thickness = 1.353
|
|
||||||
|
|
||||||
[node name="Debug" type="CanvasLayer"]
|
[node name="Debug" type="CanvasLayer"]
|
||||||
script = ExtResource("1_ek618")
|
script = ExtResource("1_ek618")
|
||||||
|
|
||||||
[node name="Root" type="Control" parent="."]
|
[node name="Root" type="Control" parent="."]
|
||||||
material = SubResource("ShaderMaterial_5fpqx")
|
material = ExtResource("2_alpen")
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
|
@ -21,6 +17,7 @@ grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
|
|
||||||
[node name="Stats" type="VBoxContainer" parent="Root"]
|
[node name="Stats" type="VBoxContainer" parent="Root"]
|
||||||
|
material = ExtResource("2_alpen")
|
||||||
use_parent_material = true
|
use_parent_material = true
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchors_preset = -1
|
anchors_preset = -1
|
||||||
|
@ -32,10 +29,12 @@ grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
|
|
||||||
[node name="Top" type="VBoxContainer" parent="Root/Stats"]
|
[node name="Top" type="VBoxContainer" parent="Root/Stats"]
|
||||||
|
material = ExtResource("2_alpen")
|
||||||
use_parent_material = true
|
use_parent_material = true
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
||||||
[node name="Header" type="RichTextLabel" parent="Root/Stats/Top"]
|
[node name="Header" type="RichTextLabel" parent="Root/Stats/Top"]
|
||||||
|
material = ExtResource("2_alpen")
|
||||||
use_parent_material = true
|
use_parent_material = true
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
bbcode_enabled = true
|
bbcode_enabled = true
|
||||||
|
@ -43,10 +42,12 @@ text = "-- Stats --"
|
||||||
fit_content = true
|
fit_content = true
|
||||||
|
|
||||||
[node name="Categories" type="VBoxContainer" parent="Root/Stats"]
|
[node name="Categories" type="VBoxContainer" parent="Root/Stats"]
|
||||||
|
material = ExtResource("2_alpen")
|
||||||
use_parent_material = true
|
use_parent_material = true
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
||||||
[node name="LogScroll" type="ScrollContainer" parent="Root"]
|
[node name="LogScroll" type="ScrollContainer" parent="Root"]
|
||||||
|
material = ExtResource("2_alpen")
|
||||||
use_parent_material = true
|
use_parent_material = true
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchors_preset = -1
|
anchors_preset = -1
|
||||||
|
@ -59,10 +60,15 @@ grow_vertical = 2
|
||||||
follow_focus = true
|
follow_focus = true
|
||||||
|
|
||||||
[node name="Log" type="VBoxContainer" parent="Root/LogScroll"]
|
[node name="Log" type="VBoxContainer" parent="Root/LogScroll"]
|
||||||
|
material = ExtResource("2_alpen")
|
||||||
use_parent_material = true
|
use_parent_material = true
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="DebugLabel" parent="Root/LogScroll/Log" instance=ExtResource("3_axf08")]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
[node name="LogTitle" type="Label" parent="Root"]
|
[node name="LogTitle" type="Label" parent="Root"]
|
||||||
|
material = ExtResource("2_alpen")
|
||||||
use_parent_material = true
|
use_parent_material = true
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchors_preset = -1
|
anchors_preset = -1
|
||||||
|
@ -79,6 +85,7 @@ text = "Log"
|
||||||
[node name="Panel" type="Panel" parent="Root/LogTitle"]
|
[node name="Panel" type="Panel" parent="Root/LogTitle"]
|
||||||
modulate = Color(1, 1, 1, 0.196078)
|
modulate = Color(1, 1, 1, 0.196078)
|
||||||
show_behind_parent = true
|
show_behind_parent = true
|
||||||
|
material = ExtResource("2_alpen")
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
|
|
9
debug/DebugLabel.tscn
Normal file
9
debug/DebugLabel.tscn
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
[gd_scene load_steps=2 format=3 uid="uid://c311q88kbpxrf"]
|
||||||
|
|
||||||
|
[ext_resource type="Material" uid="uid://ctrfy55ljeflp" path="res://debug/DebugTextOutline.tres" id="1_53ujm"]
|
||||||
|
|
||||||
|
[node name="DebugLabel" type="RichTextLabel"]
|
||||||
|
material = ExtResource("1_53ujm")
|
||||||
|
custom_minimum_size = Vector2(400, 24)
|
||||||
|
offset_right = 1.0
|
||||||
|
text = "Hello World!"
|
8
debug/DebugTextOutline.tres
Normal file
8
debug/DebugTextOutline.tres
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
[gd_resource type="ShaderMaterial" load_steps=2 format=3 uid="uid://ctrfy55ljeflp"]
|
||||||
|
|
||||||
|
[ext_resource type="Shader" path="res://assets/shaders/2d_outline.gdshader" id="1_5kv17"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
shader = ExtResource("1_5kv17")
|
||||||
|
shader_parameter/line_color = Color(0.470961, 0.281881, 0.669343, 1)
|
||||||
|
shader_parameter/line_thickness = 1.706
|
Loading…
Reference in a new issue