editor_interface.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /**************************************************************************/
  2. /* editor_interface.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. #ifndef EDITOR_INTERFACE_H
  31. #define EDITOR_INTERFACE_H
  32. #include "core/io/resource.h"
  33. #include "core/object/class_db.h"
  34. #include "core/object/object.h"
  35. #include "core/object/script_language.h"
  36. class Control;
  37. class EditorCommandPalette;
  38. class EditorFileSystem;
  39. class EditorInspector;
  40. class EditorPaths;
  41. class EditorPlugin;
  42. class EditorResourcePreview;
  43. class EditorSelection;
  44. class EditorSettings;
  45. class FileSystemDock;
  46. class Mesh;
  47. class Node;
  48. class ScriptEditor;
  49. class Texture2D;
  50. class VBoxContainer;
  51. class Window;
  52. class EditorInterface : public Object {
  53. GDCLASS(EditorInterface, Object);
  54. static EditorInterface *singleton;
  55. // Editor tools.
  56. TypedArray<Texture2D> _make_mesh_previews(const TypedArray<Mesh> &p_meshes, int p_preview_size);
  57. protected:
  58. static void _bind_methods();
  59. public:
  60. static EditorInterface *get_singleton() { return singleton; }
  61. void restart_editor(bool p_save = true);
  62. // Editor tools.
  63. EditorCommandPalette *get_command_palette() const;
  64. EditorFileSystem *get_resource_file_system() const;
  65. EditorPaths *get_editor_paths() const;
  66. EditorResourcePreview *get_resource_previewer() const;
  67. EditorSelection *get_selection() const;
  68. Ref<EditorSettings> get_editor_settings() const;
  69. Vector<Ref<Texture2D>> make_mesh_previews(const Vector<Ref<Mesh>> &p_meshes, Vector<Transform3D> *p_transforms, int p_preview_size);
  70. void set_plugin_enabled(const String &p_plugin, bool p_enabled);
  71. bool is_plugin_enabled(const String &p_plugin) const;
  72. void add_editor_plugin(EditorPlugin *p_plugin);
  73. void remove_editor_plugin(EditorPlugin *p_plugin);
  74. // Editor GUI.
  75. Control *get_base_control() const;
  76. VBoxContainer *get_editor_main_screen() const;
  77. ScriptEditor *get_script_editor() const;
  78. void set_main_screen_editor(const String &p_name);
  79. void set_distraction_free_mode(bool p_enter);
  80. bool is_distraction_free_mode_enabled() const;
  81. float get_editor_scale() const;
  82. void popup_dialog(Window *p_dialog, const Rect2i &p_screen_rect = Rect2i());
  83. void popup_dialog_centered(Window *p_dialog, const Size2i &p_minsize = Size2i());
  84. void popup_dialog_centered_ratio(Window *p_dialog, float p_ratio = 0.8);
  85. void popup_dialog_centered_clamped(Window *p_dialog, const Size2i &p_size = Size2i(), float p_fallback_ratio = 0.75);
  86. // Editor docks.
  87. FileSystemDock *get_file_system_dock() const;
  88. void select_file(const String &p_file);
  89. Vector<String> get_selected_paths() const;
  90. String get_current_path() const;
  91. String get_current_directory() const;
  92. EditorInspector *get_inspector() const;
  93. // Object/Resource/Node editing.
  94. void inspect_object(Object *p_obj, const String &p_for_property = String(), bool p_inspector_only = false);
  95. void edit_resource(const Ref<Resource> &p_resource);
  96. void edit_node(Node *p_node);
  97. void edit_script(const Ref<Script> &p_script, int p_line = -1, int p_col = 0, bool p_grab_focus = true);
  98. void open_scene_from_path(const String &scene_path);
  99. void reload_scene_from_path(const String &scene_path);
  100. PackedStringArray get_open_scenes() const;
  101. Node *get_edited_scene_root() const;
  102. Error save_scene();
  103. void save_scene_as(const String &p_scene, bool p_with_preview = true);
  104. void mark_scene_as_unsaved();
  105. // Scene playback.
  106. void play_main_scene();
  107. void play_current_scene();
  108. void play_custom_scene(const String &scene_path);
  109. void stop_playing_scene();
  110. bool is_playing_scene() const;
  111. String get_playing_scene() const;
  112. void set_movie_maker_enabled(bool p_enabled);
  113. bool is_movie_maker_enabled() const;
  114. // Base.
  115. static void create();
  116. static void free();
  117. EditorInterface();
  118. };
  119. #endif // EDITOR_INTERFACE_H