1 /*************************************************************************/
2 /*  editor_node.h                                                        */
3 /*************************************************************************/
4 /*                       This file is part of:                           */
5 /*                           GODOT ENGINE                                */
6 /*                      https://godotengine.org                          */
7 /*************************************************************************/
8 /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur.                 */
9 /* Copyright (c) 2014-2019 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 #ifndef EDITOR_NODE_H
31 #define EDITOR_NODE_H
32 
33 #include "editor/call_dialog.h"
34 #include "editor/connections_dialog.h"
35 #include "editor/create_dialog.h"
36 #include "editor/editor_data.h"
37 #include "editor/editor_path.h"
38 #include "editor/editor_run.h"
39 #include "editor/filesystem_dock.h"
40 #include "editor/groups_editor.h"
41 #include "editor/node_dock.h"
42 #include "editor/property_editor.h"
43 #include "editor/reparent_dialog.h"
44 #include "editor/scene_tree_editor.h"
45 #include "editor/settings_config_dialog.h"
46 #include "scene/gui/center_container.h"
47 #include "scene/gui/control.h"
48 #include "scene/gui/dialogs.h"
49 #include "scene/gui/file_dialog.h"
50 #include "scene/gui/menu_button.h"
51 #include "scene/gui/panel.h"
52 #include "scene/gui/panel_container.h"
53 #include "scene/gui/separator.h"
54 #include "scene/gui/split_container.h"
55 #include "scene/gui/tab_container.h"
56 #include "scene/gui/texture_progress.h"
57 #include "scene/gui/tool_button.h"
58 #include "scene/gui/tree.h"
59 
60 #include "editor/pane_drag.h"
61 
62 #include "editor/editor_log.h"
63 #include "editor/editor_run_script.h"
64 #include "editor/project_export.h"
65 #include "editor/project_settings.h"
66 #include "editor/resources_dock.h"
67 #include "editor/run_settings_dialog.h"
68 #include "editor/scene_tree_dock.h"
69 #include "editor/script_create_dialog.h"
70 
71 #include "editor/editor_name_dialog.h"
72 #include "editor/editor_plugin.h"
73 #include "editor/editor_run_native.h"
74 #include "editor/editor_sub_scene.h"
75 #include "editor/project_export.h"
76 #include "editor/quick_open.h"
77 #include "editor_import_export.h"
78 #include "editor_reimport_dialog.h"
79 #include "scene/gui/tabs.h"
80 
81 #include "editor_resource_preview.h"
82 #include "fileserver/editor_file_server.h"
83 
84 #include "editor_export_godot3.h"
85 
86 #include "progress_dialog.h"
87 
88 #include "editor_scale.h"
89 /**
90 	@author Juan Linietsky <reduzio@gmail.com>
91 */
92 
93 typedef void (*EditorNodeInitCallback)();
94 
95 class EditorPluginList;
96 
97 class EditorNode : public Node {
98 
99 	OBJ_TYPE(EditorNode, Node);
100 
101 public:
102 	enum DockSlot {
103 		DOCK_SLOT_LEFT_UL,
104 		DOCK_SLOT_LEFT_BL,
105 		DOCK_SLOT_LEFT_UR,
106 		DOCK_SLOT_LEFT_BR,
107 		DOCK_SLOT_RIGHT_UL,
108 		DOCK_SLOT_RIGHT_BL,
109 		DOCK_SLOT_RIGHT_UR,
110 		DOCK_SLOT_RIGHT_BR,
111 		DOCK_SLOT_MAX
112 	};
113 
114 private:
115 	enum {
116 		HISTORY_SIZE = 64
117 	};
118 
119 	enum MenuOptions {
120 		FILE_NEW_SCENE,
121 		FILE_NEW_INHERITED_SCENE,
122 		FILE_OPEN_SCENE,
123 		FILE_SAVE_SCENE,
124 		FILE_SAVE_AS_SCENE,
125 		FILE_SAVE_ALL_SCENES,
126 		FILE_SAVE_BEFORE_RUN,
127 		FILE_SAVE_AND_RUN,
128 		FILE_IMPORT_SUBSCENE,
129 		FILE_EXPORT_PROJECT,
130 		FILE_EXPORT_MESH_LIBRARY,
131 		FILE_EXPORT_TILESET,
132 		FILE_SAVE_OPTIMIZED,
133 		FILE_DUMP_STRINGS,
134 		FILE_OPEN_RECENT,
135 		FILE_OPEN_OLD_SCENE,
136 		FILE_QUICK_OPEN_SCENE,
137 		FILE_QUICK_OPEN_SCRIPT,
138 		FILE_RUN_SCRIPT,
139 		FILE_OPEN_PREV,
140 		FILE_CLOSE,
141 		FILE_QUIT,
142 		FILE_EXTERNAL_OPEN_SCENE,
143 		EDIT_UNDO,
144 		EDIT_REDO,
145 		EDIT_REVERT,
146 		TOOLS_ORPHAN_RESOURCES,
147 		TOOLS_EXPORT_GODOT3,
148 		RESOURCE_NEW,
149 		RESOURCE_LOAD,
150 		RESOURCE_SAVE,
151 		RESOURCE_SAVE_AS,
152 		RESOURCE_UNREF,
153 		RESOURCE_COPY,
154 		RESOURCE_PASTE,
155 		OBJECT_COPY_PARAMS,
156 		OBJECT_PASTE_PARAMS,
157 		OBJECT_UNIQUE_RESOURCES,
158 		OBJECT_CALL_METHOD,
159 		OBJECT_REQUEST_HELP,
160 		RUN_PLAY,
161 
162 		RUN_STOP,
163 		RUN_PLAY_SCENE,
164 		RUN_PLAY_NATIVE,
165 		RUN_PLAY_CUSTOM_SCENE,
166 		RUN_SCENE_SETTINGS,
167 		RUN_SETTINGS,
168 		RUN_PROJECT_MANAGER,
169 		RUN_FILE_SERVER,
170 		//RUN_DEPLOY_DUMB_CLIENTS,
171 		RUN_LIVE_DEBUG,
172 		RUN_DEBUG_COLLISONS,
173 		RUN_DEBUG_NAVIGATION,
174 		RUN_DEPLOY_REMOTE_DEBUG,
175 		RUN_RELOAD_SCRIPTS,
176 		SETTINGS_UPDATE_ALWAYS,
177 		SETTINGS_UPDATE_CHANGES,
178 		SETTINGS_UPDATE_SPINNER_HIDE,
179 		SETTINGS_EXPORT_PREFERENCES,
180 		SETTINGS_PREFERENCES,
181 		SETTINGS_OPTIMIZED_PRESETS,
182 		SETTINGS_LAYOUT_SAVE,
183 		SETTINGS_LAYOUT_DELETE,
184 		SETTINGS_LAYOUT_DEFAULT,
185 		SETTINGS_LOAD_EXPORT_TEMPLATES,
186 		SETTINGS_PICK_MAIN_SCENE,
187 		SETTINGS_HELP,
188 		SETTINGS_ABOUT,
189 		SOURCES_REIMPORT,
190 		DEPENDENCY_LOAD_CHANGED_IMAGES,
191 		DEPENDENCY_UPDATE_IMPORTED,
192 		SCENE_TAB_CLOSE,
193 
194 		IMPORT_PLUGIN_BASE = 100,
195 
196 		OBJECT_METHOD_BASE = 500
197 	};
198 
199 	//Node *edited_scene; //scene being edited
200 	Viewport *scene_root; //root of the scene being edited
201 
202 	//Ref<ResourceImportMetadata> scene_import_metadata;
203 
204 	Control *scene_root_parent;
205 	Control *gui_base;
206 	VBoxContainer *main_vbox;
207 
208 	//split
209 
210 	HSplitContainer *left_l_hsplit;
211 	VSplitContainer *left_l_vsplit;
212 	HSplitContainer *left_r_hsplit;
213 	VSplitContainer *left_r_vsplit;
214 	HSplitContainer *main_hsplit;
215 	HSplitContainer *right_hsplit;
216 	VSplitContainer *right_l_vsplit;
217 	VSplitContainer *right_r_vsplit;
218 
219 	VSplitContainer *center_split;
220 
221 	//main tabs
222 
223 	Tabs *scene_tabs;
224 	int tab_closing;
225 
226 	bool exiting;
227 
228 	int old_split_ofs;
229 	VSplitContainer *top_split;
230 	HBoxContainer *bottom_hb;
231 	Control *vp_base;
232 	PaneDrag *pd;
233 	//PaneDrag *pd_anim;
234 	Panel *menu_panel;
235 
236 	//HSplitContainer *editor_hsplit;
237 	//VSplitContainer *editor_vsplit;
238 	CenterContainer *play_cc;
239 	HBoxContainer *menu_hb;
240 	Control *viewport;
241 	MenuButton *file_menu;
242 	MenuButton *import_menu;
243 	MenuButton *tool_menu;
244 	ToolButton *export_button;
245 	ToolButton *prev_scene;
246 	MenuButton *object_menu;
247 	MenuButton *settings_menu;
248 	ToolButton *play_button;
249 	MenuButton *native_play_button;
250 	ToolButton *pause_button;
251 	ToolButton *stop_button;
252 	ToolButton *run_settings_button;
253 	ToolButton *play_scene_button;
254 	ToolButton *play_custom_scene_button;
255 	MenuButton *debug_button;
256 	ToolButton *search_button;
257 	TextureProgress *audio_vu;
258 	//MenuButton *fileserver_menu;
259 
260 	RichTextLabel *load_errors;
261 	AcceptDialog *load_error_dialog;
262 
263 	//Control *scene_root_base;
264 	Ref<Theme> theme;
265 
266 	PopupMenu *recent_scenes;
267 	Button *property_back;
268 	Button *property_forward;
269 	SceneTreeDock *scene_tree_dock;
270 	//ResourcesDock *resources_dock;
271 	PropertyEditor *property_editor;
272 	NodeDock *node_dock;
273 	VBoxContainer *prop_editor_vb;
274 	FileSystemDock *filesystem_dock;
275 	EditorRunNative *run_native;
276 
277 	HBoxContainer *search_bar;
278 	LineEdit *search_box;
279 
280 	EditorExportGodot3 export_godot3;
281 	FileDialog *export_godot3_dialog;
282 	CheckButton *export_godot3_dialog_convert_scripts;
283 	CheckButton *export_godot3_dialog_mark_converted_lines;
284 
285 	CreateDialog *create_dialog;
286 
287 	CallDialog *call_dialog;
288 	ConfirmationDialog *confirmation;
289 	ConfirmationDialog *import_confirmation;
290 	ConfirmationDialog *open_recent_confirmation;
291 	ConfirmationDialog *pick_main_scene;
292 	AcceptDialog *accept;
293 	AcceptDialog *about;
294 	AcceptDialog *warning;
295 
296 	int overridden_default_layout;
297 	Ref<ConfigFile> default_layout;
298 	PopupMenu *editor_layouts;
299 	EditorNameDialog *layout_dialog;
300 
301 	//OptimizedPresetsDialog *optimized_presets;
302 	EditorSettingsDialog *settings_config_dialog;
303 	RunSettingsDialog *run_settings_dialog;
304 	ProjectSettings *project_settings;
305 	EditorFileDialog *file;
306 	FileDialog *file_templates;
307 	FileDialog *file_export;
308 	FileDialog *file_export_lib;
309 	FileDialog *file_script;
310 	CheckButton *file_export_lib_merge;
311 	LineEdit *file_export_password;
312 	String current_path;
313 	MenuButton *update_menu;
314 	ToolButton *sources_button;
315 	//TabContainer *prop_pallete;
316 	//TabContainer *top_pallete;
317 	String defer_load_scene;
318 	String defer_translatable;
319 	String defer_optimize;
320 	String defer_optimize_preset;
321 	String defer_export;
322 	String defer_export_platform;
323 	bool defer_export_debug;
324 	Node *_last_instanced_scene;
325 	EditorPath *editor_path;
326 	ToolButton *resource_new_button;
327 	ToolButton *resource_load_button;
328 	MenuButton *resource_save_button;
329 	MenuButton *editor_history_menu;
330 
331 	EditorLog *log;
332 	CenterContainer *tabs_center;
333 	EditorQuickOpen *quick_open;
334 	EditorQuickOpen *quick_run;
335 
336 	HBoxContainer *main_editor_button_vb;
337 	Vector<ToolButton *> main_editor_buttons;
338 	Vector<EditorPlugin *> editor_table;
339 
340 	EditorReImportDialog *reimport_dialog;
341 
342 	ProgressDialog *progress_dialog;
343 	BackgroundProgress *progress_hb;
344 
345 	DependencyErrorDialog *dependency_error;
346 	DependencyEditor *dependency_fixer;
347 	OrphanResourcesDialog *orphan_resources;
348 
349 	TabContainer *dock_slot[DOCK_SLOT_MAX];
350 	Rect2 dock_select_rect[DOCK_SLOT_MAX];
351 	int dock_select_rect_over;
352 	PopupPanel *dock_select_popoup;
353 	Control *dock_select;
354 	ToolButton *dock_tab_move_left;
355 	ToolButton *dock_tab_move_right;
356 	int dock_popup_selected;
357 	Timer *dock_drag_timer;
358 	bool docks_visible;
359 	bool distraction_free_mode;
360 
361 	String _tmp_import_path;
362 
363 	EditorImportExport *editor_import_export;
364 
365 	Object *current;
366 
367 	bool _playing_edited;
368 	String run_custom_filename;
369 	bool reference_resource_mem;
370 	bool save_external_resources_mem;
371 	uint64_t saved_version;
372 	uint64_t last_checked_version;
373 	bool unsaved_cache;
374 	String open_navigate;
375 	bool changing_scene;
376 
377 	bool waiting_for_sources_changed;
378 
379 	uint32_t circle_step_msec;
380 	uint64_t circle_step_frame;
381 	int circle_step;
382 
383 	Vector<EditorPlugin *> editor_plugins;
384 	EditorPlugin *editor_plugin_screen;
385 	EditorPluginList *editor_plugins_over;
386 
387 	EditorHistory editor_history;
388 	EditorData editor_data;
389 	EditorRun editor_run;
390 	EditorSelection *editor_selection;
391 	ProjectExport *project_export;
392 	ProjectExportDialog *project_export_settings;
393 	EditorResourcePreview *resource_preview;
394 
395 	EditorFileServer *file_server;
396 
397 	struct BottomPanelItem {
398 		String name;
399 		Control *control;
400 		ToolButton *button;
401 	};
402 
403 	Vector<BottomPanelItem> bottom_panel_items;
404 
405 	PanelContainer *bottom_panel;
406 	HBoxContainer *bottom_panel_hb;
407 	VBoxContainer *bottom_panel_vb;
408 
409 	void _bottom_panel_switch(bool p_enable, int p_idx);
410 
411 	String external_file;
412 	List<String> previous_scenes;
413 	bool opening_prev;
414 
415 	void _dialog_action(String p_file);
416 
417 	void _edit_current();
418 	void _dialog_display_file_error(String p_file, Error p_error);
419 
420 	int current_option;
421 	//void _animation_visibility_toggle();
422 	void _resource_created();
423 	void _resource_selected(const RES &p_res, const String &p_property = "");
424 	void _menu_option(int p_option);
425 	void _menu_confirm_current();
426 	void _menu_option_confirm(int p_option, bool p_confirmed);
427 
428 	void _property_editor_forward();
429 	void _property_editor_back();
430 
431 	void _select_history(int p_idx);
432 	void _prepare_history();
433 
434 	void _fs_changed();
435 	void _sources_changed(bool p_exist);
436 	void _imported(Node *p_node);
437 
438 	void _node_renamed();
439 	void _editor_select_next();
440 	void _editor_select_prev();
441 	void _editor_select(int p_which);
442 	void _set_scene_metadata(const String &p_file, int p_idx = -1);
443 	void _get_scene_metadata(const String &p_file);
444 	void _update_title();
445 	void _update_scene_tabs();
446 	void _close_messages();
447 	void _show_messages();
448 	void _vp_resized();
449 
450 	void _rebuild_import_menu();
451 
452 	void _save_scene(String p_file, int idx = -1);
453 
454 	void _instance_request(const Vector<String> &p_files);
455 
456 	void _property_keyed(const String &p_keyed, const Variant &p_value, bool p_advance);
457 	void _transform_keyed(Object *sp, const String &p_sub, const Transform &p_key);
458 
459 	void _hide_top_editors();
460 	void _display_top_editors(bool p_display);
461 	void _set_top_editors(Vector<EditorPlugin *> p_editor_plugins_over);
462 	void _set_editing_top_editors(Object *p_current_object);
463 
464 	void _quick_opened();
465 	void _quick_run();
466 
467 	void _run(bool p_current = false, const String &p_custom = "");
468 
469 	void _save_optimized();
470 	void _import_action(const String &p_action);
471 	void _import(const String &p_file);
472 	void _add_to_recent_scenes(const String &p_scene);
473 	void _update_recent_scenes();
474 	void _open_recent_scene(int p_idx);
475 	void _dropped_files(const Vector<String> &p_files, int p_screen);
476 	//void _open_recent_scene_confirm();
477 	String _recent_scene;
478 
479 	bool convert_old;
480 
481 	void _unhandled_input(const InputEvent &p_event);
482 
483 	static void _load_error_notify(void *p_ud, const String &p_text);
484 
has_main_screen()485 	bool has_main_screen() const { return true; }
486 	void _fetch_translatable_strings(const Object *p_object, Set<StringName> &strings);
487 
488 	bool _find_editing_changed_scene(Node *p_from);
489 
490 	String import_reload_fn;
491 
492 	Set<FileDialog *> file_dialogs;
493 	Set<EditorFileDialog *> editor_file_dialogs;
494 
495 	Map<String, Ref<Texture> > icon_type_cache;
496 
497 	bool _initializing_addons;
498 	Map<String, EditorPlugin *> plugin_addons;
499 
500 	static Ref<Texture> _file_dialog_get_icon(const String &p_path);
501 	static void _file_dialog_register(FileDialog *p_dialog);
502 	static void _file_dialog_unregister(FileDialog *p_dialog);
503 	static void _editor_file_dialog_register(EditorFileDialog *p_dialog);
504 	static void _editor_file_dialog_unregister(EditorFileDialog *p_dialog);
505 
506 	void _cleanup_scene();
507 	void _remove_edited_scene();
508 	void _remove_scene(int index);
509 	bool _find_and_save_resource(RES p_res, Map<RES, bool> &processed, int32_t flags);
510 	bool _find_and_save_edited_subresources(Object *obj, Map<RES, bool> &processed, int32_t flags);
511 	void _save_edited_subresources(Node *scene, Map<RES, bool> &processed, int32_t flags);
512 
513 	void _find_node_types(Node *p_node, int &count_2d, int &count_3d);
514 	void _save_scene_with_preview(String p_file);
515 
516 	Map<String, Set<String> > dependency_errors;
517 
_dependency_error_report(void * ud,const String & p_path,const String & p_dep,const String & p_type)518 	static void _dependency_error_report(void *ud, const String &p_path, const String &p_dep, const String &p_type) {
519 		EditorNode *en = (EditorNode *)ud;
520 		if (!en->dependency_errors.has(p_path))
521 			en->dependency_errors[p_path] = Set<String>();
522 		en->dependency_errors[p_path].insert(p_dep + "::" + p_type);
523 	}
524 
525 	struct ExportDefer {
526 		String platform;
527 		String path;
528 		bool debug;
529 		String password;
530 
531 	} export_defer;
532 
533 	static EditorNode *singleton;
534 
535 	static Vector<EditorNodeInitCallback> _init_callbacks;
536 
537 	bool _find_scene_in_use(Node *p_node, const String &p_path) const;
538 
539 	void _dock_select_input(const InputEvent &p_input);
540 	void _dock_move_left();
541 	void _dock_move_right();
542 	void _dock_select_draw();
543 	void _dock_pre_popup(int p_which);
544 	void _dock_split_dragged(int ofs);
545 	void _dock_popup_exit();
546 	void _scene_tab_changed(int p_tab);
547 	void _scene_tab_closed(int p_tab);
548 	void _scene_tab_script_edited(int p_tab);
549 
550 	Dictionary _get_main_scene_state();
551 	void _set_main_scene_state(Dictionary p_state, Node *p_for_scene);
552 
553 	int _get_current_main_editor();
554 
555 	void _save_docks();
556 	void _load_docks();
557 	void _save_docks_to_config(Ref<ConfigFile> p_layout, const String &p_section);
558 	void _load_docks_from_config(Ref<ConfigFile> p_layout, const String &p_section);
559 	void _update_dock_slots_visibility();
560 	void _update_top_menu_visibility();
561 
562 	void _update_layouts_menu();
563 	void _layout_menu_option(int p_idx);
564 
565 	void _toggle_search_bar(bool p_pressed);
566 	void _clear_search_box();
567 	void _clear_undo_history();
568 
569 	void _update_addon_config();
570 
571 	void _export_godot3_path(const String &p_path);
572 
573 	static void _file_access_close_error_notify(const String &p_str);
574 
575 protected:
576 	void _notification(int p_what);
577 	static void _bind_methods();
578 
579 public:
580 	enum EditorTable {
581 		EDITOR_2D = 0,
582 		EDITOR_3D,
583 		EDITOR_SCRIPT,
584 		EDITOR_ASSETLIB
585 	};
586 
set_visible_editor(EditorTable p_table)587 	void set_visible_editor(EditorTable p_table) { _editor_select(p_table); }
get_singleton()588 	static EditorNode *get_singleton() { return singleton; }
589 
get_editor_plugin_screen()590 	EditorPlugin *get_editor_plugin_screen() { return editor_plugin_screen; }
get_editor_plugins_over()591 	EditorPluginList *get_editor_plugins_over() { return editor_plugins_over; }
get_property_editor()592 	PropertyEditor *get_property_editor() { return property_editor; }
get_property_editor_vb()593 	VBoxContainer *get_property_editor_vb() { return prop_editor_vb; }
594 
595 	static void add_editor_plugin(EditorPlugin *p_editor);
596 	static void remove_editor_plugin(EditorPlugin *p_editor);
597 
new_inherited_scene()598 	void new_inherited_scene() { _menu_option_confirm(FILE_NEW_INHERITED_SCENE, false); }
599 
600 	void set_docks_visible(bool p_show);
601 	bool get_docks_visible() const;
602 
603 	void set_distraction_free_mode(bool p_enter);
604 	bool get_distraction_free_mode() const;
605 
606 	void add_control_to_dock(DockSlot p_slot, Control *p_control);
607 	void remove_control_from_dock(Control *p_control);
608 
609 	void add_editor_import_plugin(const Ref<EditorImportPlugin> &p_editor_import);
610 	void remove_editor_import_plugin(const Ref<EditorImportPlugin> &p_editor_import);
611 
612 	void set_addon_plugin_enabled(const String &p_addon, bool p_enabled);
613 	bool is_addon_plugin_enabled(const String &p_addon) const;
614 
615 	void edit_node(Node *p_node);
616 	void edit_resource(const Ref<Resource> &p_resource);
617 	void open_resource(const String &p_type = "");
618 
619 	void save_resource_in_path(const Ref<Resource> &p_resource, const String &p_path);
620 	void save_resource(const Ref<Resource> &p_resource);
621 	void save_resource_as(const Ref<Resource> &p_resource, const String &p_at_path = String());
622 
merge_from_scene()623 	void merge_from_scene() { _menu_option_confirm(FILE_IMPORT_SUBSCENE, false); }
624 
has_unsaved_changes()625 	static bool has_unsaved_changes() { return singleton->unsaved_cache; }
626 
get_menu_hb()627 	static HBoxContainer *get_menu_hb() { return singleton->menu_hb; }
628 
629 	void push_item(Object *p_object, const String &p_property = "");
630 
631 	void open_request(const String &p_path);
632 
633 	bool is_changing_scene() const;
634 
get_log()635 	static EditorLog *get_log() { return singleton->log; }
636 	Control *get_viewport();
637 
638 	//void animation_editor_make_visible(bool p_visible);
639 	//void hide_animation_player_editors();
640 	//void animation_panel_make_visible(bool p_visible);
641 
642 	void set_edited_scene(Node *p_scene);
643 
get_edited_scene()644 	Node *get_edited_scene() { return editor_data.get_edited_scene_root(); }
645 
get_scene_root()646 	Viewport *get_scene_root() { return scene_root; } //root of the scene being edited
647 	Error save_optimized_copy(const String &p_scene, const String &p_preset);
648 
649 	void fix_dependencies(const String &p_for_file);
clear_scene()650 	void clear_scene() { _cleanup_scene(); }
651 	Error load_scene(const String &p_scene, bool p_ignore_broken_deps = false, bool p_set_inherited = false, bool p_clear_errors = true);
652 	Error load_resource(const String &p_scene);
653 
654 	bool is_scene_open(const String &p_path);
655 
656 	void set_current_version(uint64_t p_version);
657 	void set_current_scene(int p_idx);
658 
get_editor_data()659 	static EditorData &get_editor_data() { return singleton->editor_data; }
get_editor_history()660 	EditorHistory *get_editor_history() { return &editor_history; }
661 
get_top_split()662 	static VSplitContainer *get_top_split() { return singleton->top_split; }
663 
664 	void request_instance_scene(const String &p_path);
665 	void request_instance_scenes(const Vector<String> &p_files);
666 	FileSystemDock *get_filesystem_dock();
667 	SceneTreeDock *get_scene_tree_dock();
get_undo_redo()668 	static UndoRedo *get_undo_redo() { return &singleton->editor_data.get_undo_redo(); }
669 
get_editor_selection()670 	EditorSelection *get_editor_selection() { return editor_selection; }
671 
672 	Error save_translatable_strings(const String &p_to_file);
673 
set_convert_old_scene(bool p_old)674 	void set_convert_old_scene(bool p_old) { convert_old = p_old; }
675 
676 	void notify_child_process_exited();
677 
get_child_process_id()678 	OS::ProcessID get_child_process_id() const { return editor_run.get_pid(); }
679 	void stop_child_process();
680 
get_editor_theme()681 	Ref<Theme> get_editor_theme() const { return theme; }
682 
683 	void show_warning(const String &p_text, const String &p_title = "Warning!");
684 
685 	Error export_platform(const String &p_platform, const String &p_path, bool p_debug, const String &p_password, bool p_quit_after = false);
686 
687 	static void register_editor_types();
688 	static void unregister_editor_types();
689 
get_gui_base()690 	Control *get_gui_base() { return gui_base; }
get_theme_base()691 	Control *get_theme_base() { return gui_base->get_parent_control(); }
692 
693 	static void add_io_error(const String &p_error);
694 
695 	static void progress_add_task(const String &p_task, const String &p_label, int p_steps);
696 	static void progress_task_step(const String &p_task, const String &p_state, int p_step = -1, bool p_force_refresh = true);
697 	static void progress_end_task(const String &p_task);
698 
699 	static void progress_add_task_bg(const String &p_task, const String &p_label, int p_steps);
700 	static void progress_task_step_bg(const String &p_task, int p_step = -1);
701 	static void progress_end_task_bg(const String &p_task);
702 
save_scene(String p_file)703 	void save_scene(String p_file) { _save_scene(p_file); }
704 
705 	bool is_scene_in_use(const String &p_path);
706 
707 	void scan_import_changes();
708 
709 	void save_layout();
710 
711 	void update_keying();
712 
713 	void reload_scene(const String &p_path);
714 
is_exiting()715 	bool is_exiting() const { return exiting; }
716 
get_pause_button()717 	ToolButton *get_pause_button() { return pause_button; }
718 
719 	ToolButton *add_bottom_panel_item(String p_text, Control *p_item);
720 	bool are_bottom_panels_hidden() const;
721 	void make_bottom_panel_item_visible(Control *p_item);
722 	void raise_bottom_panel_item(Control *p_item);
723 	void hide_bottom_panel();
724 	void remove_bottom_panel_item(Control *p_item);
725 
726 	Variant drag_resource(const Ref<Resource> &p_res, Control *p_from);
727 	Variant drag_files(const Vector<String> &p_files, Control *p_from);
728 	Variant drag_files_and_dirs(const Vector<String> &p_files, Control *p_from);
729 
730 	EditorNode();
731 	~EditorNode();
732 	void get_singleton(const char *arg1, bool arg2);
733 
add_init_callback(EditorNodeInitCallback p_callback)734 	static void add_init_callback(EditorNodeInitCallback p_callback) { _init_callbacks.push_back(p_callback); }
735 };
736 
737 struct EditorProgress {
738 
739 	String task;
740 	void step(const String &p_state, int p_step = -1, bool p_force_refresh = true) { EditorNode::progress_task_step(task, p_state, p_step, p_force_refresh); }
EditorProgressEditorProgress741 	EditorProgress(const String &p_task, const String &p_label, int p_amount) {
742 		EditorNode::progress_add_task(p_task, p_label, p_amount);
743 		task = p_task;
744 	}
~EditorProgressEditorProgress745 	~EditorProgress() { EditorNode::progress_end_task(task); }
746 };
747 
748 class EditorPluginList : public Object {
749 private:
750 	Vector<EditorPlugin *> plugins_list;
751 
752 public:
set_plugins_list(Vector<EditorPlugin * > p_plugins_list)753 	void set_plugins_list(Vector<EditorPlugin *> p_plugins_list) {
754 		plugins_list = p_plugins_list;
755 	}
756 
get_plugins_list()757 	Vector<EditorPlugin *> &get_plugins_list() {
758 		return plugins_list;
759 	}
760 
761 	void make_visible(bool p_visible);
762 	void edit(Object *p_object);
763 	bool forward_input_event(const InputEvent &p_event);
764 	bool forward_spatial_input_event(Camera *p_camera, const InputEvent &p_event);
765 	void clear();
766 	bool empty();
767 
768 	EditorPluginList();
769 	~EditorPluginList();
770 };
771 
772 struct EditorProgressBG {
773 
774 	String task;
775 	void step(int p_step = -1) { EditorNode::progress_task_step_bg(task, p_step); }
EditorProgressBGEditorProgressBG776 	EditorProgressBG(const String &p_task, const String &p_label, int p_amount) {
777 		EditorNode::progress_add_task_bg(p_task, p_label, p_amount);
778 		task = p_task;
779 	}
~EditorProgressBGEditorProgressBG780 	~EditorProgressBG() { EditorNode::progress_end_task_bg(task); }
781 };
782 
783 #endif
784