Revision b3fff6fb
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/objectlib/automator/ObjectAutomator.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.objectlib.automator; |
21 | 21 |
|
22 |
import java.lang.ref.WeakReference; |
|
23 |
|
|
24 |
import android.app.Activity; |
|
25 |
|
|
22 | 26 |
import org.distorted.library.main.DistortedNode; |
23 | 27 |
import org.distorted.library.main.DistortedScreen; |
24 | 28 |
import org.distorted.library.message.EffectListener; |
25 |
|
|
26 | 29 |
import org.distorted.library.type.Static4D; |
30 |
|
|
31 |
import org.distorted.objectlib.helpers.ObjectLibInterface; |
|
27 | 32 |
import org.distorted.objectlib.main.ObjectControl; |
28 |
import org.distorted.objectlib.main.ObjectPreRender; |
|
29 | 33 |
import org.distorted.objectlib.helpers.BlockController; |
30 |
import org.distorted.objectlib.helpers.TwistyActivity; |
|
31 | 34 |
import org.distorted.objectlib.main.TwistyObject; |
32 | 35 |
|
33 |
import java.lang.ref.WeakReference; |
|
34 |
|
|
35 | 36 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
36 | 37 |
|
37 | 38 |
public class ObjectAutomator implements EffectListener |
38 | 39 |
{ |
39 | 40 |
private static ObjectAutomator mControl; |
40 |
private ObjectControl mObjectControl; |
|
41 |
private final ObjectControl mObjectControl;
|
|
41 | 42 |
|
42 |
WeakReference<TwistyActivity> mRefAct;
|
|
43 |
WeakReference<Activity> mRefAct; |
|
43 | 44 |
boolean mWholeReturned, mRotateReturned; |
44 | 45 |
|
45 | 46 |
ObjectAutomatorWhole mWhole; |
... | ... | |
49 | 50 |
|
50 | 51 |
DistortedScreen getScreen() |
51 | 52 |
{ |
52 |
TwistyActivity act = mRefAct.get();
|
|
53 |
return act!=null ? act.getScreen() : null;
|
|
53 |
ObjectLibInterface inter = mObjectControl.getInterface();
|
|
54 |
return inter.getScreen();
|
|
54 | 55 |
} |
55 | 56 |
|
56 | 57 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
64 | 65 |
|
65 | 66 |
Static4D getQuat() |
66 | 67 |
{ |
67 |
ObjectControl control = getObjectControl(); |
|
68 |
return control.getQuat(); |
|
68 |
return mObjectControl.getQuat(); |
|
69 | 69 |
} |
70 | 70 |
|
71 | 71 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
72 | 72 |
|
73 | 73 |
TwistyObject getObject() |
74 | 74 |
{ |
75 |
ObjectControl control = getObjectControl(); |
|
76 |
ObjectPreRender pre = control.getPreRender(); |
|
77 |
return pre.getObject(); |
|
75 |
return mObjectControl.getObject(); |
|
78 | 76 |
} |
79 | 77 |
|
80 | 78 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
115 | 113 |
for (DistortedNode node : screenNodes) screen.attach(node); |
116 | 114 |
} |
117 | 115 |
|
118 |
ObjectControl control = getObjectControl(); |
|
119 |
ObjectPreRender pre = control.getPreRender(); |
|
120 |
DistortedNode object = pre.getObject(); |
|
116 |
DistortedNode object = mObjectControl.getObject(); |
|
121 | 117 |
DistortedNode[] objectNodes = mRotate.getObjectNodes(); |
122 | 118 |
|
123 | 119 |
if( object!=null && objectNodes!=null ) |
... | ... | |
138 | 134 |
for (DistortedNode node : screenNodes) screen.detach(node); |
139 | 135 |
} |
140 | 136 |
|
141 |
ObjectControl control = getObjectControl(); |
|
142 |
ObjectPreRender pre = control.getPreRender(); |
|
143 |
DistortedNode object = pre.getObject(); |
|
137 |
DistortedNode object = mObjectControl.getObject(); |
|
144 | 138 |
DistortedNode[] objectNodes = mRotate.returnObjectNodes(); |
145 | 139 |
|
146 | 140 |
if( object!=null && objectNodes!=null ) |
... | ... | |
154 | 148 |
private void finishWhole() |
155 | 149 |
{ |
156 | 150 |
removeWholeObjects(); |
157 |
|
|
158 | 151 |
mWholeReturned = true; |
159 |
|
|
160 | 152 |
if( !mRotateReturned ) addRotateObjects(); |
161 | 153 |
} |
162 | 154 |
|
... | ... | |
166 | 158 |
{ |
167 | 159 |
removeRotateObjects(); |
168 | 160 |
mRotateReturned= true; |
169 |
mObjectControl.getPreRender().unblockEverything();
|
|
161 |
mObjectControl.unblockEverything(); |
|
170 | 162 |
} |
171 | 163 |
|
172 | 164 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
173 | 165 |
|
174 |
TwistyActivity getActivity()
|
|
166 |
Activity getActivity() |
|
175 | 167 |
{ |
176 | 168 |
return mRefAct.get(); |
177 | 169 |
} |
... | ... | |
213 | 205 |
|
214 | 206 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
215 | 207 |
|
216 |
public void animateAll(TwistyActivity act)
|
|
208 |
public void animateAll(Activity act) |
|
217 | 209 |
{ |
218 |
mObjectControl.getPreRender().blockEverything(BlockController.CONTROL_PLACE_0);
|
|
210 |
mObjectControl.blockEverything(BlockController.CONTROL_PLACE_0); |
|
219 | 211 |
mRefAct = new WeakReference<>(act); |
220 | 212 |
|
221 | 213 |
mWholeReturned = false; |
... | ... | |
226 | 218 |
|
227 | 219 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
228 | 220 |
|
229 |
public void animateRotate(TwistyActivity act)
|
|
221 |
public void animateRotate(Activity act) |
|
230 | 222 |
{ |
231 |
mObjectControl.getPreRender().blockEverything(BlockController.CONTROL_PLACE_1);
|
|
223 |
mObjectControl.blockEverything(BlockController.CONTROL_PLACE_1); |
|
232 | 224 |
mRefAct = new WeakReference<>(act); |
233 | 225 |
|
234 | 226 |
mWholeReturned = true; |
src/main/java/org/distorted/objectlib/automator/ObjectAutomatorRotate.java | ||
---|---|---|
22 | 22 |
import java.io.IOException; |
23 | 23 |
import java.io.InputStream; |
24 | 24 |
|
25 |
import android.app.Activity; |
|
25 | 26 |
import android.graphics.Bitmap; |
26 | 27 |
import android.graphics.BitmapFactory; |
27 | 28 |
|
... | ... | |
41 | 42 |
import org.distorted.library.main.QuatHelper; |
42 | 43 |
|
43 | 44 |
import org.distorted.objectlib.R; |
44 |
import org.distorted.objectlib.helpers.TwistyActivity; |
|
45 | 45 |
import org.distorted.objectlib.main.TwistyObject; |
46 | 46 |
|
47 | 47 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
67 | 67 |
|
68 | 68 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
69 | 69 |
|
70 |
private Bitmap openBitmap(TwistyActivity act, int resource)
|
|
70 |
private Bitmap openBitmap(Activity act, int resource) |
|
71 | 71 |
{ |
72 | 72 |
try( InputStream is = act.getResources().openRawResource(resource) ) |
73 | 73 |
{ |
... | ... | |
278 | 278 |
mObjectQuad = new MeshQuad(); |
279 | 279 |
} |
280 | 280 |
|
281 |
TwistyActivity act = mControl.getActivity();
|
|
281 |
Activity act = mControl.getActivity(); |
|
282 | 282 |
|
283 | 283 |
if( act!=null ) |
284 | 284 |
{ |
src/main/java/org/distorted/objectlib/automator/ObjectAutomatorWhole.java | ||
---|---|---|
22 | 22 |
import java.io.IOException; |
23 | 23 |
import java.io.InputStream; |
24 | 24 |
|
25 |
import android.app.Activity; |
|
25 | 26 |
import android.graphics.Bitmap; |
26 | 27 |
import android.graphics.BitmapFactory; |
27 | 28 |
|
... | ... | |
35 | 36 |
import org.distorted.library.type.Dynamic; |
36 | 37 |
import org.distorted.library.type.Dynamic3D; |
37 | 38 |
import org.distorted.library.type.Static3D; |
39 |
|
|
38 | 40 |
import org.distorted.objectlib.R; |
39 |
import org.distorted.objectlib.helpers.TwistyActivity; |
|
40 | 41 |
import org.distorted.objectlib.main.ObjectControl; |
41 | 42 |
|
42 | 43 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
79 | 80 |
|
80 | 81 |
private void setPostFrame(boolean on) |
81 | 82 |
{ |
82 |
TwistyActivity act = mControl.getActivity();
|
|
83 |
Activity act = mControl.getActivity(); |
|
83 | 84 |
// act.setControlState(on); |
84 | 85 |
mLastTime = -1; |
85 | 86 |
} |
86 | 87 |
|
87 | 88 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
88 | 89 |
|
89 |
private Bitmap openBitmap(TwistyActivity act, int resource)
|
|
90 |
private Bitmap openBitmap(Activity act, int resource) |
|
90 | 91 |
{ |
91 | 92 |
try( InputStream is = act.getResources().openRawResource(resource) ) |
92 | 93 |
{ |
... | ... | |
825 | 826 |
mQuad = new MeshQuad(); |
826 | 827 |
} |
827 | 828 |
|
828 |
TwistyActivity act = mControl.getActivity();
|
|
829 |
Activity act = mControl.getActivity(); |
|
829 | 830 |
|
830 | 831 |
if( act!=null ) |
831 | 832 |
{ |
src/main/java/org/distorted/objectlib/helpers/BlockController.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.objectlib.helpers; |
21 | 21 |
|
22 |
import android.app.Activity; |
|
23 |
|
|
22 | 24 |
import com.google.firebase.crashlytics.FirebaseCrashlytics; |
23 | 25 |
|
24 | 26 |
import java.util.Timer; |
... | ... | |
69 | 71 |
|
70 | 72 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
71 | 73 |
|
72 |
public BlockController(TwistyActivity act, ObjectPreRender pre)
|
|
74 |
public BlockController(Activity act, ObjectPreRender pre) |
|
73 | 75 |
{ |
74 | 76 |
mPre = pre; |
75 | 77 |
|
src/main/java/org/distorted/objectlib/helpers/ObjectLibInterface.java | ||
---|---|---|
1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
2 |
// Copyright 2021 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.objectlib.helpers; |
|
21 |
|
|
22 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
23 |
|
|
24 |
import org.distorted.library.main.DistortedScreen; |
|
25 |
import org.distorted.objectlib.main.ObjectControl; |
|
26 |
import org.distorted.objectlib.main.ObjectType; |
|
27 |
|
|
28 |
public interface ObjectLibInterface |
|
29 |
{ |
|
30 |
// objectlib calls those in reaction to object state changing, app has to respond |
|
31 |
void onWinEffectFinished(String debug, int scrambleNum); |
|
32 |
void onScrambleEffectFinished(); |
|
33 |
void onBeginRotation(); |
|
34 |
void onFinishRotation(int axis, int row, int angle); |
|
35 |
void failedToDrag(); |
|
36 |
void onSolved(); |
|
37 |
|
|
38 |
// objectlib calls those to figure out app's state |
|
39 |
int getCurrentColor(); |
|
40 |
int cubitIsLocked(ObjectType type, int cubit); |
|
41 |
ObjectControl getControl(); |
|
42 |
DistortedScreen getScreen(); |
|
43 |
} |
src/main/java/org/distorted/objectlib/helpers/ObjectStateActioner.java | ||
---|---|---|
1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
2 |
// Copyright 2021 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.objectlib.helpers; |
|
21 |
|
|
22 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
23 |
|
|
24 |
import org.distorted.objectlib.main.ObjectType; |
|
25 |
|
|
26 |
public interface ObjectStateActioner |
|
27 |
{ |
|
28 |
void onWinEffectFinished(TwistyActivity act, String debug, int scrambleNum); |
|
29 |
void onScrambleEffectFinished(TwistyActivity act); |
|
30 |
void onBeginRotation(TwistyActivity act); |
|
31 |
void onFinishRotation(TwistyActivity act, int axis, int row, int angle); |
|
32 |
void failedToDrag(TwistyActivity act); |
|
33 |
int getCurrentColor(); |
|
34 |
int cubitIsLocked(ObjectType type, int cubit); |
|
35 |
void onSolved(); |
|
36 |
} |
src/main/java/org/distorted/objectlib/helpers/TwistyActivity.java | ||
---|---|---|
1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
2 |
// Copyright 2021 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.objectlib.helpers; |
|
21 |
|
|
22 |
import androidx.appcompat.app.AppCompatActivity; |
|
23 |
|
|
24 |
import org.distorted.library.main.DistortedScreen; |
|
25 |
import org.distorted.objectlib.main.ObjectControl; |
|
26 |
|
|
27 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
28 |
|
|
29 |
abstract public class TwistyActivity extends AppCompatActivity |
|
30 |
{ |
|
31 |
public abstract ObjectControl getControl(); |
|
32 |
public abstract DistortedScreen getScreen(); |
|
33 |
} |
src/main/java/org/distorted/objectlib/main/ObjectControl.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.objectlib.main; |
21 | 21 |
|
22 |
import java.lang.ref.WeakReference; |
|
23 |
|
|
22 |
import android.app.Activity; |
|
24 | 23 |
import android.content.SharedPreferences; |
25 | 24 |
import android.util.DisplayMetrics; |
26 | 25 |
import android.view.MotionEvent; |
... | ... | |
30 | 29 |
import org.distorted.library.type.Static4D; |
31 | 30 |
|
32 | 31 |
import org.distorted.objectlib.helpers.MovesFinished; |
33 |
import org.distorted.objectlib.helpers.ObjectStateActioner; |
|
34 |
import org.distorted.objectlib.helpers.TwistyActivity; |
|
32 |
import org.distorted.objectlib.helpers.ObjectLibInterface; |
|
35 | 33 |
|
36 | 34 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
37 | 35 |
|
... | ... | |
52 | 50 |
|
53 | 51 |
private final Static4D CAMERA_POINT = new Static4D(0, 0, 0, 0); |
54 | 52 |
|
55 |
private final WeakReference<TwistyActivity> mAct; |
|
56 |
private final ObjectStateActioner mActioner; |
|
53 |
private final ObjectLibInterface mInterface; |
|
57 | 54 |
private final ObjectPreRender mPreRender; |
58 | 55 |
private Movement mMovement; |
59 | 56 |
private boolean mDragging, mBeginningRotation, mContinuingRotation; |
... | ... | |
189 | 186 |
|
190 | 187 |
if( down ) |
191 | 188 |
{ |
192 |
int color = mActioner.getCurrentColor();
|
|
189 |
int color = mInterface.getCurrentColor();
|
|
193 | 190 |
mLastCubitFace = mMovement.getTouchedFace(); |
194 | 191 |
float[] point = mMovement.getTouchedPoint3D(); |
195 | 192 |
mLastCubit = object.getCubit(point); |
196 | 193 |
mPreRender.setTextureMap( mLastCubit, mLastCubitFace, color ); |
197 |
mLastCubitColor = mActioner.cubitIsLocked(object.getObjectType(),mLastCubit);
|
|
194 |
mLastCubitColor = mInterface.cubitIsLocked(object.getObjectType(),mLastCubit);
|
|
198 | 195 |
} |
199 | 196 |
} |
200 | 197 |
} |
201 | 198 |
else |
202 | 199 |
{ |
203 |
final TwistyActivity act = mAct.get(); |
|
204 | 200 |
mDragging = (!mIsLocked || mIsAutomatic); |
205 | 201 |
mBeginningRotation = false; |
206 | 202 |
mContinuingRotation = false; |
207 |
if( !mDragging ) mActioner.failedToDrag(act);
|
|
203 |
if( !mDragging ) mInterface.failedToDrag();
|
|
208 | 204 |
} |
209 | 205 |
} |
210 | 206 |
} |
... | ... | |
257 | 253 |
|
258 | 254 |
if( angle!=0 ) |
259 | 255 |
{ |
260 |
TwistyActivity act = mAct.get(); |
|
261 |
|
|
262 | 256 |
int basicAngle= object.getBasicAngle()[mCurrentAxis]; |
263 | 257 |
int realAngle = (angle*basicAngle)/360; |
264 |
|
|
265 |
mActioner.onFinishRotation(act,mCurrentAxis,mCurrentRow,realAngle); |
|
258 |
mInterface.onFinishRotation(mCurrentAxis,mCurrentRow,realAngle); |
|
266 | 259 |
} |
267 | 260 |
|
268 | 261 |
mContinuingRotation = false; |
... | ... | |
314 | 307 |
|
315 | 308 |
object.beginNewRotation( mCurrentAxis, mCurrentRow ); |
316 | 309 |
|
317 |
TwistyActivity act = mAct.get(); |
|
318 |
mActioner.onBeginRotation(act); |
|
310 |
mInterface.onBeginRotation(); |
|
319 | 311 |
|
320 | 312 |
addSpeedProbe(x,y); |
321 | 313 |
|
... | ... | |
504 | 496 |
return mPreRender; |
505 | 497 |
} |
506 | 498 |
|
499 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
500 |
|
|
501 |
public ObjectLibInterface getInterface() |
|
502 |
{ |
|
503 |
return mInterface; |
|
504 |
} |
|
505 |
|
|
507 | 506 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
508 | 507 |
// PUBLIC API |
509 | 508 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
510 | 509 |
|
511 |
public ObjectControl(TwistyActivity act, ObjectStateActioner actioner)
|
|
510 |
public ObjectControl(Activity act, ObjectLibInterface actioner)
|
|
512 | 511 |
{ |
513 | 512 |
mIsAutomatic = false; |
514 | 513 |
|
... | ... | |
527 | 526 |
mDensity = dm.densityDpi; |
528 | 527 |
|
529 | 528 |
mPreRender = new ObjectPreRender(act,this,actioner); |
530 |
mAct = new WeakReference<>(act); |
|
531 |
mActioner = actioner; |
|
529 |
mInterface = actioner; |
|
532 | 530 |
} |
533 | 531 |
|
534 | 532 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objectlib/main/ObjectPreRender.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.objectlib.main; |
21 | 21 |
|
22 |
import android.app.Activity; |
|
22 | 23 |
import android.content.SharedPreferences; |
23 | 24 |
import android.content.res.Resources; |
24 | 25 |
|
25 |
import org.distorted.objectlib.helpers.ObjectStateActioner; |
|
26 |
import org.distorted.library.main.DistortedScreen; |
|
27 |
import org.distorted.objectlib.helpers.ObjectLibInterface; |
|
26 | 28 |
import org.distorted.objectlib.effects.BaseEffect; |
27 | 29 |
import org.distorted.objectlib.effects.EffectController; |
28 | 30 |
import org.distorted.objectlib.effects.scramble.ScrambleEffect; |
29 | 31 |
import org.distorted.objectlib.helpers.BlockController; |
30 | 32 |
import org.distorted.objectlib.helpers.MovesFinished; |
31 |
import org.distorted.objectlib.helpers.TwistyActivity; |
|
32 | 33 |
|
33 | 34 |
import java.lang.ref.WeakReference; |
34 | 35 |
|
... | ... | |
36 | 37 |
|
37 | 38 |
public class ObjectPreRender implements EffectController |
38 | 39 |
{ |
39 |
private final WeakReference<TwistyActivity> mAct;
|
|
40 |
private final WeakReference<Activity> mAct; |
|
40 | 41 |
private final ObjectControl mController; |
41 | 42 |
private ObjectType mNextObject; |
42 | 43 |
private TwistyObject mOldObject, mNewObject; |
43 | 44 |
private SharedPreferences mPreferences; |
44 | 45 |
private MovesFinished mAddActionListener; |
45 | 46 |
private final BlockController mBlockController; |
46 |
private final ObjectStateActioner mActioner;
|
|
47 |
private final ObjectLibInterface mInterface;
|
|
47 | 48 |
private String mDebug; |
48 | 49 |
|
49 | 50 |
private boolean mFinishRotation, mRemoveRotation, mRemovePatternRotation, mAddRotation, |
... | ... | |
64 | 65 |
|
65 | 66 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
66 | 67 |
|
67 |
public ObjectPreRender(TwistyActivity act, ObjectControl controller, ObjectStateActioner actioner)
|
|
68 |
public ObjectPreRender(Activity act, ObjectControl controller, ObjectLibInterface actioner)
|
|
68 | 69 |
{ |
69 | 70 |
mAct = new WeakReference<>(act); |
70 |
mActioner = actioner;
|
|
71 |
mInterface = actioner;
|
|
71 | 72 |
mController = controller; |
72 | 73 |
|
73 | 74 |
mFinishRotation = false; |
... | ... | |
104 | 105 |
if( mOldObject!=null ) mOldObject.releaseResources(); |
105 | 106 |
mOldObject = mNewObject; |
106 | 107 |
|
107 |
TwistyActivity tact = mAct.get(); |
|
108 |
|
|
108 |
Activity tact = mAct.get(); |
|
109 | 109 |
Resources res = tact.getResources(); |
110 | 110 |
|
111 | 111 |
mNewObject = object.create( mController.getQuat(), moves, res, mScreenWidth); |
... | ... | |
126 | 126 |
try |
127 | 127 |
{ |
128 | 128 |
int index = type.ordinal(); |
129 |
mEffectID[index] = type.startEffect(mAct.get().getScreen(),this); |
|
129 |
DistortedScreen screen = mController.getInterface().getScreen(); |
|
130 |
mEffectID[index] = type.startEffect(screen,this); |
|
130 | 131 |
} |
131 | 132 |
catch( Exception ex ) |
132 | 133 |
{ |
... | ... | |
146 | 147 |
|
147 | 148 |
if( solved && !mIsSolved ) |
148 | 149 |
{ |
149 |
mActioner.onSolved();
|
|
150 |
mInterface.onSolved();
|
|
150 | 151 |
unblockEverything(); |
151 | 152 |
doEffectNow( BaseEffect.Type.WIN ); |
152 | 153 |
} |
... | ... | |
573 | 574 |
if( effectID == mEffectID[i] ) |
574 | 575 |
{ |
575 | 576 |
if( i!=BaseEffect.Type.WIN.ordinal() ) unblockEverything(); |
576 |
if( i==BaseEffect.Type.SCRAMBLE.ordinal() ) mActioner.onScrambleEffectFinished(mAct.get());
|
|
577 |
if( i==BaseEffect.Type.WIN.ordinal() ) mActioner.onWinEffectFinished(mAct.get(),mDebug,mScrambleObjectNum);
|
|
577 |
if( i==BaseEffect.Type.SCRAMBLE.ordinal() ) mInterface.onScrambleEffectFinished();
|
|
578 |
if( i==BaseEffect.Type.WIN.ordinal() ) mInterface.onWinEffectFinished(mDebug,mScrambleObjectNum);
|
|
578 | 579 |
break; |
579 | 580 |
} |
580 | 581 |
} |
Also available in: Unified diff
Remove the concept of a 'TwistyActivity' altogether.