diff options
Diffstat (limited to 'editor/editor_node.h')
-rw-r--r-- | editor/editor_node.h | 197 |
1 files changed, 118 insertions, 79 deletions
diff --git a/editor/editor_node.h b/editor/editor_node.h index c521c0fb04..fb2544c141 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -1,43 +1,44 @@ -/*************************************************************************/ -/* editor_node.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 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 */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ +/**************************************************************************/ +/* editor_node.h */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ #ifndef EDITOR_NODE_H #define EDITOR_NODE_H #include "core/templates/safe_refcount.h" +#include "editor/editor_data.h" #include "editor/editor_folding.h" #include "editor/editor_native_shader_source_visualizer.h" +#include "editor/editor_plugin.h" #include "editor/editor_run.h" +#include "editor/editor_title_bar.h" #include "editor/export/editor_export.h" -#include "editor/inspector_dock.h" -#include "editor/property_editor.h" typedef void (*EditorNodeInitCallback)(); typedef void (*EditorPluginInitializeCallback)(); @@ -46,8 +47,9 @@ typedef bool (*EditorBuildCallback)(); class AcceptDialog; class AudioStreamPreviewGenerator; class BackgroundProgress; -class Button; class CenterContainer; +class CheckBox; +class ColorPicker; class ConfirmationDialog; class Control; class DependencyEditor; @@ -58,27 +60,34 @@ class EditorCommandPalette; class EditorExport; class EditorExtensionManager; class EditorFeatureProfileManager; +class EditorFileDialog; class EditorFileServer; class EditorFolding; class EditorInspector; class EditorLayoutsDialog; class EditorLog; -class EditorPlugin; class EditorPluginList; class EditorQuickOpen; class EditorResourcePreview; +class EditorResourceConversionPlugin; class EditorRun; class EditorRunNative; +class EditorSelectionHistory; class EditorSettingsDialog; class EditorToaster; +class EditorUndoRedoManager; class ExportTemplateManager; +class FBXImporterManager; class FileDialog; class FileSystemDock; +class HistoryDock; class HSplitContainer; class ImportDock; class LinkButton; +class MenuBar; class MenuButton; class NodeDock; +class OptionButton; class OrphanResourcesDialog; class Panel; class PanelContainer; @@ -93,7 +102,9 @@ class ScriptCreateDialog; class SubViewport; class TabBar; class TabContainer; +class TextureRect; class TextureProgressBar; +class Tree; class VSplitContainer; class Window; class EditorBuildProfileManager; @@ -121,6 +132,12 @@ public: EDITOR_ASSETLIB }; + enum SceneNameCasing { + SCENE_NAME_CASING_AUTO, + SCENE_NAME_CASING_PASCAL_CASE, + SCENE_NAME_CASING_SNAKE_CASE + }; + struct ExecuteThreadArgs { String path; List<String> args; @@ -140,6 +157,7 @@ private: FILE_SAVE_AS_SCENE, FILE_SAVE_ALL_SCENES, FILE_SAVE_AND_RUN, + FILE_SAVE_AND_RUN_MAIN_SCENE, FILE_SHOW_IN_FILESYSTEM, FILE_EXPORT_PROJECT, FILE_EXPORT_MESH_LIBRARY, @@ -180,7 +198,6 @@ private: RUN_PROJECT_MANAGER, RUN_VCS_METADATA, RUN_VCS_SETTINGS, - RUN_VCS_SHUT_DOWN, SETTINGS_UPDATE_CONTINUOUSLY, SETTINGS_UPDATE_WHEN_CHANGED, SETTINGS_UPDATE_ALWAYS, @@ -193,6 +210,7 @@ private: SETTINGS_EDITOR_DATA_FOLDER, SETTINGS_EDITOR_CONFIG_FOLDER, SETTINGS_MANAGE_EXPORT_TEMPLATES, + SETTINGS_MANAGE_FBX_IMPORTER, SETTINGS_MANAGE_FEATURE_PROFILES, SETTINGS_INSTALL_ANDROID_BUILD_TEMPLATE, SETTINGS_PICK_MAIN_SCENE, @@ -214,7 +232,7 @@ private: HELP_ABOUT, HELP_SUPPORT_GODOT_DEVELOPMENT, - SET_RENDERING_DRIVER_SAVE_AND_RESTART, + SET_RENDERER_NAME_SAVE_AND_RESTART, GLOBAL_NEW_WINDOW, GLOBAL_SCENE, @@ -229,12 +247,6 @@ private: MAX_BUILD_CALLBACKS = 128 }; - enum ScriptNameCasing { - SCENE_NAME_CASING_AUTO, - SCENE_NAME_CASING_PASCAL_CASE, - SCENE_NAME_CASING_SNAKE_CASE - }; - struct BottomPanelItem { String name; Control *control = nullptr; @@ -270,24 +282,28 @@ private: EditorRunNative *run_native = nullptr; EditorSelection *editor_selection = nullptr; EditorSettingsDialog *editor_settings_dialog = nullptr; + HistoryDock *history_dock = nullptr; ProjectExportDialog *project_export = nullptr; ProjectSettingsEditor *project_settings_editor = nullptr; + FBXImporterManager *fbx_importer_manager = nullptr; + Vector<EditorPlugin *> editor_plugins; bool _initializing_plugins = false; HashMap<String, EditorPlugin *> addon_name_to_plugin; + LocalVector<String> pending_addons; PanelContainer *scene_root_parent = nullptr; Control *theme_base = nullptr; Control *gui_base = nullptr; VBoxContainer *main_vbox = nullptr; - OptionButton *rendering_driver = nullptr; + OptionButton *renderer = nullptr; ConfirmationDialog *video_restart_dialog = nullptr; - int rendering_driver_current = 0; - String rendering_driver_request; + int renderer_current = 0; + String renderer_request; // Split containers. HSplitContainer *left_l_hsplit = nullptr; @@ -318,26 +334,32 @@ private: HBoxContainer *bottom_hb = nullptr; Control *vp_base = nullptr; - HBoxContainer *menu_hb = nullptr; - Control *main_control = nullptr; - MenuButton *file_menu = nullptr; - MenuButton *project_menu = nullptr; - MenuButton *debug_menu = nullptr; - MenuButton *settings_menu = nullptr; - MenuButton *help_menu = nullptr; + Label *project_title = nullptr; + Control *left_menu_spacer = nullptr; + Control *right_menu_spacer = nullptr; + EditorTitleBar *menu_hb = nullptr; + VBoxContainer *main_screen_vbox = nullptr; + MenuBar *main_menu = nullptr; + PopupMenu *file_menu = nullptr; + PopupMenu *project_menu = nullptr; + PopupMenu *debug_menu = nullptr; + PopupMenu *settings_menu = nullptr; + PopupMenu *help_menu = nullptr; PopupMenu *tool_menu = nullptr; PopupMenu *export_as_menu = nullptr; Button *export_button = nullptr; Button *prev_scene = nullptr; + Button *search_button = nullptr; + TextureProgressBar *audio_vu = nullptr; + + PanelContainer *launch_pad = nullptr; Button *play_button = nullptr; Button *pause_button = nullptr; Button *stop_button = nullptr; - Button *run_settings_button = nullptr; Button *play_scene_button = nullptr; Button *play_custom_scene_button = nullptr; - Button *search_button = nullptr; + PanelContainer *write_movie_panel = nullptr; Button *write_movie_button = nullptr; - TextureProgressBar *audio_vu = nullptr; Timer *screenshot_timer = nullptr; @@ -390,7 +412,7 @@ private: String current_path; MenuButton *update_spinner = nullptr; - HBoxContainer *main_editor_button_vb = nullptr; + HBoxContainer *main_editor_button_hb = nullptr; Vector<Button *> main_editor_buttons; Vector<EditorPlugin *> editor_table; @@ -420,6 +442,7 @@ private: int dock_popup_selected_idx = -1; int dock_select_rect_over_idx = -1; + PanelContainer *tabbar_panel = nullptr; HBoxContainer *tabbar_container = nullptr; Button *distraction_free = nullptr; Button *scene_tab_add = nullptr; @@ -465,10 +488,9 @@ private: String _tmp_import_path; String external_file; String open_navigate; - String run_custom_filename; - uint64_t saved_version = 1; - uint64_t last_checked_version = 0; + String run_custom_filename; + String run_current_filename; DynamicFontImportSettings *fontdata_import_settings = nullptr; SceneImportSettings *scene_import_settings = nullptr; @@ -514,6 +536,7 @@ private: static void _resource_loaded(Ref<Resource> p_resource, const String &p_path); void _build_icon_type_cache(); + void _enable_pending_addons(); void _dialog_action(String p_file); @@ -536,7 +559,6 @@ private: 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(); @@ -546,7 +568,6 @@ private: void _node_renamed(); void _editor_select_next(); void _editor_select_prev(); - void _editor_select(int p_which); void _set_scene_metadata(const String &p_file, int p_idx = -1); void _get_scene_metadata(const String &p_file); void _update_title(); @@ -555,8 +576,11 @@ private: void _close_messages(); void _show_messages(); void _vp_resized(); + void _titlebar_resized(); void _version_button_pressed(); + void _update_undo_redo_allowed(); + int _save_external_resources(); bool _validate_scene_recursive(const String &p_filename, Node *p_node); @@ -576,8 +600,11 @@ private: void _quick_run(); void _open_command_palette(); + void _write_movie_toggled(bool p_enabled); + void _run(bool p_current = false, const String &p_custom = ""); void _run_native(const Ref<EditorExportPreset> &p_preset); + void _reset_play_buttons(); void _add_to_recent_scenes(const String &p_scene); void _update_recent_scenes(); @@ -589,8 +616,8 @@ private: void _update_from_settings(); - void _rendering_driver_selected(int); - void _update_rendering_driver_color(); + void _renderer_selected(int); + void _update_renderer_color(); void _exit_editor(int p_exit_code); @@ -639,7 +666,7 @@ private: void _load_docks(); void _save_docks_to_config(Ref<ConfigFile> p_layout, const String &p_section); void _load_docks_from_config(Ref<ConfigFile> p_layout, const String &p_section); - void _update_dock_slots_visibility(); + void _update_dock_slots_visibility(bool p_keep_selected_tabs = false); void _dock_tab_changed(int p_tab); void _save_open_scenes_to_config(Ref<ConfigFile> p_layout, const String &p_section); @@ -648,8 +675,6 @@ private: void _update_layouts_menu(); void _layout_menu_option(int p_id); - void _clear_undo_history(); - void _update_addon_config(); void _toggle_distraction_free_mode(); @@ -678,6 +703,10 @@ private: void _bottom_panel_switch(bool p_enable, int p_idx); void _bottom_panel_raise_toggled(bool); + void _begin_first_scan(); + bool use_startup_benchmark = false; + String startup_benchmark_file; + protected: friend class FileSystemDock; @@ -689,23 +718,25 @@ protected: void set_current_tab(int p_tab); public: - void set_visible_editor(EditorTable p_table) { _editor_select(p_table); } + // Public for use with callable_mp. + void _on_plugin_ready(Object *p_script, const String &p_activate_name); - bool call_build(); + void editor_select(int p_which); + void set_visible_editor(EditorTable p_table) { editor_select(p_table); } - static void register_editor_types(); - static void unregister_editor_types(); + bool call_build(); static EditorNode *get_singleton() { return singleton; } static EditorLog *get_log() { return singleton->log; } static EditorData &get_editor_data() { return singleton->editor_data; } static EditorFolding &get_editor_folding() { return singleton->editor_folding; } - static UndoRedo *get_undo_redo() { return &singleton->editor_data.get_undo_redo(); } static HBoxContainer *get_menu_hb() { return singleton->menu_hb; } static VSplitContainer *get_top_split() { return singleton->top_split; } + static String adjust_scene_name_casing(const String &root_name); + static bool has_unsaved_changes() { return singleton->unsaved_cache; } static void disambiguate_filenames(const Vector<String> p_full_paths, Vector<String> &r_filenames); static void add_io_error(const String &p_error); @@ -727,6 +758,8 @@ public: static bool immediate_confirmation_dialog(const String &p_text, const String &p_ok_text = TTR("Ok"), const String &p_cancel_text = TTR("Cancel")); + static void cleanup(); + EditorPlugin *get_editor_plugin_screen() { return editor_plugin_screen; } EditorPluginList *get_editor_plugins_force_input_forwarding() { return editor_plugins_force_input_forwarding; } EditorPluginList *get_editor_plugins_force_over() { return editor_plugins_force_over; } @@ -750,8 +783,11 @@ public: void set_addon_plugin_enabled(const String &p_addon, bool p_enabled, bool p_config_changed = false); bool is_addon_plugin_enabled(const String &p_addon) const; + void set_movie_maker_enabled(bool p_enabled); + bool is_movie_maker_enabled() const; + void edit_node(Node *p_node); - void edit_resource(const Ref<Resource> &p_resource) { InspectorDock::get_singleton()->edit_resource(p_resource); }; + void edit_resource(const Ref<Resource> &p_resource); void save_resource_in_path(const Ref<Resource> &p_resource, const String &p_path); void save_resource(const Ref<Resource> &p_resource); @@ -762,7 +798,6 @@ public: void push_item(Object *p_object, const String &p_property = "", bool p_inspector_only = false); void edit_item(Object *p_object); void edit_item_resource(Ref<Resource> p_resource); - bool item_has_editor(Object *p_object); void hide_top_editors(); void select_editor_by_name(const String &p_name); @@ -770,9 +805,11 @@ public: void open_request(const String &p_path); void edit_foreign_resource(Ref<Resource> p_resource); + bool is_resource_read_only(Ref<Resource> p_resource, bool p_foreign_resources_are_writable = false); + bool is_changing_scene() const; - Control *get_main_control(); + VBoxContainer *get_main_screen_control(); SubViewport *get_scene_root() { return scene_root; } // Root of the scene being edited. void set_edited_scene(Node *p_scene); @@ -785,12 +822,11 @@ public: bool is_scene_open(const String &p_path); - void set_current_version(uint64_t p_version); void set_current_scene(int p_idx); void setup_color_picker(ColorPicker *picker); - void request_instance_scene(const String &p_path); + void request_instantiate_scene(const String &p_path); void request_instantiate_scenes(const Vector<String> &p_files); void set_convert_old_scene(bool p_old) { convert_old = p_old; } @@ -806,12 +842,15 @@ public: Ref<Texture2D> get_object_icon(const Object *p_object, const String &p_fallback = "Object"); Ref<Texture2D> get_class_icon(const String &p_class, const String &p_fallback = "Object") const; + bool is_object_of_custom_type(const Object *p_object, const StringName &p_class); + void show_accept(const String &p_text, const String &p_title); void show_save_accept(const String &p_text, const String &p_title); void show_warning(const String &p_text, const String &p_title = TTR("Warning!")); void _copy_warning(const String &p_str); + void set_use_startup_benchmark(bool p_use_startup_benchmark, const String &p_startup_benchmark_file); Error export_preset(const String &p_preset, const String &p_path, bool p_debug, bool p_pack_only); Control *get_gui_base() { return gui_base; } @@ -876,7 +915,7 @@ public: bool ensure_main_scene(bool p_from_native); - Error run_play_native(int p_idx, int p_platform); + Error run_play_native(int p_id); void run_play(); void run_play_current(); void run_play_custom(const String &p_custom); @@ -913,9 +952,9 @@ 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); - EditorPlugin::AfterGUIInput 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); + EditorPlugin::AfterGUIInput forward_3d_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event, bool serve_when_force_input_enabled); + void forward_3d_draw_over_viewport(Control *p_overlay); + void forward_3d_force_draw_over_viewport(Control *p_overlay); void add_plugin(EditorPlugin *p_plugin); void remove_plugin(EditorPlugin *p_plugin); void clear(); |