add array and dictionary expansion support to variable viewer

This commit is contained in:
Lera Elvoé 2024-01-17 10:55:54 +03:00
parent 67d90d164f
commit 84ecb41684
No known key found for this signature in database
2 changed files with 17 additions and 6 deletions

View file

@ -25,8 +25,20 @@ func rebuild_variable_tree(data: Dictionary = {}) -> void:
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])]
add_item(i, data[i])
func add_item(item_name: String, item_value: Variant, parent: TreeItem = root) -> TreeItem:
var item := variable_tree.create_item(parent)
item.set_text(0, item_name)
item.set_text(1, str(item_value))
var type: DeckType.Types = DeckType.INVERSE_GODOT_TYPES_MAP[typeof(item_value)]
item.set_text(2, DeckType.type_str(type))
if item_value is Dictionary:
for i in item_value:
add_item(i, item_value[i], item)
if item_value is Array:
for i in (item_value as Array).size():
add_item(str(i), item_value[i], item)
item.collapsed = true
return item

View file

@ -22,5 +22,4 @@ size_flags_vertical = 3
columns = 3
column_titles_visible = true
allow_search = false
hide_folding = true
hide_root = true