1 /*************************************************************************/
2 /*  editor_node.h                                                        */
3 /*************************************************************************/
4 /*                       This file is part of:                           */
5 /*                           GODOT ENGINE                                */
6 /*                      https://godotengine.org                          */
7 /*************************************************************************/
8 /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur.                 */
9 /* Copyright (c) 2014-2020 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 
31 #ifndef EDITOR_NODE_H
32 #define EDITOR_NODE_H
33 
34 #include "editor/editor_data.h"
35 #include "editor/editor_folding.h"
36 #include "editor/editor_run.h"
37 #include "editor/inspector_dock.h"
38 #include "editor/property_editor.h"
39 #include "editor/scene_tree_dock.h"
40 
41 typedef void (*EditorNodeInitCallback)();
42 typedef void (*EditorPluginInitializeCallback)();
43 typedef bool (*EditorBuildCallback)();
44 
45 class AcceptDialog;
46 class AudioStreamPreviewGenerator;
47 class BackgroundProgress;
48 class CenterContainer;
49 class ConfirmationDialog;
50 class Control;
51 class DependencyEditor;
52 class DependencyErrorDialog;
53 class EditorAbout;
54 class EditorExport;
55 class EditorFeatureProfileManager;
56 class EditorFileServer;
57 class EditorInspector;
58 class EditorLayoutsDialog;
59 class EditorLog;
60 class EditorPlugin;
61 class EditorPluginList;
62 class EditorQuickOpen;
63 class EditorResourcePreview;
64 class EditorRunNative;
65 class EditorSettingsDialog;
66 class ExportTemplateManager;
67 class FileSystemDock;
68 class HSplitContainer;
69 class ImportDock;
70 class MenuButton;
71 class NodeDock;
72 class OrphanResourcesDialog;
73 class PaneDrag;
74 class Panel;
75 class PanelContainer;
76 class PluginConfigDialog;
77 class ProgressDialog;
78 class ProjectExportDialog;
79 class ProjectSettingsEditor;
80 class RunSettingsDialog;
81 class ScriptCreateDialog;
82 class TabContainer;
83 class Tabs;
84 class TextureProgress;
85 class ToolButton;
86 class VSplitContainer;
87 
88 class EditorNode : public Node {
89 
90 	GDCLASS(EditorNode, Node);
91 
92 public:
93 	enum DockSlot {
94 		DOCK_SLOT_LEFT_UL,
95 		DOCK_SLOT_LEFT_BL,
96 		DOCK_SLOT_LEFT_UR,
97 		DOCK_SLOT_LEFT_BR,
98 		DOCK_SLOT_RIGHT_UL,
99 		DOCK_SLOT_RIGHT_BL,
100 		DOCK_SLOT_RIGHT_UR,
101 		DOCK_SLOT_RIGHT_BR,
102 		DOCK_SLOT_MAX
103 	};
104 
105 	struct ExecuteThreadArgs {
106 		String path;
107 		List<String> args;
108 		String output;
109 		Thread *execute_output_thread;
110 		Mutex *execute_output_mutex;
111 		int exitcode;
112 		volatile bool done;
113 	};
114 
115 private:
116 	enum {
117 		HISTORY_SIZE = 64
118 	};
119 
120 	enum MenuOptions {
121 		FILE_NEW_SCENE,
122 		FILE_NEW_INHERITED_SCENE,
123 		FILE_OPEN_SCENE,
124 		FILE_SAVE_SCENE,
125 		FILE_SAVE_AS_SCENE,
126 		FILE_SAVE_ALL_SCENES,
127 		FILE_SAVE_BEFORE_RUN,
128 		FILE_SAVE_AND_RUN,
129 		FILE_SHOW_IN_FILESYSTEM,
130 		FILE_IMPORT_SUBSCENE,
131 		FILE_EXPORT_PROJECT,
132 		FILE_EXPORT_MESH_LIBRARY,
133 		FILE_INSTALL_ANDROID_SOURCE,
134 		FILE_EXPLORE_ANDROID_BUILD_TEMPLATES,
135 		FILE_EXPORT_TILESET,
136 		FILE_SAVE_OPTIMIZED,
137 		FILE_OPEN_RECENT,
138 		FILE_OPEN_OLD_SCENE,
139 		FILE_QUICK_OPEN,
140 		FILE_QUICK_OPEN_SCENE,
141 		FILE_QUICK_OPEN_SCRIPT,
142 		FILE_OPEN_PREV,
143 		FILE_CLOSE,
144 		FILE_CLOSE_OTHERS,
145 		FILE_CLOSE_RIGHT,
146 		FILE_CLOSE_ALL,
147 		FILE_CLOSE_ALL_AND_QUIT,
148 		FILE_CLOSE_ALL_AND_RUN_PROJECT_MANAGER,
149 		FILE_QUIT,
150 		FILE_EXTERNAL_OPEN_SCENE,
151 		EDIT_UNDO,
152 		EDIT_REDO,
153 		EDIT_RELOAD_SAVED_SCENE,
154 		TOOLS_ORPHAN_RESOURCES,
155 		TOOLS_CUSTOM,
156 		RESOURCE_SAVE,
157 		RESOURCE_SAVE_AS,
158 		RUN_PLAY,
159 
160 		RUN_STOP,
161 		RUN_PLAY_SCENE,
162 		RUN_PLAY_NATIVE,
163 		RUN_PLAY_CUSTOM_SCENE,
164 		RUN_SCENE_SETTINGS,
165 		RUN_SETTINGS,
166 		RUN_PROJECT_DATA_FOLDER,
167 		RUN_PROJECT_MANAGER,
168 		RUN_FILE_SERVER,
169 		RUN_LIVE_DEBUG,
170 		RUN_DEBUG_COLLISONS,
171 		RUN_DEBUG_NAVIGATION,
172 		RUN_DEPLOY_REMOTE_DEBUG,
173 		RUN_RELOAD_SCRIPTS,
174 		RUN_VCS_SETTINGS,
175 		RUN_VCS_SHUT_DOWN,
176 		SETTINGS_UPDATE_CONTINUOUSLY,
177 		SETTINGS_UPDATE_WHEN_CHANGED,
178 		SETTINGS_UPDATE_ALWAYS,
179 		SETTINGS_UPDATE_CHANGES,
180 		SETTINGS_UPDATE_SPINNER_HIDE,
181 		SETTINGS_PREFERENCES,
182 		SETTINGS_LAYOUT_SAVE,
183 		SETTINGS_LAYOUT_DELETE,
184 		SETTINGS_LAYOUT_DEFAULT,
185 		SETTINGS_EDITOR_DATA_FOLDER,
186 		SETTINGS_EDITOR_CONFIG_FOLDER,
187 		SETTINGS_MANAGE_EXPORT_TEMPLATES,
188 		SETTINGS_MANAGE_FEATURE_PROFILES,
189 		SETTINGS_PICK_MAIN_SCENE,
190 		SETTINGS_TOGGLE_CONSOLE,
191 		SETTINGS_TOGGLE_FULLSCREEN,
192 		SETTINGS_HELP,
193 		SCENE_TAB_CLOSE,
194 
195 		EDITOR_SCREENSHOT,
196 		EDITOR_OPEN_SCREENSHOT,
197 
198 		HELP_SEARCH,
199 		HELP_DOCS,
200 		HELP_QA,
201 		HELP_REPORT_A_BUG,
202 		HELP_SEND_DOCS_FEEDBACK,
203 		HELP_COMMUNITY,
204 		HELP_ABOUT,
205 
206 		SET_VIDEO_DRIVER_SAVE_AND_RESTART,
207 
208 		GLOBAL_NEW_WINDOW,
209 		GLOBAL_SCENE,
210 
211 		IMPORT_PLUGIN_BASE = 100,
212 
213 		TOOL_MENU_BASE = 1000
214 	};
215 
216 	Viewport *scene_root; //root of the scene being edited
217 
218 	PanelContainer *scene_root_parent;
219 	Control *theme_base;
220 	Control *gui_base;
221 	VBoxContainer *main_vbox;
222 	OptionButton *video_driver;
223 
224 	ConfirmationDialog *video_restart_dialog;
225 
226 	int video_driver_current;
227 	String video_driver_request;
228 	void _video_driver_selected(int);
229 	void _update_video_driver_color();
230 
231 	// Split containers
232 
233 	HSplitContainer *left_l_hsplit;
234 	VSplitContainer *left_l_vsplit;
235 	HSplitContainer *left_r_hsplit;
236 	VSplitContainer *left_r_vsplit;
237 	HSplitContainer *main_hsplit;
238 	HSplitContainer *right_hsplit;
239 	VSplitContainer *right_l_vsplit;
240 	VSplitContainer *right_r_vsplit;
241 
242 	VSplitContainer *center_split;
243 
244 	// To access those easily by index
245 	Vector<VSplitContainer *> vsplits;
246 	Vector<HSplitContainer *> hsplits;
247 
248 	// Main tabs
249 
250 	Tabs *scene_tabs;
251 	PopupMenu *scene_tabs_context_menu;
252 	Panel *tab_preview_panel;
253 	TextureRect *tab_preview;
254 	int tab_closing;
255 
256 	bool exiting;
257 	bool dimmed;
258 
259 	int old_split_ofs;
260 	VSplitContainer *top_split;
261 	HBoxContainer *bottom_hb;
262 	Control *vp_base;
263 	PaneDrag *pd;
264 
265 	HBoxContainer *menu_hb;
266 	Control *viewport;
267 	MenuButton *file_menu;
268 	MenuButton *project_menu;
269 	MenuButton *debug_menu;
270 	MenuButton *settings_menu;
271 	MenuButton *help_menu;
272 	PopupMenu *tool_menu;
273 	ToolButton *export_button;
274 	ToolButton *prev_scene;
275 	ToolButton *play_button;
276 	ToolButton *pause_button;
277 	ToolButton *stop_button;
278 	ToolButton *run_settings_button;
279 	ToolButton *play_scene_button;
280 	ToolButton *play_custom_scene_button;
281 	ToolButton *search_button;
282 	TextureProgress *audio_vu;
283 
284 	Timer *screenshot_timer;
285 
286 	PluginConfigDialog *plugin_config_dialog;
287 
288 	RichTextLabel *load_errors;
289 	AcceptDialog *load_error_dialog;
290 
291 	RichTextLabel *execute_outputs;
292 	AcceptDialog *execute_output_dialog;
293 
294 	Ref<Theme> theme;
295 
296 	PopupMenu *recent_scenes;
297 	SceneTreeDock *scene_tree_dock;
298 	InspectorDock *inspector_dock;
299 	NodeDock *node_dock;
300 	ImportDock *import_dock;
301 	FileSystemDock *filesystem_dock;
302 	EditorRunNative *run_native;
303 
304 	ConfirmationDialog *confirmation;
305 	ConfirmationDialog *save_confirmation;
306 	ConfirmationDialog *import_confirmation;
307 	ConfirmationDialog *pick_main_scene;
308 	AcceptDialog *accept;
309 	EditorAbout *about;
310 	AcceptDialog *warning;
311 
312 	int overridden_default_layout;
313 	Ref<ConfigFile> default_layout;
314 	PopupMenu *editor_layouts;
315 	EditorLayoutsDialog *layout_dialog;
316 
317 	ConfirmationDialog *custom_build_manage_templates;
318 	ConfirmationDialog *install_android_build_template;
319 	ConfirmationDialog *remove_android_build_template;
320 
321 	EditorSettingsDialog *settings_config_dialog;
322 	RunSettingsDialog *run_settings_dialog;
323 	ProjectSettingsEditor *project_settings;
324 	PopupMenu *vcs_actions_menu;
325 	EditorFileDialog *file;
326 	ExportTemplateManager *export_template_manager;
327 	EditorFeatureProfileManager *feature_profile_manager;
328 	EditorFileDialog *file_templates;
329 	EditorFileDialog *file_export_lib;
330 	EditorFileDialog *file_script;
331 	CheckBox *file_export_lib_merge;
332 	String current_path;
333 	MenuButton *update_spinner;
334 
335 	String defer_load_scene;
336 	Node *_last_instanced_scene;
337 
338 	EditorLog *log;
339 	CenterContainer *tabs_center;
340 	EditorQuickOpen *quick_open;
341 	EditorQuickOpen *quick_run;
342 
343 	HBoxContainer *main_editor_button_vb;
344 	Vector<ToolButton *> main_editor_buttons;
345 	Vector<EditorPlugin *> editor_table;
346 
347 	AudioStreamPreviewGenerator *preview_gen;
348 	ProgressDialog *progress_dialog;
349 	BackgroundProgress *progress_hb;
350 
351 	DependencyErrorDialog *dependency_error;
352 	DependencyEditor *dependency_fixer;
353 	OrphanResourcesDialog *orphan_resources;
354 	ConfirmationDialog *open_imported;
355 	Button *new_inherited_button;
356 	String open_import_request;
357 
358 	TabContainer *dock_slot[DOCK_SLOT_MAX];
359 	Rect2 dock_select_rect[DOCK_SLOT_MAX];
360 	int dock_select_rect_over;
361 	PopupPanel *dock_select_popup;
362 	Control *dock_select;
363 	ToolButton *dock_tab_move_left;
364 	ToolButton *dock_tab_move_right;
365 	int dock_popup_selected;
366 	Timer *dock_drag_timer;
367 	bool docks_visible;
368 
369 	HBoxContainer *tabbar_container;
370 	ToolButton *distraction_free;
371 	ToolButton *scene_tab_add;
372 
373 	bool scene_distraction;
374 	bool script_distraction;
375 
376 	String _tmp_import_path;
377 
378 	EditorExport *editor_export;
379 
380 	Object *current;
381 	Ref<Resource> saving_resource;
382 
383 	bool _playing_edited;
384 	String run_custom_filename;
385 	bool reference_resource_mem;
386 	bool save_external_resources_mem;
387 	uint64_t saved_version;
388 	uint64_t last_checked_version;
389 	bool unsaved_cache;
390 	String open_navigate;
391 	bool changing_scene;
392 	bool waiting_for_first_scan;
393 
394 	bool waiting_for_sources_changed;
395 
396 	uint32_t update_spinner_step_msec;
397 	uint64_t update_spinner_step_frame;
398 	int update_spinner_step;
399 
400 	Vector<EditorPlugin *> editor_plugins;
401 	EditorPlugin *editor_plugin_screen;
402 	EditorPluginList *editor_plugins_over;
403 	EditorPluginList *editor_plugins_force_over;
404 	EditorPluginList *editor_plugins_force_input_forwarding;
405 
406 	EditorHistory editor_history;
407 	EditorData editor_data;
408 	EditorRun editor_run;
409 	EditorSelection *editor_selection;
410 	ProjectExportDialog *project_export;
411 	EditorResourcePreview *resource_preview;
412 	EditorFolding editor_folding;
413 
414 	EditorFileServer *file_server;
415 
416 	struct BottomPanelItem {
417 		String name;
418 		Control *control;
419 		ToolButton *button;
420 	};
421 
422 	Vector<BottomPanelItem> bottom_panel_items;
423 
424 	PanelContainer *bottom_panel;
425 	HBoxContainer *bottom_panel_hb;
426 	HBoxContainer *bottom_panel_hb_editors;
427 	VBoxContainer *bottom_panel_vb;
428 	Label *version_label;
429 	ToolButton *bottom_panel_raise;
430 
431 	void _bottom_panel_raise_toggled(bool);
432 
433 	EditorInterface *editor_interface;
434 
435 	void _bottom_panel_switch(bool p_enable, int p_idx);
436 
437 	String external_file;
438 	List<String> previous_scenes;
439 	bool opening_prev;
440 
441 	void _dialog_action(String p_file);
442 
443 	void _edit_current();
444 	void _dialog_display_save_error(String p_file, Error p_error);
445 	void _dialog_display_load_error(String p_file, Error p_error);
446 
447 	int current_option;
448 	void _menu_option(int p_option);
449 	void _menu_confirm_current();
450 	void _menu_option_confirm(int p_option, bool p_confirmed);
451 
452 	void _request_screenshot();
453 	void _screenshot(bool p_use_utc = false);
454 	void _save_screenshot(NodePath p_path);
455 
456 	void _tool_menu_option(int p_idx);
457 	void _update_debug_options();
458 	void _update_file_menu_opened();
459 	void _update_file_menu_closed();
460 
461 	void _on_plugin_ready(Object *p_script, const String &p_activate_name);
462 
463 	void _fs_changed();
464 	void _resources_reimported(const Vector<String> &p_resources);
465 	void _sources_changed(bool p_exist);
466 
467 	void _node_renamed();
468 	void _editor_select_next();
469 	void _editor_select_prev();
470 	void _editor_select(int p_which);
471 	void _set_scene_metadata(const String &p_file, int p_idx = -1);
472 	void _get_scene_metadata(const String &p_file);
473 	void _update_title();
474 	void _update_scene_tabs();
475 	void _version_control_menu_option(int p_idx);
476 	void _close_messages();
477 	void _show_messages();
478 	void _vp_resized();
479 
480 	int _save_external_resources();
481 
482 	bool _validate_scene_recursive(const String &p_filename, Node *p_node);
483 	void _save_scene(String p_file, int idx = -1);
484 	void _save_all_scenes();
485 	int _next_unsaved_scene(bool p_valid_filename, int p_start = 0);
486 	void _discard_changes(const String &p_str = String());
487 
488 	void _inherit_request(String p_file);
489 	void _instance_request(const Vector<String> &p_files);
490 
491 	void _display_top_editors(bool p_display);
492 	void _set_top_editors(Vector<EditorPlugin *> p_editor_plugins_over);
493 	void _set_editing_top_editors(Object *p_current_object);
494 
495 	void _quick_opened();
496 	void _quick_run();
497 
498 	void _run(bool p_current = false, const String &p_custom = "");
499 
500 	void _save_optimized();
501 	void _import_action(const String &p_action);
502 	void _import(const String &p_file);
503 	void _add_to_recent_scenes(const String &p_scene);
504 	void _update_recent_scenes();
505 	void _open_recent_scene(int p_idx);
506 	void _global_menu_action(const Variant &p_id, const Variant &p_meta);
507 	void _dropped_files(const Vector<String> &p_files, int p_screen);
508 	void _add_dropped_files_recursive(const Vector<String> &p_files, String to_path);
509 	String _recent_scene;
510 
511 	void _exit_editor();
512 
513 	bool convert_old;
514 
515 	void _unhandled_input(const Ref<InputEvent> &p_event);
516 
517 	static void _load_error_notify(void *p_ud, const String &p_text);
518 
has_main_screen()519 	bool has_main_screen() const { return true; }
520 
521 	String import_reload_fn;
522 
523 	Set<FileDialog *> file_dialogs;
524 	Set<EditorFileDialog *> editor_file_dialogs;
525 
526 	Map<String, Ref<Texture> > icon_type_cache;
527 	void _build_icon_type_cache();
528 
529 	bool _initializing_addons;
530 	Map<String, EditorPlugin *> plugin_addons;
531 
532 	static Ref<Texture> _file_dialog_get_icon(const String &p_path);
533 	static void _file_dialog_register(FileDialog *p_dialog);
534 	static void _file_dialog_unregister(FileDialog *p_dialog);
535 	static void _editor_file_dialog_register(EditorFileDialog *p_dialog);
536 	static void _editor_file_dialog_unregister(EditorFileDialog *p_dialog);
537 
538 	void _cleanup_scene();
539 	void _remove_edited_scene(bool p_change_tab = true);
540 	void _remove_scene(int index, bool p_change_tab = true);
541 	bool _find_and_save_resource(RES p_res, Map<RES, bool> &processed, int32_t flags);
542 	bool _find_and_save_edited_subresources(Object *obj, Map<RES, bool> &processed, int32_t flags);
543 	void _save_edited_subresources(Node *scene, Map<RES, bool> &processed, int32_t flags);
544 	void _mark_unsaved_scenes();
545 
546 	void _find_node_types(Node *p_node, int &count_2d, int &count_3d);
547 	void _save_scene_with_preview(String p_file, int p_idx = -1);
548 
549 	Map<String, Set<String> > dependency_errors;
550 
_dependency_error_report(void * ud,const String & p_path,const String & p_dep,const String & p_type)551 	static void _dependency_error_report(void *ud, const String &p_path, const String &p_dep, const String &p_type) {
552 		EditorNode *en = (EditorNode *)ud;
553 		if (!en->dependency_errors.has(p_path))
554 			en->dependency_errors[p_path] = Set<String>();
555 		en->dependency_errors[p_path].insert(p_dep + "::" + p_type);
556 	}
557 
558 	struct ExportDefer {
559 		String preset;
560 		String path;
561 		bool debug;
562 		bool pack_only;
563 	} export_defer;
564 
565 	bool cmdline_export_mode;
566 
567 	static EditorNode *singleton;
568 
569 	static Vector<EditorNodeInitCallback> _init_callbacks;
570 
571 	bool _find_scene_in_use(Node *p_node, const String &p_path) const;
572 
573 	void _dock_select_input(const Ref<InputEvent> &p_input);
574 	void _dock_move_left();
575 	void _dock_move_right();
576 	void _dock_select_draw();
577 	void _dock_pre_popup(int p_which);
578 	void _dock_split_dragged(int ofs);
579 	void _dock_popup_exit();
580 	void _scene_tab_changed(int p_tab);
581 	void _scene_tab_closed(int p_tab, int option = SCENE_TAB_CLOSE);
582 	void _scene_tab_hover(int p_tab);
583 	void _scene_tab_exit();
584 	void _scene_tab_input(const Ref<InputEvent> &p_input);
585 	void _reposition_active_tab(int idx_to);
586 	void _thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, const Variant &p_udata);
587 	void _scene_tab_script_edited(int p_tab);
588 
589 	Dictionary _get_main_scene_state();
590 	void _set_main_scene_state(Dictionary p_state, Node *p_for_scene);
591 
592 	int _get_current_main_editor();
593 
594 	void _save_docks();
595 	void _load_docks();
596 	void _save_docks_to_config(Ref<ConfigFile> p_layout, const String &p_section);
597 	void _load_docks_from_config(Ref<ConfigFile> p_layout, const String &p_section);
598 	void _update_dock_slots_visibility();
599 	void _dock_tab_changed(int p_tab);
600 
601 	bool restoring_scenes;
602 	void _save_open_scenes_to_config(Ref<ConfigFile> p_layout, const String &p_section);
603 	void _load_open_scenes_from_config(Ref<ConfigFile> p_layout, const String &p_section);
604 
605 	void _update_layouts_menu();
606 	void _layout_menu_option(int p_id);
607 
608 	void _clear_undo_history();
609 
610 	void _update_addon_config();
611 
612 	static void _file_access_close_error_notify(const String &p_str);
613 
614 	void _toggle_distraction_free_mode();
615 
616 	enum {
617 		MAX_INIT_CALLBACKS = 128,
618 		MAX_BUILD_CALLBACKS = 128
619 	};
620 
621 	void _inherit_imported(const String &p_action);
622 	void _open_imported();
623 
624 	static int plugin_init_callback_count;
625 	static EditorPluginInitializeCallback plugin_init_callbacks[MAX_INIT_CALLBACKS];
626 	void _save_default_environment();
627 
628 	static int build_callback_count;
629 	static EditorBuildCallback build_callbacks[MAX_BUILD_CALLBACKS];
630 
631 	void _license_tree_selected();
632 
633 	void _update_update_spinner();
634 
635 	Vector<Ref<EditorResourceConversionPlugin> > resource_conversion_plugins;
636 
637 	PrintHandlerList print_handler;
638 	static void _print_handler(void *p_this, const String &p_string, bool p_error);
639 
640 	static void _resource_saved(RES p_resource, const String &p_path);
641 	static void _resource_loaded(RES p_resource, const String &p_path);
642 
643 	void _resources_changed(const PoolVector<String> &p_resources);
644 
645 	void _feature_profile_changed();
646 	bool _is_class_editor_disabled_by_feature_profile(const StringName &p_class);
647 	Ref<ImageTexture> _load_custom_class_icon(const String &p_path) const;
648 
649 protected:
650 	void _notification(int p_what);
651 
652 	static void _bind_methods();
653 
654 protected:
655 	friend class FileSystemDock;
656 
657 	int get_current_tab();
658 	void set_current_tab(int p_tab);
659 
660 public:
661 	bool call_build();
662 
663 	static void add_plugin_init_callback(EditorPluginInitializeCallback p_callback);
664 
665 	enum EditorTable {
666 		EDITOR_2D = 0,
667 		EDITOR_3D,
668 		EDITOR_SCRIPT,
669 		EDITOR_ASSETLIB
670 	};
671 
set_visible_editor(EditorTable p_table)672 	void set_visible_editor(EditorTable p_table) { _editor_select(p_table); }
get_singleton()673 	static EditorNode *get_singleton() { return singleton; }
674 
get_editor_plugin_screen()675 	EditorPlugin *get_editor_plugin_screen() { return editor_plugin_screen; }
get_editor_plugins_over()676 	EditorPluginList *get_editor_plugins_over() { return editor_plugins_over; }
get_editor_plugins_force_over()677 	EditorPluginList *get_editor_plugins_force_over() { return editor_plugins_force_over; }
get_editor_plugins_force_input_forwarding()678 	EditorPluginList *get_editor_plugins_force_input_forwarding() { return editor_plugins_force_input_forwarding; }
get_inspector()679 	EditorInspector *get_inspector() { return inspector_dock->get_inspector(); }
get_inspector_dock_addon_area()680 	Container *get_inspector_dock_addon_area() { return inspector_dock->get_addon_area(); }
get_script_create_dialog()681 	ScriptCreateDialog *get_script_create_dialog() { return scene_tree_dock->get_script_create_dialog(); }
682 
get_project_settings()683 	ProjectSettingsEditor *get_project_settings() { return project_settings; }
684 
685 	static void add_editor_plugin(EditorPlugin *p_editor, bool p_config_changed = false);
686 	static void remove_editor_plugin(EditorPlugin *p_editor, bool p_config_changed = false);
687 
688 	static void disambiguate_filenames(const Vector<String> p_full_paths, Vector<String> &r_filenames);
689 
new_inherited_scene()690 	void new_inherited_scene() { _menu_option_confirm(FILE_NEW_INHERITED_SCENE, false); }
691 
692 	void set_docks_visible(bool p_show);
693 	bool get_docks_visible() const;
694 
695 	void set_distraction_free_mode(bool p_enter);
696 	bool is_distraction_free_mode_enabled() const;
697 
698 	void add_control_to_dock(DockSlot p_slot, Control *p_control);
699 	void remove_control_from_dock(Control *p_control);
700 
701 	void set_addon_plugin_enabled(const String &p_addon, bool p_enabled, bool p_config_changed = false);
702 	bool is_addon_plugin_enabled(const String &p_addon) const;
703 
704 	void edit_node(Node *p_node);
edit_resource(const Ref<Resource> & p_resource)705 	void edit_resource(const Ref<Resource> &p_resource) { inspector_dock->edit_resource(p_resource); };
open_resource(const String & p_type)706 	void open_resource(const String &p_type) { inspector_dock->open_resource(p_type); };
707 
708 	void save_resource_in_path(const Ref<Resource> &p_resource, const String &p_path);
709 	void save_resource(const Ref<Resource> &p_resource);
710 	void save_resource_as(const Ref<Resource> &p_resource, const String &p_at_path = String());
711 
merge_from_scene()712 	void merge_from_scene() { _menu_option_confirm(FILE_IMPORT_SUBSCENE, false); }
713 
show_about()714 	void show_about() { _menu_option_confirm(HELP_ABOUT, false); }
715 
has_unsaved_changes()716 	static bool has_unsaved_changes() { return singleton->unsaved_cache; }
717 
get_menu_hb()718 	static HBoxContainer *get_menu_hb() { return singleton->menu_hb; }
719 
720 	void push_item(Object *p_object, const String &p_property = "", bool p_inspector_only = false);
721 	void edit_item(Object *p_object);
722 	void edit_item_resource(RES p_resource);
723 	bool item_has_editor(Object *p_object);
724 	void hide_top_editors();
725 
726 	void select_editor_by_name(const String &p_name);
727 
728 	void open_request(const String &p_path);
729 
730 	bool is_changing_scene() const;
731 
get_log()732 	static EditorLog *get_log() { return singleton->log; }
733 	Control *get_viewport();
734 
735 	void set_edited_scene(Node *p_scene);
736 
get_edited_scene()737 	Node *get_edited_scene() { return editor_data.get_edited_scene_root(); }
738 
get_scene_root()739 	Viewport *get_scene_root() { return scene_root; } //root of the scene being edited
740 
741 	void fix_dependencies(const String &p_for_file);
clear_scene()742 	void clear_scene() { _cleanup_scene(); }
743 	int new_scene();
744 	Error load_scene(const String &p_scene, bool p_ignore_broken_deps = false, bool p_set_inherited = false, bool p_clear_errors = true, bool p_force_open_imported = false);
745 	Error load_resource(const String &p_resource, bool p_ignore_broken_deps = false);
746 
747 	bool is_scene_open(const String &p_path);
748 
749 	void set_current_version(uint64_t p_version);
750 	void set_current_scene(int p_idx);
751 
get_editor_data()752 	static EditorData &get_editor_data() { return singleton->editor_data; }
get_editor_folding()753 	static EditorFolding &get_editor_folding() { return singleton->editor_folding; }
get_editor_history()754 	EditorHistory *get_editor_history() { return &editor_history; }
755 
get_top_split()756 	static VSplitContainer *get_top_split() { return singleton->top_split; }
757 
758 	void request_instance_scene(const String &p_path);
759 	void request_instance_scenes(const Vector<String> &p_files);
760 	FileSystemDock *get_filesystem_dock();
761 	ImportDock *get_import_dock();
762 	SceneTreeDock *get_scene_tree_dock();
763 	InspectorDock *get_inspector_dock();
get_undo_redo()764 	static UndoRedo *get_undo_redo() { return &singleton->editor_data.get_undo_redo(); }
765 
get_editor_selection()766 	EditorSelection *get_editor_selection() { return editor_selection; }
767 
set_convert_old_scene(bool p_old)768 	void set_convert_old_scene(bool p_old) { convert_old = p_old; }
769 
770 	void notify_child_process_exited();
771 
get_child_process_id()772 	OS::ProcessID get_child_process_id() const { return editor_run.get_pid(); }
773 	void stop_child_process();
774 
get_editor_theme()775 	Ref<Theme> get_editor_theme() const { return theme; }
776 	Ref<Script> get_object_custom_type_base(const Object *p_object) const;
777 	StringName get_object_custom_type_name(const Object *p_object) const;
778 	Ref<Texture> get_object_icon(const Object *p_object, const String &p_fallback = "Object") const;
779 	Ref<Texture> get_class_icon(const String &p_class, const String &p_fallback = "Object") const;
780 
781 	void show_accept(const String &p_text, const String &p_title);
782 	void show_warning(const String &p_text, const String &p_title = TTR("Warning!"));
783 
784 	void _copy_warning(const String &p_str);
785 
786 	Error export_preset(const String &p_preset, const String &p_path, bool p_debug, bool p_pack_only);
787 
788 	static void register_editor_types();
789 	static void unregister_editor_types();
790 
get_gui_base()791 	Control *get_gui_base() { return gui_base; }
get_theme_base()792 	Control *get_theme_base() { return gui_base->get_parent_control(); }
793 
794 	static void add_io_error(const String &p_error);
795 
796 	static void progress_add_task(const String &p_task, const String &p_label, int p_steps, bool p_can_cancel = false);
797 	static bool progress_task_step(const String &p_task, const String &p_state, int p_step = -1, bool p_force_refresh = true);
798 	static void progress_end_task(const String &p_task);
799 
800 	static void progress_add_task_bg(const String &p_task, const String &p_label, int p_steps);
801 	static void progress_task_step_bg(const String &p_task, int p_step = -1);
802 	static void progress_end_task_bg(const String &p_task);
803 
804 	void save_scene_to_path(String p_file, bool p_with_preview = true) {
805 		if (p_with_preview)
806 			_save_scene_with_preview(p_file);
807 		else
808 			_save_scene(p_file);
809 	}
810 
811 	bool is_scene_in_use(const String &p_path);
812 
813 	void scan_import_changes();
814 
815 	void save_layout();
816 
817 	void open_export_template_manager();
818 
819 	void reload_scene(const String &p_path);
820 
is_exiting()821 	bool is_exiting() const { return exiting; }
822 
get_pause_button()823 	ToolButton *get_pause_button() { return pause_button; }
824 
825 	ToolButton *add_bottom_panel_item(String p_text, Control *p_item);
826 	bool are_bottom_panels_hidden() const;
827 	void make_bottom_panel_item_visible(Control *p_item);
828 	void raise_bottom_panel_item(Control *p_item);
829 	void hide_bottom_panel();
830 	void remove_bottom_panel_item(Control *p_item);
831 
832 	Variant drag_resource(const Ref<Resource> &p_res, Control *p_from);
833 	Variant drag_files_and_dirs(const Vector<String> &p_paths, Control *p_from);
834 
835 	void add_tool_menu_item(const String &p_name, Object *p_handler, const String &p_callback, const Variant &p_ud = Variant());
836 	void add_tool_submenu_item(const String &p_name, PopupMenu *p_submenu);
837 	void remove_tool_menu_item(const String &p_name);
838 
839 	void save_all_scenes();
840 	void save_scene_list(Vector<String> p_scene_filenames);
841 	void restart_editor();
842 
843 	void dim_editor(bool p_dimming, bool p_force_dim = false);
844 	bool is_editor_dimmed() const;
845 
edit_current()846 	void edit_current() { _edit_current(); };
847 
update_keying()848 	void update_keying() const { inspector_dock->update_keying(); };
849 	bool has_scenes_in_session();
850 
851 	int execute_and_show_output(const String &p_title, const String &p_path, const List<String> &p_arguments, bool p_close_on_ok = true, bool p_close_on_errors = false);
852 
853 	EditorNode();
854 	~EditorNode();
855 	void get_singleton(const char *arg1, bool arg2);
856 
857 	void add_resource_conversion_plugin(const Ref<EditorResourceConversionPlugin> &p_plugin);
858 	void remove_resource_conversion_plugin(const Ref<EditorResourceConversionPlugin> &p_plugin);
859 	Vector<Ref<EditorResourceConversionPlugin> > find_resource_conversion_plugin(const Ref<Resource> &p_for_resource);
860 
add_init_callback(EditorNodeInitCallback p_callback)861 	static void add_init_callback(EditorNodeInitCallback p_callback) { _init_callbacks.push_back(p_callback); }
862 	static void add_build_callback(EditorBuildCallback p_callback);
863 
864 	bool ensure_main_scene(bool p_from_native);
865 
866 	void run_play();
867 	void run_play_current();
868 	void run_play_custom(const String &p_custom);
869 	void run_stop();
870 	bool is_run_playing() const;
871 	String get_run_playing_scene() const;
872 };
873 
874 struct EditorProgress {
875 
876 	String task;
877 	bool step(const String &p_state, int p_step = -1, bool p_force_refresh = true) { return EditorNode::progress_task_step(task, p_state, p_step, p_force_refresh); }
878 	EditorProgress(const String &p_task, const String &p_label, int p_amount, bool p_can_cancel = false) {
879 		EditorNode::progress_add_task(p_task, p_label, p_amount, p_can_cancel);
880 		task = p_task;
881 	}
~EditorProgressEditorProgress882 	~EditorProgress() { EditorNode::progress_end_task(task); }
883 };
884 
885 class EditorPluginList : public Object {
886 private:
887 	Vector<EditorPlugin *> plugins_list;
888 
889 public:
set_plugins_list(Vector<EditorPlugin * > p_plugins_list)890 	void set_plugins_list(Vector<EditorPlugin *> p_plugins_list) {
891 		plugins_list = p_plugins_list;
892 	}
893 
get_plugins_list()894 	Vector<EditorPlugin *> &get_plugins_list() {
895 		return plugins_list;
896 	}
897 
898 	void make_visible(bool p_visible);
899 	void edit(Object *p_object);
900 	bool forward_gui_input(const Ref<InputEvent> &p_event);
901 	void forward_canvas_draw_over_viewport(Control *p_overlay);
902 	void forward_canvas_force_draw_over_viewport(Control *p_overlay);
903 	bool forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event, bool serve_when_force_input_enabled);
904 	void forward_spatial_draw_over_viewport(Control *p_overlay);
905 	void forward_spatial_force_draw_over_viewport(Control *p_overlay);
906 	void add_plugin(EditorPlugin *p_plugin);
907 	void remove_plugin(EditorPlugin *p_plugin);
908 	void clear();
909 	bool empty();
910 
911 	EditorPluginList();
912 	~EditorPluginList();
913 };
914 
915 struct EditorProgressBG {
916 
917 	String task;
918 	void step(int p_step = -1) { EditorNode::progress_task_step_bg(task, p_step); }
EditorProgressBGEditorProgressBG919 	EditorProgressBG(const String &p_task, const String &p_label, int p_amount) {
920 		EditorNode::progress_add_task_bg(p_task, p_label, p_amount);
921 		task = p_task;
922 	}
~EditorProgressBGEditorProgressBG923 	~EditorProgressBG() { EditorNode::progress_end_task_bg(task); }
924 };
925 
926 #endif // EDITOR_NODE_H
927