From 16bc35d75b034fb07fb191f08a1e9447916d3815 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Fri, 25 Aug 2023 18:32:34 -0500 Subject: [PATCH] manual system recent file tracking issue #1406 --- src/gui/gui.cpp | 33 +++++++++++++++++++++++++++++---- src/gui/gui.h | 1 + 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 04ccc258b..27ec53c9d 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -2115,6 +2115,7 @@ int FurnaceGUI::save(String path, int dmfVersion) { showWarning(e->getWarnings(),GUI_WARN_GENERIC); } pushRecentFile(path); + pushRecentSys(path.c_str()); logD("save complete."); return 0; } @@ -2222,6 +2223,13 @@ void FurnaceGUI::pushRecentFile(String path) { } } +void FurnaceGUI::pushRecentSys(const char* path) { +#ifdef _WIN32 + WString widePath=utf8To16(path); + SHAddToRecentDocs(SHARD_PATHW,widePath.c_str()); +#endif +} + void FurnaceGUI::delFirstBackup(String name) { std::vector listOfFiles; #ifdef _WIN32 @@ -4819,29 +4827,39 @@ bool FurnaceGUI::loop() { break; case GUI_FILE_INS_SAVE: if (curIns>=0 && curIns<(int)e->song.ins.size()) { - e->song.ins[curIns]->save(copyOfName.c_str(),false,&e->song); + if (e->song.ins[curIns]->save(copyOfName.c_str(),false,&e->song)) { + pushRecentSys(copyOfName.c_str()); + } } break; case GUI_FILE_INS_SAVE_DMP: if (curIns>=0 && curIns<(int)e->song.ins.size()) { if (!e->song.ins[curIns]->saveDMP(copyOfName.c_str())) { showError("error while saving instrument! make sure your instrument is compatible."); + } else { + pushRecentSys(copyOfName.c_str()); } } break; case GUI_FILE_WAVE_SAVE: if (curWave>=0 && curWave<(int)e->song.wave.size()) { - e->song.wave[curWave]->save(copyOfName.c_str()); + if (e->song.wave[curWave]->save(copyOfName.c_str())) { + pushRecentSys(copyOfName.c_str()); + } } break; case GUI_FILE_WAVE_SAVE_DMW: if (curWave>=0 && curWave<(int)e->song.wave.size()) { - e->song.wave[curWave]->saveDMW(copyOfName.c_str()); + if (e->song.wave[curWave]->saveDMW(copyOfName.c_str())) { + pushRecentSys(copyOfName.c_str()); + } } break; case GUI_FILE_WAVE_SAVE_RAW: if (curWave>=0 && curWave<(int)e->song.wave.size()) { - e->song.wave[curWave]->saveRaw(copyOfName.c_str()); + if (e->song.wave[curWave]->saveRaw(copyOfName.c_str())) { + pushRecentSys(copyOfName.c_str()); + } } break; case GUI_FILE_SAMPLE_OPEN: { @@ -4905,6 +4923,8 @@ bool FurnaceGUI::loop() { if (curSample>=0 && curSample<(int)e->song.sample.size()) { if (!e->song.sample[curSample]->save(copyOfName.c_str())) { showError("could not save sample! open Log Viewer for more information."); + } else { + pushRecentSys(copyOfName.c_str()); } } break; @@ -4912,6 +4932,8 @@ bool FurnaceGUI::loop() { if (curSample>=0 && curSample<(int)e->song.sample.size()) { if (!e->song.sample[curSample]->saveRaw(copyOfName.c_str())) { showError("could not save sample! open Log Viewer for more information."); + } else { + pushRecentSys(copyOfName.c_str()); } } break; @@ -5061,6 +5083,7 @@ bool FurnaceGUI::loop() { if (f!=NULL) { fwrite(w->getFinalBuf(),1,w->size(),f); fclose(f); + pushRecentSys(copyOfName.c_str()); } else { showError("could not open file!"); } @@ -5081,6 +5104,7 @@ bool FurnaceGUI::loop() { if (f!=NULL) { fwrite(w->getFinalBuf(),1,w->size(),f); fclose(f); + pushRecentSys(copyOfName.c_str()); } else { showError("could not open file!"); } @@ -5107,6 +5131,7 @@ bool FurnaceGUI::loop() { if (f!=NULL) { fwrite(w->getFinalBuf(),1,w->size(),f); fclose(f); + pushRecentSys(copyOfName.c_str()); } else { showError("could not open file!"); } diff --git a/src/gui/gui.h b/src/gui/gui.h index 410d59b5d..9f6b04b25 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -2342,6 +2342,7 @@ class FurnaceGUI { int load(String path); int loadStream(String path); void pushRecentFile(String path); + void pushRecentSys(const char* path); void exportAudio(String path, DivAudioExportModes mode); void delFirstBackup(String name);