summaryrefslogtreecommitdiff
path: root/editor/editor_node.h
diff options
context:
space:
mode:
Diffstat (limited to 'editor/editor_node.h')
-rw-r--r--editor/editor_node.h194
1 files changed, 108 insertions, 86 deletions
diff --git a/editor/editor_node.h b/editor/editor_node.h
index a5c04d3531..dcb6ad6e94 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -31,12 +31,16 @@
#ifndef EDITOR_NODE_H
#define EDITOR_NODE_H
+#include "core/templates/safe_refcount.h"
#include "editor/editor_data.h"
+#include "editor/editor_export.h"
#include "editor/editor_folding.h"
+#include "editor/editor_native_shader_source_visualizer.h"
#include "editor/editor_run.h"
#include "editor/inspector_dock.h"
#include "editor/property_editor.h"
#include "editor/scene_tree_dock.h"
+#include "scene/gui/link_button.h"
typedef void (*EditorNodeInitCallback)();
typedef void (*EditorPluginInitializeCallback)();
@@ -70,7 +74,6 @@ class ImportDock;
class MenuButton;
class NodeDock;
class OrphanResourcesDialog;
-class PaneDrag;
class Panel;
class PanelContainer;
class PluginConfigDialog;
@@ -81,12 +84,14 @@ class RunSettingsDialog;
class ScriptCreateDialog;
class TabContainer;
class Tabs;
-class TextureProgress;
-class ToolButton;
+class TextureProgressBar;
+class Button;
class VSplitContainer;
+class Window;
+class SubViewport;
+class SceneImportSettings;
class EditorNode : public Node {
-
GDCLASS(EditorNode, Node);
public:
@@ -106,10 +111,10 @@ public:
String path;
List<String> args;
String output;
- Thread *execute_output_thread;
- Mutex *execute_output_mutex;
- int exitcode;
- volatile bool done;
+ Thread execute_output_thread;
+ Mutex execute_output_mutex;
+ int exitcode = 0;
+ SafeFlag done;
};
private:
@@ -124,15 +129,12 @@ private:
FILE_SAVE_SCENE,
FILE_SAVE_AS_SCENE,
FILE_SAVE_ALL_SCENES,
- FILE_SAVE_BEFORE_RUN,
FILE_SAVE_AND_RUN,
FILE_SHOW_IN_FILESYSTEM,
- FILE_IMPORT_SUBSCENE,
FILE_EXPORT_PROJECT,
FILE_EXPORT_MESH_LIBRARY,
FILE_INSTALL_ANDROID_SOURCE,
FILE_EXPLORE_ANDROID_BUILD_TEMPLATES,
- FILE_EXPORT_TILESET,
FILE_SAVE_OPTIMIZED,
FILE_OPEN_RECENT,
FILE_OPEN_OLD_SCENE,
@@ -150,7 +152,7 @@ private:
FILE_EXTERNAL_OPEN_SCENE,
EDIT_UNDO,
EDIT_REDO,
- EDIT_REVERT,
+ EDIT_RELOAD_SAVED_SCENE,
TOOLS_ORPHAN_RESOURCES,
TOOLS_CUSTOM,
RESOURCE_SAVE,
@@ -159,18 +161,11 @@ private:
RUN_STOP,
RUN_PLAY_SCENE,
- RUN_PLAY_NATIVE,
RUN_PLAY_CUSTOM_SCENE,
- RUN_SCENE_SETTINGS,
RUN_SETTINGS,
RUN_PROJECT_DATA_FOLDER,
+ RUN_RELOAD_CURRENT_PROJECT,
RUN_PROJECT_MANAGER,
- RUN_FILE_SERVER,
- RUN_LIVE_DEBUG,
- RUN_DEBUG_COLLISONS,
- RUN_DEBUG_NAVIGATION,
- RUN_DEPLOY_REMOTE_DEBUG,
- RUN_RELOAD_SCRIPTS,
RUN_VCS_SETTINGS,
RUN_VCS_SHUT_DOWN,
SETTINGS_UPDATE_CONTINUOUSLY,
@@ -198,9 +193,12 @@ private:
HELP_SEARCH,
HELP_DOCS,
HELP_QA,
- HELP_ISSUES,
+ HELP_REPORT_A_BUG,
+ HELP_SUGGEST_A_FEATURE,
+ HELP_SEND_DOCS_FEEDBACK,
HELP_COMMUNITY,
HELP_ABOUT,
+ HELP_SUPPORT_GODOT_DEVELOPMENT,
SET_VIDEO_DRIVER_SAVE_AND_RESTART,
@@ -212,7 +210,7 @@ private:
TOOL_MENU_BASE = 1000
};
- Viewport *scene_root; //root of the scene being edited
+ SubViewport *scene_root; //root of the scene being edited
PanelContainer *scene_root_parent;
Control *theme_base;
@@ -259,26 +257,25 @@ private:
VSplitContainer *top_split;
HBoxContainer *bottom_hb;
Control *vp_base;
- PaneDrag *pd;
HBoxContainer *menu_hb;
- Control *viewport;
+ Control *main_control;
MenuButton *file_menu;
MenuButton *project_menu;
MenuButton *debug_menu;
MenuButton *settings_menu;
MenuButton *help_menu;
PopupMenu *tool_menu;
- ToolButton *export_button;
- ToolButton *prev_scene;
- ToolButton *play_button;
- ToolButton *pause_button;
- ToolButton *stop_button;
- ToolButton *run_settings_button;
- ToolButton *play_scene_button;
- ToolButton *play_custom_scene_button;
- ToolButton *search_button;
- TextureProgress *audio_vu;
+ Button *export_button;
+ Button *prev_scene;
+ Button *play_button;
+ Button *pause_button;
+ Button *stop_button;
+ Button *run_settings_button;
+ Button *play_scene_button;
+ Button *play_custom_scene_button;
+ Button *search_button;
+ TextureProgressBar *audio_vu;
Timer *screenshot_timer;
@@ -318,8 +315,10 @@ private:
ConfirmationDialog *remove_android_build_template;
EditorSettingsDialog *settings_config_dialog;
- RunSettingsDialog *run_settings_dialog;
ProjectSettingsEditor *project_settings;
+ bool settings_changed = true; //make it update settings on first frame
+ void _update_from_settings();
+
PopupMenu *vcs_actions_menu;
EditorFileDialog *file;
ExportTemplateManager *export_template_manager;
@@ -331,8 +330,10 @@ private:
String current_path;
MenuButton *update_spinner;
+ EditorNativeShaderSourceVisualizer *native_shader_source_visualizer;
+
String defer_load_scene;
- Node *_last_instanced_scene;
+ Node *_last_instantiated_scene;
EditorLog *log;
CenterContainer *tabs_center;
@@ -340,7 +341,7 @@ private:
EditorQuickOpen *quick_run;
HBoxContainer *main_editor_button_vb;
- Vector<ToolButton *> main_editor_buttons;
+ Vector<Button *> main_editor_buttons;
Vector<EditorPlugin *> editor_table;
AudioStreamPreviewGenerator *preview_gen;
@@ -354,20 +355,23 @@ private:
Button *new_inherited_button;
String open_import_request;
+ Vector<Control *> floating_docks;
+
TabContainer *dock_slot[DOCK_SLOT_MAX];
Rect2 dock_select_rect[DOCK_SLOT_MAX];
int dock_select_rect_over;
PopupPanel *dock_select_popup;
Control *dock_select;
- ToolButton *dock_tab_move_left;
- ToolButton *dock_tab_move_right;
+ Button *dock_float;
+ Button *dock_tab_move_left;
+ Button *dock_tab_move_right;
int dock_popup_selected;
Timer *dock_drag_timer;
bool docks_visible;
HBoxContainer *tabbar_container;
- ToolButton *distraction_free;
- ToolButton *scene_tab_add;
+ Button *distraction_free;
+ Button *scene_tab_add;
bool scene_distraction;
bool script_distraction;
@@ -410,12 +414,11 @@ private:
EditorResourcePreview *resource_preview;
EditorFolding editor_folding;
- EditorFileServer *file_server;
-
+ SceneImportSettings *scene_import_settings;
struct BottomPanelItem {
String name;
- Control *control;
- ToolButton *button;
+ Control *control = nullptr;
+ Button *button = nullptr;
};
Vector<BottomPanelItem> bottom_panel_items;
@@ -424,8 +427,11 @@ private:
HBoxContainer *bottom_panel_hb;
HBoxContainer *bottom_panel_hb_editors;
VBoxContainer *bottom_panel_vb;
- Label *version_label;
- ToolButton *bottom_panel_raise;
+ LinkButton *version_btn;
+ Button *bottom_panel_raise;
+
+ Tree *disk_changed_list;
+ ConfirmationDialog *disk_changed;
void _bottom_panel_raise_toggled(bool);
@@ -453,11 +459,11 @@ private:
void _save_screenshot(NodePath p_path);
void _tool_menu_option(int p_idx);
- void _update_debug_options();
void _update_file_menu_opened();
void _update_file_menu_closed();
void _on_plugin_ready(Object *p_script, const String &p_activate_name);
+ void _remove_plugin_from_enabled(const String &p_name);
void _fs_changed();
void _resources_reimported(const Vector<String> &p_resources);
@@ -475,6 +481,7 @@ private:
void _close_messages();
void _show_messages();
void _vp_resized();
+ void _version_button_pressed();
int _save_external_resources();
@@ -485,7 +492,7 @@ private:
void _discard_changes(const String &p_str = String());
void _inherit_request(String p_file);
- void _instance_request(const Vector<String> &p_files);
+ void _instantiate_request(const Vector<String> &p_files);
void _display_top_editors(bool p_display);
void _set_top_editors(Vector<EditorPlugin *> p_editor_plugins_over);
@@ -495,6 +502,7 @@ private:
void _quick_run();
void _run(bool p_current = false, const String &p_custom = "");
+ void _run_native(const Ref<EditorExportPreset> &p_preset);
void _save_optimized();
void _import_action(const String &p_action);
@@ -502,7 +510,8 @@ private:
void _add_to_recent_scenes(const String &p_scene);
void _update_recent_scenes();
void _open_recent_scene(int p_idx);
- void _global_menu_action(const Variant &p_id, const Variant &p_meta);
+ void _global_menu_scene(const Variant &p_tag);
+ void _global_menu_new_window(const Variant &p_tag);
void _dropped_files(const Vector<String> &p_files, int p_screen);
void _add_dropped_files_recursive(const Vector<String> &p_files, String to_path);
String _recent_scene;
@@ -522,13 +531,13 @@ private:
Set<FileDialog *> file_dialogs;
Set<EditorFileDialog *> editor_file_dialogs;
- Map<String, Ref<Texture> > icon_type_cache;
+ Map<String, Ref<Texture2D>> icon_type_cache;
void _build_icon_type_cache();
bool _initializing_addons;
Map<String, EditorPlugin *> plugin_addons;
- static Ref<Texture> _file_dialog_get_icon(const String &p_path);
+ static Ref<Texture2D> _file_dialog_get_icon(const String &p_path);
static void _file_dialog_register(FileDialog *p_dialog);
static void _file_dialog_unregister(FileDialog *p_dialog);
static void _editor_file_dialog_register(EditorFileDialog *p_dialog);
@@ -545,20 +554,21 @@ private:
void _find_node_types(Node *p_node, int &count_2d, int &count_3d);
void _save_scene_with_preview(String p_file, int p_idx = -1);
- Map<String, Set<String> > dependency_errors;
+ Map<String, Set<String>> dependency_errors;
static void _dependency_error_report(void *ud, const String &p_path, const String &p_dep, const String &p_type) {
EditorNode *en = (EditorNode *)ud;
- if (!en->dependency_errors.has(p_path))
+ if (!en->dependency_errors.has(p_path)) {
en->dependency_errors[p_path] = Set<String>();
+ }
en->dependency_errors[p_path].insert(p_dep + "::" + p_type);
}
struct ExportDefer {
String preset;
String path;
- bool debug;
- bool pack_only;
+ bool debug = false;
+ bool pack_only = false;
} export_defer;
bool cmdline_export_mode;
@@ -569,6 +579,8 @@ private:
bool _find_scene_in_use(Node *p_node, const String &p_path) const;
+ void _update_dock_containers();
+
void _dock_select_input(const Ref<InputEvent> &p_input);
void _dock_move_left();
void _dock_move_right();
@@ -576,13 +588,15 @@ private:
void _dock_pre_popup(int p_which);
void _dock_split_dragged(int ofs);
void _dock_popup_exit();
+ void _dock_floating_close_request(Control *p_control);
+ void _dock_make_float();
void _scene_tab_changed(int p_tab);
void _scene_tab_closed(int p_tab, int option = SCENE_TAB_CLOSE);
- void _scene_tab_hover(int p_tab);
+ void _scene_tab_hovered(int p_tab);
void _scene_tab_exit();
void _scene_tab_input(const Ref<InputEvent> &p_input);
void _reposition_active_tab(int idx_to);
- void _thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, const Variant &p_udata);
+ void _thumbnail_done(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, const Variant &p_udata);
void _scene_tab_script_edited(int p_tab);
Dictionary _get_main_scene_state();
@@ -631,7 +645,7 @@ private:
void _update_update_spinner();
- Vector<Ref<EditorResourceConversionPlugin> > resource_conversion_plugins;
+ Vector<Ref<EditorResourceConversionPlugin>> resource_conversion_plugins;
PrintHandlerList print_handler;
static void _print_handler(void *p_this, const String &p_string, bool p_error);
@@ -639,7 +653,11 @@ private:
static void _resource_saved(RES p_resource, const String &p_path);
static void _resource_loaded(RES p_resource, const String &p_path);
- void _resources_changed(const PoolVector<String> &p_resources);
+ void _resources_changed(const Vector<String> &p_resources);
+ void _scan_external_changes();
+ void _reload_modified_scenes();
+ void _reload_project_settings();
+ void _resave_scenes(String p_str);
void _feature_profile_changed();
bool _is_class_editor_disabled_by_feature_profile(const StringName &p_class);
@@ -684,13 +702,15 @@ public:
static void add_editor_plugin(EditorPlugin *p_editor, bool p_config_changed = false);
static void remove_editor_plugin(EditorPlugin *p_editor, bool p_config_changed = false);
+ static void disambiguate_filenames(const Vector<String> p_full_paths, Vector<String> &r_filenames);
+
void new_inherited_scene() { _menu_option_confirm(FILE_NEW_INHERITED_SCENE, false); }
void set_docks_visible(bool p_show);
bool get_docks_visible() const;
void set_distraction_free_mode(bool p_enter);
- bool get_distraction_free_mode() const;
+ bool is_distraction_free_mode_enabled() const;
void add_control_to_dock(DockSlot p_slot, Control *p_control);
void remove_control_from_dock(Control *p_control);
@@ -706,8 +726,6 @@ public:
void save_resource(const Ref<Resource> &p_resource);
void save_resource_as(const Ref<Resource> &p_resource, const String &p_at_path = String());
- void merge_from_scene() { _menu_option_confirm(FILE_IMPORT_SUBSCENE, false); }
-
void show_about() { _menu_option_confirm(HELP_ABOUT, false); }
static bool has_unsaved_changes() { return singleton->unsaved_cache; }
@@ -727,18 +745,18 @@ public:
bool is_changing_scene() const;
static EditorLog *get_log() { return singleton->log; }
- Control *get_viewport();
+ Control *get_main_control();
void set_edited_scene(Node *p_scene);
Node *get_edited_scene() { return editor_data.get_edited_scene_root(); }
- Viewport *get_scene_root() { return scene_root; } //root of the scene being edited
+ SubViewport *get_scene_root() { return scene_root; } //root of the scene being edited
void fix_dependencies(const String &p_for_file);
void clear_scene() { _cleanup_scene(); }
int new_scene();
- 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);
+ 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, bool p_silent_change_tab = false);
Error load_resource(const String &p_resource, bool p_ignore_broken_deps = false);
bool is_scene_open(const String &p_path);
@@ -753,7 +771,7 @@ public:
static VSplitContainer *get_top_split() { return singleton->top_split; }
void request_instance_scene(const String &p_path);
- void request_instance_scenes(const Vector<String> &p_files);
+ void request_instantiate_scenes(const Vector<String> &p_files);
FileSystemDock *get_filesystem_dock();
ImportDock *get_import_dock();
SceneTreeDock *get_scene_tree_dock();
@@ -764,16 +782,16 @@ public:
void set_convert_old_scene(bool p_old) { convert_old = p_old; }
- void notify_child_process_exited();
+ void notify_all_debug_sessions_exited();
- OS::ProcessID get_child_process_id() const { return editor_run.get_pid(); }
- void stop_child_process();
+ OS::ProcessID has_child_process(OS::ProcessID p_pid) const { return editor_run.has_child_process(p_pid); }
+ void stop_child_process(OS::ProcessID p_pid);
Ref<Theme> get_editor_theme() const { return theme; }
Ref<Script> get_object_custom_type_base(const Object *p_object) const;
StringName get_object_custom_type_name(const Object *p_object) const;
- Ref<Texture> get_object_icon(const Object *p_object, const String &p_fallback = "Object") const;
- Ref<Texture> get_class_icon(const String &p_class, const String &p_fallback = "Object") const;
+ Ref<Texture2D> get_object_icon(const Object *p_object, const String &p_fallback = "Object") const;
+ Ref<Texture2D> get_class_icon(const String &p_class, const String &p_fallback = "Object") const;
void show_accept(const String &p_text, const String &p_title);
void show_warning(const String &p_text, const String &p_title = TTR("Warning!"));
@@ -799,10 +817,11 @@ public:
static void progress_end_task_bg(const String &p_task);
void save_scene_to_path(String p_file, bool p_with_preview = true) {
- if (p_with_preview)
+ if (p_with_preview) {
_save_scene_with_preview(p_file);
- else
+ } else {
_save_scene(p_file);
+ }
}
bool is_scene_in_use(const String &p_path);
@@ -817,10 +836,9 @@ public:
bool is_exiting() const { return exiting; }
- ToolButton *get_pause_button() { return pause_button; }
+ Button *get_pause_button() { return pause_button; }
- ToolButton *add_bottom_panel_item(String p_text, Control *p_item);
- bool are_bottom_panels_hidden() const;
+ Button *add_bottom_panel_item(String p_text, Control *p_item);
void make_bottom_panel_item_visible(Control *p_item);
void raise_bottom_panel_item(Control *p_item);
void hide_bottom_panel();
@@ -829,7 +847,7 @@ public:
Variant drag_resource(const Ref<Resource> &p_res, Control *p_from);
Variant drag_files_and_dirs(const Vector<String> &p_paths, Control *p_from);
- void add_tool_menu_item(const String &p_name, Object *p_handler, const String &p_callback, const Variant &p_ud = Variant());
+ void add_tool_menu_item(const String &p_name, const Callable &p_callback);
void add_tool_submenu_item(const String &p_name, PopupMenu *p_submenu);
void remove_tool_menu_item(const String &p_name);
@@ -837,7 +855,9 @@ public:
void save_scene_list(Vector<String> p_scene_filenames);
void restart_editor();
- void dim_editor(bool p_dimming, bool p_force_dim = false);
+ void notify_settings_changed();
+
+ void dim_editor(bool p_dimming);
bool is_editor_dimmed() const;
void edit_current() { _edit_current(); };
@@ -853,7 +873,7 @@ public:
void add_resource_conversion_plugin(const Ref<EditorResourceConversionPlugin> &p_plugin);
void remove_resource_conversion_plugin(const Ref<EditorResourceConversionPlugin> &p_plugin);
- Vector<Ref<EditorResourceConversionPlugin> > find_resource_conversion_plugin(const Ref<Resource> &p_for_resource);
+ Vector<Ref<EditorResourceConversionPlugin>> find_resource_conversion_plugin(const Ref<Resource> &p_for_resource);
static void add_init_callback(EditorNodeInitCallback p_callback) { _init_callbacks.push_back(p_callback); }
static void add_build_callback(EditorBuildCallback p_callback);
@@ -861,11 +881,14 @@ public:
bool ensure_main_scene(bool p_from_native);
void run_play();
+ void run_play_current();
+ void run_play_custom(const String &p_custom);
void run_stop();
+ bool is_run_playing() const;
+ String get_run_playing_scene() const;
};
struct EditorProgress {
-
String task;
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); }
EditorProgress(const String &p_task, const String &p_label, int p_amount, bool p_can_cancel = false) {
@@ -893,20 +916,19 @@ public:
bool forward_gui_input(const Ref<InputEvent> &p_event);
void forward_canvas_draw_over_viewport(Control *p_overlay);
void forward_canvas_force_draw_over_viewport(Control *p_overlay);
- bool forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event, bool serve_when_force_input_enabled);
+ bool forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event, bool serve_when_force_input_enabled);
void forward_spatial_draw_over_viewport(Control *p_overlay);
void forward_spatial_force_draw_over_viewport(Control *p_overlay);
void add_plugin(EditorPlugin *p_plugin);
void remove_plugin(EditorPlugin *p_plugin);
void clear();
- bool empty();
+ bool is_empty();
EditorPluginList();
~EditorPluginList();
};
struct EditorProgressBG {
-
String task;
void step(int p_step = -1) { EditorNode::progress_task_step_bg(task, p_step); }
EditorProgressBG(const String &p_task, const String &p_label, int p_amount) {