GUI: batch instrument loading
This commit is contained in:
parent
b5eafcc468
commit
d7d744e633
|
@ -1492,7 +1492,8 @@ void FurnaceGUI::openFileDialog(FurnaceGUIFileDialogs type) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (DivInstrument* i: instruments) delete i;
|
for (DivInstrument* i: instruments) delete i;
|
||||||
}
|
},
|
||||||
|
(type==GUI_FILE_INS_OPEN)
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case GUI_FILE_INS_SAVE:
|
case GUI_FILE_INS_SAVE:
|
||||||
|
@ -4090,12 +4091,39 @@ bool FurnaceGUI::loop() {
|
||||||
exportAudio(copyOfName,DIV_EXPORT_MODE_MANY_CHAN);
|
exportAudio(copyOfName,DIV_EXPORT_MODE_MANY_CHAN);
|
||||||
break;
|
break;
|
||||||
case GUI_FILE_INS_OPEN: {
|
case GUI_FILE_INS_OPEN: {
|
||||||
std::vector<DivInstrument*> instruments=e->instrumentFromFile(copyOfName.c_str());
|
std::vector<DivInstrument*> instruments;
|
||||||
if (!instruments.empty()) {
|
bool ask=false;
|
||||||
if (!e->getWarnings().empty()) {
|
bool warn=false;
|
||||||
showWarning(e->getWarnings(),GUI_WARN_GENERIC);
|
String warns="there were some warnings/errors while loading instruments:\n";
|
||||||
|
for (String i: fileDialog->getFileName()) {
|
||||||
|
std::vector<DivInstrument*> insTemp=e->instrumentFromFile(i.c_str());
|
||||||
|
if (insTemp.empty()) {
|
||||||
|
warn=true;
|
||||||
|
warns+=fmt::sprintf("> %s: cannot load instrument! (%s)\n",i,e->getLastError());
|
||||||
|
} else if (!e->getWarnings().empty()) {
|
||||||
|
warn=true;
|
||||||
|
warns+=fmt::sprintf("> %s:\n%s\n",i,e->getWarnings());
|
||||||
}
|
}
|
||||||
if (instruments.size()>1) { // ask which instruments to load
|
if (insTemp.size()>1) ask=true;
|
||||||
|
for (DivInstrument* j: insTemp) {
|
||||||
|
instruments.push_back(j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (warn) {
|
||||||
|
if (instruments.empty()) {
|
||||||
|
if (fileDialog->getFileName().size()>1) {
|
||||||
|
showError(warns);
|
||||||
|
} else {
|
||||||
|
showError("cannot load instrument! ("+e->getLastError()+")");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
showWarning(warns,GUI_WARN_GENERIC);
|
||||||
|
}
|
||||||
|
} else if (instruments.empty()) {
|
||||||
|
showError("congratulations! you managed to load nothing.\nyou are entitled to a bug report.");
|
||||||
|
}
|
||||||
|
if (!instruments.empty()) {
|
||||||
|
if (ask) { // ask which instruments to load
|
||||||
for (DivInstrument* i: instruments) {
|
for (DivInstrument* i: instruments) {
|
||||||
pendingIns.push_back(std::make_pair(i,false));
|
pendingIns.push_back(std::make_pair(i,false));
|
||||||
}
|
}
|
||||||
|
@ -4106,8 +4134,6 @@ bool FurnaceGUI::loop() {
|
||||||
e->addInstrumentPtr(i);
|
e->addInstrumentPtr(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
showError("cannot load instrument! ("+e->getLastError()+")");
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue