1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2020 Leszek Koltunski //
|
3
|
// //
|
4
|
// This file is part of Magic Cube. //
|
5
|
// //
|
6
|
// Magic Cube is free software: you can redistribute it and/or modify //
|
7
|
// it under the terms of the GNU General Public License as published by //
|
8
|
// the Free Software Foundation, either version 2 of the License, or //
|
9
|
// (at your option) any later version. //
|
10
|
// //
|
11
|
// Magic Cube is distributed in the hope that it will be useful, //
|
12
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
13
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
14
|
// GNU General Public License for more details. //
|
15
|
// //
|
16
|
// You should have received a copy of the GNU General Public License //
|
17
|
// along with Magic Cube. If not, see <http://www.gnu.org/licenses/>. //
|
18
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
19
|
|
20
|
package org.distorted.main;
|
21
|
|
22
|
import android.content.Context;
|
23
|
import android.content.SharedPreferences;
|
24
|
import android.content.res.Resources;
|
25
|
import android.os.Bundle;
|
26
|
|
27
|
import androidx.annotation.NonNull;
|
28
|
|
29
|
import com.google.android.play.core.review.ReviewInfo;
|
30
|
import com.google.android.play.core.review.ReviewManager;
|
31
|
import com.google.android.play.core.review.ReviewManagerFactory;
|
32
|
import com.google.android.play.core.tasks.OnCompleteListener;
|
33
|
import com.google.android.play.core.tasks.OnFailureListener;
|
34
|
import com.google.android.play.core.tasks.Task;
|
35
|
import com.google.firebase.analytics.FirebaseAnalytics;
|
36
|
|
37
|
import org.distorted.dialogs.RubikDialogNewRecord;
|
38
|
import org.distorted.dialogs.RubikDialogSolved;
|
39
|
import org.distorted.effects.BaseEffect;
|
40
|
import org.distorted.library.message.EffectListener;
|
41
|
import org.distorted.objects.TwistyObject;
|
42
|
import org.distorted.objects.ObjectList;
|
43
|
import org.distorted.scores.RubikScores;
|
44
|
import org.distorted.states.RubikStatePlay;
|
45
|
import org.distorted.states.StateList;
|
46
|
import org.distorted.states.RubikStateSolving;
|
47
|
|
48
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
49
|
|
50
|
public class RubikPreRender implements EffectListener
|
51
|
{
|
52
|
public interface ActionFinishedListener
|
53
|
{
|
54
|
void onActionFinished(long effectID);
|
55
|
}
|
56
|
|
57
|
private RubikSurfaceView mView;
|
58
|
private boolean mFinishRotation, mRemoveRotation, mRemovePatternRotation, mAddRotation,
|
59
|
mSetQuat, mChangeObject, mSetupObject, mSolveObject, mScrambleObject,
|
60
|
mInitializeObject, mSetTextureMap, mResetAllTextureMaps;
|
61
|
private boolean mCanRotate, mCanPlay;
|
62
|
private boolean mIsSolved;
|
63
|
private ObjectList mNextObject;
|
64
|
private int mNextSize;
|
65
|
private long mRotationFinishedID;
|
66
|
private long[] mEffectID;
|
67
|
private boolean mIsNewRecord;
|
68
|
private long mNewRecord;
|
69
|
private int mScreenWidth;
|
70
|
private SharedPreferences mPreferences;
|
71
|
private int[][] mNextMoves;
|
72
|
private TwistyObject mOldObject, mNewObject;
|
73
|
private int mScrambleObjectNum;
|
74
|
private int mAddRotationAxis, mAddRotationRowBitmap, mAddRotationAngle;
|
75
|
private long mAddRotationDuration;
|
76
|
private ActionFinishedListener mAddActionListener;
|
77
|
private long mAddRotationID, mRemoveRotationID;
|
78
|
private int mCubit, mFace, mNewColor;
|
79
|
private int mNearestAngle;
|
80
|
|
81
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
82
|
|
83
|
RubikPreRender(RubikSurfaceView view)
|
84
|
{
|
85
|
mView = view;
|
86
|
|
87
|
mFinishRotation = false;
|
88
|
mRemoveRotation = false;
|
89
|
mRemovePatternRotation= false;
|
90
|
mAddRotation = false;
|
91
|
mSetQuat = false;
|
92
|
mChangeObject = false;
|
93
|
mSetupObject = false;
|
94
|
mSolveObject = false;
|
95
|
mScrambleObject = false;
|
96
|
|
97
|
mCanRotate = true;
|
98
|
mCanPlay = true;
|
99
|
|
100
|
mOldObject = null;
|
101
|
mNewObject = null;
|
102
|
|
103
|
mScreenWidth = 0;
|
104
|
mScrambleObjectNum = 0;
|
105
|
|
106
|
mEffectID = new long[BaseEffect.Type.LENGTH];
|
107
|
}
|
108
|
|
109
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
110
|
|
111
|
private void createObjectNow(ObjectList object, int size, int[][] moves)
|
112
|
{
|
113
|
boolean firstTime = (mNewObject==null);
|
114
|
|
115
|
if( mOldObject!=null ) mOldObject.releaseResources();
|
116
|
mOldObject = mNewObject;
|
117
|
|
118
|
Context con = mView.getContext();
|
119
|
Resources res = con.getResources();
|
120
|
|
121
|
mNewObject = object.create(size, mView.getQuat(), moves, res, mScreenWidth);
|
122
|
|
123
|
if( mNewObject!=null )
|
124
|
{
|
125
|
mNewObject.createTexture();
|
126
|
mView.setMovement(object.getObjectMovementClass());
|
127
|
|
128
|
if( firstTime ) mNewObject.restorePreferences(mPreferences);
|
129
|
|
130
|
if( mScreenWidth!=0 )
|
131
|
{
|
132
|
mNewObject.recomputeScaleFactor(mScreenWidth);
|
133
|
}
|
134
|
|
135
|
mIsSolved = mNewObject.isSolved();
|
136
|
}
|
137
|
}
|
138
|
|
139
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
140
|
// do all 'adjustable' effects (SizeChange, Solve, Scramble)
|
141
|
|
142
|
private void doEffectNow(BaseEffect.Type type)
|
143
|
{
|
144
|
int index = type.ordinal();
|
145
|
|
146
|
try
|
147
|
{
|
148
|
mEffectID[index] = type.startEffect(mView.getRenderer().getScreen(),this);
|
149
|
}
|
150
|
catch( Exception ex )
|
151
|
{
|
152
|
android.util.Log.e("renderer", "exception starting effect: "+ex.getMessage());
|
153
|
|
154
|
mCanPlay = true;
|
155
|
mCanRotate = true;
|
156
|
}
|
157
|
}
|
158
|
|
159
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
160
|
|
161
|
private void removeRotationNow()
|
162
|
{
|
163
|
mRemoveRotation=false;
|
164
|
mNewObject.removeRotationNow();
|
165
|
|
166
|
boolean solved = mNewObject.isSolved();
|
167
|
|
168
|
if( solved && !mIsSolved )
|
169
|
{
|
170
|
if( StateList.getCurrentState()== StateList.SOLV )
|
171
|
{
|
172
|
RubikStateSolving solving = (RubikStateSolving) StateList.SOLV.getStateClass();
|
173
|
mNewRecord = solving.getRecord();
|
174
|
|
175
|
if( mNewRecord< 0 )
|
176
|
{
|
177
|
mNewRecord = -mNewRecord;
|
178
|
mIsNewRecord = false;
|
179
|
}
|
180
|
else
|
181
|
{
|
182
|
mIsNewRecord = true;
|
183
|
}
|
184
|
}
|
185
|
|
186
|
mCanRotate = true;
|
187
|
mCanPlay = false;
|
188
|
doEffectNow( BaseEffect.Type.WIN );
|
189
|
}
|
190
|
else
|
191
|
{
|
192
|
mCanRotate = true;
|
193
|
mCanPlay = true;
|
194
|
}
|
195
|
|
196
|
mIsSolved = solved;
|
197
|
}
|
198
|
|
199
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
200
|
|
201
|
private void removeRotation()
|
202
|
{
|
203
|
mRemoveRotation = true;
|
204
|
}
|
205
|
|
206
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
207
|
|
208
|
private void removePatternRotation()
|
209
|
{
|
210
|
mRemovePatternRotation = true;
|
211
|
}
|
212
|
|
213
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
214
|
|
215
|
private void removePatternRotationNow()
|
216
|
{
|
217
|
mRemovePatternRotation=false;
|
218
|
mNewObject.removeRotationNow();
|
219
|
mAddActionListener.onActionFinished(mRemoveRotationID);
|
220
|
}
|
221
|
|
222
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
223
|
|
224
|
private void addRotationNow()
|
225
|
{
|
226
|
mAddRotation = false;
|
227
|
mAddRotationID = mNewObject.addNewRotation( mAddRotationAxis, mAddRotationRowBitmap,
|
228
|
mAddRotationAngle, mAddRotationDuration, this);
|
229
|
}
|
230
|
|
231
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
232
|
|
233
|
private void finishRotationNow()
|
234
|
{
|
235
|
mFinishRotation = false;
|
236
|
mCanRotate = false;
|
237
|
mCanPlay = false;
|
238
|
mRotationFinishedID = mNewObject.finishRotationNow(this, mNearestAngle);
|
239
|
|
240
|
if( mRotationFinishedID==0 ) // failed to add effect - should never happen
|
241
|
{
|
242
|
mCanRotate = true;
|
243
|
mCanPlay = true;
|
244
|
}
|
245
|
}
|
246
|
|
247
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
248
|
|
249
|
private void changeObjectNow()
|
250
|
{
|
251
|
mChangeObject = false;
|
252
|
|
253
|
if ( mNewObject==null || mNewObject.getObjectList()!=mNextObject || mNewObject.getSize()!=mNextSize)
|
254
|
{
|
255
|
mCanRotate= false;
|
256
|
mCanPlay = false;
|
257
|
createObjectNow(mNextObject, mNextSize, null);
|
258
|
doEffectNow( BaseEffect.Type.SIZECHANGE );
|
259
|
}
|
260
|
}
|
261
|
|
262
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
263
|
|
264
|
private void setupObjectNow()
|
265
|
{
|
266
|
mSetupObject = false;
|
267
|
|
268
|
if ( mNewObject==null || mNewObject.getObjectList()!=mNextObject || mNewObject.getSize()!=mNextSize)
|
269
|
{
|
270
|
mCanRotate= false;
|
271
|
mCanPlay = false;
|
272
|
createObjectNow(mNextObject, mNextSize, mNextMoves);
|
273
|
doEffectNow( BaseEffect.Type.SIZECHANGE );
|
274
|
}
|
275
|
else
|
276
|
{
|
277
|
mNewObject.initializeObject(mNextMoves);
|
278
|
}
|
279
|
}
|
280
|
|
281
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
282
|
|
283
|
private void scrambleObjectNow()
|
284
|
{
|
285
|
mScrambleObject = false;
|
286
|
mCanRotate = false;
|
287
|
mCanPlay = false;
|
288
|
mIsSolved = false;
|
289
|
RubikScores.getInstance().incrementNumPlays();
|
290
|
doEffectNow( BaseEffect.Type.SCRAMBLE );
|
291
|
}
|
292
|
|
293
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
294
|
|
295
|
private void solveObjectNow()
|
296
|
{
|
297
|
mSolveObject = false;
|
298
|
mCanRotate = false;
|
299
|
mCanPlay = false;
|
300
|
doEffectNow( BaseEffect.Type.SOLVE );
|
301
|
}
|
302
|
|
303
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
304
|
|
305
|
private void initializeObjectNow()
|
306
|
{
|
307
|
mInitializeObject = false;
|
308
|
mNewObject.initializeObject(mNextMoves);
|
309
|
}
|
310
|
|
311
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
312
|
|
313
|
private void setTextureMapNow()
|
314
|
{
|
315
|
mSetTextureMap = false;
|
316
|
|
317
|
if( mNewObject!=null ) mNewObject.setTextureMap(mCubit,mFace,mNewColor);
|
318
|
}
|
319
|
|
320
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
321
|
|
322
|
private void resetAllTextureMapsNow()
|
323
|
{
|
324
|
mResetAllTextureMaps = false;
|
325
|
|
326
|
if( mNewObject!=null ) mNewObject.resetAllTextureMaps();
|
327
|
}
|
328
|
|
329
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
330
|
|
331
|
private void setQuatNow()
|
332
|
{
|
333
|
mSetQuat = false;
|
334
|
mView.setQuat();
|
335
|
}
|
336
|
|
337
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
338
|
|
339
|
private void reportRecord()
|
340
|
{
|
341
|
RubikStatePlay play = (RubikStatePlay) StateList.PLAY.getStateClass();
|
342
|
RubikScores scores = RubikScores.getInstance();
|
343
|
|
344
|
int object = play.getObject();
|
345
|
int size = play.getSize();
|
346
|
int level = play.getLevel();
|
347
|
ObjectList list = ObjectList.getObject(object);
|
348
|
String name = scores.getName();
|
349
|
|
350
|
String record = list.name()+"_"+size+" level "+level+" time "+mNewRecord+" isNew: "+mIsNewRecord+" name: "+name;
|
351
|
|
352
|
final RubikActivity act = (RubikActivity)mView.getContext();
|
353
|
FirebaseAnalytics analytics = act.getAnalytics();
|
354
|
|
355
|
if( analytics!=null )
|
356
|
{
|
357
|
Bundle bundle = new Bundle();
|
358
|
bundle.putString(FirebaseAnalytics.Param.LEVEL, record);
|
359
|
analytics.logEvent(FirebaseAnalytics.Event.LEVEL_END, bundle);
|
360
|
}
|
361
|
}
|
362
|
|
363
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
364
|
|
365
|
private void requestReview()
|
366
|
{
|
367
|
final RubikScores scores = RubikScores.getInstance();
|
368
|
int numRuns = scores.getNumRuns();
|
369
|
int numPlay = scores.getNumPlays();
|
370
|
int numReview = scores.getNumReviews();
|
371
|
|
372
|
if( numRuns>=2 && numPlay>=5 ) scores.incrementNumReviews();
|
373
|
|
374
|
if( numReview==0 )
|
375
|
{
|
376
|
final long timeBegin = System.currentTimeMillis();
|
377
|
final RubikActivity act = (RubikActivity)mView.getContext();
|
378
|
final ReviewManager manager = ReviewManagerFactory.create(act);
|
379
|
Task<ReviewInfo> request = manager.requestReviewFlow();
|
380
|
|
381
|
request.addOnCompleteListener(new OnCompleteListener<ReviewInfo>()
|
382
|
{
|
383
|
@Override
|
384
|
public void onComplete (@NonNull Task<ReviewInfo> task)
|
385
|
{
|
386
|
if (task.isSuccessful())
|
387
|
{
|
388
|
final String name = scores.getName();
|
389
|
ReviewInfo reviewInfo = task.getResult();
|
390
|
Task<Void> flow = manager.launchReviewFlow(act, reviewInfo);
|
391
|
|
392
|
flow.addOnFailureListener(new OnFailureListener()
|
393
|
{
|
394
|
@Override
|
395
|
public void onFailure(Exception e)
|
396
|
{
|
397
|
analyticsReport(act,"Review Flow Failed", name, timeBegin);
|
398
|
}
|
399
|
});
|
400
|
|
401
|
flow.addOnCompleteListener(new OnCompleteListener<Void>()
|
402
|
{
|
403
|
@Override
|
404
|
public void onComplete(@NonNull Task<Void> task)
|
405
|
{
|
406
|
analyticsReport(act,"Review Flow Complete", name, timeBegin);
|
407
|
}
|
408
|
});
|
409
|
}
|
410
|
else
|
411
|
{
|
412
|
String name = scores.getName();
|
413
|
analyticsReport(act,"Request review flow not successful", name, timeBegin);
|
414
|
}
|
415
|
}
|
416
|
});
|
417
|
}
|
418
|
}
|
419
|
|
420
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
421
|
|
422
|
private void analyticsReport(RubikActivity act, String message, String name, long timeBegin)
|
423
|
{
|
424
|
long elapsed = System.currentTimeMillis() - timeBegin;
|
425
|
|
426
|
if( BuildConfig.DEBUG )
|
427
|
{
|
428
|
android.util.Log.d("pre", message);
|
429
|
android.util.Log.d("pre", name);
|
430
|
android.util.Log.d("pre", "startTime: "+timeBegin+" elapsed: "+elapsed);
|
431
|
}
|
432
|
else
|
433
|
{
|
434
|
FirebaseAnalytics analytics = act.getAnalytics();
|
435
|
|
436
|
if( analytics!=null )
|
437
|
{
|
438
|
Bundle bundle = new Bundle();
|
439
|
bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, message);
|
440
|
bundle.putString(FirebaseAnalytics.Param.CHARACTER, name);
|
441
|
bundle.putString(FirebaseAnalytics.Param.START_DATE, "startTime: "+timeBegin+" elapsed: "+elapsed);
|
442
|
analytics.logEvent(FirebaseAnalytics.Event.CAMPAIGN_DETAILS, bundle);
|
443
|
}
|
444
|
}
|
445
|
}
|
446
|
|
447
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
448
|
//
|
449
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
450
|
|
451
|
void setScreenSize(int width)
|
452
|
{
|
453
|
if( mNewObject!=null )
|
454
|
{
|
455
|
mNewObject.createTexture();
|
456
|
mNewObject.recomputeScaleFactor(width);
|
457
|
}
|
458
|
|
459
|
mScreenWidth = width;
|
460
|
}
|
461
|
|
462
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
463
|
|
464
|
void savePreferences(SharedPreferences.Editor editor)
|
465
|
{
|
466
|
if( mNewObject!=null )
|
467
|
{
|
468
|
mNewObject.savePreferences(editor);
|
469
|
}
|
470
|
}
|
471
|
|
472
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
473
|
|
474
|
void restorePreferences(SharedPreferences preferences)
|
475
|
{
|
476
|
mPreferences = preferences;
|
477
|
}
|
478
|
|
479
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
480
|
|
481
|
void finishRotation(int nearestAngle)
|
482
|
{
|
483
|
mNearestAngle = nearestAngle;
|
484
|
mFinishRotation = true;
|
485
|
}
|
486
|
|
487
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
488
|
|
489
|
void changeObject(ObjectList object, int size)
|
490
|
{
|
491
|
if( size>0 )
|
492
|
{
|
493
|
mChangeObject = true;
|
494
|
mNextObject = object;
|
495
|
mNextSize = size;
|
496
|
}
|
497
|
}
|
498
|
|
499
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
500
|
|
501
|
void setupObject(ObjectList object, int size, int[][] moves)
|
502
|
{
|
503
|
if( size>0 )
|
504
|
{
|
505
|
mSetupObject= true;
|
506
|
mNextObject = object;
|
507
|
mNextSize = size;
|
508
|
mNextMoves = moves;
|
509
|
}
|
510
|
}
|
511
|
|
512
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
513
|
|
514
|
void setTextureMap(int cubit, int face, int newColor)
|
515
|
{
|
516
|
mSetTextureMap = true;
|
517
|
|
518
|
mCubit = cubit;
|
519
|
mFace = face;
|
520
|
mNewColor = newColor;
|
521
|
}
|
522
|
|
523
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
524
|
|
525
|
boolean canRotate()
|
526
|
{
|
527
|
return mCanRotate;
|
528
|
}
|
529
|
|
530
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
531
|
|
532
|
public boolean canPlay()
|
533
|
{
|
534
|
return mCanPlay;
|
535
|
}
|
536
|
|
537
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
538
|
|
539
|
void setQuatOnNextRender()
|
540
|
{
|
541
|
mSetQuat = true;
|
542
|
}
|
543
|
|
544
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
545
|
|
546
|
void preRender()
|
547
|
{
|
548
|
if( mSetQuat ) setQuatNow();
|
549
|
if( mFinishRotation ) finishRotationNow();
|
550
|
if( mRemoveRotation ) removeRotationNow();
|
551
|
if( mRemovePatternRotation ) removePatternRotationNow();
|
552
|
if( mChangeObject ) changeObjectNow();
|
553
|
if( mSetupObject ) setupObjectNow();
|
554
|
if( mSolveObject ) solveObjectNow();
|
555
|
if( mScrambleObject ) scrambleObjectNow();
|
556
|
if( mAddRotation ) addRotationNow();
|
557
|
if( mInitializeObject ) initializeObjectNow();
|
558
|
if( mResetAllTextureMaps ) resetAllTextureMapsNow();
|
559
|
if( mSetTextureMap ) setTextureMapNow();
|
560
|
}
|
561
|
|
562
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
563
|
// PUBLIC API
|
564
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
565
|
|
566
|
public void addRotation(ActionFinishedListener listener, int axis, int rowBitmap, int angle, long duration)
|
567
|
{
|
568
|
mAddRotation = true;
|
569
|
|
570
|
mAddActionListener = listener;
|
571
|
mAddRotationAxis = axis;
|
572
|
mAddRotationRowBitmap = rowBitmap;
|
573
|
mAddRotationAngle = angle;
|
574
|
mAddRotationDuration = duration;
|
575
|
}
|
576
|
|
577
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
578
|
|
579
|
public void initializeObject(int[][] moves)
|
580
|
{
|
581
|
mInitializeObject = true;
|
582
|
mNextMoves = moves;
|
583
|
}
|
584
|
|
585
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
586
|
|
587
|
public void scrambleObject(int num)
|
588
|
{
|
589
|
if( mCanPlay )
|
590
|
{
|
591
|
mScrambleObject = true;
|
592
|
mScrambleObjectNum = num;
|
593
|
}
|
594
|
}
|
595
|
|
596
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
597
|
|
598
|
public void solveObject()
|
599
|
{
|
600
|
if( mCanPlay )
|
601
|
{
|
602
|
mSolveObject = true;
|
603
|
}
|
604
|
}
|
605
|
|
606
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
607
|
|
608
|
public void resetAllTextureMaps()
|
609
|
{
|
610
|
mResetAllTextureMaps = true;
|
611
|
}
|
612
|
|
613
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
614
|
|
615
|
public TwistyObject getObject()
|
616
|
{
|
617
|
return mNewObject;
|
618
|
}
|
619
|
|
620
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
621
|
|
622
|
public TwistyObject getOldObject()
|
623
|
{
|
624
|
return mOldObject;
|
625
|
}
|
626
|
|
627
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
628
|
|
629
|
public int getNumScrambles()
|
630
|
{
|
631
|
return mScrambleObjectNum;
|
632
|
}
|
633
|
|
634
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
635
|
|
636
|
public void effectFinished(final long effectID)
|
637
|
{
|
638
|
if( effectID == mRotationFinishedID )
|
639
|
{
|
640
|
mRotationFinishedID = 0;
|
641
|
removeRotation();
|
642
|
}
|
643
|
else if( effectID == mAddRotationID )
|
644
|
{
|
645
|
mAddRotationID = 0;
|
646
|
mRemoveRotationID = effectID;
|
647
|
removePatternRotation();
|
648
|
}
|
649
|
else
|
650
|
{
|
651
|
for(int i=0; i<BaseEffect.Type.LENGTH; i++)
|
652
|
{
|
653
|
if( effectID == mEffectID[i] )
|
654
|
{
|
655
|
mCanRotate = true;
|
656
|
mCanPlay = true;
|
657
|
|
658
|
if( i==BaseEffect.Type.SCRAMBLE.ordinal() )
|
659
|
{
|
660
|
final RubikActivity act = (RubikActivity)mView.getContext();
|
661
|
|
662
|
act.runOnUiThread(new Runnable()
|
663
|
{
|
664
|
@Override
|
665
|
public void run()
|
666
|
{
|
667
|
StateList.switchState( act, StateList.READ);
|
668
|
}
|
669
|
});
|
670
|
}
|
671
|
|
672
|
if( i==BaseEffect.Type.WIN.ordinal() )
|
673
|
{
|
674
|
if( StateList.getCurrentState()== StateList.SOLV )
|
675
|
{
|
676
|
final RubikActivity act = (RubikActivity)mView.getContext();
|
677
|
Bundle bundle = new Bundle();
|
678
|
bundle.putLong("time", mNewRecord );
|
679
|
|
680
|
reportRecord();
|
681
|
requestReview();
|
682
|
|
683
|
if( mIsNewRecord )
|
684
|
{
|
685
|
RubikDialogNewRecord dialog = new RubikDialogNewRecord();
|
686
|
dialog.setArguments(bundle);
|
687
|
dialog.show( act.getSupportFragmentManager(), RubikDialogNewRecord.getDialogTag() );
|
688
|
}
|
689
|
else
|
690
|
{
|
691
|
RubikDialogSolved dialog = new RubikDialogSolved();
|
692
|
dialog.setArguments(bundle);
|
693
|
dialog.show( act.getSupportFragmentManager(), RubikDialogSolved.getDialogTag() );
|
694
|
}
|
695
|
|
696
|
act.runOnUiThread(new Runnable()
|
697
|
{
|
698
|
@Override
|
699
|
public void run()
|
700
|
{
|
701
|
StateList.switchState( act, StateList.DONE);
|
702
|
}
|
703
|
});
|
704
|
}
|
705
|
}
|
706
|
|
707
|
break;
|
708
|
}
|
709
|
}
|
710
|
}
|
711
|
}
|
712
|
}
|