mirror of
https://codeberg.org/StreamGraph/StreamGraph.git
synced 2024-11-13 19:49:55 +01:00
32 lines
1.1 KiB
GDScript
32 lines
1.1 KiB
GDScript
# (c) 2023-present Eroax
|
|
# (c) 2023-present Yagich
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
extends VBoxContainer
|
|
class_name VariableViewer
|
|
|
|
@onready var variable_tree: Tree = %VariableTree
|
|
var root: TreeItem
|
|
|
|
func _ready() -> void:
|
|
variable_tree.set_column_title(0, "Name")
|
|
variable_tree.set_column_title(1, "Value")
|
|
variable_tree.set_column_title(2, "Type")
|
|
variable_tree.set_column_expand(1, true)
|
|
variable_tree.set_column_expand_ratio(0, 15)
|
|
variable_tree.set_column_expand_ratio(1, 70)
|
|
variable_tree.set_column_expand_ratio(2, 15)
|
|
root = variable_tree.create_item()
|
|
rebuild_variable_tree()
|
|
|
|
|
|
func rebuild_variable_tree(data: Dictionary = {}) -> void:
|
|
#variable_tree.clear() # godot will raw dog a nullptr later if we clear the whole tree
|
|
for i in root.get_children():
|
|
i.free()
|
|
|
|
for i in data:
|
|
var item := variable_tree.create_item(root)
|
|
item.set_text(0, i)
|
|
item.set_text(1, data[i])
|
|
var type: DeckType.Types = DeckType.INVERSE_GODOT_TYPES_MAP[typeof(data[i])]
|
|
item.set_text(2, DeckType.type_str(type))
|