editor_node.h 23 KB

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