Revision 0594c61f
Added by Leszek Koltunski over 3 years ago
src/main/java/org/distorted/main/RubikPreRender.java | ||
---|---|---|
59 | 59 |
private boolean mFinishRotation, mRemoveRotation, mRemovePatternRotation, mAddRotation, |
60 | 60 |
mSetQuat, mChangeObject, mSetupObject, mSolveObject, mScrambleObject, |
61 | 61 |
mInitializeObject, mSetTextureMap, mResetAllTextureMaps; |
62 |
private boolean mCanRotate, mCanPlay;
|
|
62 |
private boolean mUIBlocked, mTouchBlocked;
|
|
63 | 63 |
private boolean mIsSolved; |
64 | 64 |
private ObjectList mNextObject; |
65 | 65 |
private int mNextSize; |
... | ... | |
531 | 531 |
|
532 | 532 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
533 | 533 |
|
534 |
boolean canRotate()
|
|
534 |
boolean isTouchBlocked()
|
|
535 | 535 |
{ |
536 |
return mCanRotate;
|
|
536 |
return mTouchBlocked;
|
|
537 | 537 |
} |
538 | 538 |
|
539 | 539 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
540 | 540 |
|
541 |
public boolean canPlay()
|
|
541 |
public boolean isUINotBlocked()
|
|
542 | 542 |
{ |
543 |
return mCanPlay;
|
|
543 |
return !mUIBlocked;
|
|
544 | 544 |
} |
545 | 545 |
|
546 | 546 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
547 | 547 |
|
548 | 548 |
public void blockEverything() |
549 | 549 |
{ |
550 |
mCanRotate = false; |
|
551 |
mCanPlay = false; |
|
550 |
mUIBlocked = true; |
|
551 |
mTouchBlocked= true; |
|
552 |
} |
|
553 |
|
|
554 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
555 |
|
|
556 |
public void blockTouch() |
|
557 |
{ |
|
558 |
mTouchBlocked= true; |
|
552 | 559 |
} |
553 | 560 |
|
554 | 561 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
555 | 562 |
|
556 | 563 |
public void unblockEverything() |
557 | 564 |
{ |
558 |
mCanRotate = true; |
|
559 |
mCanPlay = true; |
|
565 |
mUIBlocked = false; |
|
566 |
mTouchBlocked= false; |
|
567 |
} |
|
568 |
|
|
569 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
570 |
|
|
571 |
public void unblockTouch() |
|
572 |
{ |
|
573 |
mTouchBlocked= false; |
|
560 | 574 |
} |
561 | 575 |
|
562 | 576 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
616 | 630 |
|
617 | 631 |
public void scrambleObject(int num) |
618 | 632 |
{ |
619 |
if( mCanPlay )
|
|
633 |
if( !mUIBlocked )
|
|
620 | 634 |
{ |
621 | 635 |
mScrambleObject = true; |
622 | 636 |
mScrambleObjectNum = num; |
... | ... | |
629 | 643 |
|
630 | 644 |
public void solveObject() |
631 | 645 |
{ |
632 |
if( mCanPlay )
|
|
646 |
if( !mUIBlocked )
|
|
633 | 647 |
{ |
634 | 648 |
mSolveObject = true; |
635 | 649 |
} |
src/main/java/org/distorted/main/RubikSurfaceView.java | ||
---|---|---|
321 | 321 |
|
322 | 322 |
if( mode==MODE_ROTATE ) |
323 | 323 |
{ |
324 |
mBeginningRotation= mPreRender.canRotate();
|
|
324 |
mBeginningRotation= !mPreRender.isTouchBlocked();
|
|
325 | 325 |
} |
326 | 326 |
else if( mode==MODE_REPLACE ) |
327 | 327 |
{ |
src/main/java/org/distorted/patterns/RubikPattern.java | ||
---|---|---|
30 | 30 |
|
31 | 31 |
public class RubikPattern |
32 | 32 |
{ |
33 |
private static final int DURATION_MILLIS = 750;
|
|
33 |
private static final int MILLIS_PER_DEGREE = 6;
|
|
34 | 34 |
|
35 |
private int[] numCategories = new int[NUM_OBJECTS]; |
|
36 |
private int[] currentCategory = new int[NUM_OBJECTS]; |
|
37 |
private int[] currentVisiblePos= new int[NUM_OBJECTS]; |
|
38 |
private int[] currentExpanded = new int[NUM_OBJECTS]; |
|
35 |
private final int[] numCategories = new int[NUM_OBJECTS];
|
|
36 |
private final int[] currentCategory = new int[NUM_OBJECTS];
|
|
37 |
private final int[] currentVisiblePos= new int[NUM_OBJECTS];
|
|
38 |
private final int[] currentExpanded = new int[NUM_OBJECTS];
|
|
39 | 39 |
|
40 |
private List<List<Category>> mCategories; |
|
40 |
private final List<List<Category>> mCategories;
|
|
41 | 41 |
private static RubikPattern mThis; |
42 | 42 |
|
43 | 43 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
44 | 44 |
|
45 | 45 |
private static class Category |
46 | 46 |
{ |
47 |
private String[] mLines; |
|
47 |
private final String[] mLines;
|
|
48 | 48 |
private int numPatterns; |
49 | 49 |
private ArrayList<Pattern> mPatterns; |
50 | 50 |
private boolean mInitialized; |
... | ... | |
270 | 270 |
int bareAngle = moves[curMove-1][2]; |
271 | 271 |
int basicAngle= pre.getObject().getBasicAngle()[axis]; |
272 | 272 |
int angle = bareAngle*(360/basicAngle); |
273 |
int numRot = Math.abs(bareAngle);
|
|
273 |
int duration = Math.abs(angle)*MILLIS_PER_DEGREE;
|
|
274 | 274 |
|
275 | 275 |
if( angle!=0 ) |
276 | 276 |
{ |
277 | 277 |
mCanRotate = false; |
278 |
pre.addRotation(this, axis, rowBitmap, angle, numRot*DURATION_MILLIS);
|
|
278 |
pre.addRotation(this, axis, rowBitmap, angle, duration);
|
|
279 | 279 |
} |
280 | 280 |
else |
281 | 281 |
{ |
... | ... | |
311 | 311 |
int bareAngle = moves[curMove][2]; |
312 | 312 |
int basicAngle= pre.getObject().getBasicAngle()[axis]; |
313 | 313 |
int angle = bareAngle*(360/basicAngle); |
314 |
int numRot = Math.abs(bareAngle);
|
|
314 |
int duration = Math.abs(angle)*MILLIS_PER_DEGREE;
|
|
315 | 315 |
|
316 | 316 |
if( angle!=0 ) |
317 | 317 |
{ |
318 | 318 |
mCanRotate = false; |
319 |
pre.addRotation(this, axis, rowBitmap, -angle, numRot*DURATION_MILLIS);
|
|
319 |
pre.addRotation(this, axis, rowBitmap, -angle, duration);
|
|
320 | 320 |
} |
321 | 321 |
else |
322 | 322 |
{ |
src/main/java/org/distorted/screens/RubikScreenBase.java | ||
---|---|---|
26 | 26 |
import org.distorted.main.R; |
27 | 27 |
import org.distorted.main.RubikActivity; |
28 | 28 |
import org.distorted.main.RubikPreRender; |
29 |
import org.distorted.objects.TwistyObject; |
|
30 | 29 |
|
31 | 30 |
import java.util.ArrayList; |
32 | 31 |
|
... | ... | |
34 | 33 |
|
35 | 34 |
abstract class RubikScreenBase extends RubikScreenAbstract implements RubikPreRender.ActionFinishedListener |
36 | 35 |
{ |
37 |
private static final int REVOLUTION_MILLIS = 2000;
|
|
36 |
private static final int MILLIS_PER_DEGREE = 6;
|
|
38 | 37 |
|
39 | 38 |
private ImageButton mPrevButton, mLockButton; |
40 | 39 |
private boolean mCanPrevMove; |
40 |
private RubikPreRender mPre; |
|
41 | 41 |
|
42 | 42 |
private static class Move |
43 | 43 |
{ |
... | ... | |
67 | 67 |
int axis = move.mAxis; |
68 | 68 |
int row = (1<<move.mRow); |
69 | 69 |
int angle = move.mAngle; |
70 |
int duration= (int)(Math.abs(angle/360.0f)*REVOLUTION_MILLIS);
|
|
70 |
int duration= Math.abs(angle)*MILLIS_PER_DEGREE;
|
|
71 | 71 |
|
72 | 72 |
if( angle!=0 ) |
73 | 73 |
{ |
74 | 74 |
mCanPrevMove = false; |
75 |
mPre = pre; |
|
76 |
pre.blockTouch(); |
|
75 | 77 |
pre.addRotation(this, axis, row, -angle, duration); |
76 | 78 |
} |
77 | 79 |
else |
... | ... | |
198 | 200 |
public void onActionFinished(final long effectID) |
199 | 201 |
{ |
200 | 202 |
mCanPrevMove = true; |
203 |
mPre.unblockTouch(); |
|
201 | 204 |
} |
202 | 205 |
} |
src/main/java/org/distorted/screens/RubikScreenPlay.java | ||
---|---|---|
33 | 33 |
import android.widget.LinearLayout; |
34 | 34 |
import android.widget.PopupWindow; |
35 | 35 |
|
36 |
import org.distorted.control.RubikControl; |
|
37 | 36 |
import org.distorted.dialogs.RubikDialogAbout; |
38 | 37 |
import org.distorted.dialogs.RubikDialogPattern; |
39 | 38 |
import org.distorted.dialogs.RubikDialogScores; |
... | ... | |
126 | 125 |
@Override |
127 | 126 |
public void onClick(View view) |
128 | 127 |
{ |
129 |
if( act.getPreRender().canPlay() )
|
|
128 |
if(act.getPreRender().isUINotBlocked())
|
|
130 | 129 |
{ |
131 | 130 |
if( mObjectPopup==null ) |
132 | 131 |
{ |
... | ... | |
163 | 162 |
@Override |
164 | 163 |
public void onClick(View view) |
165 | 164 |
{ |
166 |
if( act.getPreRender().canPlay() )
|
|
165 |
if(act.getPreRender().isUINotBlocked())
|
|
167 | 166 |
{ |
168 | 167 |
if( mPlayPopup==null ) |
169 | 168 |
{ |
... | ... | |
204 | 203 |
@Override |
205 | 204 |
public void onClick(View view) |
206 | 205 |
{ |
207 |
if( act.getPreRender().canPlay() )
|
|
206 |
if(act.getPreRender().isUINotBlocked())
|
|
208 | 207 |
{ |
209 | 208 |
if( mMenuPopup==null ) |
210 | 209 |
{ |
... | ... | |
286 | 285 |
@Override |
287 | 286 |
public void onClick(View v) |
288 | 287 |
{ |
289 |
if( act.getPreRender().canPlay() && ScreenList.getCurrentScreen()== ScreenList.PLAY )
|
|
288 |
if( act.getPreRender().isUINotBlocked() && ScreenList.getCurrentScreen()== ScreenList.PLAY )
|
|
290 | 289 |
{ |
291 | 290 |
mObject = obj; |
292 | 291 |
mSize = sizes[index]; |
... | ... | |
566 | 565 |
{ |
567 | 566 |
RubikPreRender pre = act.getPreRender(); |
568 | 567 |
|
569 |
if( pre.canPlay() )
|
|
568 |
if(pre.isUINotBlocked())
|
|
570 | 569 |
{ |
571 | 570 |
mPlayPopup.dismiss(); |
572 | 571 |
mLevelValue = scrambles; |
src/main/java/org/distorted/screens/RubikScreenSolution.java | ||
---|---|---|
38 | 38 |
|
39 | 39 |
public class RubikScreenSolution extends RubikScreenAbstract implements RubikPreRender.ActionFinishedListener |
40 | 40 |
{ |
41 |
private static final int DURATION_MILLIS = 750;
|
|
41 |
private static final int MILLIS_PER_DEGREE = 6;
|
|
42 | 42 |
|
43 | 43 |
private ImageButton mPrevButton, mNextButton, mBackButton; |
44 | 44 |
private TextView mMovesText; |
... | ... | |
202 | 202 |
int bareAngle = mMoves[mCurrMove-1][2]; |
203 | 203 |
int basicAngle= pre.getObject().getBasicAngle()[axis]; |
204 | 204 |
int angle = bareAngle*(360/basicAngle); |
205 |
int numRot = Math.abs(bareAngle);
|
|
205 |
int duration = Math.abs(angle)*MILLIS_PER_DEGREE;
|
|
206 | 206 |
|
207 | 207 |
if( angle!=0 ) |
208 | 208 |
{ |
209 | 209 |
mCanRotate = false; |
210 |
pre.addRotation(this, axis, rowBitmap, angle, numRot*DURATION_MILLIS);
|
|
210 |
pre.addRotation(this, axis, rowBitmap, angle, duration);
|
|
211 | 211 |
} |
212 | 212 |
else |
213 | 213 |
{ |
... | ... | |
241 | 241 |
int bareAngle = mMoves[mCurrMove][2]; |
242 | 242 |
int basicAngle= pre.getObject().getBasicAngle()[axis]; |
243 | 243 |
int angle = bareAngle*(360/basicAngle); |
244 |
int numRot = Math.abs(bareAngle);
|
|
244 |
int duration = Math.abs(angle)*MILLIS_PER_DEGREE;
|
|
245 | 245 |
|
246 | 246 |
if( angle!=0 ) |
247 | 247 |
{ |
248 | 248 |
mCanRotate = false; |
249 |
pre.addRotation(this, axis, rowBitmap, -angle, numRot*DURATION_MILLIS);
|
|
249 |
pre.addRotation(this, axis, rowBitmap, -angle, duration);
|
|
250 | 250 |
} |
251 | 251 |
else |
252 | 252 |
{ |
src/main/java/org/distorted/tutorials/TutorialState.java | ||
---|---|---|
27 | 27 |
import org.distorted.main.RubikActivity; |
28 | 28 |
import org.distorted.main.RubikPreRender; |
29 | 29 |
import org.distorted.objects.ObjectList; |
30 |
import org.distorted.objects.TwistyObject; |
|
31 | 30 |
import org.distorted.screens.RubikScreenPlay; |
32 | 31 |
import org.distorted.screens.ScreenList; |
33 | 32 |
import org.distorted.screens.TransparentImageButton; |
... | ... | |
38 | 37 |
|
39 | 38 |
public class TutorialState implements RubikPreRender.ActionFinishedListener |
40 | 39 |
{ |
41 |
private static final int DURATION_MILLIS = 750;
|
|
40 |
private static final int MILLIS_PER_DEGREE = 6;
|
|
42 | 41 |
|
43 | 42 |
private ImageButton mPrevButton, mLockButton, mSolveButton, mScrambleButton, mBackButton; |
44 | 43 |
|
... | ... | |
68 | 67 |
|
69 | 68 |
if( numMoves>0 ) |
70 | 69 |
{ |
71 |
Move move = mMoves.remove(numMoves-1); |
|
72 |
TwistyObject object = pre.getObject(); |
|
73 |
|
|
74 |
int axis = move.mAxis; |
|
75 |
int row = (1<<move.mRow); |
|
76 |
int angle = move.mAngle; |
|
77 |
int basic = object.getBasicAngle()[axis]; |
|
78 |
int numRot= Math.abs(angle*basic/360); |
|
70 |
Move move = mMoves.remove(numMoves-1); |
|
71 |
int axis = move.mAxis; |
|
72 |
int row = (1<<move.mRow); |
|
73 |
int angle = move.mAngle; |
|
74 |
int duration= Math.abs(angle)*MILLIS_PER_DEGREE; |
|
79 | 75 |
|
80 | 76 |
if( angle!=0 ) |
81 | 77 |
{ |
82 | 78 |
mCanPrevMove = false; |
83 |
pre.addRotation(this, axis, row, -angle, numRot*DURATION_MILLIS);
|
|
79 |
pre.addRotation(this, axis, row, -angle, duration);
|
|
84 | 80 |
} |
85 | 81 |
else |
86 | 82 |
{ |
Also available in: Unified diff
Backing moves: constant angle speed (part 2).