diff options
Diffstat (limited to 'editor/editor_node.cpp')
-rw-r--r-- | editor/editor_node.cpp | 81 |
1 files changed, 74 insertions, 7 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 3d640b4d35..9d3be1ab9e 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -222,7 +222,7 @@ void EditorNode::_unhandled_input(const Ref<InputEvent> &p_event) { _editor_select(EDITOR_SCRIPT); } else if (ED_IS_SHORTCUT("editor/editor_help", p_event)) { emit_signal("request_help_search", ""); - } else if (ED_IS_SHORTCUT("editor/editor_assetlib", p_event)) { + } else if (ED_IS_SHORTCUT("editor/editor_assetlib", p_event) && StreamPeerSSL::is_available()) { _editor_select(EDITOR_ASSETLIB); } else if (ED_IS_SHORTCUT("editor/editor_next", p_event)) { _editor_select_next(); @@ -2485,7 +2485,16 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { bool was_visible = OS::get_singleton()->is_console_visible(); OS::get_singleton()->set_console_visible(!was_visible); EditorSettings::get_singleton()->set_setting("interface/editor/hide_console_window", !was_visible); + } break; + case EDITOR_SCREENSHOT: { + + screenshot_timer->start(); + } break; + case EDITOR_OPEN_SCREENSHOT: { + bool is_checked = settings_menu->get_popup()->is_item_checked(settings_menu->get_popup()->get_item_index(EDITOR_OPEN_SCREENSHOT)); + settings_menu->get_popup()->set_item_checked(settings_menu->get_popup()->get_item_index(EDITOR_OPEN_SCREENSHOT), !is_checked); + EditorSettings::get_singleton()->set_project_metadata("screenshot_options", "open_screenshot", !is_checked); } break; case SETTINGS_PICK_MAIN_SCENE: { @@ -2540,6 +2549,30 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } } +void EditorNode::_request_screenshot() { + _screenshot(); +} + +void EditorNode::_screenshot(bool p_use_utc) { + String name = "editor_screenshot_" + OS::get_singleton()->get_iso_date_time(p_use_utc).replace(":", "") + ".png"; + NodePath path = String("user://") + name; + _save_screenshot(path); + if (EditorSettings::get_singleton()->get_project_metadata("screenshot_options", "open_screenshot", true)) { + OS::get_singleton()->shell_open(String("file://") + ProjectSettings::get_singleton()->globalize_path(path)); + } +} + +void EditorNode::_save_screenshot(NodePath p_path) { + + Viewport *viewport = EditorInterface::get_singleton()->get_editor_viewport()->get_viewport(); + viewport->set_clear_mode(Viewport::CLEAR_MODE_ONLY_NEXT_FRAME); + Ref<Image> img = viewport->get_texture()->get_data(); + img->flip_y(); + viewport->set_clear_mode(Viewport::CLEAR_MODE_ALWAYS); + Error error = img->save_png(p_path); + ERR_FAIL_COND(error != OK); +} + void EditorNode::_tool_menu_option(int p_idx) { switch (tool_menu->get_item_id(p_idx)) { case TOOLS_ORPHAN_RESOURCES: { @@ -2589,6 +2622,13 @@ void EditorNode::_exit_editor() { exiting = true; resource_preview->stop(); //stop early to avoid crashes _save_docks(); + + // Dim the editor window while it's quitting to make it clearer that it's busy. + // No transition is applied, as the effect needs to be visible immediately + float c = 1.0f - float(EDITOR_GET("interface/editor/dim_amount")); + Color dim_color = Color(c, c, c); + gui_base->set_modulate(dim_color); + get_tree()->quit(); } @@ -2818,7 +2858,7 @@ void EditorNode::set_addon_plugin_enabled(const String &p_addon, bool p_enabled, Ref<ConfigFile> cf; cf.instance(); - String addon_path = "res://addons/" + p_addon + "/plugin.cfg"; + String addon_path = String("res://addons").plus_file(p_addon).plus_file("plugin.cfg"); if (!DirAccess::exists(addon_path.get_base_dir())) { ProjectSettings *ps = ProjectSettings::get_singleton(); PoolStringArray enabled_plugins = ps->get("editor_plugins/enabled"); @@ -2845,7 +2885,7 @@ void EditorNode::set_addon_plugin_enabled(const String &p_addon, bool p_enabled, } String path = cf->get_value("plugin", "script"); - path = "res://addons/" + p_addon + "/" + path; + path = String("res://addons").plus_file(p_addon).plus_file(path); Ref<Script> script = ResourceLoader::load(path); @@ -5057,10 +5097,11 @@ void EditorNode::_feature_profile_changed() { main_editor_buttons[EDITOR_3D]->set_visible(!profile->is_feature_disabled(EditorFeatureProfile::FEATURE_3D)); main_editor_buttons[EDITOR_SCRIPT]->set_visible(!profile->is_feature_disabled(EditorFeatureProfile::FEATURE_SCRIPT)); - main_editor_buttons[EDITOR_ASSETLIB]->set_visible(!profile->is_feature_disabled(EditorFeatureProfile::FEATURE_ASSET_LIB)); + if (StreamPeerSSL::is_available()) + main_editor_buttons[EDITOR_ASSETLIB]->set_visible(!profile->is_feature_disabled(EditorFeatureProfile::FEATURE_ASSET_LIB)); if ((profile->is_feature_disabled(EditorFeatureProfile::FEATURE_3D) && singleton->main_editor_buttons[EDITOR_3D]->is_pressed()) || (profile->is_feature_disabled(EditorFeatureProfile::FEATURE_SCRIPT) && singleton->main_editor_buttons[EDITOR_SCRIPT]->is_pressed()) || - (profile->is_feature_disabled(EditorFeatureProfile::FEATURE_ASSET_LIB) && singleton->main_editor_buttons[EDITOR_ASSETLIB]->is_pressed())) { + (StreamPeerSSL::is_available() && profile->is_feature_disabled(EditorFeatureProfile::FEATURE_ASSET_LIB) && singleton->main_editor_buttons[EDITOR_ASSETLIB]->is_pressed())) { _editor_select(EDITOR_2D); } } else { @@ -5073,7 +5114,8 @@ void EditorNode::_feature_profile_changed() { filesystem_dock->set_visible(true); main_editor_buttons[EDITOR_3D]->set_visible(true); main_editor_buttons[EDITOR_SCRIPT]->set_visible(true); - main_editor_buttons[EDITOR_ASSETLIB]->set_visible(true); + if (StreamPeerSSL::is_available()) + main_editor_buttons[EDITOR_ASSETLIB]->set_visible(true); } _update_dock_slots_visibility(); @@ -5160,6 +5202,10 @@ void EditorNode::_bind_methods() { ClassDB::bind_method(D_METHOD("_resources_changed"), &EditorNode::_resources_changed); ClassDB::bind_method(D_METHOD("_feature_profile_changed"), &EditorNode::_feature_profile_changed); + ClassDB::bind_method("_screenshot", &EditorNode::_screenshot); + ClassDB::bind_method("_request_screenshot", &EditorNode::_request_screenshot); + ClassDB::bind_method("_save_screenshot", &EditorNode::_save_screenshot); + ADD_SIGNAL(MethodInfo("play_pressed")); ADD_SIGNAL(MethodInfo("pause_pressed")); ADD_SIGNAL(MethodInfo("stop_pressed")); @@ -5886,6 +5932,16 @@ EditorNode::EditorNode() { editor_layouts->connect("id_pressed", this, "_layout_menu_option"); p->add_submenu_item(TTR("Editor Layout"), "Layouts"); #ifdef OSX_ENABLED + p->add_shortcut(ED_SHORTCUT("editor/take_screenshot", TTR("Take Screenshot"), KEY_MASK_CMD | KEY_F12), EDITOR_SCREENSHOT); +#else + p->add_shortcut(ED_SHORTCUT("editor/take_screenshot", TTR("Take Screenshot"), KEY_MASK_CTRL | KEY_F12), EDITOR_SCREENSHOT); +#endif + p->set_item_tooltip(p->get_item_count() - 1, TTR("Screenshots are stored in the Editor Data/Settings Folder.")); + p->add_check_shortcut(ED_SHORTCUT("editor/open_screenshot", TTR("Automatically Open Screenshots")), EDITOR_OPEN_SCREENSHOT); + bool is_open_screenshot = EditorSettings::get_singleton()->get_project_metadata("screenshot_options", "open_screenshot", true); + p->set_item_checked(p->get_item_count() - 1, is_open_screenshot); + p->set_item_tooltip(p->get_item_count() - 1, TTR("Open in an external image editor.")); +#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); @@ -6209,7 +6265,7 @@ EditorNode::EditorNode() { file_export_lib->set_title(TTR("Export Library")); file_export_lib->set_mode(EditorFileDialog::MODE_SAVE_FILE); file_export_lib->connect("file_selected", this, "_dialog_action"); - file_export_lib_merge = memnew(CheckButton); + file_export_lib_merge = memnew(CheckBox); file_export_lib_merge->set_text(TTR("Merge With Existing")); file_export_lib_merge->set_pressed(true); file_export_lib->get_vbox()->add_child(file_export_lib_merge); @@ -6342,6 +6398,10 @@ EditorNode::EditorNode() { Ref<ParticlesMaterialConversionPlugin> particles_mat_convert; particles_mat_convert.instance(); resource_conversion_plugins.push_back(particles_mat_convert); + + Ref<VisualShaderConversionPlugin> vshader_convert; + vshader_convert.instance(); + resource_conversion_plugins.push_back(vshader_convert); } update_spinner_step_msec = OS::get_singleton()->get_ticks_msec(); update_spinner_step_frame = Engine::get_singleton()->get_frames_drawn(); @@ -6473,6 +6533,13 @@ EditorNode::EditorNode() { 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")); + + screenshot_timer = memnew(Timer); + screenshot_timer->set_one_shot(true); + screenshot_timer->set_wait_time(settings_menu->get_popup()->get_submenu_popup_delay() + 0.1f); + screenshot_timer->connect("timeout", this, "_request_screenshot"); + add_child(screenshot_timer); + screenshot_timer->set_owner(get_owner()); } EditorNode::~EditorNode() { |