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