From 3cc4add1e3154c54e8a6bb6b223152fb168351db Mon Sep 17 00:00:00 2001 From: tildearrow Date: Mon, 7 Feb 2022 23:42:54 -0500 Subject: [PATCH] don't alter instruments in patterns when moving fixes #150 --- src/engine/engine.cpp | 27 +++++++++++++++++++++++++++ src/engine/engine.h | 2 ++ 2 files changed, 29 insertions(+) diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index 7214e0128..252bb42a9 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -5546,6 +5546,16 @@ void DivEngine::delInstrument(int index) { delete song.ins[index]; song.ins.erase(song.ins.begin()+index); song.insLen=song.ins.size(); + for (int i=0; idata[k][2]>index) { + song.pat[i].data[j]->data[k][2]--; + } + } + } + } } isBusy.unlock(); } @@ -5858,12 +5868,28 @@ void DivEngine::moveOrderDown() { isBusy.unlock(); } +void DivEngine::exchangeIns(int one, int two) { + for (int i=0; idata[k][2]==one) { + song.pat[i].data[j]->data[k][2]=two; + } else if (song.pat[i].data[j]->data[k][2]==two) { + song.pat[i].data[j]->data[k][2]=one; + } + } + } + } +} + bool DivEngine::moveInsUp(int which) { if (which<1 || which>=(int)song.ins.size()) return false; isBusy.lock(); DivInstrument* prev=song.ins[which]; song.ins[which]=song.ins[which-1]; song.ins[which-1]=prev; + exchangeIns(which,which-1); isBusy.unlock(); return true; } @@ -5894,6 +5920,7 @@ bool DivEngine::moveInsDown(int which) { DivInstrument* prev=song.ins[which]; song.ins[which]=song.ins[which+1]; song.ins[which+1]=prev; + exchangeIns(which,which+1); isBusy.unlock(); return true; } diff --git a/src/engine/engine.h b/src/engine/engine.h index aa3dec8f2..7fa8f7766 100644 --- a/src/engine/engine.h +++ b/src/engine/engine.h @@ -215,6 +215,8 @@ class DivEngine { bool initAudioBackend(); bool deinitAudioBackend(); + void exchangeIns(int one, int two); + public: DivSong song; DivSystem sysOfChan[DIV_MAX_CHANS];