diff options
Diffstat (limited to 'editor/editor_node.cpp')
-rw-r--r-- | editor/editor_node.cpp | 358 |
1 files changed, 214 insertions, 144 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 865ffd1baa..3183f1ae97 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(); @@ -238,185 +238,183 @@ void EditorNode::_unhandled_input(const Ref<InputEvent> &p_event) { void EditorNode::_notification(int p_what) { - if (p_what == NOTIFICATION_EXIT_TREE) { - - editor_data.save_editor_external_data(); - FileAccess::set_file_close_fail_notify_callback(NULL); - log->deinit(); // do not get messages anymore - } - if (p_what == NOTIFICATION_PROCESS) { - - if (opening_prev && !confirmation->is_visible()) - opening_prev = false; + switch (p_what) { + case NOTIFICATION_PROCESS: { + if (opening_prev && !confirmation->is_visible()) + opening_prev = false; - if (unsaved_cache != (saved_version != editor_data.get_undo_redo().get_version())) { + 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()); + _update_title(); + } - if (last_checked_version != editor_data.get_undo_redo().get_version()) { - _update_scene_tabs(); - last_checked_version = editor_data.get_undo_redo().get_version(); - } + if (last_checked_version != editor_data.get_undo_redo().get_version()) { + _update_scene_tabs(); + last_checked_version = editor_data.get_undo_redo().get_version(); + } - // update the animation frame of the update spinner - uint64_t frame = Engine::get_singleton()->get_frames_drawn(); - uint32_t tick = OS::get_singleton()->get_ticks_msec(); + // update the animation frame of the update spinner + uint64_t frame = Engine::get_singleton()->get_frames_drawn(); + uint32_t tick = OS::get_singleton()->get_ticks_msec(); - if (frame != update_spinner_step_frame && (tick - update_spinner_step_msec) > (1000 / 8)) { + if (frame != update_spinner_step_frame && (tick - update_spinner_step_msec) > (1000 / 8)) { - update_spinner_step++; - if (update_spinner_step >= 8) - update_spinner_step = 0; + update_spinner_step++; + if (update_spinner_step >= 8) + update_spinner_step = 0; - update_spinner_step_msec = tick; - update_spinner_step_frame = frame + 1; + update_spinner_step_msec = tick; + update_spinner_step_frame = frame + 1; - // update the icon itself only when the spinner is visible - if (EditorSettings::get_singleton()->get("interface/editor/show_update_spinner")) { - update_spinner->set_icon(gui_base->get_icon("Progress" + itos(update_spinner_step + 1), "EditorIcons")); + // update the icon itself only when the spinner is visible + if (EditorSettings::get_singleton()->get("interface/editor/show_update_spinner")) { + update_spinner->set_icon(gui_base->get_icon("Progress" + itos(update_spinner_step + 1), "EditorIcons")); + } } - } - editor_selection->update(); + editor_selection->update(); - scene_root->set_size_override(true, Size2(ProjectSettings::get_singleton()->get("display/window/size/width"), ProjectSettings::get_singleton()->get("display/window/size/height"))); + scene_root->set_size_override(true, Size2(ProjectSettings::get_singleton()->get("display/window/size/width"), ProjectSettings::get_singleton()->get("display/window/size/height"))); - ResourceImporterTexture::get_singleton()->update_imports(); - } - if (p_what == NOTIFICATION_ENTER_TREE) { + ResourceImporterTexture::get_singleton()->update_imports(); + } break; - Engine::get_singleton()->set_editor_hint(true); + case NOTIFICATION_ENTER_TREE: { + Engine::get_singleton()->set_editor_hint(true); - OS::get_singleton()->set_low_processor_usage_mode_sleep_usec(int(EDITOR_GET("interface/editor/low_processor_mode_sleep_usec"))); - get_tree()->get_root()->set_usage(Viewport::USAGE_2D_NO_SAMPLING); //reduce memory usage - get_tree()->get_root()->set_disable_3d(true); - get_tree()->get_root()->set_as_audio_listener(false); - get_tree()->get_root()->set_as_audio_listener_2d(false); - get_tree()->set_auto_accept_quit(false); - get_tree()->connect("files_dropped", this, "_dropped_files"); + OS::get_singleton()->set_low_processor_usage_mode_sleep_usec(int(EDITOR_GET("interface/editor/low_processor_mode_sleep_usec"))); + get_tree()->get_root()->set_usage(Viewport::USAGE_2D_NO_SAMPLING); //reduce memory usage + get_tree()->get_root()->set_disable_3d(true); + get_tree()->get_root()->set_as_audio_listener(false); + get_tree()->get_root()->set_as_audio_listener_2d(false); + get_tree()->set_auto_accept_quit(false); + get_tree()->connect("files_dropped", this, "_dropped_files"); - /* DO NOT LOAD SCENES HERE, WAIT FOR FILE SCANNING AND REIMPORT TO COMPLETE */ - } + /* DO NOT LOAD SCENES HERE, WAIT FOR FILE SCANNING AND REIMPORT TO COMPLETE */ + } break; - if (p_what == NOTIFICATION_EXIT_TREE) { + case NOTIFICATION_EXIT_TREE: { + editor_data.save_editor_external_data(); + FileAccess::set_file_close_fail_notify_callback(NULL); + log->deinit(); // do not get messages anymore + editor_data.clear_edited_scenes(); + } break; - editor_data.clear_edited_scenes(); - } - if (p_what == NOTIFICATION_READY) { + case NOTIFICATION_READY: { - VisualServer::get_singleton()->viewport_set_hide_scenario(get_scene_root()->get_viewport_rid(), true); - VisualServer::get_singleton()->viewport_set_hide_canvas(get_scene_root()->get_viewport_rid(), true); - VisualServer::get_singleton()->viewport_set_disable_environment(get_viewport()->get_viewport_rid(), true); + VisualServer::get_singleton()->viewport_set_hide_scenario(get_scene_root()->get_viewport_rid(), true); + VisualServer::get_singleton()->viewport_set_hide_canvas(get_scene_root()->get_viewport_rid(), true); + VisualServer::get_singleton()->viewport_set_disable_environment(get_viewport()->get_viewport_rid(), true); - feature_profile_manager->notify_changed(); + feature_profile_manager->notify_changed(); - if (!main_editor_buttons[EDITOR_3D]->is_visible()) { //may be hidden due to feature profile - _editor_select(EDITOR_2D); - } else { - _editor_select(EDITOR_3D); - } + if (!main_editor_buttons[EDITOR_3D]->is_visible()) { //may be hidden due to feature profile + _editor_select(EDITOR_2D); + } else { + _editor_select(EDITOR_3D); + } - _update_debug_options(); + _update_debug_options(); - /* DO NOT LOAD SCENES HERE, WAIT FOR FILE SCANNING AND REIMPORT TO COMPLETE */ - } + /* DO NOT LOAD SCENES HERE, WAIT FOR FILE SCANNING AND REIMPORT TO COMPLETE */ + } break; - if (p_what == MainLoop::NOTIFICATION_WM_FOCUS_IN) { + case MainLoop::NOTIFICATION_WM_FOCUS_IN: { - // Restore the original FPS cap after focusing back on the editor - OS::get_singleton()->set_low_processor_usage_mode_sleep_usec(int(EDITOR_GET("interface/editor/low_processor_mode_sleep_usec"))); + // Restore the original FPS cap after focusing back on the editor + OS::get_singleton()->set_low_processor_usage_mode_sleep_usec(int(EDITOR_GET("interface/editor/low_processor_mode_sleep_usec"))); - EditorFileSystem::get_singleton()->scan_changes(); - } + EditorFileSystem::get_singleton()->scan_changes(); + } break; - if (p_what == MainLoop::NOTIFICATION_WM_FOCUS_OUT) { + case MainLoop::NOTIFICATION_WM_FOCUS_OUT: { - // Set a low FPS cap to decrease CPU/GPU usage while the editor is unfocused - OS::get_singleton()->set_low_processor_usage_mode_sleep_usec(int(EDITOR_GET("interface/editor/unfocused_low_processor_mode_sleep_usec"))); - } + // Set a low FPS cap to decrease CPU/GPU usage while the editor is unfocused + OS::get_singleton()->set_low_processor_usage_mode_sleep_usec(int(EDITOR_GET("interface/editor/unfocused_low_processor_mode_sleep_usec"))); + } break; - if (p_what == MainLoop::NOTIFICATION_WM_QUIT_REQUEST) { + case MainLoop::NOTIFICATION_WM_QUIT_REQUEST: { - _menu_option_confirm(FILE_QUIT, false); - } + _menu_option_confirm(FILE_QUIT, false); + } break; - if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { - scene_tabs->set_tab_close_display_policy((bool(EDITOR_GET("interface/scene_tabs/always_show_close_button")) ? Tabs::CLOSE_BUTTON_SHOW_ALWAYS : Tabs::CLOSE_BUTTON_SHOW_ACTIVE_ONLY)); - Ref<Theme> theme = create_editor_theme(theme_base->get_theme()); + case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { + scene_tabs->set_tab_close_display_policy((bool(EDITOR_GET("interface/scene_tabs/always_show_close_button")) ? Tabs::CLOSE_BUTTON_SHOW_ALWAYS : Tabs::CLOSE_BUTTON_SHOW_ACTIVE_ONLY)); + Ref<Theme> theme = create_editor_theme(theme_base->get_theme()); - theme_base->set_theme(theme); - gui_base->set_theme(theme); + theme_base->set_theme(theme); + gui_base->set_theme(theme); - gui_base->add_style_override("panel", gui_base->get_stylebox("Background", "EditorStyles")); - scene_root_parent->add_style_override("panel", gui_base->get_stylebox("Content", "EditorStyles")); - bottom_panel->add_style_override("panel", gui_base->get_stylebox("panel", "TabContainer")); - scene_tabs->add_style_override("tab_fg", gui_base->get_stylebox("SceneTabFG", "EditorStyles")); - scene_tabs->add_style_override("tab_bg", gui_base->get_stylebox("SceneTabBG", "EditorStyles")); + gui_base->add_style_override("panel", gui_base->get_stylebox("Background", "EditorStyles")); + scene_root_parent->add_style_override("panel", gui_base->get_stylebox("Content", "EditorStyles")); + bottom_panel->add_style_override("panel", gui_base->get_stylebox("panel", "TabContainer")); + scene_tabs->add_style_override("tab_fg", gui_base->get_stylebox("SceneTabFG", "EditorStyles")); + scene_tabs->add_style_override("tab_bg", gui_base->get_stylebox("SceneTabBG", "EditorStyles")); - file_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles")); - project_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles")); - debug_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles")); - settings_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles")); - help_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles")); + file_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles")); + project_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles")); + debug_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles")); + settings_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles")); + help_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles")); - if (EDITOR_GET("interface/scene_tabs/resize_if_many_tabs")) { - scene_tabs->set_min_width(int(EDITOR_GET("interface/scene_tabs/minimum_width")) * EDSCALE); - } else { - scene_tabs->set_min_width(0); - } - _update_scene_tabs(); + if (EDITOR_GET("interface/scene_tabs/resize_if_many_tabs")) { + scene_tabs->set_min_width(int(EDITOR_GET("interface/scene_tabs/minimum_width")) * EDSCALE); + } else { + scene_tabs->set_min_width(0); + } + _update_scene_tabs(); - recent_scenes->set_as_minsize(); + recent_scenes->set_as_minsize(); - // debugger area - if (ScriptEditor::get_singleton()->get_debugger()->is_visible()) - bottom_panel->add_style_override("panel", gui_base->get_stylebox("BottomPanelDebuggerOverride", "EditorStyles")); + // debugger area + if (ScriptEditor::get_singleton()->get_debugger()->is_visible()) + bottom_panel->add_style_override("panel", gui_base->get_stylebox("BottomPanelDebuggerOverride", "EditorStyles")); - // update_icons - for (int i = 0; i < singleton->main_editor_buttons.size(); i++) { + // update_icons + for (int i = 0; i < singleton->main_editor_buttons.size(); i++) { - ToolButton *tb = singleton->main_editor_buttons[i]; - EditorPlugin *p_editor = singleton->editor_table[i]; - Ref<Texture> icon = p_editor->get_icon(); + ToolButton *tb = singleton->main_editor_buttons[i]; + EditorPlugin *p_editor = singleton->editor_table[i]; + Ref<Texture> icon = p_editor->get_icon(); - if (icon.is_valid()) { - tb->set_icon(icon); - } else if (singleton->gui_base->has_icon(p_editor->get_name(), "EditorIcons")) { - tb->set_icon(singleton->gui_base->get_icon(p_editor->get_name(), "EditorIcons")); + if (icon.is_valid()) { + tb->set_icon(icon); + } else if (singleton->gui_base->has_icon(p_editor->get_name(), "EditorIcons")) { + tb->set_icon(singleton->gui_base->get_icon(p_editor->get_name(), "EditorIcons")); + } } - } - _build_icon_type_cache(); + _build_icon_type_cache(); - play_button->set_icon(gui_base->get_icon("MainPlay", "EditorIcons")); - play_scene_button->set_icon(gui_base->get_icon("PlayScene", "EditorIcons")); - play_custom_scene_button->set_icon(gui_base->get_icon("PlayCustom", "EditorIcons")); - pause_button->set_icon(gui_base->get_icon("Pause", "EditorIcons")); - stop_button->set_icon(gui_base->get_icon("Stop", "EditorIcons")); + play_button->set_icon(gui_base->get_icon("MainPlay", "EditorIcons")); + play_scene_button->set_icon(gui_base->get_icon("PlayScene", "EditorIcons")); + play_custom_scene_button->set_icon(gui_base->get_icon("PlayCustom", "EditorIcons")); + pause_button->set_icon(gui_base->get_icon("Pause", "EditorIcons")); + stop_button->set_icon(gui_base->get_icon("Stop", "EditorIcons")); - prev_scene->set_icon(gui_base->get_icon("PrevScene", "EditorIcons")); - distraction_free->set_icon(gui_base->get_icon("DistractionFree", "EditorIcons")); - scene_tab_add->set_icon(gui_base->get_icon("Add", "EditorIcons")); + prev_scene->set_icon(gui_base->get_icon("PrevScene", "EditorIcons")); + distraction_free->set_icon(gui_base->get_icon("DistractionFree", "EditorIcons")); + scene_tab_add->set_icon(gui_base->get_icon("Add", "EditorIcons")); - // clear_button->set_icon(gui_base->get_icon("Close", "EditorIcons")); don't have access to that node. needs to become a class property - dock_tab_move_left->set_icon(theme->get_icon("Back", "EditorIcons")); - dock_tab_move_right->set_icon(theme->get_icon("Forward", "EditorIcons")); + // clear_button->set_icon(gui_base->get_icon("Close", "EditorIcons")); don't have access to that node. needs to become a class property + dock_tab_move_left->set_icon(theme->get_icon("Back", "EditorIcons")); + dock_tab_move_right->set_icon(theme->get_icon("Forward", "EditorIcons")); - PopupMenu *p = help_menu->get_popup(); - p->set_item_icon(p->get_item_index(HELP_SEARCH), gui_base->get_icon("HelpSearch", "EditorIcons")); - p->set_item_icon(p->get_item_index(HELP_DOCS), gui_base->get_icon("Instance", "EditorIcons")); - p->set_item_icon(p->get_item_index(HELP_QA), gui_base->get_icon("Instance", "EditorIcons")); - p->set_item_icon(p->get_item_index(HELP_ISSUES), gui_base->get_icon("Instance", "EditorIcons")); - p->set_item_icon(p->get_item_index(HELP_COMMUNITY), gui_base->get_icon("Instance", "EditorIcons")); - p->set_item_icon(p->get_item_index(HELP_ABOUT), gui_base->get_icon("Godot", "EditorIcons")); + PopupMenu *p = help_menu->get_popup(); + p->set_item_icon(p->get_item_index(HELP_SEARCH), gui_base->get_icon("HelpSearch", "EditorIcons")); + p->set_item_icon(p->get_item_index(HELP_DOCS), gui_base->get_icon("Instance", "EditorIcons")); + p->set_item_icon(p->get_item_index(HELP_QA), gui_base->get_icon("Instance", "EditorIcons")); + p->set_item_icon(p->get_item_index(HELP_ISSUES), gui_base->get_icon("Instance", "EditorIcons")); + p->set_item_icon(p->get_item_index(HELP_COMMUNITY), gui_base->get_icon("Instance", "EditorIcons")); + p->set_item_icon(p->get_item_index(HELP_ABOUT), gui_base->get_icon("Godot", "EditorIcons")); - _update_update_spinner(); - } + _update_update_spinner(); + } break; - if (p_what == Control::NOTIFICATION_RESIZED) { - _update_scene_tabs(); + case Control::NOTIFICATION_RESIZED: { + _update_scene_tabs(); + } break; } } @@ -2485,7 +2483,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 +2547,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 +2620,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(); } @@ -3673,6 +3711,11 @@ void EditorNode::show_warning(const String &p_text, const String &p_title) { warning->popup_centered_minsize(); } +void EditorNode::_copy_warning(const String &p_str) { + + OS::get_singleton()->set_clipboard(warning->get_text()); +} + void EditorNode::_dock_select_input(const Ref<InputEvent> &p_input) { Ref<InputEventMouse> me = p_input; @@ -4927,18 +4970,18 @@ void EditorNode::dim_editor(bool p_dimming) { static int dim_count = 0; bool dim_ui = EditorSettings::get_singleton()->get("interface/editor/dim_editor_on_dialog_popup"); if (p_dimming) { - if (dim_ui) { - if (dim_count == 0) { - _start_dimming(true); - } - dim_count++; + if (dim_ui && dim_count == 0) { + _start_dimming(true); } + dim_count++; } else { if (dim_count == 1) { _start_dimming(false); - dim_count = 0; - } else if (dim_ui && dim_count > 0) { + } + if (dim_count > 0) { dim_count--; + } else { + ERR_PRINT("Undimmed before dimming!"); } } } @@ -5057,10 +5100,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 +5117,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(); @@ -5150,6 +5195,8 @@ void EditorNode::_bind_methods() { ClassDB::bind_method(D_METHOD("_inherit_imported"), &EditorNode::_inherit_imported); ClassDB::bind_method(D_METHOD("_dim_timeout"), &EditorNode::_dim_timeout); + ClassDB::bind_method("_copy_warning", &EditorNode::_copy_warning); + ClassDB::bind_method(D_METHOD("_resources_reimported"), &EditorNode::_resources_reimported); ClassDB::bind_method(D_METHOD("_bottom_panel_raise_toggled"), &EditorNode::_bottom_panel_raise_toggled); @@ -5160,6 +5207,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")); @@ -5747,7 +5798,9 @@ EditorNode::EditorNode() { feature_profile_manager->connect("current_feature_profile_changed", this, "_feature_profile_changed"); warning = memnew(AcceptDialog); + warning->add_button(TTR("Copy Text"), true, "copy"); gui_base->add_child(warning); + warning->connect("custom_action", this, "_copy_warning"); ED_SHORTCUT("editor/next_tab", TTR("Next tab"), KEY_MASK_CMD + KEY_TAB); ED_SHORTCUT("editor/prev_tab", TTR("Previous tab"), KEY_MASK_CMD + KEY_MASK_SHIFT + KEY_TAB); @@ -5886,6 +5939,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 +6272,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); @@ -6477,6 +6540,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() { |