diff options
Diffstat (limited to 'editor/editor_node.cpp')
-rw-r--r-- | editor/editor_node.cpp | 100 |
1 files changed, 77 insertions, 23 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 61f8ab1936..bcfc516849 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -553,6 +553,8 @@ void EditorNode::_update_from_settings() { tree->set_debug_collision_contact_color(GLOBAL_GET("debug/shapes/collision/contact_color")); tree->set_debug_navigation_color(GLOBAL_GET("debug/shapes/navigation/geometry_color")); tree->set_debug_navigation_disabled_color(GLOBAL_GET("debug/shapes/navigation/disabled_geometry_color")); + + _update_title(); } void EditorNode::_select_default_main_screen_plugin() { @@ -582,10 +584,7 @@ void EditorNode::_notification(int p_what) { opening_prev = false; } - if (unsaved_cache != (saved_version != editor_data.get_undo_redo().get_version())) { - unsaved_cache = (saved_version != editor_data.get_undo_redo().get_version()); - _update_title(); - } + unsaved_cache = saved_version != editor_data.get_undo_redo().get_version(); if (last_checked_version != editor_data.get_undo_redo().get_version()) { _update_scene_tabs(); @@ -1792,6 +1791,10 @@ void EditorNode::save_scene_list(Vector<String> p_scene_filenames) { void EditorNode::restart_editor() { exiting = true; + if (editor_run.get_status() != EditorRun::STATUS_STOP) { + editor_run.stop(); + } + String to_reopen; if (get_tree()->get_edited_scene_root()) { to_reopen = get_tree()->get_edited_scene_root()->get_scene_file_path(); @@ -2338,6 +2341,20 @@ void EditorNode::_run(bool p_current, const String &p_custom) { return; } + String write_movie_file; + if (write_movie_button->is_pressed()) { + if (p_current && get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root()->has_meta("movie_file")) { + // If the scene file has a movie_file metadata set, use this as file. Quick workaround if you want to have multiple scenes that write to multiple movies. + write_movie_file = get_tree()->get_edited_scene_root()->get_meta("movie_file"); + } else { + write_movie_file = GLOBAL_GET("editor/movie_writer/movie_file"); + } + if (write_movie_file == String()) { + show_accept(TTR("Movie Maker mode is enabled, but no movie file path has been specified.\nA default movie file path can be specified in the project settings under the 'Editor/Movie Writer' category.\nAlternatively, for running single scenes, a 'movie_path' metadata can be added to the root node,\nspecifying the path to a movie file that will be used when recording that scene."), TTR("OK")); + return; + } + } + play_button->set_pressed(false); play_button->set_icon(gui_base->get_theme_icon(SNAME("MainPlay"), SNAME("EditorIcons"))); play_scene_button->set_pressed(false); @@ -2401,7 +2418,7 @@ void EditorNode::_run(bool p_current, const String &p_custom) { } EditorDebuggerNode::get_singleton()->start(); - Error error = editor_run.run(run_filename); + Error error = editor_run.run(run_filename, write_movie_file); if (error != OK) { EditorDebuggerNode::get_singleton()->stop(); show_accept(TTR("Could not start subprocess(es)!"), TTR("OK")); @@ -2784,6 +2801,9 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { case RUN_SETTINGS: { project_settings_editor->popup_project_settings(); } break; + case RUN_WRITE_MOVIE: { + _update_write_movie_icon(); + } break; case FILE_INSTALL_ANDROID_SOURCE: { if (p_confirmed) { export_template_manager->install_android_template(); @@ -3299,33 +3319,39 @@ void EditorNode::_update_addon_config() { } void EditorNode::set_addon_plugin_enabled(const String &p_addon, bool p_enabled, bool p_config_changed) { - ERR_FAIL_COND(p_enabled && addon_name_to_plugin.has(p_addon)); - ERR_FAIL_COND(!p_enabled && !addon_name_to_plugin.has(p_addon)); + String addon_path = p_addon; + + if (!addon_path.begins_with("res://")) { + addon_path = "res://addons/" + addon_path + "/plugin.cfg"; + } + + ERR_FAIL_COND(p_enabled && addon_name_to_plugin.has(addon_path)); + ERR_FAIL_COND(!p_enabled && !addon_name_to_plugin.has(addon_path)); if (!p_enabled) { - EditorPlugin *addon = addon_name_to_plugin[p_addon]; + EditorPlugin *addon = addon_name_to_plugin[addon_path]; remove_editor_plugin(addon, p_config_changed); memdelete(addon); - addon_name_to_plugin.erase(p_addon); + addon_name_to_plugin.erase(addon_path); _update_addon_config(); return; } Ref<ConfigFile> cf; cf.instantiate(); - if (!DirAccess::exists(p_addon.get_base_dir())) { - _remove_plugin_from_enabled(p_addon); - WARN_PRINT("Addon '" + p_addon + "' failed to load. No directory found. Removing from enabled plugins."); + if (!DirAccess::exists(addon_path.get_base_dir())) { + _remove_plugin_from_enabled(addon_path); + WARN_PRINT("Addon '" + addon_path + "' failed to load. No directory found. Removing from enabled plugins."); return; } - Error err = cf->load(p_addon); + Error err = cf->load(addon_path); if (err != OK) { - show_warning(vformat(TTR("Unable to enable addon plugin at: '%s' parsing of config failed."), p_addon)); + show_warning(vformat(TTR("Unable to enable addon plugin at: '%s' parsing of config failed."), addon_path)); return; } if (!cf->has_section_key("plugin", "script")) { - show_warning(vformat(TTR("Unable to find script field for addon plugin at: '%s'."), p_addon)); + show_warning(vformat(TTR("Unable to find script field for addon plugin at: '%s'."), addon_path)); return; } @@ -3334,7 +3360,7 @@ void EditorNode::set_addon_plugin_enabled(const String &p_addon, bool p_enabled, // Only try to load the script if it has a name. Else, the plugin has no init script. if (script_path.length() > 0) { - script_path = p_addon.get_base_dir().plus_file(script_path); + script_path = addon_path.get_base_dir().plus_file(script_path); script = ResourceLoader::load(script_path); if (script.is_null()) { @@ -3344,8 +3370,8 @@ void EditorNode::set_addon_plugin_enabled(const String &p_addon, bool p_enabled, // Errors in the script cause the base_type to be an empty StringName. if (script->get_instance_base_type() == StringName()) { - show_warning(vformat(TTR("Unable to load addon script from path: '%s'. This might be due to a code error in that script.\nDisabling the addon at '%s' to prevent further errors."), script_path, p_addon)); - _remove_plugin_from_enabled(p_addon); + show_warning(vformat(TTR("Unable to load addon script from path: '%s'. This might be due to a code error in that script.\nDisabling the addon at '%s' to prevent further errors."), script_path, addon_path)); + _remove_plugin_from_enabled(addon_path); return; } @@ -3363,14 +3389,18 @@ void EditorNode::set_addon_plugin_enabled(const String &p_addon, bool p_enabled, EditorPlugin *ep = memnew(EditorPlugin); ep->set_script(script); - addon_name_to_plugin[p_addon] = ep; + addon_name_to_plugin[addon_path] = ep; add_editor_plugin(ep, p_config_changed); _update_addon_config(); } bool EditorNode::is_addon_plugin_enabled(const String &p_addon) const { - return addon_name_to_plugin.has(p_addon); + if (p_addon.begins_with("res://")) { + return addon_name_to_plugin.has(p_addon); + } + + return addon_name_to_plugin.has("res://addons/" + p_addon + "/plugin.cfg"); } void EditorNode::_remove_edited_scene(bool p_change_tab) { @@ -4863,7 +4893,7 @@ bool EditorNode::has_scenes_in_session() { bool EditorNode::ensure_main_scene(bool p_from_native) { pick_main_scene->set_meta("from_native", p_from_native); // Whether from play button or native run. - String main_scene = GLOBAL_DEF("application/run/main_scene", ""); + String main_scene = GLOBAL_DEF_BASIC("application/run/main_scene", ""); if (main_scene.is_empty()) { current_menu_option = -1; @@ -4929,12 +4959,20 @@ bool EditorNode::is_run_playing() const { String EditorNode::get_run_playing_scene() const { String run_filename = editor_run.get_running_scene(); if (run_filename.is_empty() && is_run_playing()) { - run_filename = GLOBAL_DEF("application/run/main_scene", ""); // Must be the main scene then. + run_filename = GLOBAL_DEF_BASIC("application/run/main_scene", ""); // Must be the main scene then. } return run_filename; } +void EditorNode::_update_write_movie_icon() { + if (write_movie_button->is_pressed()) { + write_movie_button->set_icon(gui_base->get_theme_icon(SNAME("MainMovieWriteEnabled"), SNAME("EditorIcons"))); + } else { + write_movie_button->set_icon(gui_base->get_theme_icon(SNAME("MainMovieWrite"), SNAME("EditorIcons"))); + } +} + void EditorNode::_immediate_dialog_confirmed() { immediate_dialog_confirmed = true; } @@ -6690,6 +6728,23 @@ EditorNode::EditorNode() { ED_SHORTCUT_OVERRIDE("editor/play_custom_scene", "macos", KeyModifierMask::CMD | KeyModifierMask::SHIFT | Key::R); play_custom_scene_button->set_shortcut(ED_GET_SHORTCUT("editor/play_custom_scene")); + write_movie_button = memnew(Button); + write_movie_button->set_flat(true); + write_movie_button->set_toggle_mode(true); + play_hb->add_child(write_movie_button); + write_movie_button->set_pressed(false); + write_movie_button->set_icon(gui_base->get_theme_icon(SNAME("MainMovieWrite"), SNAME("EditorIcons"))); + write_movie_button->set_focus_mode(Control::FOCUS_NONE); + write_movie_button->connect("pressed", callable_mp(this, &EditorNode::_menu_option), make_binds(RUN_WRITE_MOVIE)); + write_movie_button->set_tooltip(TTR("Enable Movie Maker mode.\nThe project will run at stable FPS and the visual and audio output will be recorded to a video file.")); + // Restore these values to something more useful so it ignores the theme + write_movie_button->add_theme_color_override("icon_normal_color", Color(1, 1, 1, 0.4)); + write_movie_button->add_theme_color_override("icon_pressed_color", Color(1, 1, 1, 1)); + write_movie_button->add_theme_color_override("icon_hover_color", Color(1.2, 1.2, 1.2, 0.4)); + write_movie_button->add_theme_color_override("icon_hover_pressed_color", Color(1.2, 1.2, 1.2, 1)); + write_movie_button->add_theme_color_override("icon_focus_color", Color(1, 1, 1, 1)); + write_movie_button->add_theme_color_override("icon_disabled_color", Color(1, 1, 1, 0.4)); + HBoxContainer *right_menu_hb = memnew(HBoxContainer); menu_hb->add_child(right_menu_hb); @@ -7040,7 +7095,6 @@ EditorNode::EditorNode() { add_editor_plugin(VersionControlEditorPlugin::get_singleton()); add_editor_plugin(memnew(ShaderEditorPlugin)); add_editor_plugin(memnew(ShaderFileEditorPlugin)); - add_editor_plugin(memnew(VisualShaderEditorPlugin)); add_editor_plugin(memnew(Camera3DEditorPlugin)); add_editor_plugin(memnew(ThemeEditorPlugin)); |