This commit is contained in:
Spartan322
2025-02-21 23:27:43 -05:00
283 changed files with 80699 additions and 11854 deletions

View File

@@ -155,8 +155,26 @@ void FileDialog::_native_dialog_cb_with_options(bool p_ok, const Vector<String>
emit_signal(SNAME("files_selected"), files);
} else {
if (mode == FILE_MODE_SAVE_FILE) {
if (p_filter != 0 && p_filter != filter->get_item_count() - 1) {
bool valid = false;
bool valid = false;
if (p_filter == filter->get_item_count() - 1) {
valid = true; // Match none.
} else if (filters.size() > 1 && p_filter == 0) {
// Match all filters.
for (int i = 0; i < filters.size(); i++) {
String flt = filters[i].get_slice(";", 0);
for (int j = 0; j < flt.get_slice_count(","); j++) {
String str = flt.get_slice(",", j).strip_edges();
if (f.matchn(str)) {
valid = true;
break;
}
}
if (valid) {
break;
}
}
} else {
int idx = p_filter;
if (filters.size() > 1) {
idx--;
@@ -166,7 +184,7 @@ void FileDialog::_native_dialog_cb_with_options(bool p_ok, const Vector<String>
int filter_slice_count = flt.get_slice_count(",");
for (int j = 0; j < filter_slice_count; j++) {
String str = (flt.get_slice(",", j).strip_edges());
if (f.match(str)) {
if (f.matchn(str)) {
valid = true;
break;
}
@@ -175,9 +193,21 @@ void FileDialog::_native_dialog_cb_with_options(bool p_ok, const Vector<String>
if (!valid && filter_slice_count > 0) {
String str = (flt.get_slice(",", 0).strip_edges());
f += str.substr(1, str.length() - 1);
file->set_text(f.get_file());
valid = true;
}
} else {
valid = true;
}
}
// Add first extension of filter if no valid extension is found.
if (!valid) {
int idx = p_filter;
String flt = filters[idx].get_slice(";", 0);
String ext = flt.get_slice(",", 0).strip_edges().get_extension();
f += "." + ext;
}
emit_signal(SNAME("file_selected"), f);
} else if ((mode == FILE_MODE_OPEN_ANY || mode == FILE_MODE_OPEN_FILE) && dir_access->file_exists(f)) {
emit_signal(SNAME("file_selected"), f);
@@ -503,9 +533,9 @@ void FileDialog::_action_pressed() {
bool valid = false;
if (filter->get_selected() == filter->get_item_count() - 1) {
valid = true; // match none
valid = true; // Match none.
} else if (filters.size() > 1 && filter->get_selected() == 0) {
// match all filters
// Match all filters.
for (int i = 0; i < filters.size(); i++) {
String flt = filters[i].get_slice(";", 0);
for (int j = 0; j < flt.get_slice_count(","); j++) {