resource_preloader_editor_plugin.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*************************************************************************/
  2. /* resource_preloader_editor_plugin.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2019 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 RESOURCE_PRELOADER_EDITOR_PLUGIN_H
  31. #define RESOURCE_PRELOADER_EDITOR_PLUGIN_H
  32. #include "editor/editor_node.h"
  33. #include "editor/editor_plugin.h"
  34. #include "scene/gui/dialogs.h"
  35. #include "scene/gui/file_dialog.h"
  36. #include "scene/gui/tree.h"
  37. #include "scene/main/resource_preloader.h"
  38. class ResourcePreloaderEditor : public PanelContainer {
  39. GDCLASS(ResourcePreloaderEditor, PanelContainer);
  40. enum {
  41. BUTTON_OPEN_SCENE,
  42. BUTTON_EDIT_RESOURCE,
  43. BUTTON_REMOVE
  44. };
  45. Button *load;
  46. Button *paste;
  47. Tree *tree;
  48. bool loading_scene;
  49. EditorFileDialog *file;
  50. AcceptDialog *dialog;
  51. ResourcePreloader *preloader;
  52. void _load_pressed();
  53. void _load_scene_pressed();
  54. void _files_load_request(const Vector<String> &p_paths);
  55. void _paste_pressed();
  56. void _remove_resource(const String &p_to_remove);
  57. void _update_library();
  58. void _cell_button_pressed(Object *p_item, int p_column, int p_id);
  59. void _item_edited();
  60. UndoRedo *undo_redo;
  61. Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
  62. bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
  63. void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
  64. protected:
  65. void _notification(int p_what);
  66. void _gui_input(Ref<InputEvent> p_event);
  67. static void _bind_methods();
  68. public:
  69. void set_undo_redo(UndoRedo *p_undo_redo) { undo_redo = p_undo_redo; }
  70. void edit(ResourcePreloader *p_preloader);
  71. ResourcePreloaderEditor();
  72. };
  73. class ResourcePreloaderEditorPlugin : public EditorPlugin {
  74. GDCLASS(ResourcePreloaderEditorPlugin, EditorPlugin);
  75. ResourcePreloaderEditor *preloader_editor;
  76. EditorNode *editor;
  77. Button *button;
  78. public:
  79. virtual String get_name() const { return "ResourcePreloader"; }
  80. bool has_main_screen() const { return false; }
  81. virtual void edit(Object *p_object);
  82. virtual bool handles(Object *p_object) const;
  83. virtual void make_visible(bool p_visible);
  84. ResourcePreloaderEditorPlugin(EditorNode *p_node);
  85. ~ResourcePreloaderEditorPlugin();
  86. };
  87. #endif // RESOURCE_PRELOADER_EDITOR_PLUGIN_H