add range cell for numeric values

This commit is contained in:
Lera Elvoé 2024-01-17 12:45:23 +03:00
parent 84ecb41684
commit 7f263b45fb
No known key found for this signature in database

View file

@ -31,8 +31,16 @@ func rebuild_variable_tree(data: Dictionary = {}) -> void:
func add_item(item_name: String, item_value: Variant, parent: TreeItem = root) -> TreeItem: func add_item(item_name: String, item_value: Variant, parent: TreeItem = root) -> TreeItem:
var item := variable_tree.create_item(parent) var item := variable_tree.create_item(parent)
item.set_text(0, item_name) 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)] var type: DeckType.Types = DeckType.INVERSE_GODOT_TYPES_MAP[typeof(item_value)]
match type:
DeckType.Types.NUMERIC:
item.set_cell_mode(1, TreeItem.CELL_MODE_RANGE)
item.set_range(1, item_value)
item.set_range_config(1, -9999, 9999, 0.0001)
_:
item.set_text(1, str(item_value))
item.set_text(2, DeckType.type_str(type)) item.set_text(2, DeckType.type_str(type))
if item_value is Dictionary: if item_value is Dictionary:
for i in item_value: for i in item_value:
@ -41,4 +49,5 @@ func add_item(item_name: String, item_value: Variant, parent: TreeItem = root) -
for i in (item_value as Array).size(): for i in (item_value as Array).size():
add_item(str(i), item_value[i], item) add_item(str(i), item_value[i], item)
item.collapsed = true item.collapsed = true
return item return item