No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Project.gd 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. tool
  2. extends Panel
  3. signal tree_built # used for debugging
  4. const Todo := preload("res://addons/Todo_Manager/todo_class.gd")
  5. var sort_alphabetical := true
  6. onready var tree := $Tree as Tree
  7. func build_tree(todo_items : Array, ignore_paths : Array, patterns : Array, sort_alphabetical : bool, full_path : bool) -> void:
  8. tree.clear()
  9. if sort_alphabetical:
  10. todo_items.sort_custom(self, "sort_alphabetical")
  11. else:
  12. todo_items.sort_custom(self, "sort_backwards")
  13. var root := tree.create_item()
  14. root.set_text(0, "Scripts")
  15. for todo_item in todo_items:
  16. var ignore := false
  17. for ignore_path in ignore_paths:
  18. var script_path : String = todo_item.script_path
  19. if script_path.begins_with(ignore_path) or script_path.begins_with("res://" + ignore_path) or script_path.begins_with("res:///" + ignore_path):
  20. ignore = true
  21. break
  22. if ignore:
  23. continue
  24. var script := tree.create_item(root)
  25. if full_path:
  26. script.set_text(0, todo_item.script_path + " -------")
  27. else:
  28. script.set_text(0, todo_item.get_short_path() + " -------")
  29. script.set_metadata(0, todo_item)
  30. for todo in todo_item.todos:
  31. var item := tree.create_item(script)
  32. var content_header : String = todo.content
  33. if "\n" in todo.content:
  34. content_header = content_header.split("\n")[0] + "..."
  35. item.set_text(0, "(%0) - %1".format([todo.line_number, content_header], "%_"))
  36. item.set_tooltip(0, todo.content)
  37. item.set_metadata(0, todo)
  38. for pattern in patterns:
  39. if pattern[0] == todo.pattern:
  40. item.set_custom_color(0, pattern[1])
  41. emit_signal("tree_built")
  42. func sort_alphabetical(a, b) -> bool:
  43. if a.script_path > b.script_path:
  44. return true
  45. else:
  46. return false
  47. func sort_backwards(a, b) -> bool:
  48. if a.script_path < b.script_path:
  49. return true
  50. else:
  51. return false