20 |
20 |
package org.distorted.control;
|
21 |
21 |
|
22 |
22 |
import org.distorted.library.main.DistortedNode;
|
|
23 |
import org.distorted.library.main.DistortedScreen;
|
23 |
24 |
import org.distorted.library.message.EffectListener;
|
24 |
25 |
import org.distorted.main.RubikActivity;
|
25 |
|
import org.distorted.main.RubikPreRender;
|
26 |
|
import org.distorted.objects.TwistyObject;
|
27 |
26 |
|
28 |
27 |
import java.lang.ref.WeakReference;
|
29 |
28 |
|
... | ... | |
39 |
38 |
|
40 |
39 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
41 |
40 |
|
42 |
|
private TwistyObject getObject()
|
|
41 |
private DistortedScreen getScreen()
|
43 |
42 |
{
|
44 |
43 |
RubikActivity act = mRefAct.get();
|
45 |
|
|
46 |
|
if( act!=null )
|
47 |
|
{
|
48 |
|
RubikPreRender pre = act.getPreRender();
|
49 |
|
return pre!=null ? pre.getObject() : null;
|
50 |
|
}
|
51 |
|
|
52 |
|
return null;
|
|
44 |
return act!=null ? act.getScreen() : null;
|
53 |
45 |
}
|
54 |
46 |
|
55 |
47 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
56 |
48 |
|
57 |
49 |
private void addWholeObjects()
|
58 |
50 |
{
|
59 |
|
TwistyObject object = getObject();
|
|
51 |
DistortedScreen screen = getScreen();
|
60 |
52 |
DistortedNode[] nodes = mWhole.getNodes();
|
61 |
53 |
|
62 |
|
if( object!=null && nodes!=null )
|
|
54 |
if( screen!=null && nodes!=null )
|
63 |
55 |
{
|
64 |
|
for (DistortedNode node : nodes) object.attach(node);
|
|
56 |
for (DistortedNode node : nodes) screen.attach(node);
|
65 |
57 |
}
|
66 |
58 |
}
|
67 |
59 |
|
... | ... | |
69 |
61 |
|
70 |
62 |
private void removeWholeObjects()
|
71 |
63 |
{
|
72 |
|
TwistyObject object = getObject();
|
|
64 |
DistortedScreen screen = getScreen();
|
73 |
65 |
DistortedNode[] nodes = mWhole.returnNodes();
|
74 |
66 |
|
75 |
|
if( object!=null && nodes!=null )
|
|
67 |
if( screen!=null && nodes!=null )
|
76 |
68 |
{
|
77 |
|
for (DistortedNode node : nodes) object.detach(node);
|
|
69 |
for (DistortedNode node : nodes) screen.detach(node);
|
78 |
70 |
}
|
79 |
71 |
}
|
80 |
72 |
|
... | ... | |
82 |
74 |
|
83 |
75 |
private void addRotateObjects()
|
84 |
76 |
{
|
85 |
|
TwistyObject object = getObject();
|
|
77 |
DistortedScreen screen = getScreen();
|
86 |
78 |
DistortedNode[] nodes = mRotate.getNodes();
|
87 |
79 |
|
88 |
|
if( object!=null && nodes!=null )
|
|
80 |
if( screen!=null && nodes!=null )
|
89 |
81 |
{
|
90 |
|
for (DistortedNode node : nodes) object.attach(node);
|
|
82 |
for (DistortedNode node : nodes) screen.attach(node);
|
91 |
83 |
}
|
92 |
84 |
}
|
93 |
85 |
|
... | ... | |
95 |
87 |
|
96 |
88 |
private void removeRotateObjects()
|
97 |
89 |
{
|
98 |
|
TwistyObject object = getObject();
|
|
90 |
DistortedScreen screen = getScreen();
|
99 |
91 |
DistortedNode[] nodes = mRotate.returnNodes();
|
100 |
92 |
|
101 |
|
if( object!=null && nodes!=null )
|
|
93 |
if( screen!=null && nodes!=null )
|
102 |
94 |
{
|
103 |
|
for (DistortedNode node : nodes) object.detach(node);
|
|
95 |
for (DistortedNode node : nodes) screen.detach(node);
|
104 |
96 |
}
|
105 |
97 |
}
|
106 |
98 |
|
Attach the control nodes directly to the screen, not to the Object Node.