Project

General

Profile

« Previous | Next » 

Revision 917d15f5

Added by Leszek Koltunski about 2 years ago

BandagedPlay: configurable mode and scramble depth

View differences:

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

  
24 24
import android.app.Activity;
25 25
import android.content.SharedPreferences;
26
import android.os.Bundle;
26 27
import android.view.View;
27 28
import android.widget.LinearLayout;
28 29

  
......
42 43
  public static final int ANIMATION_ON  = 0;
43 44
  public static final int ANIMATION_OFF = 1;
44 45

  
45
  private static final int NUM_SCRAMBLES = 30;
46

  
47 46
  private TransparentImageButton mBackButton, mScrambleButton, mSolveButton, mSettingsButton;
48 47
  private final LockController mLockController;
49 48
  private final MovesController mMovesController;
......
60 59
    {
61 60
    mLockController = new LockController();
62 61
    mMovesController= new MovesController();
63

  
64
    mAnimationMode = ANIMATION_OFF;
65
    mScrambleDepth = NUM_SCRAMBLES;
66 62
    }
67 63

  
68 64
///////////////////////////////////////////////////////////////////////////////////////////////////
......
98 94
      @Override
99 95
      public void onClick(View v)
100 96
        {
97
        Bundle bundle = new Bundle();
98
        bundle.putInt("scraPos", mScrambleDepth );
99
        bundle.putInt("animPos", mAnimationMode );
100

  
101 101
        RubikDialogBandagedSettings setDiag = new RubikDialogBandagedSettings();
102
        setDiag.setArguments(bundle);
102 103
        setDiag.show(act.getSupportFragmentManager(), null);
103 104
        }
104 105
      });
......
142 143
        TwistyObject object = control.getObject();
143 144
        ObjectScrambler.setSignature(object.getSignature());
144 145

  
146
        int depth = RubikDialogBandagedSettings.DEPTHS[mScrambleDepth];
147

  
145 148
        if( mAnimationMode==ANIMATION_OFF )
146 149
          {
147
          if( mMoves==null || mMoves.length<mScrambleDepth ) mMoves = new int[mScrambleDepth][3];
150
          if( mMoves==null || mMoves.length<depth ) mMoves = new int[depth][3];
148 151
          if( mRnd==null ) mRnd = new Random();
149 152

  
150
          for(int move=0; move<mScrambleDepth; move++)
153
          for(int move=0; move<depth; move++)
151 154
            {
152
            object.randomizeNewScramble(mMoves, mRnd, move, mScrambleDepth);
155
            object.randomizeNewScramble(mMoves, mRnd, move, depth);
153 156
            }
154
          for(int move=0; move<mScrambleDepth; move++)
157
          for(int move=0; move<depth; move++)
155 158
            {
156 159
            int row = mMoves[move][1];
157 160
            mMoves[move][1] = (1<<row);
......
162 165

  
163 166
        if( mAnimationMode==ANIMATION_ON )
164 167
          {
165
          control.scrambleObject(mScrambleDepth);
168
          control.scrambleObject(depth);
166 169
          }
167 170
        }
168 171
      });
......
255 258
    mMovesController.savePreferences(mKey,editor);
256 259
    ObjectControl control = act.getControl();
257 260
    control.savePreferences(editor);
261

  
262
    editor.putInt("playScreen_scramble" , mScrambleDepth);
263
    editor.putInt("playScreen_animation", mAnimationMode);
258 264
    }
259 265

  
260 266
///////////////////////////////////////////////////////////////////////////////////////////////////
......
264 270
    mMovesController.restorePreferences(act,mKey,preferences);
265 271
    ObjectControl control = act.getControl();
266 272
    control.restorePreferences(preferences);
273

  
274
    mScrambleDepth = preferences.getInt("playScreen_scramble",1);
275
    mAnimationMode = preferences.getInt("playScreen_animation",ANIMATION_OFF);
267 276
    }
268 277

  
269 278
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff