Project

General

Profile

« Previous | Next » 

Revision b72b71a1

Added by Leszek Koltunski about 2 years ago

preparation for dual animation on/off modes in BandagedPlay

View differences:

src/main/java/org/distorted/bandaged/BandagedPlayScreen.java
19 19

  
20 20
package org.distorted.bandaged;
21 21

  
22
import java.util.Random;
23

  
22 24
import android.app.Activity;
23 25
import android.content.SharedPreferences;
24 26
import android.view.View;
......
36 38

  
37 39
public class BandagedPlayScreen
38 40
{
39
  private static final int NUM_SCRAMBLES = 24;
41
  public static final int ANIMATION_ON  = 0;
42
  public static final int ANIMATION_OFF = 1;
43

  
44
  private static final int NUM_SCRAMBLES = 2;
40 45

  
41 46
  private TransparentImageButton mBackButton, mScrambleButton, mSolveButton;
42 47
  private final LockController mLockController;
43
  private MovesController mMovesController;
48
  private final MovesController mMovesController;
44 49
  private String mKey;
50
  private int[][] mMoves;
51
  private Random mRnd;
52

  
53
  private int mAnimationMode;
54
  private int mScrambleDepth;
45 55

  
46 56
///////////////////////////////////////////////////////////////////////////////////////////////////
47 57

  
......
49 59
    {
50 60
    mLockController = new LockController();
51 61
    mMovesController= new MovesController();
62

  
63
    mAnimationMode = ANIMATION_OFF;
64
    mScrambleDepth = NUM_SCRAMBLES;
52 65
    }
53 66

  
54 67
///////////////////////////////////////////////////////////////////////////////////////////////////
......
84 97
      @Override
85 98
      public void onClick(View v)
86 99
        {
87
        act.getControl().solveObject();
100
        ObjectControl control = act.getControl();
101
        if( mAnimationMode==ANIMATION_OFF ) control.solveOnly();
102
        if( mAnimationMode==ANIMATION_ON  ) control.solveObject();
88 103
        mMovesController.clearMoves(act);
89 104
        }
90 105
      });
......
106 121
        ObjectControl control = act.getControl();
107 122
        TwistyObject object = control.getObject();
108 123
        ObjectScrambler.setSignature(object.getSignature());
109
        control.scrambleObject(NUM_SCRAMBLES);
124

  
125
        if( mAnimationMode==ANIMATION_OFF )
126
          {
127
          if( mMoves==null || mMoves.length<mScrambleDepth ) mMoves = new int[mScrambleDepth][3];
128
          if( mRnd==null ) mRnd = new Random();
129

  
130
          for(int move=0; move<mScrambleDepth; move++)
131
            {
132
            object.randomizeNewScramble(mMoves, mRnd, move, mScrambleDepth);
133
            }
134
          for(int move=0; move<mScrambleDepth; move++)
135
            {
136
            int row = mMoves[move][1];
137
            mMoves[move][1] = (1<<row);
138
            }
139

  
140
          control.initializeObject(mMoves);
141
          }
142

  
143
        if( mAnimationMode==ANIMATION_ON )
144
          {
145
          control.scrambleObject(mScrambleDepth);
146
          }
110 147
        }
111 148
      });
112 149
    }
......
206 243
    ObjectControl control = act.getControl();
207 244
    control.restorePreferences(preferences);
208 245
    }
246

  
247
///////////////////////////////////////////////////////////////////////////////////////////////////
248

  
249
  public void setAnimationMode(int mode)
250
    {
251
    mAnimationMode = mode;
252
    }
253

  
254
///////////////////////////////////////////////////////////////////////////////////////////////////
255

  
256
  public void setScrambleDepth(int depth)
257
    {
258
    mScrambleDepth = depth;
259
    }
209 260
}

Also available in: Unified diff