Revision 338babe8
Added by Leszek Koltunski about 3 years ago
src/main/java/org/distorted/main/RubikActivity.java | ||
---|---|---|
42 | 42 |
import com.google.firebase.analytics.FirebaseAnalytics; |
43 | 43 |
|
44 | 44 |
import org.distorted.library.main.DistortedLibrary; |
45 |
import org.distorted.library.main.DistortedScreen; |
|
46 | 45 |
|
47 | 46 |
import org.distorted.objectlib.main.ObjectControl; |
48 | 47 |
import org.distorted.objectlib.main.TwistyObject; |
... | ... | |
416 | 415 |
return view.getObjectControl(); |
417 | 416 |
} |
418 | 417 |
|
419 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
420 |
|
|
421 |
public DistortedScreen getScreen() |
|
422 |
{ |
|
423 |
RubikSurfaceView view = findViewById(R.id.rubikSurfaceView); |
|
424 |
RubikRenderer renderer = view.getRenderer(); |
|
425 |
return renderer.getScreen(); |
|
426 |
} |
|
427 |
|
|
428 | 418 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
429 | 419 |
|
430 | 420 |
public int getScreenWidthInPixels() |
src/main/java/org/distorted/main/RubikObjectLibInterface.java | ||
---|---|---|
31 | 31 |
import com.google.android.play.core.tasks.Task; |
32 | 32 |
import com.google.firebase.analytics.FirebaseAnalytics; |
33 | 33 |
|
34 |
import org.distorted.library.main.DistortedFramebuffer; |
|
35 | 34 |
import org.distorted.objectlib.helpers.ObjectLibInterface; |
36 | 35 |
import org.distorted.objectlib.main.ObjectType; |
37 | 36 |
|
... | ... | |
322 | 321 |
{ |
323 | 322 |
return SolverMain.cubitIsLocked(type,cubit); |
324 | 323 |
} |
325 |
|
|
326 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
327 |
|
|
328 |
public DistortedFramebuffer getFramebuffer() |
|
329 |
{ |
|
330 |
RubikActivity act = mAct.get(); |
|
331 |
return act.getScreen(); |
|
332 |
} |
|
333 | 324 |
} |
src/main/java/org/distorted/main/RubikSurfaceView.java | ||
---|---|---|
30 | 30 |
|
31 | 31 |
import com.google.firebase.crashlytics.FirebaseCrashlytics; |
32 | 32 |
|
33 |
import org.distorted.library.main.DistortedNode; |
|
33 | 34 |
import org.distorted.objectlib.main.ObjectControl; |
34 | 35 |
|
35 | 36 |
import org.distorted.screens.ScreenList; |
... | ... | |
41 | 42 |
private ObjectControl mObjectController; |
42 | 43 |
private RubikRenderer mRenderer; |
43 | 44 |
private int mScreenWidth, mScreenHeight; |
45 |
private boolean mCreated; |
|
44 | 46 |
|
45 | 47 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
46 | 48 |
|
... | ... | |
50 | 52 |
mScreenHeight= height; |
51 | 53 |
mObjectController.setScreenSize(width,height); |
52 | 54 |
|
55 |
if( !mCreated ) |
|
56 |
{ |
|
57 |
mCreated = true; |
|
58 |
mObjectController.createNode(width,height); |
|
59 |
DistortedNode objectNode = mObjectController.getNode(); |
|
60 |
mRenderer.getScreen().attach(objectNode); |
|
61 |
} |
|
62 |
|
|
53 | 63 |
try |
54 | 64 |
{ |
55 | 65 |
RubikActivity act = (RubikActivity)getContext(); |
... | ... | |
90 | 100 |
{ |
91 | 101 |
super(context,attrs); |
92 | 102 |
|
103 |
mCreated = false; |
|
104 |
|
|
93 | 105 |
if(!isInEditMode()) |
94 | 106 |
{ |
95 | 107 |
RubikActivity act = (RubikActivity)context; |
src/main/java/org/distorted/tutorials/TutorialActivity.java | ||
---|---|---|
255 | 255 |
return view.getObjectControl(); |
256 | 256 |
} |
257 | 257 |
|
258 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
259 |
|
|
260 |
public DistortedScreen getScreen() |
|
261 |
{ |
|
262 |
TutorialSurfaceView view = findViewById(R.id.tutorialSurfaceView); |
|
263 |
TutorialRenderer renderer = view.getRenderer(); |
|
264 |
return renderer.getScreen(); |
|
265 |
} |
|
266 |
|
|
267 | 258 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
268 | 259 |
|
269 | 260 |
public static int getDrawableSize() |
src/main/java/org/distorted/tutorials/TutorialObjectLibInterface.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.tutorials; |
21 | 21 |
|
22 |
import org.distorted.library.main.DistortedFramebuffer; |
|
23 |
|
|
24 | 22 |
import org.distorted.objectlib.helpers.ObjectLibInterface; |
25 | 23 |
import org.distorted.objectlib.main.ObjectType; |
26 | 24 |
|
... | ... | |
63 | 61 |
TutorialScreen state = act.getState(); |
64 | 62 |
state.reddenLock(act); |
65 | 63 |
} |
66 |
|
|
67 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
68 |
|
|
69 |
public DistortedFramebuffer getFramebuffer() |
|
70 |
{ |
|
71 |
TutorialActivity act = mAct.get(); |
|
72 |
return act.getScreen(); |
|
73 |
} |
|
74 | 64 |
} |
src/main/java/org/distorted/tutorials/TutorialSurfaceView.java | ||
---|---|---|
29 | 29 |
|
30 | 30 |
import com.google.firebase.crashlytics.FirebaseCrashlytics; |
31 | 31 |
|
32 |
import org.distorted.library.main.DistortedNode; |
|
32 | 33 |
import org.distorted.objectlib.main.ObjectControl; |
33 | 34 |
|
34 | 35 |
import static org.distorted.objectlib.main.ObjectControl.MODE_ROTATE; |
... | ... | |
40 | 41 |
private ObjectControl mObjectController; |
41 | 42 |
private TutorialRenderer mRenderer; |
42 | 43 |
private int mScreenWidth, mScreenHeight; |
44 |
private boolean mCreated; |
|
43 | 45 |
|
44 | 46 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
45 | 47 |
|
... | ... | |
49 | 51 |
mScreenHeight= height; |
50 | 52 |
mObjectController.setScreenSize(width,height); |
51 | 53 |
mObjectController.setMove( (int)(-0.5f*width*TutorialActivity.BAR_RATIO), 0); |
54 |
|
|
55 |
if( !mCreated ) |
|
56 |
{ |
|
57 |
mCreated = true; |
|
58 |
mObjectController.createNode(width,height); |
|
59 |
DistortedNode objectNode = mObjectController.getNode(); |
|
60 |
mRenderer.getScreen().attach(objectNode); |
|
61 |
} |
|
52 | 62 |
} |
53 | 63 |
|
54 | 64 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
58 | 68 |
return mScreenHeight>mScreenWidth; |
59 | 69 |
} |
60 | 70 |
|
61 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
62 |
|
|
63 |
TutorialRenderer getRenderer() |
|
64 |
{ |
|
65 |
return mRenderer; |
|
66 |
} |
|
67 |
|
|
68 | 71 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
69 | 72 |
|
70 | 73 |
ObjectControl getObjectControl() |
... | ... | |
80 | 83 |
{ |
81 | 84 |
super(context,attrs); |
82 | 85 |
|
86 |
mCreated = false; |
|
87 |
|
|
83 | 88 |
if(!isInEditMode()) |
84 | 89 |
{ |
85 | 90 |
TutorialActivity act = (TutorialActivity)context; |
Also available in: Unified diff
Major change: separate the notion of a TwistyObject and its Node. Now,
1) the Node stays when we change objects (this makes transitions faster)
2) it's possible to just create an Object without adding it to the Screen (now app needs to explicitly create the Node and add it to its Screen itself)