Debian Codegraph @

editor/editor_interface.h

raw symbols SCIP
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 #pragma once
32
33 #include "core/io/resource.h"
34 #include "core/object/class_db.h"
35 #include "core/object/object.h"
36 #include "core/object/script_language.h"
37
38 class Control;
39 class CreateDialog;
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 EditorToaster;
49 class EditorUndoRedoManager;
50 class FileSystemDock;
51 class Mesh;
52 class Node;
53 class PropertySelector;
54 class SceneTreeDialog;
55 class ScriptEditor;
56 class SubViewport;
57 class Texture2D;
58 class Theme;
59 class VBoxContainer;
60 class Window;
61
62 class EditorInterface : public Object {
63 GDCLASS(EditorInterface, Object);
64
65 static EditorInterface *singleton;
66
67 // Editor dialogs.
68
69 PropertySelector *property_selector = nullptr;
70 PropertySelector *method_selector = nullptr;
71 SceneTreeDialog *node_selector = nullptr;
72 CreateDialog *create_dialog = nullptr;
73
74 void _node_selected(const NodePath &p_node_paths, const Callable &p_callback);
75 void _property_selected(const String &p_property_name, const Callable &p_callback);
76 void _method_selected(const String &p_property_name, const Callable &p_callback);
77 void _quick_open(const String &p_file_path, const Callable &p_callback);
78 void _create_dialog_item_selected(bool p_is_canceled, const Callable &p_callback);
79 void _call_dialog_callback(const Callable &p_callback, const Variant &p_selected, const String &p_context);
80
81 // Editor tools.
82
83 TypedArray<Texture2D> _make_mesh_previews(const TypedArray<Mesh> &p_meshes, int p_preview_size);
84 AABB _calculate_aabb_for_scene(Node *p_node, AABB &p_scene_aabb);
85
86 protected:
87 static void _bind_methods();
88
89 #ifndef DISABLE_DEPRECATED
90 void _popup_node_selector_bind_compat_94323(const Callable &p_callback, const TypedArray<StringName> &p_valid_types = TypedArray<StringName>());
91 void _popup_property_selector_bind_compat_94323(Object *p_object, const Callable &p_callback, const PackedInt32Array &p_type_filter = PackedInt32Array());
92 void _open_scene_from_path_bind_compat_90057(const String &scene_path);
93 static void _bind_compatibility_methods();
94 #endif
95
96 public:
97 static EditorInterface *get_singleton() { return singleton; }
98
99 void restart_editor(bool p_save = true);
100
101 // Editor tools.
102
103 EditorCommandPalette *get_command_palette() const;
104 EditorFileSystem *get_resource_filesystem() const;
105 EditorPaths *get_editor_paths() const;
106 EditorResourcePreview *get_resource_previewer() const;
107 EditorSelection *get_selection() const;
108 Ref<EditorSettings> get_editor_settings() const;
109 EditorToaster *get_editor_toaster() const;
110 EditorUndoRedoManager *get_editor_undo_redo() const;
111
112 Vector<Ref<Texture2D>> make_mesh_previews(const Vector<Ref<Mesh>> &p_meshes, Vector<Transform3D> *p_transforms, int p_preview_size);
113 void make_scene_preview(const String &p_path, Node *p_scene, int p_preview_size);
114
115 void set_plugin_enabled(const String &p_plugin, bool p_enabled);
116 bool is_plugin_enabled(const String &p_plugin) const;
117
118 // Editor GUI.
119
120 Ref<Theme> get_editor_theme() const;
121
122 Control *get_base_control() const;
123 VBoxContainer *get_editor_main_screen() const;
124 ScriptEditor *get_script_editor() const;
125 SubViewport *get_editor_viewport_2d() const;
126 SubViewport *get_editor_viewport_3d(int p_idx = 0) const;
127
128 void set_main_screen_editor(const String &p_name);
129 void set_distraction_free_mode(bool p_enter);
130 bool is_distraction_free_mode_enabled() const;
131 bool is_multi_window_enabled() const;
132
133 float get_editor_scale() const;
134 String get_editor_language() const;
135
136 bool is_node_3d_snap_enabled() const;
137 real_t get_node_3d_translate_snap() const;
138 real_t get_node_3d_rotate_snap() const;
139 real_t get_node_3d_scale_snap() const;
140
141 void popup_dialog(Window *p_dialog, const Rect2i &p_screen_rect = Rect2i());
142 void popup_dialog_centered(Window *p_dialog, const Size2i &p_minsize = Size2i());
143 void popup_dialog_centered_ratio(Window *p_dialog, float p_ratio = 0.8);
144 void popup_dialog_centered_clamped(Window *p_dialog, const Size2i &p_size = Size2i(), float p_fallback_ratio = 0.75);
145
146 String get_current_feature_profile() const;
147 void set_current_feature_profile(const String &p_profile_name);
148
149 // Editor dialogs.
150
151 void popup_node_selector(const Callable &p_callback, const TypedArray<StringName> &p_valid_types = TypedArray<StringName>(), Node *p_current_value = nullptr);
152 // Must use Vector<int> because exposing Vector<Variant::Type> is not supported.
153 void popup_property_selector(Object *p_object, const Callable &p_callback, const PackedInt32Array &p_type_filter = PackedInt32Array(), const String &p_current_value = String());
154 void popup_method_selector(Object *p_object, const Callable &p_callback, const String &p_current_value = String());
155 void popup_quick_open(const Callable &p_callback, const TypedArray<StringName> &p_base_types = TypedArray<StringName>());
156 void popup_create_dialog(const Callable &p_callback, const StringName &p_base_type = "", const String &p_current_type = "", const String &p_dialog_title = "", const TypedArray<StringName> &p_custom_type_blocklist = TypedArray<StringName>());
157
158 // Editor docks.
159
160 FileSystemDock *get_file_system_dock() const;
161 void select_file(const String &p_file);
162 Vector<String> get_selected_paths() const;
163 String get_current_path() const;
164 String get_current_directory() const;
165
166 EditorInspector *get_inspector() const;
167
168 // Object/Resource/Node editing.
169
170 void inspect_object(Object *p_obj, const String &p_for_property = String(), bool p_inspector_only = false);
171
172 void edit_resource(const Ref<Resource> &p_resource);
173 void edit_node(Node *p_node);
174 void edit_script(const Ref<Script> &p_script, int p_line = -1, int p_col = 0, bool p_grab_focus = true);
175 void open_scene_from_path(const String &scene_path, bool p_set_inherited = false);
176 void reload_scene_from_path(const String &scene_path);
177
178 void set_object_edited(Object *p_object, bool p_edited);
179 bool is_object_edited(Object *p_object) const;
180
181 PackedStringArray get_open_scenes() const;
182 TypedArray<Node> get_open_scene_roots() const;
183 Node *get_edited_scene_root() const;
184
185 void add_root_node(Node *p_node);
186
187 Error save_scene();
188 void save_scene_as(const String &p_scene, bool p_with_preview = true);
189 void mark_scene_as_unsaved();
190 void save_all_scenes();
191 Error close_scene();
192
193 // Scene playback.
194
195 void play_main_scene();
196 void play_current_scene();
197 void play_custom_scene(const String &scene_path);
198 void stop_playing_scene();
199 bool is_playing_scene() const;
200 String get_playing_scene() const;
201
202 void set_movie_maker_enabled(bool p_enabled);
203 bool is_movie_maker_enabled() const;
204
205 virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override;
206
207 // Base.
208 static void create();
209 static void free();
210
211 EditorInterface();
212 };