parent
75f99cfb09
commit
2cd454a59d
|
|
@ -28,14 +28,14 @@ void FurnaceGUI::doAction(int what) {
|
||||||
switch (what) {
|
switch (what) {
|
||||||
case GUI_ACTION_OPEN:
|
case GUI_ACTION_OPEN:
|
||||||
if (modified) {
|
if (modified) {
|
||||||
showWarning("Unsaved changes! Are you sure?",GUI_WARN_OPEN);
|
showWarning("Unsaved changes! Save changes before opening another file?",GUI_WARN_OPEN);
|
||||||
} else {
|
} else {
|
||||||
openFileDialog(GUI_FILE_OPEN);
|
openFileDialog(GUI_FILE_OPEN);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GUI_ACTION_OPEN_BACKUP:
|
case GUI_ACTION_OPEN_BACKUP:
|
||||||
if (modified) {
|
if (modified) {
|
||||||
showWarning("Unsaved changes! Are you sure?",GUI_WARN_OPEN_BACKUP);
|
showWarning("Unsaved changes! Save changes before opening backup?",GUI_WARN_OPEN_BACKUP);
|
||||||
} else {
|
} else {
|
||||||
if (load(backupPath)>0) {
|
if (load(backupPath)>0) {
|
||||||
showError("No backup available! (or unable to open it)");
|
showError("No backup available! (or unable to open it)");
|
||||||
|
|
|
||||||
249
src/gui/gui.cpp
249
src/gui/gui.cpp
|
|
@ -2177,7 +2177,7 @@ bool FurnaceGUI::loop() {
|
||||||
if (ev.drop.file!=NULL) {
|
if (ev.drop.file!=NULL) {
|
||||||
if (modified) {
|
if (modified) {
|
||||||
nextFile=ev.drop.file;
|
nextFile=ev.drop.file;
|
||||||
showWarning("Unsaved changes! Are you sure?",GUI_WARN_OPEN_DROP);
|
showWarning("Unsaved changes! Save changes before opening file?",GUI_WARN_OPEN_DROP);
|
||||||
} else {
|
} else {
|
||||||
if (load(ev.drop.file)>0) {
|
if (load(ev.drop.file)>0) {
|
||||||
showError(fmt::sprintf("Error while loading file! (%s)",lastError));
|
showError(fmt::sprintf("Error while loading file! (%s)",lastError));
|
||||||
|
|
@ -2188,7 +2188,7 @@ bool FurnaceGUI::loop() {
|
||||||
break;
|
break;
|
||||||
case SDL_QUIT:
|
case SDL_QUIT:
|
||||||
if (modified) {
|
if (modified) {
|
||||||
showWarning("Unsaved changes! Are you sure you want to quit?",GUI_WARN_QUIT);
|
showWarning("Unsaved changes! Save changes before quitting?",GUI_WARN_QUIT);
|
||||||
} else {
|
} else {
|
||||||
quit=true;
|
quit=true;
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -2345,14 +2345,14 @@ bool FurnaceGUI::loop() {
|
||||||
if (ImGui::BeginMenu("file")) {
|
if (ImGui::BeginMenu("file")) {
|
||||||
if (ImGui::MenuItem("new...")) {
|
if (ImGui::MenuItem("new...")) {
|
||||||
if (modified) {
|
if (modified) {
|
||||||
showWarning("Unsaved changes! Are you sure?",GUI_WARN_NEW);
|
showWarning("Unsaved changes! Save changes before creating a new song?",GUI_WARN_NEW);
|
||||||
} else {
|
} else {
|
||||||
displayNew=true;
|
displayNew=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ImGui::MenuItem("open...",BIND_FOR(GUI_ACTION_OPEN))) {
|
if (ImGui::MenuItem("open...",BIND_FOR(GUI_ACTION_OPEN))) {
|
||||||
if (modified) {
|
if (modified) {
|
||||||
showWarning("Unsaved changes! Are you sure?",GUI_WARN_OPEN);
|
showWarning("Unsaved changes! Save changes before opening another file?",GUI_WARN_OPEN);
|
||||||
} else {
|
} else {
|
||||||
openFileDialog(GUI_FILE_OPEN);
|
openFileDialog(GUI_FILE_OPEN);
|
||||||
}
|
}
|
||||||
|
|
@ -2474,7 +2474,7 @@ bool FurnaceGUI::loop() {
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
if (ImGui::MenuItem("exit")) {
|
if (ImGui::MenuItem("exit")) {
|
||||||
if (modified) {
|
if (modified) {
|
||||||
showWarning("Unsaved changes! Are you sure you want to quit?",GUI_WARN_QUIT);
|
showWarning("Unsaved changes! Save before quitting?",GUI_WARN_QUIT);
|
||||||
} else {
|
} else {
|
||||||
quit=true;
|
quit=true;
|
||||||
}
|
}
|
||||||
|
|
@ -2651,6 +2651,7 @@ bool FurnaceGUI::loop() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileDialog->render(ImVec2(600.0f*dpiScale,400.0f*dpiScale),ImVec2(scrW*dpiScale,scrH*dpiScale))) {
|
if (fileDialog->render(ImVec2(600.0f*dpiScale,400.0f*dpiScale),ImVec2(scrW*dpiScale,scrH*dpiScale))) {
|
||||||
|
bool openOpen=false;
|
||||||
//ImGui::GetIO().ConfigFlags&=~ImGuiConfigFlags_NavEnableKeyboard;
|
//ImGui::GetIO().ConfigFlags&=~ImGuiConfigFlags_NavEnableKeyboard;
|
||||||
switch (curFileDialog) {
|
switch (curFileDialog) {
|
||||||
case GUI_FILE_OPEN:
|
case GUI_FILE_OPEN:
|
||||||
|
|
@ -2744,15 +2745,47 @@ bool FurnaceGUI::loop() {
|
||||||
for (char& i: lowerCase) {
|
for (char& i: lowerCase) {
|
||||||
if (i>='A' && i<='Z') i+='a'-'A';
|
if (i>='A' && i<='Z') i+='a'-'A';
|
||||||
}
|
}
|
||||||
|
bool saveWasSuccessful=true;
|
||||||
if ((lowerCase.size()<4 || lowerCase.rfind(".dmf")!=lowerCase.size()-4)) {
|
if ((lowerCase.size()<4 || lowerCase.rfind(".dmf")!=lowerCase.size()-4)) {
|
||||||
if (save(copyOfName,0)>0) {
|
if (save(copyOfName,0)>0) {
|
||||||
showError(fmt::sprintf("Error while saving file! (%s)",lastError));
|
showError(fmt::sprintf("Error while saving file! (%s)",lastError));
|
||||||
|
saveWasSuccessful=false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (save(copyOfName,26)>0) {
|
if (save(copyOfName,26)>0) {
|
||||||
showError(fmt::sprintf("Error while saving file! (%s)",lastError));
|
showError(fmt::sprintf("Error while saving file! (%s)",lastError));
|
||||||
|
saveWasSuccessful=false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (saveWasSuccessful && postWarnAction!=GUI_WARN_GENERIC) {
|
||||||
|
switch (postWarnAction) {
|
||||||
|
case GUI_WARN_QUIT:
|
||||||
|
quit=true;
|
||||||
|
break;
|
||||||
|
case GUI_WARN_NEW:
|
||||||
|
displayNew=true;
|
||||||
|
break;
|
||||||
|
case GUI_WARN_OPEN:
|
||||||
|
openOpen=true;
|
||||||
|
break;
|
||||||
|
case GUI_WARN_OPEN_DROP:
|
||||||
|
if (load(nextFile)>0) {
|
||||||
|
showError(fmt::sprintf("Error while loading file! (%s)",lastError));
|
||||||
|
}
|
||||||
|
nextFile="";
|
||||||
|
break;
|
||||||
|
case GUI_WARN_OPEN_BACKUP:
|
||||||
|
if (load(backupPath)>0) {
|
||||||
|
showError("No backup available! (or unable to open it)");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
postWarnAction=GUI_WARN_GENERIC;
|
||||||
|
} else if (postWarnAction==GUI_WARN_OPEN_DROP) {
|
||||||
|
nextFile="";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GUI_FILE_SAVE_DMF_LEGACY:
|
case GUI_FILE_SAVE_DMF_LEGACY:
|
||||||
|
|
@ -2862,6 +2895,11 @@ bool FurnaceGUI::loop() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fileDialog->close();
|
fileDialog->close();
|
||||||
|
postWarnAction=GUI_WARN_GENERIC;
|
||||||
|
|
||||||
|
if (openOpen) {
|
||||||
|
openFileDialog(GUI_FILE_OPEN);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (warnQuit) {
|
if (warnQuit) {
|
||||||
|
|
@ -2920,49 +2958,193 @@ bool FurnaceGUI::loop() {
|
||||||
|
|
||||||
if (ImGui::BeginPopupModal("Warning",NULL,ImGuiWindowFlags_AlwaysAutoResize)) {
|
if (ImGui::BeginPopupModal("Warning",NULL,ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||||
ImGui::Text("%s",warnString.c_str());
|
ImGui::Text("%s",warnString.c_str());
|
||||||
if (ImGui::Button(warnAction==GUI_WARN_GENERIC?"OK":"Yes")) {
|
switch (warnAction) {
|
||||||
ImGui::CloseCurrentPopup();
|
case GUI_WARN_QUIT:
|
||||||
switch (warnAction) {
|
if (ImGui::Button("Yes")) {
|
||||||
case GUI_WARN_QUIT:
|
ImGui::CloseCurrentPopup();
|
||||||
|
if (curFileName=="" || curFileName==backupPath || e->song.version>=0xff00) {
|
||||||
|
openFileDialog(GUI_FILE_SAVE);
|
||||||
|
postWarnAction=GUI_WARN_QUIT;
|
||||||
|
} else {
|
||||||
|
if (save(curFileName,e->song.isDMF?e->song.version:0)>0) {
|
||||||
|
showError(fmt::sprintf("Error while saving file! (%s)",lastError));
|
||||||
|
} else {
|
||||||
|
quit=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ImGui::SameLine();
|
||||||
|
if (ImGui::Button("No")) {
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
quit=true;
|
quit=true;
|
||||||
break;
|
}
|
||||||
case GUI_WARN_NEW:
|
ImGui::SameLine();
|
||||||
|
if (ImGui::Button("Cancel")) {
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case GUI_WARN_NEW:
|
||||||
|
if (ImGui::Button("Yes")) {
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
|
if (curFileName=="" || curFileName==backupPath || e->song.version>=0xff00) {
|
||||||
|
openFileDialog(GUI_FILE_SAVE);
|
||||||
|
postWarnAction=GUI_WARN_NEW;
|
||||||
|
} else {
|
||||||
|
if (save(curFileName,e->song.isDMF?e->song.version:0)>0) {
|
||||||
|
showError(fmt::sprintf("Error while saving file! (%s)",lastError));
|
||||||
|
} else {
|
||||||
|
displayNew=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ImGui::SameLine();
|
||||||
|
if (ImGui::Button("No")) {
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
displayNew=true;
|
displayNew=true;
|
||||||
break;
|
}
|
||||||
case GUI_WARN_OPEN:
|
ImGui::SameLine();
|
||||||
|
if (ImGui::Button("Cancel")) {
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case GUI_WARN_OPEN:
|
||||||
|
if (ImGui::Button("Yes")) {
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
|
if (curFileName=="" || curFileName==backupPath || e->song.version>=0xff00) {
|
||||||
|
openFileDialog(GUI_FILE_SAVE);
|
||||||
|
postWarnAction=GUI_WARN_OPEN;
|
||||||
|
} else {
|
||||||
|
if (save(curFileName,e->song.isDMF?e->song.version:0)>0) {
|
||||||
|
showError(fmt::sprintf("Error while saving file! (%s)",lastError));
|
||||||
|
} else {
|
||||||
|
openFileDialog(GUI_FILE_OPEN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ImGui::SameLine();
|
||||||
|
if (ImGui::Button("No")) {
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
openFileDialog(GUI_FILE_OPEN);
|
openFileDialog(GUI_FILE_OPEN);
|
||||||
break;
|
}
|
||||||
case GUI_WARN_OPEN_BACKUP:
|
ImGui::SameLine();
|
||||||
|
if (ImGui::Button("Cancel")) {
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case GUI_WARN_OPEN_BACKUP:
|
||||||
|
if (ImGui::Button("Yes")) {
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
|
if (curFileName=="" || curFileName==backupPath || e->song.version>=0xff00) {
|
||||||
|
openFileDialog(GUI_FILE_SAVE);
|
||||||
|
postWarnAction=GUI_WARN_OPEN_BACKUP;
|
||||||
|
} else {
|
||||||
|
if (save(curFileName,e->song.isDMF?e->song.version:0)>0) {
|
||||||
|
showError(fmt::sprintf("Error while saving file! (%s)",lastError));
|
||||||
|
} else {
|
||||||
|
if (load(backupPath)>0) {
|
||||||
|
showError("No backup available! (or unable to open it)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ImGui::SameLine();
|
||||||
|
if (ImGui::Button("No")) {
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
if (load(backupPath)>0) {
|
if (load(backupPath)>0) {
|
||||||
showError("No backup available! (or unable to open it)");
|
showError("No backup available! (or unable to open it)");
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
case GUI_WARN_OPEN_DROP:
|
ImGui::SameLine();
|
||||||
|
if (ImGui::Button("Cancel")) {
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case GUI_WARN_OPEN_DROP:
|
||||||
|
if (ImGui::Button("Yes")) {
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
|
if (curFileName=="" || curFileName==backupPath || e->song.version>=0xff00) {
|
||||||
|
openFileDialog(GUI_FILE_SAVE);
|
||||||
|
postWarnAction=GUI_WARN_OPEN_DROP;
|
||||||
|
} else {
|
||||||
|
if (save(curFileName,e->song.isDMF?e->song.version:0)>0) {
|
||||||
|
showError(fmt::sprintf("Error while saving file! (%s)",lastError));
|
||||||
|
nextFile="";
|
||||||
|
} else {
|
||||||
|
if (load(nextFile)>0) {
|
||||||
|
showError(fmt::sprintf("Error while loading file! (%s)",lastError));
|
||||||
|
}
|
||||||
|
nextFile="";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ImGui::SameLine();
|
||||||
|
if (ImGui::Button("No")) {
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
if (load(nextFile)>0) {
|
if (load(nextFile)>0) {
|
||||||
showError(fmt::sprintf("Error while loading file! (%s)",lastError));
|
showError(fmt::sprintf("Error while loading file! (%s)",lastError));
|
||||||
}
|
}
|
||||||
nextFile="";
|
nextFile="";
|
||||||
break;
|
}
|
||||||
case GUI_WARN_RESET_LAYOUT:
|
ImGui::SameLine();
|
||||||
|
if (ImGui::Button("Cancel")) {
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
|
nextFile="";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case GUI_WARN_RESET_LAYOUT:
|
||||||
|
if (ImGui::Button("Yes")) {
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
ImGui::LoadIniSettingsFromMemory(defaultLayout);
|
ImGui::LoadIniSettingsFromMemory(defaultLayout);
|
||||||
ImGui::SaveIniSettingsToDisk(finalLayoutPath);
|
ImGui::SaveIniSettingsToDisk(finalLayoutPath);
|
||||||
break;
|
}
|
||||||
case GUI_WARN_RESET_KEYBINDS:
|
ImGui::SameLine();
|
||||||
|
if (ImGui::Button("No")) {
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case GUI_WARN_RESET_KEYBINDS:
|
||||||
|
if (ImGui::Button("Yes")) {
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
resetKeybinds();
|
resetKeybinds();
|
||||||
break;
|
}
|
||||||
case GUI_WARN_RESET_COLORS:
|
ImGui::SameLine();
|
||||||
|
if (ImGui::Button("No")) {
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case GUI_WARN_RESET_COLORS:
|
||||||
|
if (ImGui::Button("Yes")) {
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
resetColors();
|
resetColors();
|
||||||
applyUISettings(false);
|
applyUISettings(false);
|
||||||
break;
|
}
|
||||||
case GUI_WARN_GENERIC:
|
ImGui::SameLine();
|
||||||
break;
|
if (ImGui::Button("No")) {
|
||||||
}
|
ImGui::CloseCurrentPopup();
|
||||||
}
|
}
|
||||||
if (warnAction!=GUI_WARN_GENERIC) {
|
break;
|
||||||
ImGui::SameLine();
|
case GUI_WARN_CLOSE_SETTINGS:
|
||||||
if (ImGui::Button("No")) {
|
if (ImGui::Button("Yes")) {
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
}
|
settingsOpen=false;
|
||||||
|
willCommit=true;
|
||||||
|
}
|
||||||
|
ImGui::SameLine();
|
||||||
|
if (ImGui::Button("No")) {
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
|
settingsOpen=false;
|
||||||
|
syncSettings();
|
||||||
|
}
|
||||||
|
ImGui::SameLine();
|
||||||
|
if (ImGui::Button("Cancel")) {
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case GUI_WARN_GENERIC:
|
||||||
|
if (ImGui::Button("OK")) {
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
|
|
@ -3268,6 +3450,7 @@ FurnaceGUI::FurnaceGUI():
|
||||||
vgmExportVersion(0x171),
|
vgmExportVersion(0x171),
|
||||||
curFileDialog(GUI_FILE_OPEN),
|
curFileDialog(GUI_FILE_OPEN),
|
||||||
warnAction(GUI_WARN_OPEN),
|
warnAction(GUI_WARN_OPEN),
|
||||||
|
postWarnAction(GUI_WARN_GENERIC),
|
||||||
fileDialog(NULL),
|
fileDialog(NULL),
|
||||||
scrW(1280),
|
scrW(1280),
|
||||||
scrH(800),
|
scrH(800),
|
||||||
|
|
|
||||||
|
|
@ -261,6 +261,7 @@ enum FurnaceGUIWarnings {
|
||||||
GUI_WARN_RESET_LAYOUT,
|
GUI_WARN_RESET_LAYOUT,
|
||||||
GUI_WARN_RESET_COLORS,
|
GUI_WARN_RESET_COLORS,
|
||||||
GUI_WARN_RESET_KEYBINDS,
|
GUI_WARN_RESET_KEYBINDS,
|
||||||
|
GUI_WARN_CLOSE_SETTINGS,
|
||||||
GUI_WARN_GENERIC
|
GUI_WARN_GENERIC
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -714,6 +715,7 @@ class FurnaceGUI {
|
||||||
|
|
||||||
FurnaceGUIFileDialogs curFileDialog;
|
FurnaceGUIFileDialogs curFileDialog;
|
||||||
FurnaceGUIWarnings warnAction;
|
FurnaceGUIWarnings warnAction;
|
||||||
|
FurnaceGUIWarnings postWarnAction;
|
||||||
|
|
||||||
FurnaceGUIFileDialog* fileDialog;
|
FurnaceGUIFileDialog* fileDialog;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -201,7 +201,6 @@ struct MappedInput {
|
||||||
// TODO:
|
// TODO:
|
||||||
// - add metronome volume setting
|
// - add metronome volume setting
|
||||||
// - maybe add metronome sound setting
|
// - maybe add metronome sound setting
|
||||||
// - add a "close" button to this window
|
|
||||||
void FurnaceGUI::drawSettings() {
|
void FurnaceGUI::drawSettings() {
|
||||||
if (nextWindow==GUI_WINDOW_SETTINGS) {
|
if (nextWindow==GUI_WINDOW_SETTINGS) {
|
||||||
settingsOpen=true;
|
settingsOpen=true;
|
||||||
|
|
@ -209,7 +208,11 @@ void FurnaceGUI::drawSettings() {
|
||||||
nextWindow=GUI_WINDOW_NOTHING;
|
nextWindow=GUI_WINDOW_NOTHING;
|
||||||
}
|
}
|
||||||
if (!settingsOpen) return;
|
if (!settingsOpen) return;
|
||||||
if (ImGui::Begin("Settings",NULL,ImGuiWindowFlags_NoDocking)) {
|
if (ImGui::Begin("Settings",&settingsOpen,ImGuiWindowFlags_NoDocking)) {
|
||||||
|
if (!settingsOpen) {
|
||||||
|
settingsOpen=true;
|
||||||
|
showWarning("Do you want to save your settings?",GUI_WARN_CLOSE_SETTINGS);
|
||||||
|
}
|
||||||
if (ImGui::BeginTabBar("settingsTab")) {
|
if (ImGui::BeginTabBar("settingsTab")) {
|
||||||
if (ImGui::BeginTabItem("General")) {
|
if (ImGui::BeginTabItem("General")) {
|
||||||
ImGui::Text("Workspace layout");
|
ImGui::Text("Workspace layout");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue