| 1 |
/** |
| 2 |
* Furnace Tracker - multi-system chiptune tracker |
| 3 |
* Copyright (C) 2021-2025 tildearrow and contributors |
| 4 |
* |
| 5 |
* This program is free software; you can redistribute it and/or modify |
| 6 |
* it under the terms of the GNU General Public License as published by |
| 7 |
* the Free Software Foundation; either version 2 of the License, or |
| 8 |
* (at your option) any later version. |
| 9 |
* |
| 10 |
* This program is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
* GNU General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License along |
| 16 |
* with this program; if not, write to the Free Software Foundation, Inc., |
| 17 |
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 |
*/ |
| 19 |
|
| 20 |
#include "gui.h" |
| 21 |
#include "imgui.h" |
| 22 |
#include "IconsFontAwesome4.h" |
| 23 |
#include "misc/cpp/imgui_stdlib.h" |
| 24 |
#include "guiConst.h" |
| 25 |
#include "intConst.h" |
| 26 |
#include "../ta-log.h" |
| 27 |
|
| 28 |
const char* queryModes[GUI_QUERY_MAX]={ |
| 29 |
_N("ignore"), |
| 30 |
_N("equals"), |
| 31 |
_N("not equal"), |
| 32 |
_N("between"), |
| 33 |
_N("not between"), |
| 34 |
_N("any"), |
| 35 |
_N("none") |
| 36 |
}; |
| 37 |
|
| 38 |
const char* queryReplaceModes[GUI_QUERY_REPLACE_MAX]={ |
| 39 |
_N("set"), |
| 40 |
_N("add"), |
| 41 |
_N("add (overflow)"), |
| 42 |
_N("scale %"), |
| 43 |
_N("clear") |
| 44 |
}; |
| 45 |
|
| 46 |
int queryNote(int note, int octave) { |
| 47 |
if (note==100) { |
| 48 |
return 128; |
| 49 |
} else if (note==101) { // note off and envelope release |
| 50 |
return 129; |
| 51 |
} else if (note==102) { // envelope release only |
| 52 |
return 130; |
| 53 |
} else if (octave==0 && note==0) { |
| 54 |
return -61; |
| 55 |
} else if (note==0 && octave!=0) { |
| 56 |
return -61; // bug note? |
| 57 |
} |
| 58 |
int seek=(note+(signed char)octave*12); |
| 59 |
if (seek<-60 || seek>=120) { |
| 60 |
return -61; // out of range note |
| 61 |
} |
| 62 |
return seek; |
| 63 |
} |
| 64 |
|
| 65 |
bool checkCondition(int mode, int arg, int argMax, int val, bool noteMode=false) { |
| 66 |
const int emptyVal=noteMode?-61:-1; |
| 67 |
switch (mode) { |
| 68 |
case GUI_QUERY_IGNORE: |
| 69 |
return true; |
| 70 |
break; |
| 71 |
case GUI_QUERY_MATCH: |
| 72 |
return (val==arg); |
| 73 |
break; |
| 74 |
case GUI_QUERY_MATCH_NOT: |
| 75 |
return (val!=emptyVal && val!=arg); |
| 76 |
break; |
| 77 |
case GUI_QUERY_RANGE: |
| 78 |
return (val>=arg && val<=argMax); |
| 79 |
break; |
| 80 |
case GUI_QUERY_RANGE_NOT: |
| 81 |
return (val!=emptyVal && (val<arg || val>argMax) && (!noteMode || val<120)); |
| 82 |
break; |
| 83 |
case GUI_QUERY_ANY: |
| 84 |
return (val!=emptyVal); |
| 85 |
break; |
| 86 |
case GUI_QUERY_NONE: |
| 87 |
return (val==emptyVal); |
| 88 |
break; |
| 89 |
} |
| 90 |
return false; |
| 91 |
} |
| 92 |
|
| 93 |
void FurnaceGUI::doFind() { |
| 94 |
int firstOrder=0; |
| 95 |
int lastOrder=e->curSubSong->ordersLen-1; |
| 96 |
|
| 97 |
if (curQueryRangeY==1 || curQueryRangeY==2) { |
| 98 |
firstOrder=curOrder; |
| 99 |
lastOrder=curOrder; |
| 100 |
} |
| 101 |
|
| 102 |
int firstRow=0; |
| 103 |
int lastRow=e->curSubSong->patLen-1; |
| 104 |
|
| 105 |
if (curQueryRangeY==1) { |
| 106 |
finishSelection(); |
| 107 |
|
| 108 |
firstOrder=selStart.order; |
| 109 |
lastOrder=selEnd.order; |
| 110 |
firstRow=selStart.y; |
| 111 |
lastRow=selEnd.y; |
| 112 |
} |
| 113 |
|
| 114 |
int firstChan=0; |
| 115 |
int lastChan=e->getTotalChannelCount()-1; |
| 116 |
|
| 117 |
if (curQueryRangeX) { |
| 118 |
firstChan=curQueryRangeXMin; |
| 119 |
lastChan=curQueryRangeXMax; |
| 120 |
} |
| 121 |
|
| 122 |
if (curQueryRangeY==1) { |
| 123 |
firstChan=selStart.xCoarse; |
| 124 |
lastChan=selEnd.xCoarse; |
| 125 |
} |
| 126 |
|
| 127 |
curQueryResults.clear(); |
| 128 |
|
| 129 |
signed char effectPos[8]; |
| 130 |
|
| 131 |
for (int i=firstOrder; i<=lastOrder; i++) { |
| 132 |
for (int j=firstRow; j<=lastRow; j++) { |
| 133 |
for (int k=firstChan; k<=lastChan; k++) { |
| 134 |
DivPattern* p=e->curPat[k].getPattern(e->curOrders->ord[k][i],false); |
| 135 |
bool matched=false; |
| 136 |
memset(effectPos,-1,8); |
| 137 |
for (FurnaceGUIFindQuery& l: curQuery) { |
| 138 |
if (matched) break; |
| 139 |
|
| 140 |
if (!checkCondition(l.noteMode,l.note,l.noteMax,queryNote(p->data[j][0],p->data[j][1]),true)) continue; |
| 141 |
if (!checkCondition(l.insMode,l.ins,l.insMax,p->data[j][2])) continue; |
| 142 |
if (!checkCondition(l.volMode,l.vol,l.volMax,p->data[j][3])) continue; |
| 143 |
|
| 144 |
if (l.effectCount>0) { |
| 145 |
bool notMatched=false; |
| 146 |
switch (curQueryEffectPos) { |
| 147 |
case 0: // no |
| 148 |
for (int m=0; m<l.effectCount; m++) { |
| 149 |
bool allGood=false; |
| 150 |
for (int n=0; n<e->curPat[k].effectCols; n++) { |
| 151 |
if (!checkCondition(l.effectMode[m],l.effect[m],l.effectMax[m],p->data[j][4+n*2])) continue; |
| 152 |
if (!checkCondition(l.effectValMode[m],l.effectVal[m],l.effectValMax[m],p->data[j][5+n*2])) continue; |
| 153 |
allGood=true; |
| 154 |
effectPos[m]=n; |
| 155 |
break; |
| 156 |
} |
| 157 |
if (!allGood) { |
| 158 |
notMatched=true; |
| 159 |
break; |
| 160 |
} |
| 161 |
} |
| 162 |
break; |
| 163 |
case 1: { // lax |
| 164 |
// locate first effect |
| 165 |
int posOfFirst=-1; |
| 166 |
for (int m=0; m<e->curPat[k].effectCols; m++) { |
| 167 |
if (!checkCondition(l.effectMode[0],l.effect[0],l.effectMax[0],p->data[j][4+m*2])) continue; |
| 168 |
if (!checkCondition(l.effectValMode[0],l.effectVal[0],l.effectValMax[0],p->data[j][5+m*2])) continue; |
| 169 |
posOfFirst=m; |
| 170 |
break; |
| 171 |
} |
| 172 |
if (posOfFirst<0) { |
| 173 |
notMatched=true; |
| 174 |
break; |
| 175 |
} |
| 176 |
// make sure we aren't too far to the right |
| 177 |
if ((posOfFirst+l.effectCount)>e->curPat[k].effectCols) { |
| 178 |
notMatched=true; |
| 179 |
break; |
| 180 |
} |
| 181 |
// search from first effect location |
| 182 |
for (int m=0; m<l.effectCount; m++) { |
| 183 |
if (!checkCondition(l.effectMode[m],l.effect[m],l.effectMax[m],p->data[j][4+(m+posOfFirst)*2])) { |
| 184 |
notMatched=true; |
| 185 |
break; |
| 186 |
} |
| 187 |
if (!checkCondition(l.effectValMode[m],l.effectVal[m],l.effectValMax[m],p->data[j][5+(m+posOfFirst)*2])) { |
| 188 |
notMatched=true; |
| 189 |
break; |
| 190 |
} |
| 191 |
effectPos[m]=m+posOfFirst; |
| 192 |
} |
| 193 |
break; |
| 194 |
} |
| 195 |
case 2: // strict |
| 196 |
int effectMax=l.effectCount; |
| 197 |
if (effectMax>e->curPat[k].effectCols) { |
| 198 |
notMatched=true; |
| 199 |
} else { |
| 200 |
for (int m=0; m<effectMax; m++) { |
| 201 |
if (!checkCondition(l.effectMode[m],l.effect[m],l.effectMax[m],p->data[j][4+m*2])) { |
| 202 |
notMatched=true; |
| 203 |
break; |
| 204 |
} |
| 205 |
if (!checkCondition(l.effectValMode[m],l.effectVal[m],l.effectValMax[m],p->data[j][5+m*2])) { |
| 206 |
notMatched=true; |
| 207 |
break; |
| 208 |
} |
| 209 |
effectPos[m]=m; |
| 210 |
} |
| 211 |
} |
| 212 |
break; |
| 213 |
} |
| 214 |
if (notMatched) continue; |
| 215 |
} |
| 216 |
|
| 217 |
matched=true; |
| 218 |
} |
| 219 |
if (matched) { |
| 220 |
curQueryResults.push_back(FurnaceGUIQueryResult(e->getCurrentSubSong(),i,k,j,effectPos)); |
| 221 |
} |
| 222 |
} |
| 223 |
} |
| 224 |
} |
| 225 |
queryViewingResults=true; |
| 226 |
} |
| 227 |
|
| 228 |
void FurnaceGUI::doReplace() { |
| 229 |
doFind(); |
| 230 |
queryViewingResults=false; |
| 231 |
|
| 232 |
bool* touched[DIV_MAX_CHANS]; |
| 233 |
memset(touched,0,DIV_MAX_CHANS*sizeof(bool*)); |
| 234 |
|
| 235 |
UndoStep us; |
| 236 |
us.type=GUI_UNDO_REPLACE; |
| 237 |
|
| 238 |
short prevVal[DIV_MAX_COLS]; |
| 239 |
memset(prevVal,0,DIV_MAX_COLS*sizeof(short)); |
| 240 |
|
| 241 |
for (FurnaceGUIQueryResult& i: curQueryResults) { |
| 242 |
int patIndex=e->song.subsong[i.subsong]->orders.ord[i.x][i.order]; |
| 243 |
DivPattern* p=e->song.subsong[i.subsong]->pat[i.x].getPattern(patIndex,true); |
| 244 |
if (touched[i.x]==NULL) { |
| 245 |
touched[i.x]=new bool[DIV_MAX_PATTERNS*DIV_MAX_ROWS]; |
| 246 |
memset(touched[i.x],0,DIV_MAX_PATTERNS*DIV_MAX_ROWS*sizeof(bool)); |
| 247 |
} |
| 248 |
if (touched[i.x][(patIndex<<8)|i.y]) continue; |
| 249 |
touched[i.x][(patIndex<<8)|i.y]=true; |
| 250 |
|
| 251 |
memcpy(prevVal,p->data[i.y],DIV_MAX_COLS*sizeof(short)); |
| 252 |
|
| 253 |
if (queryReplaceNoteDo) { |
| 254 |
switch (queryReplaceNoteMode) { |
| 255 |
case GUI_QUERY_REPLACE_SET: |
| 256 |
if (queryReplaceNote==130) { // macro release |
| 257 |
p->data[i.y][0]=102; |
| 258 |
p->data[i.y][1]=0; |
| 259 |
} else if (queryReplaceNote==129) { // note release |
| 260 |
p->data[i.y][0]=101; |
| 261 |
p->data[i.y][1]=0; |
| 262 |
} else if (queryReplaceNote==128) { // note off |
| 263 |
p->data[i.y][0]=100; |
| 264 |
p->data[i.y][1]=0; |
| 265 |
} else if (queryReplaceNote>=-60 && queryReplaceNote<120) { // note |
| 266 |
p->data[i.y][0]=(queryReplaceNote+60)%12; |
| 267 |
if (p->data[i.y][0]==0) p->data[i.y][0]=12; |
| 268 |
p->data[i.y][1]=(unsigned char)((queryReplaceNote-1)/12); |
| 269 |
} else { // invalid |
| 270 |
p->data[i.y][0]=0; |
| 271 |
p->data[i.y][1]=0; |
| 272 |
} |
| 273 |
break; |
| 274 |
case GUI_QUERY_REPLACE_ADD: |
| 275 |
if (p->data[i.y][0]<100) { |
| 276 |
int note=queryNote(p->data[i.y][0],p->data[i.y][1]); |
| 277 |
if (note>=-60 && note<120) { |
| 278 |
note+=queryReplaceNote; |
| 279 |
if (note<-60) note=-60; |
| 280 |
if (note>119) note=119; |
| 281 |
|
| 282 |
p->data[i.y][0]=(note+60)%12; |
| 283 |
p->data[i.y][1]=(unsigned char)(((note+60)/12)-5); |
| 284 |
if (p->data[i.y][0]==0) { |
| 285 |
p->data[i.y][0]=12; |
| 286 |
p->data[i.y][1]=(unsigned char)(p->data[i.y][1]-1); |
| 287 |
} |
| 288 |
} |
| 289 |
} |
| 290 |
break; |
| 291 |
case GUI_QUERY_REPLACE_ADD_OVERFLOW: |
| 292 |
if (p->data[i.y][0]<100) { |
| 293 |
int note=queryNote(p->data[i.y][0],p->data[i.y][1]); |
| 294 |
if (note>=-60 && note<120) { |
| 295 |
note+=queryReplaceNote; |
| 296 |
if (note<-60) { |
| 297 |
while (note<-60) note+=180; |
| 298 |
} else if (note>119) { |
| 299 |
while (note>119) note-=180; |
| 300 |
} |
| 301 |
|
| 302 |
p->data[i.y][0]=(note+60)%12; |
| 303 |
p->data[i.y][1]=(unsigned char)(((note+60)/12)-5); |
| 304 |
if (p->data[i.y][0]==0) { |
| 305 |
p->data[i.y][0]=12; |
| 306 |
p->data[i.y][1]=(unsigned char)(p->data[i.y][1]-1); |
| 307 |
} |
| 308 |
} |
| 309 |
} |
| 310 |
break; |
| 311 |
case GUI_QUERY_REPLACE_SCALE: |
| 312 |
break; |
| 313 |
case GUI_QUERY_REPLACE_CLEAR: |
| 314 |
p->data[i.y][0]=0; |
| 315 |
p->data[i.y][1]=0; |
| 316 |
break; |
| 317 |
} |
| 318 |
} |
| 319 |
|
| 320 |
if (queryReplaceInsDo) { |
| 321 |
switch (queryReplaceInsMode) { |
| 322 |
case GUI_QUERY_REPLACE_SET: |
| 323 |
p->data[i.y][2]=queryReplaceIns; |
| 324 |
break; |
| 325 |
case GUI_QUERY_REPLACE_ADD: |
| 326 |
if (p->data[i.y][2]>=0) { |
| 327 |
p->data[i.y][2]+=queryReplaceIns; |
| 328 |
if (p->data[i.y][2]<0) p->data[i.y][2]=0; |
| 329 |
if (p->data[i.y][2]>255) p->data[i.y][2]=255; |
| 330 |
} |
| 331 |
break; |
| 332 |
case GUI_QUERY_REPLACE_ADD_OVERFLOW: |
| 333 |
if (p->data[i.y][2]>=0) p->data[i.y][2]=(p->data[i.y][2]+queryReplaceIns)&0xff; |
| 334 |
break; |
| 335 |
case GUI_QUERY_REPLACE_SCALE: |
| 336 |
if (p->data[i.y][2]>=0) { |
| 337 |
p->data[i.y][2]=(p->data[i.y][2]*queryReplaceIns)/100; |
| 338 |
if (p->data[i.y][2]<0) p->data[i.y][2]=0; |
| 339 |
if (p->data[i.y][2]>255) p->data[i.y][2]=255; |
| 340 |
} |
| 341 |
break; |
| 342 |
case GUI_QUERY_REPLACE_CLEAR: |
| 343 |
p->data[i.y][2]=-1; |
| 344 |
break; |
| 345 |
} |
| 346 |
} |
| 347 |
|
| 348 |
if (queryReplaceVolDo) { |
| 349 |
switch (queryReplaceVolMode) { |
| 350 |
case GUI_QUERY_REPLACE_SET: |
| 351 |
p->data[i.y][3]=queryReplaceVol; |
| 352 |
break; |
| 353 |
case GUI_QUERY_REPLACE_ADD: |
| 354 |
if (p->data[i.y][3]>=0) { |
| 355 |
p->data[i.y][3]+=queryReplaceVol; |
| 356 |
if (p->data[i.y][3]<0) p->data[i.y][3]=0; |
| 357 |
if (p->data[i.y][3]>255) p->data[i.y][3]=255; |
| 358 |
} |
| 359 |
break; |
| 360 |
case GUI_QUERY_REPLACE_ADD_OVERFLOW: |
| 361 |
if (p->data[i.y][3]>=0) p->data[i.y][3]=(p->data[i.y][3]+queryReplaceVol)&0xff; |
| 362 |
break; |
| 363 |
case GUI_QUERY_REPLACE_SCALE: |
| 364 |
if (p->data[i.y][3]>=0) { |
| 365 |
p->data[i.y][3]=(p->data[i.y][3]*queryReplaceVol)/100; |
| 366 |
if (p->data[i.y][3]<0) p->data[i.y][3]=0; |
| 367 |
if (p->data[i.y][3]>255) p->data[i.y][3]=255; |
| 368 |
} |
| 369 |
break; |
| 370 |
case GUI_QUERY_REPLACE_CLEAR: |
| 371 |
p->data[i.y][3]=-1; |
| 372 |
break; |
| 373 |
} |
| 374 |
} |
| 375 |
|
| 376 |
signed char effectOrder[8]; |
| 377 |
memset(effectOrder,-1,8); |
| 378 |
|
| 379 |
switch (queryReplaceEffectPos) { |
| 380 |
case 0: // clear |
| 381 |
for (int j=0; j<e->song.subsong[i.subsong]->pat[i.x].effectCols && j<8; j++) { |
| 382 |
effectOrder[j]=j; |
| 383 |
} |
| 384 |
break; |
| 385 |
case 1: { // replace matches |
| 386 |
int placementIndex=0; |
| 387 |
for (int j=0; j<8 && placementIndex<8 && i.effectPos[j]>=0; j++) { |
| 388 |
effectOrder[placementIndex++]=i.effectPos[j]; |
| 389 |
} |
| 390 |
for (int j=0; j<e->song.subsong[i.subsong]->pat[i.x].effectCols && placementIndex<8 && j<8; j++) { |
| 391 |
if (p->data[i.y][4+j*2]!=-1 || p->data[i.y][5+j*2]!=-1) { |
| 392 |
effectOrder[placementIndex++]=j; |
| 393 |
} |
| 394 |
} |
| 395 |
break; |
| 396 |
} |
| 397 |
case 2: { // replace matches then free spaces |
| 398 |
int placementIndex=0; |
| 399 |
for (int j=0; j<8 && placementIndex<8 && i.effectPos[j]>=0; j++) { |
| 400 |
effectOrder[placementIndex++]=i.effectPos[j]; |
| 401 |
} |
| 402 |
for (int j=0; j<e->song.subsong[i.subsong]->pat[i.x].effectCols && placementIndex<8 && j<8; j++) { |
| 403 |
if (p->data[i.y][4+j*2]!=-1 || p->data[i.y][5+j*2]!=-1) { |
| 404 |
effectOrder[placementIndex++]=j; |
| 405 |
} |
| 406 |
} |
| 407 |
for (int j=0; j<e->song.subsong[i.subsong]->pat[i.x].effectCols; j++) { |
| 408 |
if (p->data[i.y][4+j*2]==-1 && p->data[i.y][5+j*2]==-1) { |
| 409 |
effectOrder[placementIndex++]=j; |
| 410 |
} |
| 411 |
} |
| 412 |
break; |
| 413 |
} |
| 414 |
case 3: { // insert in free spaces |
| 415 |
int placementIndex=0; |
| 416 |
for (int j=0; j<e->song.subsong[i.subsong]->pat[i.x].effectCols && j<8; j++) { |
| 417 |
if (p->data[i.y][4+j*2]==-1 && p->data[i.y][5+j*2]==-1) { |
| 418 |
effectOrder[placementIndex++]=j; |
| 419 |
} |
| 420 |
} |
| 421 |
break; |
| 422 |
} |
| 423 |
} |
| 424 |
|
| 425 |
for (int j=0; j<queryReplaceEffectCount && j<8; j++) { |
| 426 |
signed char pos=effectOrder[j]; |
| 427 |
if (pos==-1) continue; |
| 428 |
if (queryReplaceEffectDo[j]) { |
| 429 |
switch (queryReplaceEffectMode[j]) { |
| 430 |
case GUI_QUERY_REPLACE_SET: |
| 431 |
p->data[i.y][4+pos*2]=queryReplaceEffect[j]; |
| 432 |
break; |
| 433 |
case GUI_QUERY_REPLACE_ADD: |
| 434 |
if (p->data[i.y][4+pos*2]>=0) { |
| 435 |
p->data[i.y][4+pos*2]+=queryReplaceEffect[j]; |
| 436 |
if (p->data[i.y][4+pos*2]<0) p->data[i.y][4+pos*2]=0; |
| 437 |
if (p->data[i.y][4+pos*2]>255) p->data[i.y][4+pos*2]=255; |
| 438 |
} |
| 439 |
break; |
| 440 |
case GUI_QUERY_REPLACE_ADD_OVERFLOW: |
| 441 |
if (p->data[i.y][4+pos*2]>=0) p->data[i.y][4+pos*2]=(p->data[i.y][4+pos*2]+queryReplaceEffect[j])&0xff; |
| 442 |
break; |
| 443 |
case GUI_QUERY_REPLACE_SCALE: |
| 444 |
if (p->data[i.y][4+pos*2]>=0) { |
| 445 |
p->data[i.y][4+pos*2]=(p->data[i.y][4+pos*2]*queryReplaceEffect[j])/100; |
| 446 |
if (p->data[i.y][4+pos*2]<0) p->data[i.y][4+pos*2]=0; |
| 447 |
if (p->data[i.y][4+pos*2]>255) p->data[i.y][4+pos*2]=255; |
| 448 |
} |
| 449 |
break; |
| 450 |
case GUI_QUERY_REPLACE_CLEAR: |
| 451 |
p->data[i.y][4+pos*2]=-1; |
| 452 |
break; |
| 453 |
} |
| 454 |
} |
| 455 |
|
| 456 |
if (queryReplaceEffectValDo[j]) { |
| 457 |
switch (queryReplaceEffectValMode[j]) { |
| 458 |
case GUI_QUERY_REPLACE_SET: |
| 459 |
p->data[i.y][5+pos*2]=queryReplaceEffectVal[j]; |
| 460 |
break; |
| 461 |
case GUI_QUERY_REPLACE_ADD: |
| 462 |
if (p->data[i.y][5+pos*2]>=0) { |
| 463 |
p->data[i.y][5+pos*2]+=queryReplaceEffectVal[j]; |
| 464 |
if (p->data[i.y][5+pos*2]<0) p->data[i.y][5+pos*2]=0; |
| 465 |
if (p->data[i.y][5+pos*2]>255) p->data[i.y][5+pos*2]=255; |
| 466 |
} |
| 467 |
break; |
| 468 |
case GUI_QUERY_REPLACE_ADD_OVERFLOW: |
| 469 |
if (p->data[i.y][5+pos*2]>=0) p->data[i.y][5+pos*2]=(p->data[i.y][5+pos*2]+queryReplaceEffectVal[j])&0xff; |
| 470 |
break; |
| 471 |
case GUI_QUERY_REPLACE_SCALE: |
| 472 |
if (p->data[i.y][5+pos*2]>=0) { |
| 473 |
p->data[i.y][5+pos*2]=(p->data[i.y][5+pos*2]*queryReplaceEffectVal[j])/100; |
| 474 |
if (p->data[i.y][5+pos*2]<0) p->data[i.y][5+pos*2]=0; |
| 475 |
if (p->data[i.y][5+pos*2]>255) p->data[i.y][5+pos*2]=255; |
| 476 |
} |
| 477 |
break; |
| 478 |
case GUI_QUERY_REPLACE_CLEAR: |
| 479 |
p->data[i.y][5+pos*2]=-1; |
| 480 |
break; |
| 481 |
} |
| 482 |
} |
| 483 |
} |
| 484 |
|
| 485 |
// issue undo step |
| 486 |
for (int j=0; j<DIV_MAX_COLS; j++) { |
| 487 |
if (p->data[i.y][j]!=prevVal[j]) { |
| 488 |
us.pat.push_back(UndoPatternData(i.subsong,i.x,patIndex,i.y,j,prevVal[j],p->data[i.y][j])); |
| 489 |
} |
| 490 |
} |
| 491 |
} |
| 492 |
|
| 493 |
for (int i=0; i<DIV_MAX_CHANS; i++) { |
| 494 |
if (touched[i]!=NULL) delete[] touched[i]; |
| 495 |
} |
| 496 |
|
| 497 |
if (!curQueryResults.empty()) { |
| 498 |
MARK_MODIFIED; |
| 499 |
} |
| 500 |
|
| 501 |
if (!us.pat.empty()) { |
| 502 |
undoHist.push_back(us); |
| 503 |
redoHist.clear(); |
| 504 |
if (undoHist.size()>settings.maxUndoSteps) undoHist.pop_front(); |
| 505 |
} |
| 506 |
} |
| 507 |
|
| 508 |
#define FIRST_VISIBLE(x) (x==GUI_QUERY_MATCH || x==GUI_QUERY_MATCH_NOT || x==GUI_QUERY_RANGE || x==GUI_QUERY_RANGE_NOT) |
| 509 |
#define SECOND_VISIBLE(x) (x==GUI_QUERY_RANGE || x==GUI_QUERY_RANGE_NOT) |
| 510 |
|
| 511 |
void FurnaceGUI::drawFindReplace() { |
| 512 |
if (nextWindow==GUI_WINDOW_FIND) { |
| 513 |
findOpen=true; |
| 514 |
ImGui::SetNextWindowFocus(); |
| 515 |
nextWindow=GUI_WINDOW_NOTHING; |
| 516 |
} |
| 517 |
if (!findOpen) return; |
| 518 |
ImGui::SetNextWindowSizeConstraints(ImVec2(64.0f*dpiScale,32.0f*dpiScale),ImVec2(canvasW,canvasH)); |
| 519 |
if (ImGui::Begin("Find/Replace",&findOpen,globalWinFlags,_("Find/Replace"))) { |
| 520 |
if (curQuery.empty()) { |
| 521 |
curQuery.push_back(FurnaceGUIFindQuery()); |
| 522 |
} |
| 523 |
int index=0; |
| 524 |
int eraseIndex=-1; |
| 525 |
char tempID[1024]; |
| 526 |
if (ImGui::BeginTabBar("FindOrReplace")) { |
| 527 |
if (ImGui::BeginTabItem(_("Find"))) { |
| 528 |
if (queryViewingResults) { |
| 529 |
if (!curQueryResults.empty()) { |
| 530 |
ImVec2 avail=ImGui::GetContentRegionAvail(); |
| 531 |
avail.y-=ImGui::GetFrameHeightWithSpacing(); |
| 532 |
if (ImGui::BeginTable("FindResults",4,ImGuiTableFlags_Borders|ImGuiTableFlags_ScrollY,avail)) { |
| 533 |
ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthFixed,ImGui::CalcTextSize(_("order")).x); |
| 534 |
ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthFixed,ImGui::CalcTextSize(_("row")).x); |
| 535 |
ImGui::TableSetupColumn("c2",ImGuiTableColumnFlags_WidthStretch); |
| 536 |
ImGui::TableSetupColumn("c3",ImGuiTableColumnFlags_WidthFixed); |
| 537 |
|
| 538 |
ImGui::TableSetupScrollFreeze(0,1); |
| 539 |
|
| 540 |
ImGui::TableNextRow(ImGuiTableRowFlags_Headers); |
| 541 |
ImGui::TableNextColumn(); |
| 542 |
ImGui::Text(_("order")); |
| 543 |
ImGui::TableNextColumn(); |
| 544 |
ImGui::Text(_("row")); |
| 545 |
ImGui::TableNextColumn(); |
| 546 |
ImGui::Text(_("channel")); |
| 547 |
ImGui::TableNextColumn(); |
| 548 |
ImGui::Text(_("go")); |
| 549 |
|
| 550 |
int index=0; |
| 551 |
for (FurnaceGUIQueryResult& i: curQueryResults) { |
| 552 |
ImGui::TableNextRow(); |
| 553 |
ImGui::TableNextColumn(); |
| 554 |
if (settings.orderRowsBase==1) { |
| 555 |
ImGui::Text("%.2X",i.order); |
| 556 |
} else { |
| 557 |
ImGui::Text("%d",i.order); |
| 558 |
} |
| 559 |
ImGui::TableNextColumn(); |
| 560 |
if (settings.patRowsBase==1) { |
| 561 |
ImGui::Text("%.2X",i.y); |
| 562 |
} else { |
| 563 |
ImGui::Text("%d",i.y); |
| 564 |
} |
| 565 |
ImGui::TableNextColumn(); |
| 566 |
ImGui::Text("%d (%s)",i.x+1,e->getChannelName(i.x)); |
| 567 |
if (ImGui::TableNextColumn()) { |
| 568 |
snprintf(tempID,1024,ICON_FA_CHEVRON_RIGHT "##_FR%d",index); |
| 569 |
if (ImGui::Selectable(tempID)) { |
| 570 |
makeCursorUndo(); |
| 571 |
e->changeSongP(i.subsong); |
| 572 |
if (e->isPlaying()) { |
| 573 |
if (followPattern) { |
| 574 |
wasFollowing=followPattern; |
| 575 |
followPattern=false; |
| 576 |
} |
| 577 |
} else { |
| 578 |
e->setOrder(i.order); |
| 579 |
} |
| 580 |
curOrder=i.order; |
| 581 |
cursor.xCoarse=i.x; |
| 582 |
cursor.xFine=0; |
| 583 |
cursor.y=i.y; |
| 584 |
selStart=cursor; |
| 585 |
selEnd=cursor; |
| 586 |
demandScrollX=true; |
| 587 |
updateScroll(cursor.y); |
| 588 |
nextWindow=GUI_WINDOW_PATTERN; |
| 589 |
} |
| 590 |
} |
| 591 |
index++; |
| 592 |
} |
| 593 |
ImGui::EndTable(); |
| 594 |
} |
| 595 |
} else { |
| 596 |
ImGui::Text(_("no matches found!")); |
| 597 |
} |
| 598 |
if (ImGui::Button(_("Back"))) { |
| 599 |
queryViewingResults=false; |
| 600 |
} |
| 601 |
} else { |
| 602 |
for (FurnaceGUIFindQuery& i: curQuery) { |
| 603 |
ImGui::PushID(index+0x100); |
| 604 |
if (ImGui::BeginTable("FindRep",4,ImGuiTableFlags_BordersOuter)) { |
| 605 |
ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthFixed); |
| 606 |
ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthStretch,0.5); |
| 607 |
ImGui::TableSetupColumn("c2",ImGuiTableColumnFlags_WidthStretch,0.25); |
| 608 |
ImGui::TableSetupColumn("c3",ImGuiTableColumnFlags_WidthStretch,0.25); |
| 609 |
ImGui::TableNextRow(); |
| 610 |
ImGui::TableNextColumn(); |
| 611 |
ImGui::AlignTextToFramePadding(); |
| 612 |
ImGui::Text(_("Note")); |
| 613 |
ImGui::TableNextColumn(); |
| 614 |
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); |
| 615 |
ImGui::Combo("##NCondition",&i.noteMode,LocalizedComboGetter,queryModes,GUI_QUERY_MAX); |
| 616 |
ImGui::TableNextColumn(); |
| 617 |
if (FIRST_VISIBLE(i.noteMode)) { |
| 618 |
if ((i.noteMode==GUI_QUERY_RANGE || i.noteMode==GUI_QUERY_RANGE_NOT) && i.note>=120) { |
| 619 |
i.note=0; |
| 620 |
} |
| 621 |
if (i.note==130) { |
| 622 |
snprintf(tempID,1024,"%s##MREL",macroRelLabel); |
| 623 |
} else if (i.note==129) { |
| 624 |
snprintf(tempID,1024,"%s##NREL",noteRelLabel); |
| 625 |
} else if (i.note==128) { |
| 626 |
snprintf(tempID,1024,"%s##NOFF",noteOffLabel); |
| 627 |
} else if (i.note>=-60 && i.note<120) { |
| 628 |
snprintf(tempID,1024,"%c%c",noteNames[i.note+60][0],(noteNames[i.note+60][1]=='-')?' ':noteNames[i.note+60][1]); |
| 629 |
} else { |
| 630 |
snprintf(tempID,1024,"???"); |
| 631 |
i.note=0; |
| 632 |
} |
| 633 |
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x/2); |
| 634 |
bool updateNote1=false; |
| 635 |
int note1=i.note%12; |
| 636 |
int oct1=i.note/12; |
| 637 |
if (ImGui::BeginCombo("##NN1",tempID)) { |
| 638 |
for (int j=0; j<12; j++) { |
| 639 |
snprintf(tempID,1024,"%c%c",noteNames[j+72][0],(noteNames[j+72][1]=='-')?' ':noteNames[j+72][1]); |
| 640 |
if (ImGui::Selectable(tempID,note1==j)) { |
| 641 |
note1=j; |
| 642 |
updateNote1=true; |
| 643 |
} |
| 644 |
} |
| 645 |
if (i.noteMode!=GUI_QUERY_RANGE && i.noteMode!=GUI_QUERY_RANGE_NOT) { |
| 646 |
if (ImGui::Selectable(noteOffLabel,note1==13)) { |
| 647 |
i.note=128; |
| 648 |
} |
| 649 |
if (ImGui::Selectable(noteRelLabel,note1==14)) { |
| 650 |
i.note=129; |
| 651 |
} |
| 652 |
if (ImGui::Selectable(macroRelLabel,note1==15)) { |
| 653 |
i.note=130; |
| 654 |
} |
| 655 |
} |
| 656 |
ImGui::EndCombo(); |
| 657 |
} |
| 658 |
ImGui::SameLine(); |
| 659 |
if (i.note<128) { |
| 660 |
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x/2); |
| 661 |
if (ImGui::InputScalar("##NNO1",ImGuiDataType_S32,&oct1)) { |
| 662 |
if (oct1<-5) oct1=-5; |
| 663 |
if (oct1>9) oct1=9; |
| 664 |
updateNote1=true; |
| 665 |
} |
| 666 |
} |
| 667 |
if (updateNote1) { |
| 668 |
i.note=oct1*12+note1; |
| 669 |
} |
| 670 |
} |
| 671 |
ImGui::TableNextColumn(); |
| 672 |
if (SECOND_VISIBLE(i.noteMode)) { |
| 673 |
if (i.noteMax<-60 || i.noteMax>=120) { |
| 674 |
i.noteMax=0; |
| 675 |
} |
| 676 |
if (i.noteMax>=-60 && i.noteMax<120) { |
| 677 |
snprintf(tempID,1024,"%c%c",noteNames[i.noteMax+60][0],(noteNames[i.noteMax+60][1]=='-')?' ':noteNames[i.noteMax+60][1]); |
| 678 |
} else { |
| 679 |
snprintf(tempID,1024,"???"); |
| 680 |
} |
| 681 |
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x/2); |
| 682 |
bool updateNote2=false; |
| 683 |
int note2=i.noteMax%12; |
| 684 |
int oct2=i.noteMax/12; |
| 685 |
if (ImGui::BeginCombo("##NN2",tempID)) { |
| 686 |
for (int j=0; j<12; j++) { |
| 687 |
snprintf(tempID,1024,"%c%c",noteNames[j+72][0],(noteNames[j+72][1]=='-')?' ':noteNames[j+72][1]); |
| 688 |
if (ImGui::Selectable(tempID,note2==j)) { |
| 689 |
note2=j; |
| 690 |
updateNote2=true; |
| 691 |
} |
| 692 |
} |
| 693 |
ImGui::EndCombo(); |
| 694 |
} |
| 695 |
ImGui::SameLine(); |
| 696 |
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x/2); |
| 697 |
if (ImGui::InputScalar("##NNO2",ImGuiDataType_S32,&oct2)) { |
| 698 |
if (oct2<-5) oct2=-5; |
| 699 |
if (oct2>9) oct2=9; |
| 700 |
updateNote2=true; |
| 701 |
} |
| 702 |
if (updateNote2) { |
| 703 |
i.noteMax=oct2*12+note2; |
| 704 |
} |
| 705 |
} |
| 706 |
|
| 707 |
ImGui::TableNextRow(); |
| 708 |
ImGui::TableNextColumn(); |
| 709 |
ImGui::AlignTextToFramePadding(); |
| 710 |
ImGui::Text(_("Ins")); |
| 711 |
ImGui::TableNextColumn(); |
| 712 |
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); |
| 713 |
ImGui::Combo("##ICondition",&i.insMode,LocalizedComboGetter,queryModes,GUI_QUERY_MAX); |
| 714 |
ImGui::TableNextColumn(); |
| 715 |
if (FIRST_VISIBLE(i.insMode)) { |
| 716 |
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); |
| 717 |
ImGui::InputScalar("##II1",ImGuiDataType_U8,&i.ins,NULL,NULL,"%.2X",ImGuiInputTextFlags_CharsHexadecimal); |
| 718 |
} |
| 719 |
ImGui::TableNextColumn(); |
| 720 |
if (SECOND_VISIBLE(i.insMode)) { |
| 721 |
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); |
| 722 |
ImGui::InputScalar("##II2",ImGuiDataType_U8,&i.insMax,NULL,NULL,"%.2X",ImGuiInputTextFlags_CharsHexadecimal); |
| 723 |
} |
| 724 |
|
| 725 |
ImGui::TableNextRow(); |
| 726 |
ImGui::TableNextColumn(); |
| 727 |
ImGui::AlignTextToFramePadding(); |
| 728 |
ImGui::Text(_("Volume")); |
| 729 |
ImGui::TableNextColumn(); |
| 730 |
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); |
| 731 |
ImGui::Combo("##VCondition",&i.volMode,LocalizedComboGetter,queryModes,GUI_QUERY_MAX); |
| 732 |
ImGui::TableNextColumn(); |
| 733 |
if (FIRST_VISIBLE(i.volMode)) { |
| 734 |
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); |
| 735 |
ImGui::InputScalar("##VV1",ImGuiDataType_U8,&i.vol,NULL,NULL,"%.2X",ImGuiInputTextFlags_CharsHexadecimal); |
| 736 |
} |
| 737 |
ImGui::TableNextColumn(); |
| 738 |
if (SECOND_VISIBLE(i.volMode)) { |
| 739 |
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); |
| 740 |
ImGui::InputScalar("##VV2",ImGuiDataType_U8,&i.volMax,NULL,NULL,"%.2X",ImGuiInputTextFlags_CharsHexadecimal); |
| 741 |
} |
| 742 |
|
| 743 |
for (int j=0; j<i.effectCount; j++) { |
| 744 |
ImGui::PushID(0x1000+j); |
| 745 |
ImGui::TableNextRow(); |
| 746 |
ImGui::TableNextColumn(); |
| 747 |
ImGui::AlignTextToFramePadding(); |
| 748 |
ImGui::Text(_("Effect")); |
| 749 |
ImGui::TableNextColumn(); |
| 750 |
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); |
| 751 |
ImGui::Combo("##ECondition",&i.effectMode[j],LocalizedComboGetter,queryModes,GUI_QUERY_MAX); |
| 752 |
ImGui::TableNextColumn(); |
| 753 |
if (FIRST_VISIBLE(i.effectMode[j])) { |
| 754 |
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); |
| 755 |
ImGui::InputScalar("##EE1",ImGuiDataType_U8,&i.effect[j],NULL,NULL,"%.2X",ImGuiInputTextFlags_CharsHexadecimal); |
| 756 |
} |
| 757 |
ImGui::TableNextColumn(); |
| 758 |
if (SECOND_VISIBLE(i.effectMode[j])) { |
| 759 |
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); |
| 760 |
ImGui::InputScalar("##EE2",ImGuiDataType_U8,&i.effectMax[j],NULL,NULL,"%.2X",ImGuiInputTextFlags_CharsHexadecimal); |
| 761 |
} |
| 762 |
|
| 763 |
ImGui::TableNextRow(); |
| 764 |
ImGui::TableNextColumn(); |
| 765 |
ImGui::AlignTextToFramePadding(); |
| 766 |
ImGui::Text(_("Value")); |
| 767 |
ImGui::TableNextColumn(); |
| 768 |
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); |
| 769 |
ImGui::Combo("##EVCondition",&i.effectValMode[j],LocalizedComboGetter,queryModes,GUI_QUERY_MAX); |
| 770 |
ImGui::TableNextColumn(); |
| 771 |
if (FIRST_VISIBLE(i.effectValMode[j])) { |
| 772 |
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); |
| 773 |
ImGui::InputScalar("##EV1",ImGuiDataType_U8,&i.effectVal[j],NULL,NULL,"%.2X",ImGuiInputTextFlags_CharsHexadecimal); |
| 774 |
} |
| 775 |
ImGui::TableNextColumn(); |
| 776 |
if (SECOND_VISIBLE(i.effectValMode[j])) { |
| 777 |
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); |
| 778 |
ImGui::InputScalar("##EV2",ImGuiDataType_U8,&i.effectValMax[j],NULL,NULL,"%.2X",ImGuiInputTextFlags_CharsHexadecimal); |
| 779 |
} |
| 780 |
|
| 781 |
ImGui::PopID(); |
| 782 |
} |
| 783 |
ImGui::TableNextRow(); |
| 784 |
ImGui::TableNextColumn(); |
| 785 |
pushDestColor(); |
| 786 |
if (ImGui::Button(ICON_FA_MINUS "##DelQuery")) { |
| 787 |
eraseIndex=index; |
| 788 |
} |
| 789 |
popDestColor(); |
| 790 |
if (ImGui::IsItemHovered()) { |
| 791 |
ImGui::SetTooltip(_("Delete query")); |
| 792 |
} |
| 793 |
ImGui::TableNextColumn(); |
| 794 |
if (i.effectCount<8) { |
| 795 |
if (ImGui::Button(_("Add effect"))) { |
| 796 |
i.effectCount++; |
| 797 |
} |
| 798 |
} |
| 799 |
ImGui::TableNextColumn(); |
| 800 |
if (i.effectCount>0) { |
| 801 |
pushDestColor(); |
| 802 |
if (ImGui::Button(_("Remove effect"))) { |
| 803 |
i.effectCount--; |
| 804 |
} |
| 805 |
popDestColor(); |
| 806 |
} |
| 807 |
ImGui::EndTable(); |
| 808 |
} |
| 809 |
ImGui::PopID(); |
| 810 |
index++; |
| 811 |
} |
| 812 |
if (eraseIndex>=0) { |
| 813 |
curQuery.erase(curQuery.begin()+eraseIndex); |
| 814 |
} |
| 815 |
if (ImGui::Button(ICON_FA_PLUS "##AddQuery")) { |
| 816 |
curQuery.push_back(FurnaceGUIFindQuery()); |
| 817 |
} |
| 818 |
|
| 819 |
if (ImGui::BeginTable("QueryLimits",3)) { |
| 820 |
ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthFixed); |
| 821 |
ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthStretch,0.5f); |
| 822 |
ImGui::TableSetupColumn("c2",ImGuiTableColumnFlags_WidthStretch,0.5f); |
| 823 |
|
| 824 |
ImGui::TableNextRow(); |
| 825 |
ImGui::TableNextColumn(); |
| 826 |
|
| 827 |
ImGui::Text(_("Search range:")); |
| 828 |
|
| 829 |
if (ImGui::RadioButton(_("Song"),curQueryRangeY==0)) { |
| 830 |
curQueryRangeY=0; |
| 831 |
} |
| 832 |
if (ImGui::RadioButton(_("Selection"),curQueryRangeY==1)) { |
| 833 |
curQueryRangeY=1; |
| 834 |
} |
| 835 |
if (ImGui::RadioButton(_("Pattern"),curQueryRangeY==2)) { |
| 836 |
curQueryRangeY=2; |
| 837 |
} |
| 838 |
|
| 839 |
ImGui::TableNextColumn(); |
| 840 |
ImGui::BeginDisabled(curQueryRangeY==1); |
| 841 |
ImGui::Checkbox(_("Confine to channels"),&curQueryRangeX); |
| 842 |
|
| 843 |
ImGui::BeginDisabled(!curQueryRangeX); |
| 844 |
snprintf(tempID,1024,"%d: %s",curQueryRangeXMin+1,e->getChannelName(curQueryRangeXMin)); |
| 845 |
if (ImGui::BeginCombo(_("From"),tempID)) { |
| 846 |
for (int i=0; i<e->getTotalChannelCount(); i++) { |
| 847 |
snprintf(tempID,1024,"%d: %s",i+1,e->getChannelName(i)); |
| 848 |
if (ImGui::Selectable(tempID,curQueryRangeXMin==i)) { |
| 849 |
curQueryRangeXMin=i; |
| 850 |
} |
| 851 |
} |
| 852 |
ImGui::EndCombo(); |
| 853 |
} |
| 854 |
|
| 855 |
snprintf(tempID,1024,"%d: %s",curQueryRangeXMax+1,e->getChannelName(curQueryRangeXMax)); |
| 856 |
if (ImGui::BeginCombo(_("To"),tempID)) { |
| 857 |
for (int i=0; i<e->getTotalChannelCount(); i++) { |
| 858 |
snprintf(tempID,1024,"%d: %s",i+1,e->getChannelName(i)); |
| 859 |
if (ImGui::Selectable(tempID,curQueryRangeXMax==i)) { |
| 860 |
curQueryRangeXMax=i; |
| 861 |
} |
| 862 |
} |
| 863 |
ImGui::EndCombo(); |
| 864 |
} |
| 865 |
ImGui::EndDisabled(); |
| 866 |
ImGui::EndDisabled(); |
| 867 |
|
| 868 |
ImGui::TableNextColumn(); |
| 869 |
ImGui::Text(_("Match effect position:")); |
| 870 |
|
| 871 |
if (ImGui::RadioButton(_("No"),curQueryEffectPos==0)) { |
| 872 |
curQueryEffectPos=0; |
| 873 |
} |
| 874 |
if (ImGui::IsItemHovered()) { |
| 875 |
ImGui::SetTooltip(_("match effects regardless of position.")); |
| 876 |
} |
| 877 |
if (ImGui::RadioButton(_("Lax"),curQueryEffectPos==1)) { |
| 878 |
curQueryEffectPos=1; |
| 879 |
} |
| 880 |
if (ImGui::IsItemHovered()) { |
| 881 |
ImGui::SetTooltip(_("match effects only if they appear in-order.")); |
| 882 |
} |
| 883 |
if (ImGui::RadioButton(_("Strict"),curQueryEffectPos==2)) { |
| 884 |
curQueryEffectPos=2; |
| 885 |
} |
| 886 |
if (ImGui::IsItemHovered()) { |
| 887 |
ImGui::SetTooltip(_("match effects only if they appear exactly as specified.")); |
| 888 |
} |
| 889 |
|
| 890 |
ImGui::EndTable(); |
| 891 |
} |
| 892 |
|
| 893 |
if (ImGui::Button(_("Find"))) { |
| 894 |
doFind(); |
| 895 |
} |
| 896 |
} |
| 897 |
ImGui::EndTabItem(); |
| 898 |
} |
| 899 |
if (ImGui::BeginTabItem(_("Replace"))) { |
| 900 |
if (ImGui::BeginTable("QueryReplace",3,ImGuiTableFlags_BordersOuter)) { |
| 901 |
ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthFixed); |
| 902 |
ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthStretch,0.5); |
| 903 |
ImGui::TableSetupColumn("c2",ImGuiTableColumnFlags_WidthStretch,0.5); |
| 904 |
|
| 905 |
ImGui::TableNextRow(); |
| 906 |
ImGui::TableNextColumn(); |
| 907 |
ImGui::Checkbox(_("Note"),&queryReplaceNoteDo); |
| 908 |
ImGui::TableNextColumn(); |
| 909 |
ImGui::BeginDisabled(!queryReplaceNoteDo); |
| 910 |
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); |
| 911 |
ImGui::Combo("##NRMode",&queryReplaceNoteMode,LocalizedComboGetter,queryReplaceModes,GUI_QUERY_REPLACE_MAX); |
| 912 |
ImGui::TableNextColumn(); |
| 913 |
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); |
| 914 |
if (queryReplaceNoteMode==GUI_QUERY_REPLACE_SET) { |
| 915 |
if (queryReplaceNote==130) { |
| 916 |
snprintf(tempID,1024,"%s##MREL",macroRelLabel); |
| 917 |
} else if (queryReplaceNote==129) { |
| 918 |
snprintf(tempID,1024,"%s##NREL",noteRelLabel); |
| 919 |
} else if (queryReplaceNote==128) { |
| 920 |
snprintf(tempID,1024,"%s##NOFF",noteOffLabel); |
| 921 |
} else if (queryReplaceNote>=-60 && queryReplaceNote<120) { |
| 922 |
snprintf(tempID,1024,"%c%c",noteNames[queryReplaceNote+60][0],(noteNames[queryReplaceNote+60][1]=='-')?' ':noteNames[queryReplaceNote+60][1]); |
| 923 |
} else { |
| 924 |
snprintf(tempID,1024,"???"); |
| 925 |
queryReplaceNote=0; |
| 926 |
} |
| 927 |
bool updateNote=false; |
| 928 |
int note1=queryReplaceNote%12; |
| 929 |
int oct1=queryReplaceNote/12; |
| 930 |
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x/2); |
| 931 |
if (ImGui::BeginCombo("##NRValueC",tempID)) { |
| 932 |
for (int i=0; i<12; i++) { |
| 933 |
snprintf(tempID,1024,"%c%c",noteNames[i+72][0],(noteNames[i+72][1]=='-')?' ':noteNames[i+72][1]); |
| 934 |
if (ImGui::Selectable(tempID,note1==i)) { |
| 935 |
note1=i; |
| 936 |
updateNote=true; |
| 937 |
} |
| 938 |
} |
| 939 |
if (ImGui::Selectable(noteOffLabel,note1==13)) { |
| 940 |
queryReplaceNote=128; |
| 941 |
} |
| 942 |
if (ImGui::Selectable(noteRelLabel,note1==14)) { |
| 943 |
queryReplaceNote=129; |
| 944 |
} |
| 945 |
if (ImGui::Selectable(macroRelLabel,note1==15)) { |
| 946 |
queryReplaceNote=130; |
| 947 |
} |
| 948 |
ImGui::EndCombo(); |
| 949 |
} |
| 950 |
ImGui::SameLine(); |
| 951 |
if (queryReplaceNote<128) { |
| 952 |
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x/2); |
| 953 |
if (ImGui::InputScalar("##NRValueCO",ImGuiDataType_S32,&oct1)) { |
| 954 |
if (oct1<-5) oct1=-5; |
| 955 |
if (oct1>9) oct1=9; |
| 956 |
updateNote=true; |
| 957 |
} |
| 958 |
} |
| 959 |
if (updateNote) { |
| 960 |
queryReplaceNote=oct1*12+note1; |
| 961 |
} |
| 962 |
} else if (queryReplaceNoteMode==GUI_QUERY_REPLACE_ADD || queryReplaceNoteMode==GUI_QUERY_REPLACE_ADD_OVERFLOW) { |
| 963 |
if (ImGui::InputInt("##NRValue",&queryReplaceNote,1,12)) { |
| 964 |
if (queryReplaceNote<-180) queryReplaceNote=-180; |
| 965 |
if (queryReplaceNote>180) queryReplaceNote=180; |
| 966 |
} |
| 967 |
} else if (queryReplaceNoteMode==GUI_QUERY_REPLACE_SCALE) { |
| 968 |
ImGui::Text(_("INVALID")); |
| 969 |
} |
| 970 |
ImGui::EndDisabled(); |
| 971 |
|
| 972 |
ImGui::TableNextRow(); |
| 973 |
ImGui::TableNextColumn(); |
| 974 |
ImGui::Checkbox(_("Ins"),&queryReplaceInsDo); |
| 975 |
ImGui::TableNextColumn(); |
| 976 |
ImGui::BeginDisabled(!queryReplaceInsDo); |
| 977 |
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); |
| 978 |
ImGui::Combo("##IRMode",&queryReplaceInsMode,LocalizedComboGetter,queryReplaceModes,GUI_QUERY_REPLACE_MAX); |
| 979 |
ImGui::TableNextColumn(); |
| 980 |
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); |
| 981 |
if (queryReplaceInsMode==GUI_QUERY_REPLACE_SET) { |
| 982 |
if (ImGui::InputScalar("##IRValueH",ImGuiDataType_S32,&queryReplaceIns,&_ONE,&_SIXTEEN,"%.2X",ImGuiInputTextFlags_CharsHexadecimal)) { |
| 983 |
if (queryReplaceIns<0) queryReplaceIns=0; |
| 984 |
if (queryReplaceIns>255) queryReplaceIns=255; |
| 985 |
} |
| 986 |
} else if (queryReplaceInsMode==GUI_QUERY_REPLACE_ADD || queryReplaceInsMode==GUI_QUERY_REPLACE_ADD_OVERFLOW) { |
| 987 |
if (ImGui::InputInt("##IRValue",&queryReplaceIns,1,16)) { |
| 988 |
if (queryReplaceIns<-255) queryReplaceIns=-255; |
| 989 |
if (queryReplaceIns>255) queryReplaceIns=255; |
| 990 |
} |
| 991 |
} else if (queryReplaceInsMode==GUI_QUERY_REPLACE_SCALE) { |
| 992 |
if (queryReplaceIns<0) queryReplaceIns=0; |
| 993 |
if (queryReplaceIns>400) queryReplaceIns=400; |
| 994 |
if (ImGui::InputInt("##IRValue",&queryReplaceIns,1,10)) { |
| 995 |
if (queryReplaceIns<0) queryReplaceIns=0; |
| 996 |
if (queryReplaceIns>400) queryReplaceIns=400; |
| 997 |
} |
| 998 |
} |
| 999 |
ImGui::EndDisabled(); |
| 1000 |
|
| 1001 |
ImGui::TableNextRow(); |
| 1002 |
ImGui::TableNextColumn(); |
| 1003 |
ImGui::Checkbox(_("Volume"),&queryReplaceVolDo); |
| 1004 |
ImGui::TableNextColumn(); |
| 1005 |
ImGui::BeginDisabled(!queryReplaceVolDo); |
| 1006 |
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); |
| 1007 |
ImGui::Combo("##VRMode",&queryReplaceVolMode,LocalizedComboGetter,queryReplaceModes,GUI_QUERY_REPLACE_MAX); |
| 1008 |
ImGui::TableNextColumn(); |
| 1009 |
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); |
| 1010 |
if (queryReplaceVolMode==GUI_QUERY_REPLACE_SET) { |
| 1011 |
if (ImGui::InputScalar("##VRValueH",ImGuiDataType_S32,&queryReplaceVol,&_ONE,&_SIXTEEN,"%.2X",ImGuiInputTextFlags_CharsHexadecimal)) { |
| 1012 |
if (queryReplaceVol<0) queryReplaceVol=0; |
| 1013 |
if (queryReplaceVol>255) queryReplaceVol=255; |
| 1014 |
} |
| 1015 |
} else if (queryReplaceVolMode==GUI_QUERY_REPLACE_ADD || queryReplaceVolMode==GUI_QUERY_REPLACE_ADD_OVERFLOW) { |
| 1016 |
if (ImGui::InputInt("##VRValue",&queryReplaceVol,1,16)) { |
| 1017 |
if (queryReplaceVol<-255) queryReplaceVol=-255; |
| 1018 |
if (queryReplaceVol>255) queryReplaceVol=255; |
| 1019 |
} |
| 1020 |
} else if (queryReplaceVolMode==GUI_QUERY_REPLACE_SCALE) { |
| 1021 |
if (queryReplaceVol<0) queryReplaceVol=0; |
| 1022 |
if (queryReplaceVol>400) queryReplaceVol=400; |
| 1023 |
if (ImGui::InputInt("##VRValue",&queryReplaceVol,1,10)) { |
| 1024 |
if (queryReplaceVol<0) queryReplaceVol=0; |
| 1025 |
if (queryReplaceVol>400) queryReplaceVol=400; |
| 1026 |
} |
| 1027 |
} |
| 1028 |
ImGui::EndDisabled(); |
| 1029 |
|
| 1030 |
for (int i=0; i<queryReplaceEffectCount; i++) { |
| 1031 |
ImGui::PushID(0x100+i); |
| 1032 |
ImGui::TableNextRow(); |
| 1033 |
ImGui::TableNextColumn(); |
| 1034 |
ImGui::Checkbox(_("Effect"),&queryReplaceEffectDo[i]); |
| 1035 |
ImGui::TableNextColumn(); |
| 1036 |
ImGui::BeginDisabled(!queryReplaceEffectDo[i]); |
| 1037 |
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); |
| 1038 |
ImGui::Combo("##ERMode",&queryReplaceEffectMode[i],LocalizedComboGetter,queryReplaceModes,GUI_QUERY_REPLACE_MAX); |
| 1039 |
ImGui::TableNextColumn(); |
| 1040 |
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); |
| 1041 |
if (queryReplaceEffectMode[i]==GUI_QUERY_REPLACE_SET) { |
| 1042 |
if (ImGui::InputScalar("##ERValueH",ImGuiDataType_S32,&queryReplaceEffect[i],&_ONE,&_SIXTEEN,"%.2X",ImGuiInputTextFlags_CharsHexadecimal)) { |
| 1043 |
if (queryReplaceEffect[i]<0) queryReplaceEffect[i]=0; |
| 1044 |
if (queryReplaceEffect[i]>255) queryReplaceEffect[i]=255; |
| 1045 |
} |
| 1046 |
} else if (queryReplaceEffectMode[i]==GUI_QUERY_REPLACE_ADD || queryReplaceEffectMode[i]==GUI_QUERY_REPLACE_ADD_OVERFLOW) { |
| 1047 |
if (ImGui::InputInt("##ERValue",&queryReplaceEffect[i],1,16)) { |
| 1048 |
if (queryReplaceEffect[i]<-255) queryReplaceEffect[i]=-255; |
| 1049 |
if (queryReplaceEffect[i]>255) queryReplaceEffect[i]=255; |
| 1050 |
} |
| 1051 |
} else if (queryReplaceEffectMode[i]==GUI_QUERY_REPLACE_SCALE) { |
| 1052 |
if (queryReplaceEffect[i]<0) queryReplaceEffect[i]=0; |
| 1053 |
if (queryReplaceEffect[i]>400) queryReplaceEffect[i]=400; |
| 1054 |
if (ImGui::InputInt("##ERValue",&queryReplaceEffect[i],1,10)) { |
| 1055 |
if (queryReplaceEffect[i]<0) queryReplaceEffect[i]=0; |
| 1056 |
if (queryReplaceEffect[i]>400) queryReplaceEffect[i]=400; |
| 1057 |
} |
| 1058 |
} |
| 1059 |
ImGui::EndDisabled(); |
| 1060 |
|
| 1061 |
ImGui::TableNextRow(); |
| 1062 |
ImGui::TableNextColumn(); |
| 1063 |
ImGui::Checkbox(_("Value"),&queryReplaceEffectValDo[i]); |
| 1064 |
ImGui::TableNextColumn(); |
| 1065 |
ImGui::BeginDisabled(!queryReplaceEffectValDo[i]); |
| 1066 |
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); |
| 1067 |
ImGui::Combo("##ERModeV",&queryReplaceEffectValMode[i],LocalizedComboGetter,queryReplaceModes,GUI_QUERY_REPLACE_MAX); |
| 1068 |
ImGui::TableNextColumn(); |
| 1069 |
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); |
| 1070 |
if (queryReplaceEffectValMode[i]==GUI_QUERY_REPLACE_SET) { |
| 1071 |
if (ImGui::InputScalar("##ERValueVH",ImGuiDataType_S32,&queryReplaceEffectVal[i],&_ONE,&_SIXTEEN,"%.2X",ImGuiInputTextFlags_CharsHexadecimal)) { |
| 1072 |
if (queryReplaceEffectVal[i]<0) queryReplaceEffectVal[i]=0; |
| 1073 |
if (queryReplaceEffectVal[i]>255) queryReplaceEffectVal[i]=255; |
| 1074 |
} |
| 1075 |
} else if (queryReplaceEffectValMode[i]==GUI_QUERY_REPLACE_ADD || queryReplaceEffectValMode[i]==GUI_QUERY_REPLACE_ADD_OVERFLOW) { |
| 1076 |
if (ImGui::InputInt("##ERValueV",&queryReplaceEffectVal[i],1,16)) { |
| 1077 |
if (queryReplaceEffectVal[i]<-255) queryReplaceEffectVal[i]=-255; |
| 1078 |
if (queryReplaceEffectVal[i]>255) queryReplaceEffectVal[i]=255; |
| 1079 |
} |
| 1080 |
} else if (queryReplaceEffectValMode[i]==GUI_QUERY_REPLACE_SCALE) { |
| 1081 |
if (queryReplaceEffectVal[i]<0) queryReplaceEffectVal[i]=0; |
| 1082 |
if (queryReplaceEffectVal[i]>400) queryReplaceEffectVal[i]=400; |
| 1083 |
if (ImGui::InputInt("##ERValueV",&queryReplaceEffectVal[i],1,10)) { |
| 1084 |
if (queryReplaceEffectVal[i]<0) queryReplaceEffectVal[i]=0; |
| 1085 |
if (queryReplaceEffectVal[i]>400) queryReplaceEffectVal[i]=400; |
| 1086 |
} |
| 1087 |
} |
| 1088 |
ImGui::EndDisabled(); |
| 1089 |
|
| 1090 |
ImGui::PopID(); |
| 1091 |
} |
| 1092 |
|
| 1093 |
ImGui::TableNextRow(); |
| 1094 |
ImGui::TableNextColumn(); |
| 1095 |
ImGui::TableNextColumn(); |
| 1096 |
if (queryReplaceEffectCount<8) { |
| 1097 |
if (ImGui::Button(_("Add effect"))) { |
| 1098 |
queryReplaceEffectCount++; |
| 1099 |
} |
| 1100 |
} |
| 1101 |
ImGui::TableNextColumn(); |
| 1102 |
if (queryReplaceEffectCount>0) { |
| 1103 |
pushDestColor(); |
| 1104 |
if (ImGui::Button(_("Remove effect"))) { |
| 1105 |
queryReplaceEffectCount--; |
| 1106 |
} |
| 1107 |
popDestColor(); |
| 1108 |
} |
| 1109 |
|
| 1110 |
ImGui::EndTable(); |
| 1111 |
} |
| 1112 |
ImGui::Text(_("Effect replace mode:")); |
| 1113 |
if (ImGui::RadioButton(_("Replace matches only"),queryReplaceEffectPos==1)) { |
| 1114 |
queryReplaceEffectPos=1; |
| 1115 |
} |
| 1116 |
if (ImGui::RadioButton(_("Replace matches, then free spaces"),queryReplaceEffectPos==2)) { |
| 1117 |
queryReplaceEffectPos=2; |
| 1118 |
} |
| 1119 |
if (ImGui::RadioButton(_("Clear effects"),queryReplaceEffectPos==0)) { |
| 1120 |
queryReplaceEffectPos=0; |
| 1121 |
} |
| 1122 |
if (ImGui::RadioButton(_("Insert in free spaces"),queryReplaceEffectPos==3)) { |
| 1123 |
queryReplaceEffectPos=3; |
| 1124 |
} |
| 1125 |
if (ImGui::Button(_("Replace##QueryReplace"))) { |
| 1126 |
doReplace(); |
| 1127 |
} |
| 1128 |
ImGui::EndTabItem(); |
| 1129 |
} |
| 1130 |
ImGui::EndTabBar(); |
| 1131 |
} |
| 1132 |
} |
| 1133 |
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_FIND; |
| 1134 |
ImGui::End(); |
| 1135 |
} |