diff options
Diffstat (limited to 'editor/editor_node.cpp')
-rw-r--r-- | editor/editor_node.cpp | 205 |
1 files changed, 149 insertions, 56 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 4b068f1000..6256856b40 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -51,7 +51,6 @@ #include "scene/resources/packed_scene.h" #include "servers/physics_2d_server.h" -#include "editor/animation_editor.h" #include "editor/editor_audio_buses.h" #include "editor/editor_file_system.h" #include "editor/editor_help.h" @@ -67,7 +66,11 @@ #include "editor/import/resource_importer_scene.h" #include "editor/import/resource_importer_texture.h" #include "editor/import/resource_importer_wav.h" +#include "editor/plugins/animation_blend_space_1d_editor.h" +#include "editor/plugins/animation_blend_space_2d_editor.h" +#include "editor/plugins/animation_blend_tree_editor_plugin.h" #include "editor/plugins/animation_player_editor_plugin.h" +#include "editor/plugins/animation_state_machine_editor.h" #include "editor/plugins/animation_tree_editor_plugin.h" #include "editor/plugins/asset_library_editor_plugin.h" #include "editor/plugins/baked_lightmap_editor_plugin.h" @@ -88,7 +91,6 @@ #include "editor/plugins/mesh_editor_plugin.h" #include "editor/plugins/mesh_instance_editor_plugin.h" #include "editor/plugins/multimesh_editor_plugin.h" -#include "editor/plugins/navigation_mesh_editor_plugin.h" #include "editor/plugins/navigation_polygon_editor_plugin.h" #include "editor/plugins/particles_2d_editor_plugin.h" #include "editor/plugins/particles_editor_plugin.h" @@ -97,6 +99,7 @@ #include "editor/plugins/physical_bone_plugin.h" #include "editor/plugins/polygon_2d_editor_plugin.h" #include "editor/plugins/resource_preloader_editor_plugin.h" +#include "editor/plugins/root_motion_editor_plugin.h" #include "editor/plugins/script_editor_plugin.h" #include "editor/plugins/script_text_editor.h" #include "editor/plugins/shader_editor_plugin.h" @@ -584,7 +587,6 @@ void EditorNode::edit_node(Node *p_node) { void EditorNode::save_resource_in_path(const Ref<Resource> &p_resource, const String &p_path) { editor_data.apply_changes_in_editors(); - int flg = 0; if (EditorSettings::get_singleton()->get("filesystem/on_save/compress_binary_resources")) flg |= ResourceSaver::FLAG_COMPRESS; @@ -1052,8 +1054,23 @@ void EditorNode::_save_scene(String p_file, int idx) { flg |= ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS; err = ResourceSaver::save(p_file, sdata, flg); - Map<RES, bool> processed; - _save_edited_subresources(scene, processed, flg); + //Map<RES, bool> processed; + //this method is slow and not always works, deprecating + //_save_edited_subresources(scene, processed, flg); + { //instead, just find globally unsaved subresources and save them + + List<Ref<Resource> > cached; + ResourceCache::get_cached_resources(&cached); + for (List<Ref<Resource> >::Element *E = cached.front(); E; E = E->next()) { + + Ref<Resource> res = E->get(); + if (res->is_edited() && res->get_path().is_resource_file()) { + ResourceSaver::save(res->get_path(), res, flg); + res->set_edited(false); + } + } + } + editor_data.save_editor_external_data(); if (err == OK) { scene->set_filename(ProjectSettings::get_singleton()->localize_path(p_file)); @@ -1071,8 +1088,7 @@ void EditorNode::_save_scene(String p_file, int idx) { void EditorNode::_save_all_scenes() { - int i = _next_unsaved_scene(true, 0); - while (i != -1) { + for (int i = 0; i < editor_data.get_edited_scene_count(); i++) { Node *scene = editor_data.get_edited_scene_root(i); if (scene && scene->get_filename() != "") { if (i != editor_data.get_edited_scene()) @@ -1080,7 +1096,6 @@ void EditorNode::_save_all_scenes() { else _save_scene_with_preview(scene->get_filename()); } // else: ignore new scenes - i = _next_unsaved_scene(true, ++i); } _save_default_environment(); @@ -1302,7 +1317,31 @@ void EditorNode::_dialog_action(String p_file) { } } -void EditorNode::push_item(Object *p_object, const String &p_property) { +bool EditorNode::item_has_editor(Object *p_object) { + + return editor_data.get_subeditors(p_object).size() > 0; +} + +void EditorNode::edit_item(Object *p_object) { + + Vector<EditorPlugin *> sub_plugins; + + if (p_object) { + sub_plugins = editor_data.get_subeditors(p_object); + } + + if (!sub_plugins.empty()) { + _display_top_editors(false); + + _set_top_editors(sub_plugins); + _set_editing_top_editors(p_object); + _display_top_editors(true); + } else { + _hide_top_editors(); + } +} + +void EditorNode::push_item(Object *p_object, const String &p_property, bool p_inspector_only) { if (!p_object) { get_inspector()->edit(NULL); @@ -1314,7 +1353,9 @@ void EditorNode::push_item(Object *p_object, const String &p_property) { uint32_t id = p_object->get_instance_id(); if (id != editor_history.get_current()) { - if (p_property == "") + if (p_inspector_only) { + editor_history.add_object_inspector_only(id); + } else if (p_property == "") editor_history.add_object(id); else editor_history.add_object(id, p_property); @@ -1330,8 +1371,7 @@ void EditorNode::_save_default_environment() { if (fallback.is_valid() && fallback->get_path().is_resource_file()) { Map<RES, bool> processed; _find_and_save_edited_subresources(fallback.ptr(), processed, 0); - if (fallback->get_last_modified_time() != fallback->get_import_last_modified_time()) - save_resource_in_path(fallback, fallback->get_path()); + save_resource_in_path(fallback, fallback->get_path()); } } @@ -1368,6 +1408,7 @@ void EditorNode::_edit_current() { uint32_t current = editor_history.get_current(); Object *current_obj = current > 0 ? ObjectDB::get_instance(current) : NULL; + bool inspector_only = editor_history.is_current_inspector_only(); this->current = current_obj; @@ -1383,7 +1424,8 @@ void EditorNode::_edit_current() { return; } - bool capitalize = bool(EDITOR_DEF("interface/editor/capitalize_properties", true)); + bool capitalize = bool(EDITOR_GET("interface/inspector/capitalize_properties")); + bool disable_folding = bool(EDITOR_GET("interface/inspector/disable_folding")); bool is_resource = current_obj->is_class("Resource"); bool is_node = current_obj->is_class("Node"); @@ -1439,6 +1481,7 @@ void EditorNode::_edit_current() { if (current_obj->is_class("ScriptEditorDebuggerInspectedObject")) { editable_warning = TTR("This is a remote object so changes to it will not be kept.\nPlease read the documentation relevant to debugging to better understand this workflow."); capitalize = false; + disable_folding = true; } get_inspector()->edit(current_obj); @@ -1451,59 +1494,66 @@ void EditorNode::_edit_current() { get_inspector()->set_enable_capitalize_paths(capitalize); } + if (get_inspector()->is_using_folding() == disable_folding) { + get_inspector()->set_use_folding(!disable_folding); + } + /* Take care of PLUGIN EDITOR */ - EditorPlugin *main_plugin = editor_data.get_editor(current_obj); + if (!inspector_only) { - if (main_plugin) { + EditorPlugin *main_plugin = editor_data.get_editor(current_obj); - // special case if use of external editor is true - if (main_plugin->get_name() == "Script" && (bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor")) || overrides_external_editor(current_obj))) { - if (!changing_scene) - main_plugin->edit(current_obj); - } + if (main_plugin) { - else if (main_plugin != editor_plugin_screen && (!ScriptEditor::get_singleton() || !ScriptEditor::get_singleton()->is_visible_in_tree() || ScriptEditor::get_singleton()->can_take_away_focus())) { - // update screen main_plugin + // special case if use of external editor is true + if (main_plugin->get_name() == "Script" && (bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor")) || overrides_external_editor(current_obj))) { + if (!changing_scene) + main_plugin->edit(current_obj); + } - if (!changing_scene) { + else if (main_plugin != editor_plugin_screen && (!ScriptEditor::get_singleton() || !ScriptEditor::get_singleton()->is_visible_in_tree() || ScriptEditor::get_singleton()->can_take_away_focus())) { + // update screen main_plugin - if (editor_plugin_screen) - editor_plugin_screen->make_visible(false); - editor_plugin_screen = main_plugin; - editor_plugin_screen->edit(current_obj); + if (!changing_scene) { - editor_plugin_screen->make_visible(true); + if (editor_plugin_screen) + editor_plugin_screen->make_visible(false); + editor_plugin_screen = main_plugin; + editor_plugin_screen->edit(current_obj); - int plugin_count = editor_data.get_editor_plugin_count(); - for (int i = 0; i < plugin_count; i++) { - editor_data.get_editor_plugin(i)->notify_main_screen_changed(editor_plugin_screen->get_name()); - } + editor_plugin_screen->make_visible(true); + + int plugin_count = editor_data.get_editor_plugin_count(); + for (int i = 0; i < plugin_count; i++) { + editor_data.get_editor_plugin(i)->notify_main_screen_changed(editor_plugin_screen->get_name()); + } - for (int i = 0; i < editor_table.size(); i++) { + for (int i = 0; i < editor_table.size(); i++) { - main_editor_buttons[i]->set_pressed(editor_table[i] == main_plugin); + main_editor_buttons[i]->set_pressed(editor_table[i] == main_plugin); + } } - } - } else { + } else { - editor_plugin_screen->edit(current_obj); + editor_plugin_screen->edit(current_obj); + } } - } - Vector<EditorPlugin *> sub_plugins = editor_data.get_subeditors(current_obj); + Vector<EditorPlugin *> sub_plugins = editor_data.get_subeditors(current_obj); - if (!sub_plugins.empty()) { - _display_top_editors(false); + if (!sub_plugins.empty()) { + _display_top_editors(false); - _set_top_editors(sub_plugins); - _set_editing_top_editors(current_obj); - _display_top_editors(true); + _set_top_editors(sub_plugins); + _set_editing_top_editors(current_obj); + _display_top_editors(true); - } else if (!editor_plugins_over->get_plugins_list().empty()) { + } else if (!editor_plugins_over->get_plugins_list().empty()) { - _hide_top_editors(); + _hide_top_editors(); + } } inspector_dock->update(current_obj); @@ -2163,7 +2213,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { export_template_manager->popup_manager(); } break; - case SETTINGS_TOGGLE_FULLSCREN: { + case SETTINGS_TOGGLE_FULLSCREEN: { OS::get_singleton()->set_window_fullscreen(!OS::get_singleton()->is_window_fullscreen()); @@ -3039,6 +3089,7 @@ void EditorNode::register_editor_types() { ClassDB::register_class<EditorInspector>(); ClassDB::register_class<EditorInspectorPlugin>(); ClassDB::register_class<EditorProperty>(); + ClassDB::register_class<AnimationTrackEditPlugin>(); // FIXME: Is this stuff obsolete, or should it be ported to new APIs? ClassDB::register_class<EditorScenePostImport>(); @@ -4596,6 +4647,10 @@ EditorNode::EditorNode() { Ref<EditorInspectorDefaultPlugin> eidp; eidp.instance(); EditorInspector::add_inspector_plugin(eidp); + + Ref<EditorInspectorRootMotionPlugin> rmp; + rmp.instance(); + EditorInspector::add_inspector_plugin(rmp); } _pvrtc_register_compressors(); @@ -4621,9 +4676,7 @@ EditorNode::EditorNode() { GLOBAL_DEF("editor/main_run_args", ""); - ClassDB::set_class_enabled("CollisionShape", true); - ClassDB::set_class_enabled("CollisionShape2D", true); - ClassDB::set_class_enabled("CollisionPolygon2D", true); + ClassDB::set_class_enabled("RootMotionView", true); //defs here, use EDITOR_GET in logic EDITOR_DEF("interface/scene_tabs/always_show_close_button", false); @@ -4638,6 +4691,7 @@ EditorNode::EditorNode() { EDITOR_DEF("interface/scene_tabs/restore_scenes_on_load", false); EDITOR_DEF("interface/scene_tabs/show_thumbnail_on_hover", true); EDITOR_DEF("interface/inspector/capitalize_properties", true); + EDITOR_DEF("interface/inspector/disable_folding", false); EDITOR_DEF("interface/inspector/open_resources_in_new_inspector", false); EDITOR_DEF("run/auto_save/save_before_running", true); @@ -4835,7 +4889,11 @@ EditorNode::EditorNode() { srt->add_child(tabbar_container); tabbar_container->add_child(scene_tabs); distraction_free = memnew(ToolButton); +#ifdef OSX_ENABLED + distraction_free->set_shortcut(ED_SHORTCUT("editor/distraction_free_mode", TTR("Distraction Free Mode"), KEY_MASK_CMD | KEY_MASK_CTRL | KEY_D)); +#else distraction_free->set_shortcut(ED_SHORTCUT("editor/distraction_free_mode", TTR("Distraction Free Mode"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_F11)); +#endif distraction_free->set_tooltip(TTR("Toggle distraction-free mode.")); distraction_free->connect("pressed", this, "_toggle_distraction_free_mode"); distraction_free->set_icon(gui_base->get_icon("DistractionFree", "EditorIcons")); @@ -4942,7 +5000,7 @@ EditorNode::EditorNode() { p->add_shortcut(ED_SHORTCUT("editor/save_scene_as", TTR("Save Scene As..."), KEY_MASK_SHIFT + KEY_MASK_CMD + KEY_S), FILE_SAVE_AS_SCENE); p->add_shortcut(ED_SHORTCUT("editor/save_all_scenes", TTR("Save all Scenes"), KEY_MASK_ALT + KEY_MASK_SHIFT + KEY_MASK_CMD + KEY_S), FILE_SAVE_ALL_SCENES); p->add_separator(); - p->add_shortcut(ED_SHORTCUT("editor/close_scene", TTR("Close Scene"), KEY_MASK_SHIFT + KEY_MASK_CTRL + KEY_W), FILE_CLOSE); + p->add_shortcut(ED_SHORTCUT("editor/close_scene", TTR("Close Scene"), KEY_MASK_SHIFT + KEY_MASK_CMD + KEY_W), FILE_CLOSE); p->add_separator(); p->add_submenu_item(TTR("Open Recent"), "RecentScenes", FILE_OPEN_RECENT); p->add_separator(); @@ -4995,7 +5053,7 @@ EditorNode::EditorNode() { #ifdef OSX_ENABLED p->add_item(TTR("Quit to Project List"), RUN_PROJECT_MANAGER, KEY_MASK_SHIFT + KEY_MASK_ALT + KEY_Q); #else - p->add_item(TTR("Quit to Project List"), RUN_PROJECT_MANAGER, KEY_MASK_SHIFT + KEY_MASK_CTRL + KEY_Q); + p->add_item(TTR("Quit to Project List"), RUN_PROJECT_MANAGER, KEY_MASK_SHIFT + KEY_MASK_CMD + KEY_Q); #endif PanelContainer *editor_region = memnew(PanelContainer); @@ -5044,7 +5102,11 @@ EditorNode::EditorNode() { p->add_child(editor_layouts); editor_layouts->connect("id_pressed", this, "_layout_menu_option"); p->add_submenu_item(TTR("Editor Layout"), "Layouts"); - p->add_shortcut(ED_SHORTCUT("editor/fullscreen_mode", TTR("Toggle Fullscreen"), KEY_MASK_SHIFT | KEY_F11), SETTINGS_TOGGLE_FULLSCREN); +#ifdef OSX_ENABLED + p->add_shortcut(ED_SHORTCUT("editor/fullscreen_mode", TTR("Toggle Fullscreen"), KEY_MASK_CMD | KEY_MASK_CTRL | KEY_F), SETTINGS_TOGGLE_FULLSCREEN); +#else + p->add_shortcut(ED_SHORTCUT("editor/fullscreen_mode", TTR("Toggle Fullscreen"), KEY_MASK_SHIFT | KEY_F11), SETTINGS_TOGGLE_FULLSCREEN); +#endif p->add_separator(); p->add_item(TTR("Manage Export Templates"), SETTINGS_MANAGE_EXPORT_TEMPLATES); @@ -5084,7 +5146,11 @@ EditorNode::EditorNode() { play_button->set_focus_mode(Control::FOCUS_NONE); play_button->connect("pressed", this, "_menu_option", make_binds(RUN_PLAY)); play_button->set_tooltip(TTR("Play the project.")); +#ifdef OSX_ENABLED + play_button->set_shortcut(ED_SHORTCUT("editor/play", TTR("Play"), KEY_MASK_CMD | KEY_B)); +#else play_button->set_shortcut(ED_SHORTCUT("editor/play", TTR("Play"), KEY_F5)); +#endif pause_button = memnew(ToolButton); pause_button->set_toggle_mode(true); @@ -5093,7 +5159,11 @@ EditorNode::EditorNode() { pause_button->set_tooltip(TTR("Pause the scene")); pause_button->set_disabled(true); play_hb->add_child(pause_button); +#ifdef OSX_ENABLED + pause_button->set_shortcut(ED_SHORTCUT("editor/pause_scene", TTR("Pause Scene"), KEY_MASK_CMD | KEY_MASK_CTRL | KEY_Y)); +#else pause_button->set_shortcut(ED_SHORTCUT("editor/pause_scene", TTR("Pause Scene"), KEY_F7)); +#endif stop_button = memnew(ToolButton); play_hb->add_child(stop_button); @@ -5102,7 +5172,11 @@ EditorNode::EditorNode() { stop_button->connect("pressed", this, "_menu_option", make_binds(RUN_STOP)); stop_button->set_tooltip(TTR("Stop the scene.")); stop_button->set_disabled(true); +#ifdef OSX_ENABLED + stop_button->set_shortcut(ED_SHORTCUT("editor/stop", TTR("Stop"), KEY_MASK_CMD | KEY_PERIOD)); +#else stop_button->set_shortcut(ED_SHORTCUT("editor/stop", TTR("Stop"), KEY_F8)); +#endif run_native = memnew(EditorRunNative); play_hb->add_child(run_native); @@ -5120,7 +5194,11 @@ EditorNode::EditorNode() { play_scene_button->set_icon(gui_base->get_icon("PlayScene", "EditorIcons")); play_scene_button->connect("pressed", this, "_menu_option", make_binds(RUN_PLAY_SCENE)); play_scene_button->set_tooltip(TTR("Play the edited scene.")); +#ifdef OSX_ENABLED + play_scene_button->set_shortcut(ED_SHORTCUT("editor/play_scene", TTR("Play Scene"), KEY_MASK_CMD | KEY_R)); +#else play_scene_button->set_shortcut(ED_SHORTCUT("editor/play_scene", TTR("Play Scene"), KEY_F6)); +#endif play_custom_scene_button = memnew(ToolButton); play_hb->add_child(play_custom_scene_button); @@ -5129,7 +5207,11 @@ EditorNode::EditorNode() { play_custom_scene_button->set_icon(gui_base->get_icon("PlayCustom", "EditorIcons")); play_custom_scene_button->connect("pressed", this, "_menu_option", make_binds(RUN_PLAY_CUSTOM_SCENE)); play_custom_scene_button->set_tooltip(TTR("Play custom scene")); +#ifdef OSX_ENABLED + play_custom_scene_button->set_shortcut(ED_SHORTCUT("editor/play_custom_scene", TTR("Play Custom Scene"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_R)); +#else play_custom_scene_button->set_shortcut(ED_SHORTCUT("editor/play_custom_scene", TTR("Play Custom Scene"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_F5)); +#endif progress_hb = memnew(BackgroundProgress); @@ -5301,6 +5383,8 @@ EditorNode::EditorNode() { file->connect("file_selected", this, "_dialog_action"); file_templates->connect("file_selected", this, "_dialog_action"); + preview_gen = memnew(AudioStreamPreviewGenerator); + add_child(preview_gen); //plugin stuff file_server = memnew(EditorFileServer); @@ -5331,6 +5415,10 @@ EditorNode::EditorNode() { add_editor_plugin(memnew(ShaderEditorPlugin(this))); // FIXME: Disabled for Godot 3.0 as made incompatible, it needs to be ported to the new API. //add_editor_plugin(memnew(ShaderGraphEditorPlugin(this))); + add_editor_plugin(memnew(AnimationNodeBlendTreeEditorPlugin(this))); + add_editor_plugin(memnew(AnimationNodeBlendSpace1DEditorPlugin(this))); + add_editor_plugin(memnew(AnimationNodeBlendSpace2DEditorPlugin(this))); + add_editor_plugin(memnew(AnimationNodeStateMachineEditorPlugin(this))); add_editor_plugin(memnew(CameraEditorPlugin(this))); add_editor_plugin(memnew(ThemeEditorPlugin(this))); @@ -5365,7 +5453,6 @@ EditorNode::EditorNode() { add_editor_plugin(memnew(TextureEditorPlugin(this))); add_editor_plugin(memnew(AudioBusesEditorPlugin(audio_bus_editor))); add_editor_plugin(memnew(AudioBusesEditorPlugin(audio_bus_editor))); - add_editor_plugin(memnew(NavigationMeshEditorPlugin(this))); add_editor_plugin(memnew(SkeletonEditorPlugin(this))); add_editor_plugin(memnew(PhysicalBonePlugin(this))); @@ -5384,8 +5471,7 @@ EditorNode::EditorNode() { resource_preview->add_preview_generator(Ref<EditorPackedScenePreviewPlugin>(memnew(EditorPackedScenePreviewPlugin))); resource_preview->add_preview_generator(Ref<EditorMaterialPreviewPlugin>(memnew(EditorMaterialPreviewPlugin))); resource_preview->add_preview_generator(Ref<EditorScriptPreviewPlugin>(memnew(EditorScriptPreviewPlugin))); - // FIXME: Needs to be rewritten for AudioStream in Godot 3.0+ - //resource_preview->add_preview_generator( Ref<EditorSamplePreviewPlugin>( memnew(EditorSamplePreviewPlugin ))); + resource_preview->add_preview_generator(Ref<EditorAudioStreamPreviewPlugin>(memnew(EditorAudioStreamPreviewPlugin))); resource_preview->add_preview_generator(Ref<EditorMeshPreviewPlugin>(memnew(EditorMeshPreviewPlugin))); resource_preview->add_preview_generator(Ref<EditorBitmapPreviewPlugin>(memnew(EditorBitmapPreviewPlugin))); resource_preview->add_preview_generator(Ref<EditorFontPreviewPlugin>(memnew(EditorFontPreviewPlugin))); @@ -5512,10 +5598,17 @@ EditorNode::EditorNode() { print_handler.userdata = this; add_print_handler(&print_handler); +#ifdef OSX_ENABLED + ED_SHORTCUT("editor/editor_2d", TTR("Open 2D Editor"), KEY_MASK_ALT | KEY_1); + ED_SHORTCUT("editor/editor_3d", TTR("Open 3D Editor"), KEY_MASK_ALT | KEY_2); + ED_SHORTCUT("editor/editor_script", TTR("Open Script Editor"), KEY_MASK_ALT | KEY_3); + ED_SHORTCUT("editor/editor_help", TTR("Search Help"), KEY_MASK_ALT | KEY_SPACE); +#else ED_SHORTCUT("editor/editor_2d", TTR("Open 2D Editor"), KEY_F1); ED_SHORTCUT("editor/editor_3d", TTR("Open 3D Editor"), KEY_F2); ED_SHORTCUT("editor/editor_script", TTR("Open Script Editor"), KEY_F3); //hack neded for script editor F3 search to work :) Assign like this or don't use F3 ED_SHORTCUT("editor/editor_help", TTR("Search Help"), KEY_F4); +#endif ED_SHORTCUT("editor/editor_assetlib", TTR("Open Asset Library")); ED_SHORTCUT("editor/editor_next", TTR("Open the next Editor")); ED_SHORTCUT("editor/editor_prev", TTR("Open the previous Editor")); |