Added property lists. Renamed FileAdapter to FileSystemAdapter. And more smaller stuff.
68 lines
2.0 KiB
GDScript
68 lines
2.0 KiB
GDScript
extends Node
|
|
|
|
class_name GDBUIUtility
|
|
|
|
static func uncollapse_tree_item(tree_item : TreeItem):
|
|
while tree_item:
|
|
tree_item.collapsed = false
|
|
tree_item = tree_item.get_parent()
|
|
|
|
static func find_scene_tree_editor(root : Node = null) -> Node:
|
|
if not root:
|
|
root = (Engine.get_main_loop() as SceneTree).root
|
|
if root.get_class() == "SceneTreeEditor":
|
|
return root
|
|
for child in root.get_children():
|
|
var scene_tree_editor := find_scene_tree_editor(child)
|
|
if scene_tree_editor:
|
|
return scene_tree_editor
|
|
return null
|
|
|
|
static func new_item_sorted(tree : Tree, parent : TreeItem, key : String, meta_column := 0) -> TreeItem:
|
|
var item := parent.get_children()
|
|
var found_itm : TreeItem
|
|
var idx := 0
|
|
while true:
|
|
if item == null:
|
|
break
|
|
|
|
var itm_key := item.get_metadata(meta_column) as String
|
|
if itm_key == key:
|
|
return item
|
|
elif itm_key > key:
|
|
break
|
|
item = item.get_next()
|
|
idx += 1
|
|
|
|
# not found
|
|
var new_itm : TreeItem = tree.create_item(parent, idx)
|
|
new_itm.set_metadata(meta_column, key)
|
|
return new_itm
|
|
|
|
static func find_tree_item_with_meta(root : TreeItem, value, column := 0) -> TreeItem:
|
|
if root == null:
|
|
return null
|
|
elif root.get_metadata(column) == value:
|
|
return root
|
|
else:
|
|
var itm := find_tree_item_with_meta(root.get_next(), value, column)
|
|
if itm != null:
|
|
return itm
|
|
itm = find_tree_item_with_meta(root.get_children(), value, column)
|
|
return itm
|
|
|
|
static func copy_size(target : Control, source : Control) -> void:
|
|
target.rect_min_size = source.rect_min_size
|
|
target.rect_size = source.rect_size
|
|
target.size_flags_horizontal = source.size_flags_horizontal
|
|
target.size_flags_vertical = source.size_flags_vertical
|
|
target.size_flags_stretch_ratio = source.size_flags_stretch_ratio
|
|
target.anchor_top = source.anchor_top
|
|
target.anchor_bottom = source.anchor_bottom
|
|
target.anchor_left = source.anchor_left
|
|
target.anchor_right = source.anchor_right
|
|
target.margin_top = source.margin_top
|
|
target.margin_bottom = source.margin_bottom
|
|
target.margin_left = source.margin_left
|
|
target.margin_right = source.margin_right
|