From 1f4b1e1488551ad297ffa10379ebcbff9cdc764b Mon Sep 17 00:00:00 2001 From: volzhs Date: Wed, 14 Oct 2020 03:28:45 +0900 Subject: Enhance editor file dialog 1. show valid directory path when opening editor file dialog 2. keep file name when changing path by entering path 3. add first extension in filter automatically if not given 4. remove directory in recent list if it's not valid anymore --- editor/editor_node.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'editor/editor_node.cpp') diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 73562e0695..849b053357 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -2262,7 +2262,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { int scene_idx = (p_option == FILE_SAVE_SCENE) ? -1 : tab_closing; Node *scene = editor_data.get_edited_scene_root(scene_idx); - if (scene && scene->get_filename() != "") { + if (scene && scene->get_filename() != "" && FileAccess::exists(scene->get_filename())) { if (scene_idx != editor_data.get_edited_scene()) { _save_scene_with_preview(scene->get_filename(), scene_idx); } else { @@ -2307,11 +2307,12 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } if (scene->get_filename() != "") { - file->set_current_path(scene->get_filename()); + String path = scene->get_filename(); + file->set_current_path(path); if (extensions.size()) { - String ext = scene->get_filename().get_extension().to_lower(); + String ext = path.get_extension().to_lower(); if (extensions.find(ext) == nullptr) { - file->set_current_path(scene->get_filename().replacen("." + ext, "." + extensions.front()->get())); + file->set_current_path(path.replacen("." + ext, "." + extensions.front()->get())); } } } else { -- cgit v1.2.3