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();
}
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:
if (ImGui::Button("OK")) {
ImGui::CloseCurrentPopup();

View File

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

View File

@ -63,22 +63,10 @@ void FurnaceGUI::drawSubSongs() {
}
ImGui::SameLine();
if (ImGui::Button(ICON_FA_MINUS "##SubSongDel")) {
if (!e->removeSubSong(e->getCurrentSubSong())) {
if (e->song.subsong.size()<=1) {
showError("this is the only subsong!");
} else {
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;
showWarning("are you sure you want to remove this subsong?",GUI_WARN_SUBSONG_DEL);
}
}