Revision 81141862
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/objectlib/main/ObjectPreRender.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.objectlib.main; |
21 | 21 |
|
22 |
import java.lang.ref.WeakReference; |
|
23 |
|
|
22 | 24 |
import android.app.Activity; |
23 | 25 |
import android.content.SharedPreferences; |
24 |
import android.content.res.Resources; |
|
25 | 26 |
|
26 | 27 |
import org.distorted.library.main.DistortedScreen; |
28 |
|
|
27 | 29 |
import org.distorted.objectlib.helpers.ObjectLibInterface; |
28 | 30 |
import org.distorted.objectlib.effects.BaseEffect; |
29 | 31 |
import org.distorted.objectlib.effects.EffectController; |
... | ... | |
31 | 33 |
import org.distorted.objectlib.helpers.BlockController; |
32 | 34 |
import org.distorted.objectlib.helpers.MovesFinished; |
33 | 35 |
|
34 |
import java.lang.ref.WeakReference; |
|
35 |
|
|
36 | 36 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
37 | 37 |
|
38 | 38 |
public class ObjectPreRender implements EffectController |
... | ... | |
48 | 48 |
private String mDebug; |
49 | 49 |
|
50 | 50 |
private boolean mFinishRotation, mRemoveRotation, mRemovePatternRotation, mAddRotation, |
51 |
mSetQuat, mChangeObject, mSetupObject, mSolveObject, mScrambleObject,
|
|
51 |
mSetQuat, mChangeObject, mSolveObject, mScrambleObject, |
|
52 | 52 |
mInitializeObject, mSetTextureMap, mResetAllTextureMaps, mSolve; |
53 | 53 |
private boolean mUIBlocked, mTouchBlocked, mIsSolved; |
54 | 54 |
private long mRotationFinishedID; |
... | ... | |
77 | 77 |
mAddRotation = false; |
78 | 78 |
mSetQuat = false; |
79 | 79 |
mChangeObject = false; |
80 |
mSetupObject = false; |
|
81 | 80 |
mSolveObject = false; |
82 | 81 |
mSolve = false; |
83 | 82 |
mScrambleObject = false; |
... | ... | |
98 | 97 |
|
99 | 98 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
100 | 99 |
|
101 |
private void createObjectNow(ObjectType object, int[][] moves)
|
|
100 |
private void createObjectNow(ObjectType object) |
|
102 | 101 |
{ |
103 | 102 |
boolean firstTime = (mNewObject==null); |
104 | 103 |
|
105 | 104 |
if( mOldObject!=null ) mOldObject.releaseResources(); |
106 | 105 |
mOldObject = mNewObject; |
107 | 106 |
|
108 |
Activity tact = mAct.get(); |
|
109 |
Resources res = tact.getResources(); |
|
110 |
|
|
111 |
mNewObject = object.create( mController.getQuat(), moves, res, mScreenWidth); |
|
107 |
mNewObject = object.create( mController.getQuat(), mAct.get().getResources(), mScreenWidth); |
|
112 | 108 |
|
113 | 109 |
if( mNewObject!=null ) |
114 | 110 |
{ |
... | ... | |
219 | 215 |
if ( mNewObject==null || mNewObject.getObjectType()!=mNextObject ) |
220 | 216 |
{ |
221 | 217 |
blockEverything(BlockController.PLACE_1); |
222 |
createObjectNow(mNextObject, null); |
|
223 |
doEffectNow( BaseEffect.Type.SIZECHANGE ); |
|
224 |
} |
|
225 |
} |
|
226 |
|
|
227 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
228 |
|
|
229 |
private void setupObjectNow() |
|
230 |
{ |
|
231 |
mSetupObject = false; |
|
232 |
|
|
233 |
if ( mNewObject==null || mNewObject.getObjectType()!=mNextObject) |
|
234 |
{ |
|
235 |
blockEverything(BlockController.PLACE_2); |
|
236 |
createObjectNow(mNextObject, mNextMoves); |
|
218 |
createObjectNow(mNextObject); |
|
237 | 219 |
doEffectNow( BaseEffect.Type.SIZECHANGE ); |
238 | 220 |
} |
239 |
else |
|
240 |
{ |
|
241 |
mNewObject.initializeObject(mNextMoves); |
|
242 |
} |
|
243 | 221 |
} |
244 | 222 |
|
245 | 223 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
390 | 368 |
mNextObject = object; |
391 | 369 |
} |
392 | 370 |
|
393 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
394 |
|
|
395 |
public void setupObject(ObjectType object, int[][] moves) |
|
396 |
{ |
|
397 |
mSetupObject= true; |
|
398 |
mNextObject = object; |
|
399 |
mNextMoves = moves; |
|
400 |
} |
|
401 |
|
|
402 | 371 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
403 | 372 |
|
404 | 373 |
public boolean isTouchBlocked() |
... | ... | |
467 | 436 |
if( mRemoveRotation ) removeRotationNow(); |
468 | 437 |
if( mRemovePatternRotation ) removePatternRotationNow(); |
469 | 438 |
if( mChangeObject ) changeObjectNow(); |
470 |
if( mSetupObject ) setupObjectNow(); |
|
471 | 439 |
if( mSolveObject ) solveObjectNow(); |
472 | 440 |
if( mScrambleObject ) scrambleObjectNow(); |
473 | 441 |
if( mAddRotation ) addRotationNow(); |
Also available in: Unified diff
Remove the 'setupObject()' redundant API.