mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-23 13:05:11 +00:00
GUI: add option to restore backup
This commit is contained in:
parent
8c961f0aae
commit
854d0fea48
3 changed files with 24 additions and 1 deletions
|
@ -3672,6 +3672,15 @@ void FurnaceGUI::doAction(int what) {
|
|||
openFileDialog(GUI_FILE_OPEN);
|
||||
}
|
||||
break;
|
||||
case GUI_ACTION_OPEN_BACKUP:
|
||||
if (modified) {
|
||||
showWarning("Unsaved changes! Are you sure?",GUI_WARN_OPEN_BACKUP);
|
||||
} else {
|
||||
if (load(backupPath)>0) {
|
||||
showError("No backup available! (or unable to open it)");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GUI_ACTION_SAVE:
|
||||
if (curFileName=="" || e->song.version>=0xff00) {
|
||||
openFileDialog(GUI_FILE_SAVE);
|
||||
|
@ -5993,6 +6002,10 @@ bool FurnaceGUI::loop() {
|
|||
ImGui::EndMenu();
|
||||
}
|
||||
ImGui::Separator();
|
||||
if (ImGui::MenuItem("restore backup",BIND_FOR(GUI_ACTION_OPEN_BACKUP))) {
|
||||
doAction(GUI_ACTION_OPEN_BACKUP);
|
||||
}
|
||||
ImGui::Separator();
|
||||
if (ImGui::MenuItem("exit")) {
|
||||
if (modified) {
|
||||
showWarning("Unsaved changes! Are you sure you want to quit?",GUI_WARN_QUIT);
|
||||
|
@ -6392,6 +6405,11 @@ bool FurnaceGUI::loop() {
|
|||
case GUI_WARN_OPEN:
|
||||
openFileDialog(GUI_FILE_OPEN);
|
||||
break;
|
||||
case GUI_WARN_OPEN_BACKUP:
|
||||
if (load(backupPath)>0) {
|
||||
showError("No backup available! (or unable to open it)");
|
||||
}
|
||||
break;
|
||||
case GUI_WARN_OPEN_DROP:
|
||||
if (load(nextFile)>0) {
|
||||
showError(fmt::sprintf("Error while loading file! (%s)",lastError));
|
||||
|
@ -7093,7 +7111,7 @@ FurnaceGUI::FurnaceGUI():
|
|||
aboutScroll(0),
|
||||
aboutSin(0),
|
||||
aboutHue(0.0f),
|
||||
backupTimer(0.1),
|
||||
backupTimer(15.0),
|
||||
curIns(0),
|
||||
curWave(0),
|
||||
curSample(0),
|
||||
|
|
|
@ -187,6 +187,7 @@ enum FurnaceGUIWarnings {
|
|||
GUI_WARN_QUIT,
|
||||
GUI_WARN_NEW,
|
||||
GUI_WARN_OPEN,
|
||||
GUI_WARN_OPEN_BACKUP,
|
||||
GUI_WARN_OPEN_DROP,
|
||||
GUI_WARN_RESET_LAYOUT,
|
||||
GUI_WARN_GENERIC
|
||||
|
@ -201,6 +202,7 @@ enum FurnaceGUIFMAlgs {
|
|||
enum FurnaceGUIActions {
|
||||
GUI_ACTION_GLOBAL_MIN=0,
|
||||
GUI_ACTION_OPEN,
|
||||
GUI_ACTION_OPEN_BACKUP,
|
||||
GUI_ACTION_SAVE,
|
||||
GUI_ACTION_SAVE_AS,
|
||||
GUI_ACTION_UNDO,
|
||||
|
|
|
@ -579,6 +579,7 @@ void FurnaceGUI::drawSettings() {
|
|||
KEYBIND_CONFIG_BEGIN("keysGlobal");
|
||||
|
||||
UI_KEYBIND_CONFIG(GUI_ACTION_OPEN,"Open file");
|
||||
UI_KEYBIND_CONFIG(GUI_ACTION_OPEN_BACKUP,"Restore backup");
|
||||
UI_KEYBIND_CONFIG(GUI_ACTION_SAVE,"Save file");
|
||||
UI_KEYBIND_CONFIG(GUI_ACTION_SAVE_AS,"Save as");
|
||||
UI_KEYBIND_CONFIG(GUI_ACTION_UNDO,"Undo");
|
||||
|
@ -970,6 +971,7 @@ void FurnaceGUI::syncSettings() {
|
|||
|
||||
// keybinds
|
||||
LOAD_KEYBIND(GUI_ACTION_OPEN,FURKMOD_CMD|SDLK_o);
|
||||
LOAD_KEYBIND(GUI_ACTION_OPEN_BACKUP,0);
|
||||
LOAD_KEYBIND(GUI_ACTION_SAVE,FURKMOD_CMD|SDLK_s);
|
||||
LOAD_KEYBIND(GUI_ACTION_SAVE_AS,FURKMOD_CMD|FURKMOD_SHIFT|SDLK_s);
|
||||
LOAD_KEYBIND(GUI_ACTION_UNDO,FURKMOD_CMD|SDLK_z);
|
||||
|
@ -1251,6 +1253,7 @@ void FurnaceGUI::commitSettings() {
|
|||
PUT_UI_COLOR(GUI_COLOR_PLAYBACK_STAT);
|
||||
|
||||
SAVE_KEYBIND(GUI_ACTION_OPEN);
|
||||
SAVE_KEYBIND(GUI_ACTION_OPEN_BACKUP);
|
||||
SAVE_KEYBIND(GUI_ACTION_SAVE);
|
||||
SAVE_KEYBIND(GUI_ACTION_SAVE_AS);
|
||||
SAVE_KEYBIND(GUI_ACTION_UNDO);
|
||||
|
|
Loading…
Reference in a new issue