Project

General

Profile

« Previous | Next » 

Revision 568d4698

Added by Leszek Koltunski over 2 years ago

New API to objectlib to recreate an already displayed object (because the settings, like 'IconMode' might have changed) and using the new API in puzzle-creator.

View differences:

src/main/java/org/distorted/objectlib/main/ObjectControl.java
80 80
    private static final Static4D mQuat= new Static4D(-0.25189602f,0.3546389f,0.009657208f,0.90038127f);
81 81
    private static final Static4D mTemp= new Static4D(0,0,0,1);
82 82

  
83
    private static boolean mForcedIconMode;
83
    private static boolean mForcedIconMode = false, mForcedCreateMesh = false;
84 84

  
85 85
///////////////////////////////////////////////////////////////////////////////////////////////////
86 86
// cast the 3D axis we are currently rotating along (which is already casted to the surface of the
......
508 508

  
509 509
///////////////////////////////////////////////////////////////////////////////////////////////////
510 510

  
511
    public static void setIconMode()
511
    public static void setIconMode(boolean mode)
512 512
      {
513
      mForcedIconMode = true;
513
      mForcedIconMode = mode;
514
      }
515

  
516
///////////////////////////////////////////////////////////////////////////////////////////////////
517

  
518
    public static void setForcedMesh(boolean mode)
519
      {
520
      mForcedCreateMesh = mode;
514 521
      }
515 522

  
516 523
///////////////////////////////////////////////////////////////////////////////////////////////////
......
520 527
      return mForcedIconMode;
521 528
      }
522 529

  
530
///////////////////////////////////////////////////////////////////////////////////////////////////
531

  
532
    public static boolean isInCreateMesh()
533
      {
534
      return mForcedCreateMesh;
535
      }
536

  
523 537
///////////////////////////////////////////////////////////////////////////////////////////////////
524 538
// PUBLIC API
525 539
///////////////////////////////////////////////////////////////////////////////////////////////////
......
527 541
    public ObjectControl(Activity act, ObjectLibInterface actioner)
528 542
      {
529 543
      mIsAutomatic = false;
530
      mForcedIconMode = false;
531 544

  
532 545
      mLastCubitColor = -1;
533 546
      mCurrRotSpeed   = 0.0f;
......
696 709
      mPreRender.changeObject(object);
697 710
      }
698 711

  
712
///////////////////////////////////////////////////////////////////////////////////////////////////
713

  
714
    public void recreateObject()
715
      {
716
      mPreRender.recreateObject();
717
      }
718

  
699 719
///////////////////////////////////////////////////////////////////////////////////////////////////
700 720

  
701 721
    public void scrambleObject(int num)
src/main/java/org/distorted/objectlib/main/ObjectPreRender.java
50 50
  private float mMoveX, mMoveY;
51 51

  
52 52
  private boolean mFinishRotation, mRemoveRotation, mRemovePatternRotation, mAddRotation,
53
                  mSetQuat, mChangeObject, mSolveObject, mScrambleObject,
53
                  mSetQuat, mChangeObject, mSolveObject, mScrambleObject, mRecreateObject,
54 54
                  mInitializeObject, mSetTextureMap, mResetAllTextureMaps, mSolve;
55 55
  private boolean mUIBlocked, mTouchBlocked, mIsSolved;
56 56
  private long mRotationFinishedID;
......
79 79
    mAddRotation          = false;
80 80
    mSetQuat              = false;
81 81
    mChangeObject         = false;
82
    mRecreateObject       = false;
82 83
    mSolveObject          = false;
83 84
    mSolve                = false;
84 85
    mScrambleObject       = false;
......
223 224
      }
224 225
    }
225 226

  
227
///////////////////////////////////////////////////////////////////////////////////////////////////
228

  
229
  private void recreateObjectNow()
230
    {
231
    mRecreateObject = false;
232

  
233
    if ( mNewObject!=null )
234
      {
235
      blockEverything(BlockController.PLACE_1);
236
      createObjectNow(mNewObject.getObjectType());
237
      doEffectNow( BaseEffect.Type.SIZECHANGE );
238
      }
239
    }
240

  
226 241
///////////////////////////////////////////////////////////////////////////////////////////////////
227 242

  
228 243
  private void scrambleObjectNow()
......
393 408
    mNextObject = object;
394 409
    }
395 410

  
411
///////////////////////////////////////////////////////////////////////////////////////////////////
412

  
413
  public void recreateObject()
414
    {
415
    mRecreateObject = true;
416
    }
417

  
396 418
///////////////////////////////////////////////////////////////////////////////////////////////////
397 419

  
398 420
  public boolean isTouchBlocked()
......
461 483
    if( mRemoveRotation        ) removeRotationNow();
462 484
    if( mRemovePatternRotation ) removePatternRotationNow();
463 485
    if( mChangeObject          ) changeObjectNow();
486
    if( mRecreateObject        ) recreateObjectNow();
464 487
    if( mSolveObject           ) solveObjectNow();
465 488
    if( mScrambleObject        ) scrambleObjectNow();
466 489
    if( mAddRotation           ) addRotationNow();
src/main/java/org/distorted/objectlib/main/TwistyObject.java
277 277
    {
278 278
    int resourceID= getResource(mNumLayers);
279 279

  
280
    if( resourceID!=0 && !ObjectControl.isInIconMode() )
280
    if( resourceID!=0 && !ObjectControl.isInCreateMesh() )
281 281
      {
282 282
      InputStream is = res.openRawResource(resourceID);
283 283
      DataInputStream dos = new DataInputStream(is);

Also available in: Unified diff