implement chip cloning/duplication

muwahahaha
This commit is contained in:
tildearrow 2024-02-21 16:27:52 -05:00
parent f0bf58eef2
commit b972e54a7e
5 changed files with 36 additions and 3 deletions

View file

@ -6,8 +6,12 @@ the **chip manager** window allows you to manage chips, including adding, changi
**Preserve channel order**: make existing pattern data stay in place even when chips are rearranged. when turned off, pattern data will be arranged to match (the default, and usually desired behavior).
**Clone channel data**: when cloning chips, also copy patterns, pattern names, channel names and other parameters to the clone.
to move a chip around, click and drag the ![crossed-arrows](chip-manager-move.png) button to the left.
to duplicate a chip, click the **Clone** button.
to replace a chip with a different one, click the **Change** button. this will display the chip selector.
to remove a chip, click the ![X](chip-manager-remove.png) button.

View file

@ -1158,7 +1158,33 @@ bool DivEngine::duplicateSystem(int index, bool pat, bool end) {
// duplicate patterns
if (pat) {
int srcChan=0;
int destChan=0;
for (int i=0; i<index; i++) {
srcChan+=getChannelCount(song.system[i]);
}
for (int i=0; i<song.systemLen-1; i++) {
destChan+=getChannelCount(song.system[i]);
}
for (DivSubSong* i: song.subsong) {
for (int j=0; j<getChannelCount(song.system[index]); j++) {
i->pat[destChan+j].effectCols=i->pat[srcChan+j].effectCols;
i->chanShow[destChan+j]=i->chanShow[srcChan+j];
i->chanShowChanOsc[destChan+j]=i->chanShowChanOsc[srcChan+j];
i->chanCollapse[destChan+j]=i->chanCollapse[srcChan+j];
i->chanName[destChan+j]=i->chanName[srcChan+j];
i->chanShortName[destChan+j]=i->chanShortName[srcChan+j];
for (int k=0; k<DIV_MAX_PATTERNS; k++) {
if (i->pat[srcChan+j].data[k]!=NULL) {
i->pat[srcChan+j].data[k]->copyOn(i->pat[destChan+j].getPattern(k,true));
}
}
for (int k=0; k<DIV_MAX_PATTERNS; k++) {
i->orders.ord[destChan+j][k]=i->orders.ord[srcChan+j][k];
}
}
}
}
saveLock.unlock();
renderSamples();

View file

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

View file

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

View file

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