restore backup opens the backup dir

This commit is contained in:
tildearrow 2023-04-06 15:16:52 -05:00
parent 02450b8683
commit 8c55076177
4 changed files with 21 additions and 12 deletions

BIN
src/check/calc_checksum Executable file

Binary file not shown.

View File

@ -50,9 +50,7 @@ void FurnaceGUI::doAction(int what) {
if (modified) { if (modified) {
showWarning("Unsaved changes! Save changes before opening backup?",GUI_WARN_OPEN_BACKUP); showWarning("Unsaved changes! Save changes before opening backup?",GUI_WARN_OPEN_BACKUP);
} else { } else {
if (load(backupPath)>0) { openFileDialog(GUI_FILE_OPEN_BACKUP);
showError("No backup available! (or unable to open it)");
}
} }
break; break;
case GUI_ACTION_SAVE: case GUI_ACTION_SAVE:

View File

@ -1474,6 +1474,19 @@ void FurnaceGUI::openFileDialog(FurnaceGUIFileDialogs type) {
dpiScale dpiScale
); );
break; break;
case GUI_FILE_OPEN_BACKUP:
if (!dirExists(backupPath)) {
showError("no backups made yet!");
break;
}
hasOpened=fileDialog->openLoad(
"Restore Backup",
{"Furnace song", "*.fur"},
"Furnace song{.fur}",
backupPath,
dpiScale
);
break;
case GUI_FILE_SAVE: case GUI_FILE_SAVE:
if (!dirExists(workingDirSong)) workingDirSong=getHomeDir(); if (!dirExists(workingDirSong)) workingDirSong=getHomeDir();
hasOpened=fileDialog->openSave( hasOpened=fileDialog->openSave(
@ -4375,6 +4388,8 @@ bool FurnaceGUI::loop() {
case GUI_FILE_TEST_SAVE: case GUI_FILE_TEST_SAVE:
workingDirTest=fileDialog->getPath()+DIR_SEPARATOR_STR; workingDirTest=fileDialog->getPath()+DIR_SEPARATOR_STR;
break; break;
case GUI_FILE_OPEN_BACKUP:
break;
} }
if (fileDialog->isError()) { if (fileDialog->isError()) {
#if defined(_WIN32) || defined(__APPLE__) #if defined(_WIN32) || defined(__APPLE__)
@ -4451,6 +4466,7 @@ bool FurnaceGUI::loop() {
String copyOfName=fileName; String copyOfName=fileName;
switch (curFileDialog) { switch (curFileDialog) {
case GUI_FILE_OPEN: case GUI_FILE_OPEN:
case GUI_FILE_OPEN_BACKUP:
if (load(copyOfName)>0) { if (load(copyOfName)>0) {
showError(fmt::sprintf("Error while loading file! (%s)",lastError)); showError(fmt::sprintf("Error while loading file! (%s)",lastError));
} }
@ -4479,9 +4495,7 @@ bool FurnaceGUI::loop() {
nextFile=""; nextFile="";
break; break;
case GUI_WARN_OPEN_BACKUP: case GUI_WARN_OPEN_BACKUP:
if (load(backupPath)>0) { openFileDialog(GUI_FILE_OPEN_BACKUP);
showError("No backup available! (or unable to open it)");
}
break; break;
default: default:
break; break;
@ -5027,18 +5041,14 @@ bool FurnaceGUI::loop() {
if (save(curFileName,e->song.isDMF?e->song.version:0)>0) { if (save(curFileName,e->song.isDMF?e->song.version:0)>0) {
showError(fmt::sprintf("Error while saving file! (%s)",lastError)); showError(fmt::sprintf("Error while saving file! (%s)",lastError));
} else { } else {
if (load(backupPath)>0) { openFileDialog(GUI_FILE_OPEN_BACKUP);
showError("No backup available! (or unable to open it)");
}
} }
} }
} }
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Button("No")) { if (ImGui::Button("No")) {
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup();
if (load(backupPath)>0) { openFileDialog(GUI_FILE_OPEN_BACKUP);
showError("No backup available! (or unable to open it)");
}
} }
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Button("Cancel")) { if (ImGui::Button("Cancel")) {

View File

@ -346,6 +346,7 @@ enum FurnaceGUIMobileScenes {
enum FurnaceGUIFileDialogs { enum FurnaceGUIFileDialogs {
GUI_FILE_OPEN, GUI_FILE_OPEN,
GUI_FILE_OPEN_BACKUP,
GUI_FILE_SAVE, GUI_FILE_SAVE,
GUI_FILE_SAVE_DMF, GUI_FILE_SAVE_DMF,
GUI_FILE_SAVE_DMF_LEGACY, GUI_FILE_SAVE_DMF_LEGACY,