Revision 34e43b0a
Added by Leszek Koltunski over 6 years ago
| src/main/java/org/distorted/library/effectqueue/EffectQueue.java | ||
|---|---|---|
| 337 | 337 |
{
|
| 338 | 338 |
if( mMax[mIndex]>mNumEffectsToBe || !mCreated ) |
| 339 | 339 |
{
|
| 340 |
mJobs.add(new Job(ATTACH,0,false,effect)); |
|
| 340 |
mJobs.add(new Job(ATTACH,-1,false,effect)); |
|
| 341 |
InternalMaster.newSlave(this); |
|
| 342 |
mNumEffectsToBe++; |
|
| 343 |
return true; |
|
| 344 |
} |
|
| 345 |
|
|
| 346 |
return false; |
|
| 347 |
} |
|
| 348 |
|
|
| 349 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 350 |
|
|
| 351 |
public boolean add(Effect effect, int position) |
|
| 352 |
{
|
|
| 353 |
if( mMax[mIndex]>mNumEffectsToBe || !mCreated ) |
|
| 354 |
{
|
|
| 355 |
mJobs.add(new Job(ATTACH,position,false,effect)); |
|
| 341 | 356 |
InternalMaster.newSlave(this); |
| 342 | 357 |
mNumEffectsToBe++; |
| 343 | 358 |
return true; |
| ... | ... | |
| 373 | 388 |
break; |
| 374 | 389 |
case ATTACH: if( mMax[mIndex]>mNumEffects ) // it is possible that we have first |
| 375 | 390 |
{ // added effects and then lowered mMax
|
| 376 |
mCurrentDuration[mNumEffects] = 0; |
|
| 377 |
mEffects[mNumEffects] = job.effect; |
|
| 378 |
mName[mNumEffects] = job.effect.getName().ordinal(); |
|
| 391 |
int position = job.num; |
|
| 392 |
|
|
| 393 |
if( position==-1 ) |
|
| 394 |
{
|
|
| 395 |
mCurrentDuration[mNumEffects] = 0; |
|
| 396 |
mEffects[mNumEffects] = job.effect; |
|
| 397 |
mName[mNumEffects] = job.effect.getName().ordinal(); |
|
| 398 |
} |
|
| 399 |
else if( position>=0 && position<=mNumEffects ) |
|
| 400 |
{
|
|
| 401 |
//android.util.Log.e("queue", "adding new effect to pos "+position);
|
|
| 402 |
|
|
| 403 |
for(int j=mNumEffects; j>position; j--) |
|
| 404 |
{
|
|
| 405 |
mCurrentDuration[j] = mCurrentDuration[j-1]; |
|
| 406 |
mEffects[j] = mEffects[j-1]; |
|
| 407 |
mName[j] = mName[j-1]; |
|
| 408 |
} |
|
| 409 |
|
|
| 410 |
mCurrentDuration[position] = 0; |
|
| 411 |
mEffects[position] = job.effect; |
|
| 412 |
mName[position] = job.effect.getName().ordinal(); |
|
| 413 |
} |
|
| 414 |
|
|
| 379 | 415 |
mNumEffects++; |
| 380 | 416 |
changed = true; |
| 381 | 417 |
} |
| src/main/java/org/distorted/library/main/DistortedEffects.java | ||
|---|---|---|
| 194 | 194 |
|
| 195 | 195 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 196 | 196 |
/** |
| 197 |
* Add a new Effect to our queue. |
|
| 197 |
* Add a new Effect to the tail of our queue.
|
|
| 198 | 198 |
* |
| 199 | 199 |
* @param effect The Effect to add. |
| 200 | 200 |
* @return <code>true</code> if operation was successful, <code>false</code> otherwise. |
| ... | ... | |
| 204 | 204 |
int num = effect.getType().ordinal(); |
| 205 | 205 |
return mQueues[num].add(effect); |
| 206 | 206 |
} |
| 207 |
|
|
| 208 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 209 |
/** |
|
| 210 |
* Add a new Effect to our queue at a specified position. |
|
| 211 |
* |
|
| 212 |
* @param effect The Effect to add. |
|
| 213 |
* @param position the place in the effects queue where to add the new effect. |
|
| 214 |
* @return <code>true</code> if operation was successful, <code>false</code> otherwise. |
|
| 215 |
*/ |
|
| 216 |
public boolean apply(Effect effect, int position) |
|
| 217 |
{
|
|
| 218 |
int num = effect.getType().ordinal(); |
|
| 219 |
return mQueues[num].add(effect,position); |
|
| 220 |
} |
|
| 207 | 221 |
} |
Also available in: Unified diff
Progress with DistortedCube.