summaryrefslogtreecommitdiff
path: root/editor/editor_node.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/editor_node.cpp')
-rw-r--r--editor/editor_node.cpp64
1 files changed, 60 insertions, 4 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 865ffd1baa..d9600172d7 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: {
@@ -5057,10 +5090,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 +5107,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 +5195,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 +5925,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);
@@ -6477,6 +6526,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() {