mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-30 08:23:01 +00:00
GUI: implement clear
This commit is contained in:
parent
e414056f2d
commit
521b311692
3 changed files with 96 additions and 1 deletions
|
@ -19,21 +19,57 @@
|
|||
|
||||
#include "song.h"
|
||||
|
||||
void DivSong::clearSongData() {
|
||||
for (int i=0; i<DIV_MAX_CHANS; i++) {
|
||||
pat[i].wipePatterns();
|
||||
}
|
||||
|
||||
memset(orders.ord,0,DIV_MAX_CHANS*256);
|
||||
ordersLen=1;
|
||||
}
|
||||
|
||||
void DivSong::clearInstruments() {
|
||||
for (DivInstrument* i: ins) {
|
||||
delete i;
|
||||
}
|
||||
ins.clear();
|
||||
insLen=0;
|
||||
}
|
||||
|
||||
void DivSong::clearWavetables() {
|
||||
for (DivWavetable* i: wave) {
|
||||
delete i;
|
||||
}
|
||||
wave.clear();
|
||||
waveLen=0;
|
||||
}
|
||||
|
||||
void DivSong::clearSamples() {
|
||||
for (DivSample* i: sample) {
|
||||
delete i;
|
||||
}
|
||||
sample.clear();
|
||||
sampleLen=0;
|
||||
}
|
||||
|
||||
void DivSong::unload() {
|
||||
for (DivInstrument* i: ins) {
|
||||
delete i;
|
||||
}
|
||||
ins.clear();
|
||||
insLen=0;
|
||||
|
||||
for (DivWavetable* i: wave) {
|
||||
delete i;
|
||||
}
|
||||
wave.clear();
|
||||
waveLen=0;
|
||||
|
||||
for (DivSample* i: sample) {
|
||||
delete i;
|
||||
}
|
||||
sample.clear();
|
||||
sampleLen=0;
|
||||
|
||||
for (int i=0; i<DIV_MAX_CHANS; i++) {
|
||||
pat[i].wipePatterns();
|
||||
|
|
|
@ -339,6 +339,27 @@ struct DivSong {
|
|||
DivWavetable nullWave;
|
||||
DivSample nullSample;
|
||||
|
||||
/**
|
||||
* clear orders and patterns.
|
||||
*/
|
||||
void clearSongData();
|
||||
|
||||
/**
|
||||
* clear instruments.
|
||||
*/
|
||||
void clearInstruments();
|
||||
|
||||
/**
|
||||
* clear wavetables.
|
||||
*/
|
||||
void clearWavetables();
|
||||
|
||||
/**
|
||||
* clear samples.
|
||||
*/
|
||||
void clearSamples();
|
||||
|
||||
|
||||
/**
|
||||
* unloads the song, freeing all memory associated with it.
|
||||
* use before destroying the object.
|
||||
|
|
|
@ -3374,26 +3374,64 @@ bool FurnaceGUI::loop() {
|
|||
break;
|
||||
case GUI_WARN_CLEAR:
|
||||
if (ImGui::Button("Song (orders and patterns)")) {
|
||||
stop();
|
||||
e->lockEngine([this]() {
|
||||
e->song.clearSongData();
|
||||
});
|
||||
e->setOrder(0);
|
||||
curOrder=0;
|
||||
oldOrder=0;
|
||||
oldOrder1=0;
|
||||
MARK_MODIFIED;
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Pattern")) {
|
||||
stop();
|
||||
e->lockEngine([this]() {
|
||||
for (int i=0; i<e->getTotalChannelCount(); i++) {
|
||||
DivPattern* pat=e->song.pat[i].getPattern(e->song.orders.ord[i][curOrder],true);
|
||||
memset(pat->data,-1,256*32*sizeof(short));
|
||||
for (int j=0; j<256; j++) {
|
||||
pat->data[j][0]=0;
|
||||
pat->data[j][1]=0;
|
||||
}
|
||||
}
|
||||
});
|
||||
MARK_MODIFIED;
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Instruments")) {
|
||||
stop();
|
||||
e->lockEngine([this]() {
|
||||
e->song.clearInstruments();
|
||||
});
|
||||
curIns=-1;
|
||||
MARK_MODIFIED;
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Wavetables")) {
|
||||
stop();
|
||||
e->lockEngine([this]() {
|
||||
e->song.clearWavetables();
|
||||
});
|
||||
curWave=0;
|
||||
MARK_MODIFIED;
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Samples")) {
|
||||
stop();
|
||||
e->lockEngine([this]() {
|
||||
e->song.clearSamples();
|
||||
});
|
||||
curSample=0;
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
|
||||
if (ImGui::Button("Wait! What am I doing?")) {
|
||||
if (ImGui::Button("Wait! What am I doing? Cancel!")) {
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue