GUI: turn sub-song removal into a warning

issue #466
This commit is contained in:
tildearrow 2022-05-17 17:21:29 -05:00
parent 80165094f0
commit 68b5522070
3 changed files with 27 additions and 14 deletions

View file

@ -3673,6 +3673,30 @@ bool FurnaceGUI::loop() {
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup();
} }
break; break;
case GUI_WARN_SUBSONG_DEL:
if (ImGui::Button("Yes")) {
if (e->removeSubSong(e->getCurrentSubSong())) {
undoHist.clear();
redoHist.clear();
updateScroll(0);
oldOrder=0;
oldOrder1=0;
oldRow=0;
cursor.xCoarse=0;
cursor.xFine=0;
cursor.y=0;
selStart=cursor;
selEnd=cursor;
curOrder=0;
MARK_MODIFIED;
}
ImGui::CloseCurrentPopup();
}
ImGui::SameLine();
if (ImGui::Button("No")) {
ImGui::CloseCurrentPopup();
}
break;
case GUI_WARN_GENERIC: case GUI_WARN_GENERIC:
if (ImGui::Button("OK")) { if (ImGui::Button("OK")) {
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup();

View file

@ -283,6 +283,7 @@ enum FurnaceGUIWarnings {
GUI_WARN_RESET_KEYBINDS, GUI_WARN_RESET_KEYBINDS,
GUI_WARN_CLOSE_SETTINGS, GUI_WARN_CLOSE_SETTINGS,
GUI_WARN_CLEAR, GUI_WARN_CLEAR,
GUI_WARN_SUBSONG_DEL,
GUI_WARN_GENERIC GUI_WARN_GENERIC
}; };

View file

@ -63,22 +63,10 @@ void FurnaceGUI::drawSubSongs() {
} }
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Button(ICON_FA_MINUS "##SubSongDel")) { if (ImGui::Button(ICON_FA_MINUS "##SubSongDel")) {
if (!e->removeSubSong(e->getCurrentSubSong())) { if (e->song.subsong.size()<=1) {
showError("this is the only subsong!"); showError("this is the only subsong!");
} else { } else {
undoHist.clear(); showWarning("are you sure you want to remove this subsong?",GUI_WARN_SUBSONG_DEL);
redoHist.clear();
updateScroll(0);
oldOrder=0;
oldOrder1=0;
oldRow=0;
cursor.xCoarse=0;
cursor.xFine=0;
cursor.y=0;
selStart=cursor;
selEnd=cursor;
curOrder=0;
MARK_MODIFIED;
} }
} }