dependency_editor.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*************************************************************************/
  2. /* dependency_editor.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2020 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 EditorNode;
  38. class DependencyEditor : public AcceptDialog {
  39. OBJ_TYPE(DependencyEditor, AcceptDialog);
  40. Tree *tree;
  41. Button *fixdeps;
  42. EditorFileDialog *search;
  43. String replacing;
  44. String editing;
  45. List<String> missing;
  46. void _fix_and_find(EditorFileSystemDirectory *efsd, Map<String, Map<String, String> > &candidates);
  47. void _searched(const String &p_path);
  48. void _load_pressed(Object *p_item, int p_cell, int p_button);
  49. void _fix_all();
  50. void _update_list();
  51. void _update_file();
  52. protected:
  53. static void _bind_methods();
  54. void _notification(int p_what);
  55. public:
  56. void edit(const String &p_path);
  57. DependencyEditor();
  58. };
  59. class DependencyEditorOwners : public AcceptDialog {
  60. OBJ_TYPE(DependencyEditorOwners, AcceptDialog);
  61. ItemList *owners;
  62. PopupMenu *file_options;
  63. EditorNode *editor;
  64. String editing;
  65. void _fill_owners(EditorFileSystemDirectory *efsd);
  66. static void _bind_methods();
  67. void _list_rmb_select(int p_item, const Vector2 &p_pos);
  68. void _select_file(int p_idx);
  69. void _file_option(int p_option);
  70. private:
  71. enum FileMenu {
  72. FILE_OPEN
  73. };
  74. public:
  75. void show(const String &p_path);
  76. DependencyEditorOwners(EditorNode *p_editor);
  77. };
  78. class DependencyRemoveDialog : public ConfirmationDialog {
  79. OBJ_TYPE(DependencyRemoveDialog, ConfirmationDialog);
  80. Label *text;
  81. Tree *owners;
  82. bool exist;
  83. Map<String, TreeItem *> files;
  84. void _fill_owners(EditorFileSystemDirectory *efsd);
  85. void ok_pressed();
  86. public:
  87. void show(const Vector<String> &to_erase);
  88. DependencyRemoveDialog();
  89. };
  90. class DependencyErrorDialog : public ConfirmationDialog {
  91. OBJ_TYPE(DependencyErrorDialog, ConfirmationDialog);
  92. String for_file;
  93. Button *fdep;
  94. Label *text;
  95. Tree *files;
  96. void ok_pressed();
  97. void custom_action(const String &);
  98. public:
  99. void show(const String &p_for, const Vector<String> &report);
  100. DependencyErrorDialog();
  101. };
  102. class OrphanResourcesDialog : public ConfirmationDialog {
  103. OBJ_TYPE(OrphanResourcesDialog, ConfirmationDialog);
  104. DependencyEditor *dep_edit;
  105. Tree *files;
  106. ConfirmationDialog *delete_confirm;
  107. void ok_pressed();
  108. bool _fill_owners(EditorFileSystemDirectory *efsd, HashMap<String, int> &refs, TreeItem *p_parent);
  109. List<String> paths;
  110. void _find_to_delete(TreeItem *p_item, List<String> &paths);
  111. void _delete_confirm();
  112. void _button_pressed(Object *p_item, int p_column, int p_id);
  113. void refresh();
  114. static void _bind_methods();
  115. public:
  116. void show();
  117. OrphanResourcesDialog();
  118. };
  119. #endif // DEPENDENCY_EDITOR_H