GUI: de-duplicate file dialog filters
untested. may not work...
This commit is contained in:
parent
c21f880e3e
commit
1c171ed7bd
3 changed files with 43 additions and 44 deletions
|
|
@ -76,7 +76,38 @@ void _nfdThread(const NFDState state, std::atomic<bool>* ok, std::vector<String>
|
|||
}
|
||||
#endif
|
||||
|
||||
bool FurnaceGUIFileDialog::openLoad(String header, std::vector<String> filter, const char* noSysFilter, String path, double dpiScale, FileDialogSelectCallback clickCallback, bool allowMultiple) {
|
||||
void FurnaceGUIFileDialog::convertFilterList(std::vector<String>& filter) {
|
||||
memset(noSysFilter,0,4096);
|
||||
|
||||
String result;
|
||||
|
||||
for (size_t i=0; (i+1)<filter.size(); i+=2) {
|
||||
String label=filter[i];
|
||||
String ext;
|
||||
|
||||
if (filter[i+1]=="*") {
|
||||
ext=".*";
|
||||
} else for (char i: filter[i+1]) {
|
||||
switch (i) {
|
||||
case '*':
|
||||
break;
|
||||
case ' ':
|
||||
ext+=',';
|
||||
break;
|
||||
default:
|
||||
ext+=i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!result.empty()) result+=',';
|
||||
result+=fmt::sprintf("%s{%s}",label,ext);
|
||||
}
|
||||
|
||||
strncpy(noSysFilter,result.c_str(),4095);
|
||||
}
|
||||
|
||||
bool FurnaceGUIFileDialog::openLoad(String header, std::vector<String> filter, String path, double dpiScale, FileDialogSelectCallback clickCallback, bool allowMultiple) {
|
||||
if (opened) return false;
|
||||
saving=false;
|
||||
curPath=path;
|
||||
|
|
@ -149,6 +180,8 @@ bool FurnaceGUIFileDialog::openLoad(String header, std::vector<String> filter, c
|
|||
}
|
||||
#endif
|
||||
|
||||
convertFilterList(filter);
|
||||
|
||||
ImGuiFileDialog::Instance()->singleClickSel=mobileUI;
|
||||
ImGuiFileDialog::Instance()->DpiScale=dpiScale;
|
||||
ImGuiFileDialog::Instance()->mobileMode=mobileUI;
|
||||
|
|
@ -159,7 +192,7 @@ bool FurnaceGUIFileDialog::openLoad(String header, std::vector<String> filter, c
|
|||
return true;
|
||||
}
|
||||
|
||||
bool FurnaceGUIFileDialog::openSave(String header, std::vector<String> filter, const char* noSysFilter, String path, double dpiScale) {
|
||||
bool FurnaceGUIFileDialog::openSave(String header, std::vector<String> filter, String path, double dpiScale) {
|
||||
if (opened) return false;
|
||||
|
||||
#ifdef ANDROID
|
||||
|
|
@ -233,6 +266,8 @@ bool FurnaceGUIFileDialog::openSave(String header, std::vector<String> filter, c
|
|||
} else {
|
||||
hasError=false;
|
||||
|
||||
convertFilterList(filter);
|
||||
|
||||
ImGuiFileDialog::Instance()->singleClickSel=false;
|
||||
ImGuiFileDialog::Instance()->DpiScale=dpiScale;
|
||||
ImGuiFileDialog::Instance()->mobileMode=mobileUI;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue