瀏覽代碼

File path in save dialog automatically appended with correct extension if not manually added by the user.

Nathan Warden 10 年之前
父節點
當前提交
7d2f359a0c
共有 1 個文件被更改,包括 8 次插入1 次删除
  1. 8 1
      scene/gui/file_dialog.cpp

+ 8 - 1
scene/gui/file_dialog.cpp

@@ -184,7 +184,8 @@ void FileDialog::_action_pressed() {
 			if (idx>=0 && idx<filters.size()) {
 			if (idx>=0 && idx<filters.size()) {
 
 
 				String flt=filters[idx].get_slice(";",0);
 				String flt=filters[idx].get_slice(";",0);
-				for (int j=0;j<flt.get_slice_count(",");j++) {
+				int filterSliceCount=flt.get_slice_count(",");
+				for (int j=0;j<filterSliceCount;j++) {
 
 
 					String str = (flt.get_slice(",",j).strip_edges());
 					String str = (flt.get_slice(",",j).strip_edges());
 					if (f.match(str)) {
 					if (f.match(str)) {
@@ -192,6 +193,12 @@ void FileDialog::_action_pressed() {
 						break;
 						break;
 					}
 					}
 				}
 				}
+
+				if (!valid && filterSliceCount>0) {
+					String str = (flt.get_slice(",",0).strip_edges());
+					f+=str.substr(1, str.length()-1);
+					valid=true;
+				}
 			} else {
 			} else {
 				valid=true;
 				valid=true;
 			}
 			}