GUI: fix effect replace

issue #652
This commit is contained in:
tildearrow 2023-02-13 18:33:25 -05:00
parent 5dcb0097f1
commit 9f48bda59a
3 changed files with 24 additions and 8 deletions

View file

@ -117,11 +117,14 @@ void FurnaceGUI::doFind() {
curQueryResults.clear();
signed char effectPos[8];
for (int i=firstOrder; i<=lastOrder; i++) {
for (int j=firstRow; j<=lastRow; j++) {
for (int k=firstChan; k<=lastChan; k++) {
DivPattern* p=e->curPat[k].getPattern(e->curOrders->ord[k][i],false);
bool matched=false;
memset(effectPos,-1,8);
for (FurnaceGUIFindQuery& l: curQuery) {
if (matched) break;
@ -139,6 +142,7 @@ void FurnaceGUI::doFind() {
if (!checkCondition(l.effectMode[m],l.effect[m],l.effectMax[m],p->data[j][4+n*2])) continue;
if (!checkCondition(l.effectValMode[m],l.effectVal[m],l.effectValMax[m],p->data[j][5+n*2])) continue;
allGood=true;
effectPos[m]=n;
break;
}
if (!allGood) {
@ -175,6 +179,7 @@ void FurnaceGUI::doFind() {
notMatched=true;
break;
}
effectPos[m]=m+posOfFirst;
}
break;
}
@ -192,6 +197,7 @@ void FurnaceGUI::doFind() {
notMatched=true;
break;
}
effectPos[m]=m;
}
}
break;
@ -202,7 +208,7 @@ void FurnaceGUI::doFind() {
matched=true;
}
if (matched) {
curQueryResults.push_back(FurnaceGUIQueryResult(e->getCurrentSubSong(),i,k,j));
curQueryResults.push_back(FurnaceGUIQueryResult(e->getCurrentSubSong(),i,k,j,effectPos));
}
}
}
@ -369,6 +375,9 @@ void FurnaceGUI::doReplace() {
break;
case 1: { // replace matches
int placementIndex=0;
for (int j=0; j<8 && placementIndex<8 && i.effectPos[j]>=0; j++) {
effectOrder[placementIndex++]=i.effectPos[j];
}
for (int j=0; j<e->song.subsong[i.subsong]->pat[i.x].effectCols; j++) {
if (p->data[i.y][4+j*2]!=-1 || p->data[i.y][5+j*2]!=-1) {
effectOrder[placementIndex++]=j;
@ -378,6 +387,9 @@ void FurnaceGUI::doReplace() {
}
case 2: { // replace matches then free spaces
int placementIndex=0;
for (int j=0; j<8 && placementIndex<8 && i.effectPos[j]>=0; j++) {
effectOrder[placementIndex++]=i.effectPos[j];
}
for (int j=0; j<e->song.subsong[i.subsong]->pat[i.x].effectCols; j++) {
if (p->data[i.y][4+j*2]!=-1 || p->data[i.y][5+j*2]!=-1) {
effectOrder[placementIndex++]=j;
@ -1094,15 +1106,15 @@ void FurnaceGUI::drawFindReplace() {
ImGui::EndTable();
}
ImGui::Text("Effect replace mode:");
if (ImGui::RadioButton("Clear effects",queryReplaceEffectPos==0)) {
queryReplaceEffectPos=0;
}
if (ImGui::RadioButton("Replace matches only",queryReplaceEffectPos==1)) {
queryReplaceEffectPos=1;
}
if (ImGui::RadioButton("Replace matches, then free spaces",queryReplaceEffectPos==2)) {
queryReplaceEffectPos=2;
}
if (ImGui::RadioButton("Clear effects",queryReplaceEffectPos==0)) {
queryReplaceEffectPos=0;
}
if (ImGui::RadioButton("Insert in free spaces",queryReplaceEffectPos==3)) {
queryReplaceEffectPos=3;
}

View file

@ -6029,7 +6029,7 @@ FurnaceGUI::FurnaceGUI():
curQueryRangeY(0),
curQueryEffectPos(0),
queryReplaceEffectCount(0),
queryReplaceEffectPos(0),
queryReplaceEffectPos(1),
queryReplaceNoteMode(0),
queryReplaceInsMode(0),
queryReplaceVolMode(0),

View file

@ -1073,16 +1073,20 @@ struct FurnaceGUIFindQuery {
struct FurnaceGUIQueryResult {
int subsong, order, x, y;
signed char effectPos[8];
FurnaceGUIQueryResult():
subsong(0),
order(0),
x(0),
y(0) {}
FurnaceGUIQueryResult(int ss, int o, int xPos, int yPos):
y(0),
effectPos{-1,-1,-1,-1,-1,-1,-1,-1} {}
FurnaceGUIQueryResult(int ss, int o, int xPos, int yPos, const signed char* fxPos):
subsong(ss),
order(o),
x(xPos),
y(yPos) {}
y(yPos) {
memcpy(effectPos,fxPos,8);
}
};
class FurnaceGUI {