Revision 6f2a942e
Added by Leszek Koltunski about 4 years ago
src/main/java/org/distorted/patterns/RubikPattern.java | ||
---|---|---|
154 | 154 |
|
155 | 155 |
private static class Pattern implements RubikPostRender.ActionFinishedListener |
156 | 156 |
{ |
157 |
private String name; |
|
157 |
private String nameStr, moveStr;
|
|
158 | 158 |
private int[][] moves; |
159 | 159 |
private int curMove; |
160 | 160 |
private int numMove; |
161 | 161 |
private boolean mCanRotate; |
162 |
private boolean mInitialized; |
|
162 | 163 |
|
163 | 164 |
///////////////////////////////////////////////////////////// |
164 | 165 |
|
165 | 166 |
Pattern(String n, String m) |
166 | 167 |
{ |
167 |
name=n;
|
|
168 |
moves= movesParser(m);
|
|
169 |
curMove=numMove;
|
|
170 |
mCanRotate = true;
|
|
168 |
nameStr = n;
|
|
169 |
moveStr = m;
|
|
170 |
mCanRotate = true;
|
|
171 |
mInitialized = false;
|
|
171 | 172 |
} |
172 | 173 |
|
173 | 174 |
///////////////////////////////////////////////////////////// |
... | ... | |
175 | 176 |
private int[][] movesParser(String moves) |
176 | 177 |
{ |
177 | 178 |
numMove = moves.length()/4; |
179 |
curMove=numMove; |
|
178 | 180 |
|
179 | 181 |
int digit0, digit1, digit2; |
180 | 182 |
int[][] result = new int[numMove][3]; |
... | ... | |
197 | 199 |
|
198 | 200 |
String getName() |
199 | 201 |
{ |
200 |
return name; |
|
202 |
return nameStr;
|
|
201 | 203 |
} |
202 | 204 |
|
203 | 205 |
///////////////////////////////////////////////////////////// |
204 | 206 |
|
205 | 207 |
int getNumMove() |
206 | 208 |
{ |
209 |
if( !mInitialized ) |
|
210 |
{ |
|
211 |
mInitialized = true; |
|
212 |
moves = movesParser(moveStr); |
|
213 |
moveStr = null; |
|
214 |
} |
|
215 |
|
|
207 | 216 |
return numMove; |
208 | 217 |
} |
209 | 218 |
|
... | ... | |
211 | 220 |
|
212 | 221 |
int getCurMove() |
213 | 222 |
{ |
223 |
if( !mInitialized ) |
|
224 |
{ |
|
225 |
mInitialized = true; |
|
226 |
moves = movesParser(moveStr); |
|
227 |
moveStr = null; |
|
228 |
} |
|
229 |
|
|
214 | 230 |
return curMove; |
215 | 231 |
} |
216 | 232 |
|
... | ... | |
218 | 234 |
|
219 | 235 |
void makeMove(RubikPostRender post) |
220 | 236 |
{ |
237 |
if( !mInitialized ) |
|
238 |
{ |
|
239 |
mInitialized = true; |
|
240 |
moves = movesParser(moveStr); |
|
241 |
moveStr = null; |
|
242 |
} |
|
243 |
|
|
221 | 244 |
curMove++; |
222 | 245 |
RubikObject object = post.getObject(); |
223 | 246 |
|
... | ... | |
252 | 275 |
|
253 | 276 |
void backMove(RubikPostRender post) |
254 | 277 |
{ |
278 |
if( !mInitialized ) |
|
279 |
{ |
|
280 |
mInitialized = true; |
|
281 |
moves = movesParser(moveStr); |
|
282 |
moveStr = null; |
|
283 |
} |
|
284 |
|
|
255 | 285 |
curMove--; |
256 | 286 |
RubikObject object = post.getObject(); |
257 | 287 |
|
... | ... | |
286 | 316 |
|
287 | 317 |
int[][] getMoves() |
288 | 318 |
{ |
319 |
if( !mInitialized ) |
|
320 |
{ |
|
321 |
mInitialized = true; |
|
322 |
moves = movesParser(moveStr); |
|
323 |
moveStr = null; |
|
324 |
} |
|
325 |
|
|
326 |
curMove = numMove; |
|
289 | 327 |
return moves; |
290 | 328 |
} |
291 | 329 |
|
Also available in: Unified diff
Bugfixes for Pretty Patterns