From 0fd72afeb455b7e828c87765c2f6cb6a8cc6b651 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Thu, 1 Aug 2024 01:19:29 -0500 Subject: [PATCH] here we go --- src/gui/fileDialog.cpp | 2 +- src/gui/gui.cpp | 58 ++++++++++++++++++++++++++++++++++++++---- 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/src/gui/fileDialog.cpp b/src/gui/fileDialog.cpp index cfebb2015..38afb3274 100644 --- a/src/gui/fileDialog.cpp +++ b/src/gui/fileDialog.cpp @@ -486,7 +486,7 @@ std::vector& 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()) { diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 48ffc95f0..3ba5e2705 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -5159,7 +5159,8 @@ bool FurnaceGUI::loop() { } } break; - case GUI_FILE_INS_SAVE_ALL: + case GUI_FILE_INS_SAVE_ALL: { + String errors; for (int i=0; isong.insLen; i++) { String nextPath=copyOfName; nextPath+=DIR_SEPARATOR_STR; @@ -5178,14 +5179,61 @@ bool FurnaceGUI::loop() { 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: - case GUI_FILE_SAMPLE_SAVE_ALL: - showError("Placeholder."); + } + case GUI_FILE_WAVE_SAVE_ALL: { + String errors; + for (int i=0; isong.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; isong.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())) {