fix inspector and variable viewer not clearing in some cases when there are no decks (#172)

Reviewed-on: https://codeberg.org/StreamGraph/StreamGraph/pulls/172
Co-authored-by: Lera Elvoé <yagich@poto.cafe>
Co-committed-by: Lera Elvoé <yagich@poto.cafe>
This commit is contained in:
Lera Elvoé 2024-07-28 11:23:59 +00:00 committed by yagich
parent 616c185abf
commit b5cd7336a4
4 changed files with 10 additions and 1 deletions

View file

@ -13,5 +13,5 @@ func _ready() -> void:
set_tab_title(i, tab_names[i])
func rebuild_variable_tree(data: Dictionary) -> void:
func rebuild_variable_tree(data: Dictionary = {}) -> void:
variable_viewer.rebuild_variable_tree(data)

View file

@ -315,6 +315,8 @@ func close_tab(tab: int) -> void:
tab_container.close_tab(tab)
if tab_container.get_tab_count() == 0:
bottom_dock.variable_viewer.disable_new_button()
bottom_dock.rebuild_variable_tree()
sidebar.clear_node_list()
sidebar.set_edited_deck()

View file

@ -88,6 +88,11 @@ func refresh_node_list(_unused = null) -> void:
node_list_menu.add_child(hb)
func clear_node_list() -> void:
for i in node_list_menu.get_children():
i.queue_free()
#func _set_button_text(new_text: String, button: Button) -> void:
# this was also bad. "Cannot convert argument 2 from Object to Object" 🙃
#button.text = "\"%s\"" % new_text

View file

@ -145,6 +145,8 @@ func add_item(item_name: String, item_value: Variant, parent: TreeItem = root, c
set_item_value(item, item_value)
# TODO: TreeItem has a barely-documented quirk that can make the RANGE cell mode
# into a dropdown if the item text is comma-separated values, so use that
item.set_text(2, DeckType.type_str(type))
item.set_metadata(2, type)
if item_value is Dictionary: