editor_node.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838
  1. /*************************************************************************/
  2. /* editor_node.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2017 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/connections_dialog.h"
  33. #include "editor/create_dialog.h"
  34. #include "editor/editor_about.h"
  35. #include "editor/editor_data.h"
  36. #include "editor/editor_export.h"
  37. #include "editor/editor_log.h"
  38. #include "editor/editor_name_dialog.h"
  39. #include "editor/editor_path.h"
  40. #include "editor/editor_plugin.h"
  41. #include "editor/editor_resource_preview.h"
  42. #include "editor/editor_run.h"
  43. #include "editor/editor_run_native.h"
  44. #include "editor/editor_run_script.h"
  45. #include "editor/editor_scale.h"
  46. #include "editor/editor_sub_scene.h"
  47. #include "editor/export_template_manager.h"
  48. #include "editor/fileserver/editor_file_server.h"
  49. #include "editor/filesystem_dock.h"
  50. #include "editor/groups_editor.h"
  51. #include "editor/import_dock.h"
  52. #include "editor/node_dock.h"
  53. #include "editor/pane_drag.h"
  54. #include "editor/progress_dialog.h"
  55. #include "editor/project_export.h"
  56. #include "editor/project_settings_editor.h"
  57. #include "editor/property_editor.h"
  58. #include "editor/quick_open.h"
  59. #include "editor/reparent_dialog.h"
  60. #include "editor/run_settings_dialog.h"
  61. #include "editor/scene_tree_dock.h"
  62. #include "editor/scene_tree_editor.h"
  63. #include "editor/script_create_dialog.h"
  64. #include "editor/settings_config_dialog.h"
  65. #include "scene/gui/center_container.h"
  66. #include "scene/gui/control.h"
  67. #include "scene/gui/dialogs.h"
  68. #include "scene/gui/file_dialog.h"
  69. #include "scene/gui/menu_button.h"
  70. #include "scene/gui/panel.h"
  71. #include "scene/gui/panel_container.h"
  72. #include "scene/gui/separator.h"
  73. #include "scene/gui/split_container.h"
  74. #include "scene/gui/tab_container.h"
  75. #include "scene/gui/tabs.h"
  76. #include "scene/gui/texture_progress.h"
  77. #include "scene/gui/tool_button.h"
  78. #include "scene/gui/tree.h"
  79. #include "scene/gui/viewport_container.h"
  80. /**
  81. @author Juan Linietsky <reduzio@gmail.com>
  82. */
  83. typedef void (*EditorNodeInitCallback)();
  84. typedef void (*EditorPluginInitializeCallback)();
  85. typedef bool (*EditorBuildCallback)();
  86. class EditorPluginList;
  87. class EditorNode : public Node {
  88. GDCLASS(EditorNode, Node);
  89. public:
  90. enum DockSlot {
  91. DOCK_SLOT_LEFT_UL,
  92. DOCK_SLOT_LEFT_BL,
  93. DOCK_SLOT_LEFT_UR,
  94. DOCK_SLOT_LEFT_BR,
  95. DOCK_SLOT_RIGHT_UL,
  96. DOCK_SLOT_RIGHT_BL,
  97. DOCK_SLOT_RIGHT_UR,
  98. DOCK_SLOT_RIGHT_BR,
  99. DOCK_SLOT_MAX
  100. };
  101. private:
  102. enum {
  103. HISTORY_SIZE = 64
  104. };
  105. enum MenuOptions {
  106. FILE_NEW_SCENE,
  107. FILE_NEW_INHERITED_SCENE,
  108. FILE_OPEN_SCENE,
  109. FILE_SAVE_SCENE,
  110. FILE_SAVE_AS_SCENE,
  111. FILE_SAVE_ALL_SCENES,
  112. FILE_SAVE_BEFORE_RUN,
  113. FILE_SAVE_AND_RUN,
  114. FILE_IMPORT_SUBSCENE,
  115. FILE_EXPORT_PROJECT,
  116. FILE_EXPORT_MESH_LIBRARY,
  117. FILE_EXPORT_TILESET,
  118. FILE_SAVE_OPTIMIZED,
  119. FILE_OPEN_RECENT,
  120. FILE_OPEN_OLD_SCENE,
  121. FILE_QUICK_OPEN_SCENE,
  122. FILE_QUICK_OPEN_SCRIPT,
  123. FILE_OPEN_PREV,
  124. FILE_CLOSE,
  125. FILE_CLOSE_ALL_AND_QUIT,
  126. FILE_CLOSE_ALL_AND_RUN_PROJECT_MANAGER,
  127. FILE_QUIT,
  128. FILE_EXTERNAL_OPEN_SCENE,
  129. EDIT_UNDO,
  130. EDIT_REDO,
  131. EDIT_REVERT,
  132. TOOLS_ORPHAN_RESOURCES,
  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_REQUEST_HELP,
  144. RUN_PLAY,
  145. RUN_STOP,
  146. RUN_PLAY_SCENE,
  147. RUN_PLAY_NATIVE,
  148. RUN_PLAY_CUSTOM_SCENE,
  149. RUN_SCENE_SETTINGS,
  150. RUN_SETTINGS,
  151. RUN_PROJECT_MANAGER,
  152. RUN_FILE_SERVER,
  153. RUN_LIVE_DEBUG,
  154. RUN_DEBUG_COLLISONS,
  155. RUN_DEBUG_NAVIGATION,
  156. RUN_DEPLOY_REMOTE_DEBUG,
  157. RUN_RELOAD_SCRIPTS,
  158. SETTINGS_UPDATE_ALWAYS,
  159. SETTINGS_UPDATE_CHANGES,
  160. SETTINGS_UPDATE_SPINNER_HIDE,
  161. SETTINGS_EXPORT_PREFERENCES,
  162. SETTINGS_PREFERENCES,
  163. SETTINGS_LAYOUT_SAVE,
  164. SETTINGS_LAYOUT_DELETE,
  165. SETTINGS_LAYOUT_DEFAULT,
  166. SETTINGS_MANAGE_EXPORT_TEMPLATES,
  167. SETTINGS_PICK_MAIN_SCENE,
  168. SETTINGS_TOGGLE_FULLSCREN,
  169. SETTINGS_HELP,
  170. SCENE_TAB_CLOSE,
  171. HELP_CLASSES,
  172. HELP_SEARCH,
  173. HELP_DOCS,
  174. HELP_QA,
  175. HELP_ISSUES,
  176. HELP_COMMUNITY,
  177. HELP_ABOUT,
  178. IMPORT_PLUGIN_BASE = 100,
  179. OBJECT_METHOD_BASE = 500,
  180. TOOL_MENU_BASE = 1000
  181. };
  182. Viewport *scene_root; //root of the scene being edited
  183. PanelContainer *scene_root_parent;
  184. Control *theme_base;
  185. Control *gui_base;
  186. VBoxContainer *main_vbox;
  187. PanelContainer *play_button_panel;
  188. //split
  189. HSplitContainer *left_l_hsplit;
  190. VSplitContainer *left_l_vsplit;
  191. HSplitContainer *left_r_hsplit;
  192. VSplitContainer *left_r_vsplit;
  193. HSplitContainer *main_hsplit;
  194. HSplitContainer *right_hsplit;
  195. VSplitContainer *right_l_vsplit;
  196. VSplitContainer *right_r_vsplit;
  197. VSplitContainer *center_split;
  198. //main tabs
  199. Tabs *scene_tabs;
  200. Panel *tab_preview_panel;
  201. TextureRect *tab_preview;
  202. int tab_closing;
  203. bool exiting;
  204. int old_split_ofs;
  205. VSplitContainer *top_split;
  206. HBoxContainer *bottom_hb;
  207. Control *vp_base;
  208. PaneDrag *pd;
  209. CenterContainer *play_cc;
  210. HBoxContainer *menu_hb;
  211. Control *viewport;
  212. MenuButton *file_menu;
  213. MenuButton *project_menu;
  214. MenuButton *debug_menu;
  215. MenuButton *settings_menu;
  216. MenuButton *help_menu;
  217. PopupMenu *tool_menu;
  218. ToolButton *export_button;
  219. ToolButton *prev_scene;
  220. MenuButton *object_menu;
  221. ToolButton *play_button;
  222. MenuButton *native_play_button;
  223. ToolButton *pause_button;
  224. ToolButton *stop_button;
  225. ToolButton *run_settings_button;
  226. ToolButton *play_scene_button;
  227. ToolButton *play_custom_scene_button;
  228. ToolButton *search_button;
  229. TextureProgress *audio_vu;
  230. RichTextLabel *load_errors;
  231. AcceptDialog *load_error_dialog;
  232. Ref<Theme> theme;
  233. PopupMenu *recent_scenes;
  234. Button *property_back;
  235. Button *property_forward;
  236. SceneTreeDock *scene_tree_dock;
  237. PropertyEditor *property_editor;
  238. Button *property_editable_warning;
  239. AcceptDialog *property_editable_warning_dialog;
  240. void _property_editable_warning_pressed();
  241. NodeDock *node_dock;
  242. ImportDock *import_dock;
  243. VBoxContainer *prop_editor_vb;
  244. FileSystemDock *filesystem_dock;
  245. EditorRunNative *run_native;
  246. HBoxContainer *search_bar;
  247. LineEdit *search_box;
  248. CreateDialog *create_dialog;
  249. ConfirmationDialog *confirmation;
  250. ConfirmationDialog *save_confirmation;
  251. ConfirmationDialog *import_confirmation;
  252. ConfirmationDialog *pick_main_scene;
  253. AcceptDialog *accept;
  254. EditorAbout *about;
  255. AcceptDialog *warning;
  256. int overridden_default_layout;
  257. Ref<ConfigFile> default_layout;
  258. PopupMenu *editor_layouts;
  259. EditorNameDialog *layout_dialog;
  260. EditorSettingsDialog *settings_config_dialog;
  261. RunSettingsDialog *run_settings_dialog;
  262. ProjectSettingsEditor *project_settings;
  263. EditorFileDialog *file;
  264. ExportTemplateManager *export_template_manager;
  265. FileDialog *file_templates;
  266. FileDialog *file_export;
  267. FileDialog *file_export_lib;
  268. FileDialog *file_script;
  269. CheckButton *file_export_lib_merge;
  270. LineEdit *file_export_password;
  271. String current_path;
  272. MenuButton *update_menu;
  273. String defer_load_scene;
  274. String defer_export;
  275. String defer_export_platform;
  276. bool defer_export_debug;
  277. Node *_last_instanced_scene;
  278. EditorPath *editor_path;
  279. ToolButton *resource_new_button;
  280. ToolButton *resource_load_button;
  281. MenuButton *resource_save_button;
  282. MenuButton *editor_history_menu;
  283. EditorLog *log;
  284. CenterContainer *tabs_center;
  285. EditorQuickOpen *quick_open;
  286. EditorQuickOpen *quick_run;
  287. HBoxContainer *main_editor_button_vb;
  288. Vector<ToolButton *> main_editor_buttons;
  289. Vector<EditorPlugin *> editor_table;
  290. ProgressDialog *progress_dialog;
  291. BackgroundProgress *progress_hb;
  292. DependencyErrorDialog *dependency_error;
  293. DependencyEditor *dependency_fixer;
  294. OrphanResourcesDialog *orphan_resources;
  295. ConfirmationDialog *open_imported;
  296. Button *new_inherited_button;
  297. String open_import_request;
  298. TabContainer *dock_slot[DOCK_SLOT_MAX];
  299. Rect2 dock_select_rect[DOCK_SLOT_MAX];
  300. int dock_select_rect_over;
  301. PopupPanel *dock_select_popup;
  302. Control *dock_select;
  303. ToolButton *dock_tab_move_left;
  304. ToolButton *dock_tab_move_right;
  305. int dock_popup_selected;
  306. Timer *dock_drag_timer;
  307. bool docks_visible;
  308. ToolButton *distraction_free;
  309. bool scene_distraction;
  310. bool script_distraction;
  311. String _tmp_import_path;
  312. EditorExport *editor_export;
  313. Object *current;
  314. bool _playing_edited;
  315. String run_custom_filename;
  316. bool reference_resource_mem;
  317. bool save_external_resources_mem;
  318. uint64_t saved_version;
  319. uint64_t last_checked_version;
  320. bool unsaved_cache;
  321. String open_navigate;
  322. bool changing_scene;
  323. bool waiting_for_first_scan;
  324. bool waiting_for_sources_changed;
  325. uint32_t circle_step_msec;
  326. uint64_t circle_step_frame;
  327. int circle_step;
  328. Vector<EditorPlugin *> editor_plugins;
  329. EditorPlugin *editor_plugin_screen;
  330. EditorPluginList *editor_plugins_over;
  331. EditorPluginList *editor_plugins_force_input_forwarding;
  332. EditorHistory editor_history;
  333. EditorData editor_data;
  334. EditorRun editor_run;
  335. EditorSelection *editor_selection;
  336. ProjectExportDialog *project_export;
  337. EditorResourcePreview *resource_preview;
  338. EditorFileServer *file_server;
  339. struct BottomPanelItem {
  340. String name;
  341. Control *control;
  342. ToolButton *button;
  343. };
  344. Vector<BottomPanelItem> bottom_panel_items;
  345. PanelContainer *bottom_panel;
  346. HBoxContainer *bottom_panel_hb;
  347. VBoxContainer *bottom_panel_vb;
  348. EditorInterface *editor_interface;
  349. void _bottom_panel_switch(bool p_enable, int p_idx);
  350. String external_file;
  351. List<String> previous_scenes;
  352. bool opening_prev;
  353. void _dialog_action(String p_file);
  354. void _edit_current();
  355. void _dialog_display_save_error(String p_file, Error p_error);
  356. void _dialog_display_load_error(String p_file, Error p_error);
  357. int current_option;
  358. void _resource_created();
  359. void _resource_selected(const RES &p_res, const String &p_property = "");
  360. void _menu_option(int p_option);
  361. void _menu_confirm_current();
  362. void _menu_option_confirm(int p_option, bool p_confirmed);
  363. void _update_debug_options();
  364. void _property_editor_forward();
  365. void _property_editor_back();
  366. void _select_history(int p_idx);
  367. void _prepare_history();
  368. void _fs_changed();
  369. void _resources_reimported(const Vector<String> &p_resources);
  370. void _sources_changed(bool p_exist);
  371. void _node_renamed();
  372. void _editor_select_next();
  373. void _editor_select_prev();
  374. void _editor_select(int p_which);
  375. void _set_scene_metadata(const String &p_file, int p_idx = -1);
  376. void _get_scene_metadata(const String &p_file);
  377. void _update_title();
  378. void _update_scene_tabs();
  379. void _close_messages();
  380. void _show_messages();
  381. void _vp_resized();
  382. void _save_scene(String p_file, int idx = -1);
  383. void _save_all_scenes();
  384. int _next_unsaved_scene(bool p_valid_filename, int p_start = 0);
  385. void _discard_changes(const String &p_str = String());
  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. String _recent_scene;
  404. bool convert_old;
  405. void _unhandled_input(const Ref<InputEvent> &p_event);
  406. static void _load_error_notify(void *p_ud, const String &p_text);
  407. bool has_main_screen() const { return true; }
  408. String import_reload_fn;
  409. Set<FileDialog *> file_dialogs;
  410. Set<EditorFileDialog *> editor_file_dialogs;
  411. Map<String, Ref<Texture> > icon_type_cache;
  412. bool _initializing_addons;
  413. Map<String, EditorPlugin *> plugin_addons;
  414. static Ref<Texture> _file_dialog_get_icon(const String &p_path);
  415. static void _file_dialog_register(FileDialog *p_dialog);
  416. static void _file_dialog_unregister(FileDialog *p_dialog);
  417. static void _editor_file_dialog_register(EditorFileDialog *p_dialog);
  418. static void _editor_file_dialog_unregister(EditorFileDialog *p_dialog);
  419. void _cleanup_scene();
  420. void _remove_edited_scene();
  421. void _remove_scene(int index);
  422. bool _find_and_save_resource(RES p_res, Map<RES, bool> &processed, int32_t flags);
  423. bool _find_and_save_edited_subresources(Object *obj, Map<RES, bool> &processed, int32_t flags);
  424. void _save_edited_subresources(Node *scene, Map<RES, bool> &processed, int32_t flags);
  425. void _mark_unsaved_scenes();
  426. void _find_node_types(Node *p_node, int &count_2d, int &count_3d);
  427. void _save_scene_with_preview(String p_file);
  428. Map<String, Set<String> > dependency_errors;
  429. static void _dependency_error_report(void *ud, const String &p_path, const String &p_dep, const String &p_type) {
  430. EditorNode *en = (EditorNode *)ud;
  431. if (!en->dependency_errors.has(p_path))
  432. en->dependency_errors[p_path] = Set<String>();
  433. en->dependency_errors[p_path].insert(p_dep + "::" + p_type);
  434. }
  435. struct ExportDefer {
  436. String preset;
  437. String path;
  438. bool debug;
  439. String password;
  440. } export_defer;
  441. static EditorNode *singleton;
  442. static Vector<EditorNodeInitCallback> _init_callbacks;
  443. bool _find_scene_in_use(Node *p_node, const String &p_path) const;
  444. void _dock_select_input(const Ref<InputEvent> &p_input);
  445. void _dock_move_left();
  446. void _dock_move_right();
  447. void _dock_select_draw();
  448. void _dock_pre_popup(int p_which);
  449. void _dock_split_dragged(int ofs);
  450. void _dock_popup_exit();
  451. void _scene_tab_changed(int p_tab);
  452. void _scene_tab_closed(int p_tab);
  453. void _scene_tab_hover(int p_tab);
  454. void _scene_tab_exit();
  455. void _scene_tab_input(const Ref<InputEvent> &p_input);
  456. void _reposition_active_tab(int idx_to);
  457. void _thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Variant &p_udata);
  458. void _scene_tab_script_edited(int p_tab);
  459. Dictionary _get_main_scene_state();
  460. void _set_main_scene_state(Dictionary p_state, Node *p_for_scene);
  461. int _get_current_main_editor();
  462. void _save_docks();
  463. void _load_docks();
  464. void _save_docks_to_config(Ref<ConfigFile> p_layout, const String &p_section);
  465. void _load_docks_from_config(Ref<ConfigFile> p_layout, const String &p_section);
  466. void _update_dock_slots_visibility();
  467. void _update_layouts_menu();
  468. void _layout_menu_option(int p_id);
  469. void _toggle_search_bar(bool p_pressed);
  470. void _clear_search_box();
  471. void _clear_undo_history();
  472. void _update_addon_config();
  473. static void _file_access_close_error_notify(const String &p_str);
  474. void _toggle_distraction_free_mode();
  475. enum {
  476. MAX_INIT_CALLBACKS = 128,
  477. MAX_BUILD_CALLBACKS = 128
  478. };
  479. void _inherit_imported(const String &p_action);
  480. void _open_imported();
  481. static int plugin_init_callback_count;
  482. static EditorPluginInitializeCallback plugin_init_callbacks[MAX_INIT_CALLBACKS];
  483. void _save_default_environment();
  484. bool _call_build();
  485. static int build_callback_count;
  486. static EditorBuildCallback build_callbacks[MAX_BUILD_CALLBACKS];
  487. bool _initializing_tool_menu;
  488. struct ToolMenuItem {
  489. String name;
  490. String submenu;
  491. Variant ud;
  492. ObjectID handler;
  493. String callback;
  494. };
  495. Vector<ToolMenuItem> tool_menu_items;
  496. void _tool_menu_insert_item(const ToolMenuItem &p_item);
  497. void _rebuild_tool_menu() const;
  498. bool _dimming;
  499. float _dim_time;
  500. Timer *_dim_timer;
  501. void _start_dimming(bool p_dimming);
  502. void _dim_timeout();
  503. void _license_tree_selected();
  504. Vector<Ref<EditorResourceConversionPlugin> > resource_conversion_plugins;
  505. protected:
  506. void _notification(int p_what);
  507. static void _bind_methods();
  508. public:
  509. static void add_plugin_init_callback(EditorPluginInitializeCallback p_callback);
  510. enum EditorTable {
  511. EDITOR_2D = 0,
  512. EDITOR_3D,
  513. EDITOR_SCRIPT,
  514. EDITOR_ASSETLIB
  515. };
  516. void set_visible_editor(EditorTable p_table) { _editor_select(p_table); }
  517. static EditorNode *get_singleton() { return singleton; }
  518. EditorPlugin *get_editor_plugin_screen() { return editor_plugin_screen; }
  519. EditorPluginList *get_editor_plugins_over() { return editor_plugins_over; }
  520. EditorPluginList *get_editor_plugins_force_input_forwarding() { return editor_plugins_force_input_forwarding; }
  521. PropertyEditor *get_property_editor() { return property_editor; }
  522. VBoxContainer *get_property_editor_vb() { return prop_editor_vb; }
  523. static void add_editor_plugin(EditorPlugin *p_editor);
  524. static void remove_editor_plugin(EditorPlugin *p_editor);
  525. void new_inherited_scene() { _menu_option_confirm(FILE_NEW_INHERITED_SCENE, false); }
  526. void set_docks_visible(bool p_show);
  527. bool get_docks_visible() const;
  528. void set_distraction_free_mode(bool p_enter);
  529. bool get_distraction_free_mode() const;
  530. void add_control_to_dock(DockSlot p_slot, Control *p_control);
  531. void remove_control_from_dock(Control *p_control);
  532. void set_addon_plugin_enabled(const String &p_addon, bool p_enabled);
  533. bool is_addon_plugin_enabled(const String &p_addon) const;
  534. void edit_node(Node *p_node);
  535. void edit_resource(const Ref<Resource> &p_resource);
  536. void open_resource(const String &p_type = "");
  537. void save_resource_in_path(const Ref<Resource> &p_resource, const String &p_path);
  538. void save_resource(const Ref<Resource> &p_resource);
  539. void save_resource_as(const Ref<Resource> &p_resource, const String &p_at_path = String());
  540. void merge_from_scene() { _menu_option_confirm(FILE_IMPORT_SUBSCENE, false); }
  541. void show_about() { _menu_option_confirm(HELP_ABOUT, false); }
  542. static bool has_unsaved_changes() { return singleton->unsaved_cache; }
  543. static HBoxContainer *get_menu_hb() { return singleton->menu_hb; }
  544. void push_item(Object *p_object, const String &p_property = "");
  545. void open_request(const String &p_path);
  546. bool is_changing_scene() const;
  547. static EditorLog *get_log() { return singleton->log; }
  548. Control *get_viewport();
  549. void set_edited_scene(Node *p_scene);
  550. Node *get_edited_scene() { return editor_data.get_edited_scene_root(); }
  551. Viewport *get_scene_root() { return scene_root; } //root of the scene being edited
  552. void fix_dependencies(const String &p_for_file);
  553. void clear_scene() { _cleanup_scene(); }
  554. 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);
  555. Error load_resource(const String &p_scene);
  556. bool is_scene_open(const String &p_path);
  557. void set_current_version(uint64_t p_version);
  558. void set_current_scene(int p_idx);
  559. static EditorData &get_editor_data() { return singleton->editor_data; }
  560. EditorHistory *get_editor_history() { return &editor_history; }
  561. static VSplitContainer *get_top_split() { return singleton->top_split; }
  562. void request_instance_scene(const String &p_path);
  563. void request_instance_scenes(const Vector<String> &p_files);
  564. FileSystemDock *get_filesystem_dock();
  565. ImportDock *get_import_dock();
  566. SceneTreeDock *get_scene_tree_dock();
  567. static UndoRedo *get_undo_redo() { return &singleton->editor_data.get_undo_redo(); }
  568. EditorSelection *get_editor_selection() { return editor_selection; }
  569. void set_convert_old_scene(bool p_old) { convert_old = p_old; }
  570. void notify_child_process_exited();
  571. OS::ProcessID get_child_process_id() const { return editor_run.get_pid(); }
  572. void stop_child_process();
  573. Ref<Theme> get_editor_theme() const { return theme; }
  574. void show_warning(const String &p_text, const String &p_title = "Warning!");
  575. Error export_preset(const String &p_preset, const String &p_path, bool p_debug, const String &p_password, bool p_quit_after = false);
  576. static void register_editor_types();
  577. static void unregister_editor_types();
  578. Control *get_gui_base() { return gui_base; }
  579. Control *get_theme_base() { return gui_base->get_parent_control(); }
  580. static void add_io_error(const String &p_error);
  581. static void progress_add_task(const String &p_task, const String &p_label, int p_steps);
  582. static void progress_task_step(const String &p_task, const String &p_state, int p_step = -1, bool p_force_refresh = true);
  583. static void progress_end_task(const String &p_task);
  584. static void progress_add_task_bg(const String &p_task, const String &p_label, int p_steps);
  585. static void progress_task_step_bg(const String &p_task, int p_step = -1);
  586. static void progress_end_task_bg(const String &p_task);
  587. void save_scene_to_path(String p_file, bool p_with_preview = true) {
  588. if (p_with_preview)
  589. _save_scene_with_preview(p_file);
  590. else
  591. _save_scene(p_file);
  592. }
  593. bool is_scene_in_use(const String &p_path);
  594. void scan_import_changes();
  595. void save_layout();
  596. void update_keying();
  597. void open_export_template_manager();
  598. void reload_scene(const String &p_path);
  599. bool is_exiting() const { return exiting; }
  600. ToolButton *get_pause_button() { return pause_button; }
  601. ToolButton *add_bottom_panel_item(String p_text, Control *p_item);
  602. bool are_bottom_panels_hidden() const;
  603. void make_bottom_panel_item_visible(Control *p_item);
  604. void raise_bottom_panel_item(Control *p_item);
  605. void hide_bottom_panel();
  606. void remove_bottom_panel_item(Control *p_item);
  607. Variant drag_resource(const Ref<Resource> &p_res, Control *p_from);
  608. Variant drag_files(const Vector<String> &p_files, Control *p_from);
  609. Variant drag_files_and_dirs(const Vector<String> &p_files, Control *p_from);
  610. void add_tool_menu_item(const String &p_name, Object *p_handler, const String &p_callback, const Variant &p_ud = Variant());
  611. void add_tool_submenu_item(const String &p_name, PopupMenu *p_submenu);
  612. void remove_tool_menu_item(const String &p_name);
  613. void dim_editor(bool p_dimming);
  614. EditorNode();
  615. ~EditorNode();
  616. void get_singleton(const char *arg1, bool arg2);
  617. void add_resource_conversion_plugin(const Ref<EditorResourceConversionPlugin> &p_plugin);
  618. void remove_resource_conversion_plugin(const Ref<EditorResourceConversionPlugin> &p_plugin);
  619. Vector<Ref<EditorResourceConversionPlugin> > find_resource_conversion_plugin(const Ref<Resource> &p_for_resource);
  620. static void add_init_callback(EditorNodeInitCallback p_callback) { _init_callbacks.push_back(p_callback); }
  621. static void add_build_callback(EditorBuildCallback p_callback);
  622. };
  623. struct EditorProgress {
  624. String task;
  625. 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); }
  626. EditorProgress(const String &p_task, const String &p_label, int p_amount) {
  627. EditorNode::progress_add_task(p_task, p_label, p_amount);
  628. task = p_task;
  629. }
  630. ~EditorProgress() { EditorNode::progress_end_task(task); }
  631. };
  632. class EditorPluginList : public Object {
  633. private:
  634. Vector<EditorPlugin *> plugins_list;
  635. public:
  636. void set_plugins_list(Vector<EditorPlugin *> p_plugins_list) {
  637. plugins_list = p_plugins_list;
  638. }
  639. Vector<EditorPlugin *> &get_plugins_list() {
  640. return plugins_list;
  641. }
  642. void make_visible(bool p_visible);
  643. void edit(Object *p_object);
  644. bool forward_gui_input(const Ref<InputEvent> &p_event);
  645. bool forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event, bool serve_when_force_input_enabled);
  646. void forward_draw_over_canvas(Control *p_canvas);
  647. void add_plugin(EditorPlugin *p_plugin);
  648. void clear();
  649. bool empty();
  650. EditorPluginList();
  651. ~EditorPluginList();
  652. };
  653. struct EditorProgressBG {
  654. String task;
  655. void step(int p_step = -1) { EditorNode::progress_task_step_bg(task, p_step); }
  656. EditorProgressBG(const String &p_task, const String &p_label, int p_amount) {
  657. EditorNode::progress_add_task_bg(p_task, p_label, p_amount);
  658. task = p_task;
  659. }
  660. ~EditorProgressBG() { EditorNode::progress_end_task_bg(task); }
  661. };
  662. #endif // EDITOR_NODE_H