diff options
Diffstat (limited to 'editor/editor_file_dialog.cpp')
-rw-r--r-- | editor/editor_file_dialog.cpp | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index 24c5a788b6..1f43740858 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "editor_file_dialog.h" + #include "core/os/file_access.h" #include "core/os/keyboard.h" #include "core/os/os.h" @@ -679,7 +680,12 @@ void EditorFileDialog::update_file_name() { String filter_str = filters[idx]; String file_str = file->get_text(); String base_name = file_str.get_basename(); - file_str = base_name + "." + filter_str.split(";")[1].strip_edges().to_lower(); + Vector<String> filter_substr = filter_str.split(";"); + if (filter_substr.size() >= 2) { + file_str = base_name + "." + filter_substr[1].strip_edges().to_lower(); + } else { + file_str = base_name + "." + filter_str.get_extension().strip_edges().to_lower(); + } file->set_text(file_str); } } @@ -731,19 +737,15 @@ void EditorFileDialog::update_file_list() { List<String> files; List<String> dirs; - bool is_dir; - bool is_hidden; String item; - while ((item = dir_access->get_next(&is_dir)) != "") { + while ((item = dir_access->get_next()) != "") { if (item == "." || item == "..") continue; - is_hidden = dir_access->current_is_hidden(); - - if (show_hidden_files || !is_hidden) { - if (!is_dir) + if (show_hidden_files || !dir_access->current_is_hidden()) { + if (!dir_access->current_is_dir()) files.push_back(item); else dirs.push_back(item); @@ -1507,9 +1509,9 @@ EditorFileDialog::EditorFileDialog() { HBoxContainer *pathhb = memnew(HBoxContainer); dir_prev = memnew(ToolButton); - dir_prev->set_tooltip(TTR("Previous Folder")); + dir_prev->set_tooltip(TTR("Go to previous folder.")); dir_next = memnew(ToolButton); - dir_next->set_tooltip(TTR("Next Folder")); + dir_next->set_tooltip(TTR("Go to next folder.")); dir_up = memnew(ToolButton); dir_up->set_tooltip(TTR("Go to parent folder.")); @@ -1528,7 +1530,7 @@ EditorFileDialog::EditorFileDialog() { dir->set_h_size_flags(SIZE_EXPAND_FILL); refresh = memnew(ToolButton); - refresh->set_tooltip(TTR("Refresh")); + refresh->set_tooltip(TTR("Refresh files.")); refresh->connect("pressed", this, "_update_file_list"); pathhb->add_child(refresh); @@ -1541,7 +1543,7 @@ EditorFileDialog::EditorFileDialog() { show_hidden = memnew(ToolButton); show_hidden->set_toggle_mode(true); show_hidden->set_pressed(is_showing_hidden_files()); - show_hidden->set_tooltip(TTR("Toggle visibility of hidden files.")); + show_hidden->set_tooltip(TTR("Toggle the visibility of hidden files.")); show_hidden->connect("toggled", this, "set_show_hidden_files"); pathhb->add_child(show_hidden); |