Merge branch 'tildearrow:master' into SID3

This commit is contained in:
LTVA1 2024-08-02 11:13:15 +03:00 committed by GitHub
commit 1a67453b99
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 100 additions and 6 deletions

View file

@ -486,7 +486,7 @@ std::vector<String>& FurnaceGUIFileDialog::getFileName() {
return fileName;
} else {
fileName.clear();
if (dialogType==1) {
if (dialogType!=0) {
fileName.push_back(ImGuiFileDialog::Instance()->GetFilePathName());
} else {
for (auto& i: ImGuiFileDialog::Instance()->GetSelection()) {

View file

@ -5159,11 +5159,81 @@ bool FurnaceGUI::loop() {
}
}
break;
case GUI_FILE_INS_SAVE_ALL:
case GUI_FILE_WAVE_SAVE_ALL:
case GUI_FILE_SAMPLE_SAVE_ALL:
showError("Placeholder.");
case GUI_FILE_INS_SAVE_ALL: {
String errors;
for (int i=0; i<e->song.insLen; i++) {
String nextPath=copyOfName;
nextPath+=DIR_SEPARATOR_STR;
nextPath+=fmt::sprintf("%.2X_",i);
for (char j: e->song.ins[i]->name) {
switch (j) {
// these chars are reserved
case '/': case '<': case '>': case ':': case '"': case '\\': case '|': case '?': case '*':
nextPath+='_';
break;
default:
nextPath+=j;
break;
}
}
nextPath+=".fui";
logV("%s",nextPath);
if (!e->song.ins[i]->save(nextPath.c_str(),&e->song,settings.writeInsNames)) {
errors+=fmt::sprintf("%s: could not save!\n",e->song.ins[i]->name);
}
}
if (!errors.empty()) {
showError(errors);
}
break;
}
case GUI_FILE_WAVE_SAVE_ALL: {
String errors;
for (int i=0; i<e->song.waveLen; i++) {
String nextPath=copyOfName;
nextPath+=DIR_SEPARATOR_STR;
nextPath+=fmt::sprintf("%.2X.fuw",i);
logV("%s",nextPath);
if (!e->song.wave[i]->save(nextPath.c_str())) {
errors+=fmt::sprintf("%d: could not save!\n",i);
}
}
if (!errors.empty()) {
showError(errors);
}
break;
}
case GUI_FILE_SAMPLE_SAVE_ALL: {
String errors;
for (int i=0; i<e->song.sampleLen; i++) {
String nextPath=copyOfName;
nextPath+=DIR_SEPARATOR_STR;
nextPath+=fmt::sprintf("%.2X_",i);
for (char j: e->song.sample[i]->name) {
switch (j) {
// these chars are reserved
case '/': case '<': case '>': case ':': case '"': case '\\': case '|': case '?': case '*':
nextPath+='_';
break;
default:
nextPath+=j;
break;
}
}
nextPath+=".wav";
logV("%s",nextPath);
if (!e->song.sample[i]->save(nextPath.c_str())) {
errors+=fmt::sprintf("%s: could not save!\n",e->song.sample[i]->name);
}
}
if (!errors.empty()) {
showError(errors);
}
break;
}
case GUI_FILE_WAVE_SAVE:
if (curWave>=0 && curWave<(int)e->song.wave.size()) {
if (e->song.wave[curWave]->save(copyOfName.c_str())) {