Revision 5a4d4fba
Added by Leszek Koltunski almost 4 years ago
src/main/java/org/distorted/states/RubikStateSolution.java | ||
---|---|---|
31 | 31 |
|
32 | 32 |
import org.distorted.main.R; |
33 | 33 |
import org.distorted.main.RubikActivity; |
34 |
import org.distorted.main.RubikPostRender;
|
|
34 |
import org.distorted.main.RubikPreRender;
|
|
35 | 35 |
import org.distorted.objects.RubikObject; |
36 | 36 |
import org.distorted.patterns.RubikPattern; |
37 | 37 |
|
38 | 38 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
39 | 39 |
|
40 |
public class RubikStateSolution extends RubikStateAbstract implements RubikPostRender.ActionFinishedListener
|
|
40 |
public class RubikStateSolution extends RubikStateAbstract implements RubikPreRender.ActionFinishedListener
|
|
41 | 41 |
{ |
42 | 42 |
private static final int DURATION_MILLIS = 750; |
43 | 43 |
|
... | ... | |
106 | 106 |
@Override |
107 | 107 |
public void onClick(View v) |
108 | 108 |
{ |
109 |
RubikPostRender post = act.getPostRender();
|
|
110 |
backMove(post);
|
|
109 |
RubikPreRender pre = act.getPreRender();
|
|
110 |
backMove(pre);
|
|
111 | 111 |
mMovesText.setText(act.getString(R.string.mo_placeholder,mCurrMove,mNumMoves)); |
112 | 112 |
} |
113 | 113 |
}); |
... | ... | |
129 | 129 |
@Override |
130 | 130 |
public void onClick(View v) |
131 | 131 |
{ |
132 |
RubikPostRender post = act.getPostRender();
|
|
133 |
makeMove(post);
|
|
132 |
RubikPreRender pre = act.getPreRender();
|
|
133 |
makeMove(pre);
|
|
134 | 134 |
mMovesText.setText(act.getString(R.string.mo_placeholder,mCurrMove,mNumMoves)); |
135 | 135 |
} |
136 | 136 |
}); |
... | ... | |
174 | 174 |
|
175 | 175 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
176 | 176 |
|
177 |
private void makeMove(RubikPostRender post)
|
|
177 |
private void makeMove(RubikPreRender pre)
|
|
178 | 178 |
{ |
179 | 179 |
if( mCanRotate ) |
180 | 180 |
{ |
... | ... | |
183 | 183 |
if( mCurrMove>mNumMoves ) |
184 | 184 |
{ |
185 | 185 |
mCurrMove= 0; |
186 |
post.initializeObject(null);
|
|
186 |
pre.initializeObject(null);
|
|
187 | 187 |
} |
188 | 188 |
else |
189 | 189 |
{ |
190 | 190 |
int axis = mMoves[mCurrMove-1][0]; |
191 | 191 |
int rowBitmap= mMoves[mCurrMove-1][1]; |
192 | 192 |
int bareAngle= mMoves[mCurrMove-1][2]; |
193 |
int angle = bareAngle*(360/post.getObject().getBasicAngle());
|
|
193 |
int angle = bareAngle*(360/pre.getObject().getBasicAngle());
|
|
194 | 194 |
int numRot = Math.abs(bareAngle); |
195 | 195 |
|
196 | 196 |
if( angle!=0 ) |
197 | 197 |
{ |
198 | 198 |
mCanRotate = false; |
199 |
post.addRotation(this, axis, rowBitmap, angle, numRot*DURATION_MILLIS);
|
|
199 |
pre.addRotation(this, axis, rowBitmap, angle, numRot*DURATION_MILLIS);
|
|
200 | 200 |
} |
201 | 201 |
else |
202 | 202 |
{ |
... | ... | |
212 | 212 |
|
213 | 213 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
214 | 214 |
|
215 |
private void backMove(RubikPostRender post)
|
|
215 |
private void backMove(RubikPreRender pre)
|
|
216 | 216 |
{ |
217 | 217 |
if( mCanRotate ) |
218 | 218 |
{ |
... | ... | |
221 | 221 |
if( mCurrMove<0 ) |
222 | 222 |
{ |
223 | 223 |
mCurrMove=mNumMoves; |
224 |
post.initializeObject(mMoves);
|
|
224 |
pre.initializeObject(mMoves);
|
|
225 | 225 |
} |
226 | 226 |
else |
227 | 227 |
{ |
228 | 228 |
int axis = mMoves[mCurrMove][0]; |
229 | 229 |
int rowBitmap= mMoves[mCurrMove][1]; |
230 | 230 |
int bareAngle= mMoves[mCurrMove][2]; |
231 |
int angle = bareAngle*(360/post.getObject().getBasicAngle());
|
|
231 |
int angle = bareAngle*(360/pre.getObject().getBasicAngle());
|
|
232 | 232 |
int numRot = Math.abs(bareAngle); |
233 | 233 |
|
234 | 234 |
if( angle!=0 ) |
235 | 235 |
{ |
236 | 236 |
mCanRotate = false; |
237 |
post.addRotation(this, axis, rowBitmap, -angle, numRot*DURATION_MILLIS);
|
|
237 |
pre.addRotation(this, axis, rowBitmap, -angle, numRot*DURATION_MILLIS);
|
|
238 | 238 |
} |
239 | 239 |
else |
240 | 240 |
{ |
Also available in: Unified diff
Convert the PostRender to a PreRender, called before we render.
This makes more sense as this way things are prepared for the very first render.