From c4614bff306606207719654973061fc5140fbef8 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Tue, 17 May 2022 01:42:21 -0500 Subject: [PATCH] GUI: implement "clear all subsongs" --- src/engine/engine.cpp | 10 ++++++++++ src/engine/engine.h | 3 +++ src/gui/gui.cpp | 5 +---- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index 9fcb85008..dd5473f38 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -813,6 +813,16 @@ bool DivEngine::removeSubSong(int index) { return true; } +void DivEngine::clearSubSongs() { + BUSY_BEGIN; + saveLock.lock(); + song.clearSongData(); + changeSong(0); + curOrder=0; + saveLock.unlock(); + BUSY_END; +} + void DivEngine::changeSystem(int index, DivSystem which, bool preserveOrder) { int chanCount=chans; quitDispatch(); diff --git a/src/engine/engine.h b/src/engine/engine.h index a6e502953..895d288e4 100644 --- a/src/engine/engine.h +++ b/src/engine/engine.h @@ -821,6 +821,9 @@ class DivEngine { // remove subsong bool removeSubSong(int index); + // clear all subsong data + void clearSubSongs(); + // change system void changeSystem(int index, DivSystem which, bool preserveOrder=true); diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 56e9f0e76..788850662 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -3494,10 +3494,7 @@ bool FurnaceGUI::loop() { case GUI_WARN_CLEAR: if (ImGui::Button("All subsongs")) { stop(); - //e->lockEngine([this]() { - //e->curSubSong->clearData(); - //}); - e->setOrder(0); + e->clearSubSongs(); curOrder=0; oldOrder=0; oldOrder1=0;