This commit is contained in:
tildearrow 2024-02-22 12:48:16 -05:00
parent aae9aad4f6
commit ecd3875a64
5 changed files with 48 additions and 20 deletions

View file

@ -1190,6 +1190,25 @@ bool DivEngine::duplicateSystem(int index, bool pat, bool end) {
renderSamples(); renderSamples();
reset(); reset();
BUSY_END; BUSY_END;
if (!end) {
quitDispatch();
BUSY_BEGIN;
saveLock.lock();
for (int i=song.systemLen-1; i>index; i--) {
swapSystemUnsafe(i,i-1,false);
}
recalcChans();
saveLock.unlock();
BUSY_END;
initDispatch();
BUSY_BEGIN;
renderSamples();
reset();
BUSY_END;
}
return true; return true;
} }
@ -1247,24 +1266,7 @@ bool DivEngine::removeSystem(int index, bool preserveOrder) {
return true; return true;
} }
bool DivEngine::swapSystem(int src, int dest, bool preserveOrder) { void DivEngine::swapSystemUnsafe(int src, int dest, bool preserveOrder) {
if (src==dest) {
lastError="source and destination are equal";
return false;
}
if (src<0 || src>=song.systemLen) {
lastError="invalid source index";
return false;
}
if (dest<0 || dest>=song.systemLen) {
lastError="invalid destination index";
return false;
}
//int chanCount=chans;
quitDispatch();
BUSY_BEGIN;
saveLock.lock();
if (!preserveOrder) { if (!preserveOrder) {
// move channels // move channels
unsigned char unswappedChannels[DIV_MAX_CHANS]; unsigned char unswappedChannels[DIV_MAX_CHANS];
@ -1380,6 +1382,27 @@ bool DivEngine::swapSystem(int src, int dest, bool preserveOrder) {
i=(i&(~0xfff00000))|((unsigned int)src<<20); i=(i&(~0xfff00000))|((unsigned int)src<<20);
} }
} }
}
bool DivEngine::swapSystem(int src, int dest, bool preserveOrder) {
if (src==dest) {
lastError="source and destination are equal";
return false;
}
if (src<0 || src>=song.systemLen) {
lastError="invalid source index";
return false;
}
if (dest<0 || dest>=song.systemLen) {
lastError="invalid destination index";
return false;
}
//int chanCount=chans;
quitDispatch();
BUSY_BEGIN;
saveLock.lock();
swapSystemUnsafe(src,dest,preserveOrder);
recalcChans(); recalcChans();
saveLock.unlock(); saveLock.unlock();

View file

@ -584,6 +584,8 @@ class DivEngine {
// change song (UNSAFE) // change song (UNSAFE)
void changeSong(size_t songIndex); void changeSong(size_t songIndex);
void swapSystemUnsafe(int src, int dest, bool preserveOrder=true);
// move an asset // move an asset
void moveAsset(std::vector<DivAssetDir>& dir, int before, int after); void moveAsset(std::vector<DivAssetDir>& dir, int before, int after);

View file

@ -7319,6 +7319,7 @@ FurnaceGUI::FurnaceGUI():
fullScreen(false), fullScreen(false),
preserveChanPos(false), preserveChanPos(false),
sysDupCloneChannels(true), sysDupCloneChannels(true),
sysDupEnd(false),
wantScrollList(false), wantScrollList(false),
noteInputPoly(true), noteInputPoly(true),
notifyWaveChange(false), notifyWaveChange(false),

View file

@ -1503,7 +1503,7 @@ class FurnaceGUI {
bool vgmExportDirectStream, displayInsTypeList, displayWaveSizeList; bool vgmExportDirectStream, displayInsTypeList, displayWaveSizeList;
bool portrait, injectBackUp, mobileMenuOpen, warnColorPushed; bool portrait, injectBackUp, mobileMenuOpen, warnColorPushed;
bool wantCaptureKeyboard, oldWantCaptureKeyboard, displayMacroMenu; bool wantCaptureKeyboard, oldWantCaptureKeyboard, displayMacroMenu;
bool displayNew, displayExport, displayPalette, fullScreen, preserveChanPos, sysDupCloneChannels, wantScrollList, noteInputPoly, notifyWaveChange; bool displayNew, displayExport, displayPalette, fullScreen, preserveChanPos, sysDupCloneChannels, sysDupEnd, wantScrollList, noteInputPoly, notifyWaveChange;
bool displayPendingIns, pendingInsSingle, displayPendingRawSample, snesFilterHex, modTableHex, displayEditString; bool displayPendingIns, pendingInsSingle, displayPendingRawSample, snesFilterHex, modTableHex, displayEditString;
bool mobileEdit; bool mobileEdit;
bool killGraphics; bool killGraphics;

View file

@ -42,6 +42,8 @@ void FurnaceGUI::drawSysManager() {
ImGui::Checkbox("Preserve channel order",&preserveChanPos); ImGui::Checkbox("Preserve channel order",&preserveChanPos);
ImGui::SameLine(); ImGui::SameLine();
ImGui::Checkbox("Clone channel data",&sysDupCloneChannels); ImGui::Checkbox("Clone channel data",&sysDupCloneChannels);
ImGui::SameLine();
ImGui::Checkbox("Clone at end",&sysDupEnd);
if (ImGui::BeginTable("SystemList",3)) { if (ImGui::BeginTable("SystemList",3)) {
ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthFixed); ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthFixed);
ImGui::TableSetupColumn("c2",ImGuiTableColumnFlags_WidthStretch); ImGui::TableSetupColumn("c2",ImGuiTableColumnFlags_WidthStretch);
@ -86,7 +88,7 @@ void FurnaceGUI::drawSysManager() {
} }
ImGui::TableNextColumn(); ImGui::TableNextColumn();
if (ImGui::Button("Clone##SysDup")) { if (ImGui::Button("Clone##SysDup")) {
if (!e->duplicateSystem(i,sysDupCloneChannels)) { if (!e->duplicateSystem(i,sysDupCloneChannels,sysDupEnd)) {
showError("cannot clone chip! ("+e->getLastError()+")"); showError("cannot clone chip! ("+e->getLastError()+")");
} else { } else {
MARK_MODIFIED; MARK_MODIFIED;