dependency_editor.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /*************************************************************************/
  2. /* dependency_editor.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #ifndef DEPENDENCY_EDITOR_H
  31. #define DEPENDENCY_EDITOR_H
  32. #include "editor_file_dialog.h"
  33. #include "scene/gui/dialogs.h"
  34. #include "scene/gui/tab_container.h"
  35. #include "scene/gui/tree.h"
  36. class EditorFileSystemDirectory;
  37. class DependencyEditor : public AcceptDialog {
  38. GDCLASS(DependencyEditor, AcceptDialog);
  39. Tree *tree;
  40. Button *fixdeps;
  41. EditorFileDialog *search;
  42. String replacing;
  43. String editing;
  44. List<String> missing;
  45. void _fix_and_find(EditorFileSystemDirectory *efsd, Map<String, Map<String, String> > &candidates);
  46. void _searched(const String &p_path);
  47. void _load_pressed(Object *p_item, int p_cell, int p_button);
  48. void _fix_all();
  49. void _update_list();
  50. void _update_file();
  51. protected:
  52. static void _bind_methods();
  53. void _notification(int p_what);
  54. public:
  55. void edit(const String &p_path);
  56. DependencyEditor();
  57. };
  58. class DependencyEditorOwners : public AcceptDialog {
  59. GDCLASS(DependencyEditorOwners, AcceptDialog);
  60. ItemList *owners;
  61. String editing;
  62. void _fill_owners(EditorFileSystemDirectory *efsd);
  63. public:
  64. void show(const String &p_path);
  65. DependencyEditorOwners();
  66. };
  67. class DependencyRemoveDialog : public ConfirmationDialog {
  68. GDCLASS(DependencyRemoveDialog, ConfirmationDialog);
  69. Label *text;
  70. Tree *owners;
  71. Map<String, String> all_remove_files;
  72. Vector<String> to_delete;
  73. struct RemovedDependency {
  74. String file;
  75. String file_type;
  76. String dependency;
  77. String dependency_folder;
  78. bool operator<(const RemovedDependency &p_other) const {
  79. if (dependency_folder.empty() != p_other.dependency_folder.empty()) {
  80. return p_other.dependency_folder.empty();
  81. } else {
  82. return dependency < p_other.dependency;
  83. }
  84. }
  85. };
  86. void _find_files_in_removed_folder(EditorFileSystemDirectory *efsd, const String &p_folder);
  87. void _find_all_removed_dependencies(EditorFileSystemDirectory *efsd, Vector<RemovedDependency> &p_removed);
  88. void _build_removed_dependency_tree(const Vector<RemovedDependency> &p_removed);
  89. void ok_pressed();
  90. public:
  91. void show(const Vector<String> &p_folders, const Vector<String> &p_files);
  92. DependencyRemoveDialog();
  93. };
  94. class DependencyErrorDialog : public ConfirmationDialog {
  95. GDCLASS(DependencyErrorDialog, ConfirmationDialog);
  96. String for_file;
  97. Button *fdep;
  98. Label *text;
  99. Tree *files;
  100. void ok_pressed();
  101. void custom_action(const String &);
  102. public:
  103. void show(const String &p_for_file, const Vector<String> &report);
  104. DependencyErrorDialog();
  105. };
  106. class OrphanResourcesDialog : public ConfirmationDialog {
  107. GDCLASS(OrphanResourcesDialog, ConfirmationDialog);
  108. DependencyEditor *dep_edit;
  109. Tree *files;
  110. ConfirmationDialog *delete_confirm;
  111. void ok_pressed();
  112. bool _fill_owners(EditorFileSystemDirectory *efsd, HashMap<String, int> &refs, TreeItem *p_parent);
  113. List<String> paths;
  114. void _find_to_delete(TreeItem *p_item, List<String> &paths);
  115. void _delete_confirm();
  116. void _button_pressed(Object *p_item, int p_column, int p_id);
  117. void refresh();
  118. static void _bind_methods();
  119. public:
  120. void show();
  121. OrphanResourcesDialog();
  122. };
  123. #endif // DEPENDENCY_EDITOR_H