resource_preloader_editor_plugin.h 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  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. #pragma once
  31. #include "editor/plugins/editor_plugin.h"
  32. #include "scene/gui/dialogs.h"
  33. #include "scene/gui/panel_container.h"
  34. #include "scene/gui/tree.h"
  35. #include "scene/main/resource_preloader.h"
  36. class EditorFileDialog;
  37. class ResourcePreloaderEditor : public PanelContainer {
  38. GDCLASS(ResourcePreloaderEditor, PanelContainer);
  39. enum {
  40. BUTTON_OPEN_SCENE,
  41. BUTTON_EDIT_RESOURCE,
  42. BUTTON_REMOVE
  43. };
  44. Button *load = nullptr;
  45. Button *paste = nullptr;
  46. Tree *tree = nullptr;
  47. bool loading_scene;
  48. EditorFileDialog *file = nullptr;
  49. AcceptDialog *dialog = nullptr;
  50. ResourcePreloader *preloader = nullptr;
  51. void _load_pressed();
  52. void _files_load_request(const Vector<String> &p_paths);
  53. void _paste_pressed();
  54. void _remove_resource(const String &p_to_remove);
  55. void _update_library();
  56. void _cell_button_pressed(Object *p_item, int p_column, int p_id, MouseButton p_button);
  57. void _item_edited();
  58. Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
  59. bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
  60. void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
  61. protected:
  62. void _notification(int p_what);
  63. static void _bind_methods();
  64. public:
  65. void edit(ResourcePreloader *p_preloader);
  66. ResourcePreloaderEditor();
  67. };
  68. class ResourcePreloaderEditorPlugin : public EditorPlugin {
  69. GDCLASS(ResourcePreloaderEditorPlugin, EditorPlugin);
  70. ResourcePreloaderEditor *preloader_editor = nullptr;
  71. Button *button = nullptr;
  72. public:
  73. virtual String get_plugin_name() const override { return "ResourcePreloader"; }
  74. bool has_main_screen() const override { return false; }
  75. virtual void edit(Object *p_object) override;
  76. virtual bool handles(Object *p_object) const override;
  77. virtual void make_visible(bool p_visible) override;
  78. ResourcePreloaderEditorPlugin();
  79. };