Revision 302600e5
Added by Leszek Koltunski 9 months ago
| src/main/java/org/distorted/dialogs/DialogPattern.java | ||
|---|---|---|
| 18 | 18 |
import androidx.fragment.app.FragmentActivity; |
| 19 | 19 |
|
| 20 | 20 |
import org.distorted.main.R; |
| 21 |
import org.distorted.objectlib.helpers.ObjectMove; |
|
| 21 | 22 |
import org.distorted.objectlib.main.ObjectControl; |
| 22 | 23 |
import org.distorted.objectlib.patterns.RubikPattern; |
| 23 | 24 |
import org.distorted.objectlib.patterns.RubikPatternList; |
| ... | ... | |
| 110 | 111 |
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) |
| 111 | 112 |
{
|
| 112 | 113 |
RubikPattern pattern = RubikPattern.getInstance(); |
| 113 |
int[][] moves = pattern.reInitialize(mPatternOrdinal, groupPosition, childPosition);
|
|
| 114 |
ObjectMove[] moves = pattern.reInitialize(mPatternOrdinal, groupPosition, childPosition);
|
|
| 114 | 115 |
if( control!=null ) control.initializeObject(moves); |
| 115 | 116 |
|
| 116 | 117 |
ScreenPattern state = (ScreenPattern) ScreenList.PATT.getScreenClass(); |
| src/main/java/org/distorted/patterns/ScreenPattern.java | ||
|---|---|---|
| 21 | 21 |
import org.distorted.helpers.TransparentButton; |
| 22 | 22 |
import org.distorted.helpers.TransparentImageButton; |
| 23 | 23 |
import org.distorted.main.R; |
| 24 |
import org.distorted.objectlib.helpers.ObjectMove; |
|
| 24 | 25 |
import org.distorted.objectlib.main.ObjectControl; |
| 25 | 26 |
import org.distorted.objectlib.patterns.RubikPattern; |
| 26 | 27 |
|
| ... | ... | |
| 315 | 316 |
} |
| 316 | 317 |
} |
| 317 | 318 |
|
| 318 |
int[][] moves = patt.reInitialize(mPatternOrdinal, mCategory, mPattern);
|
|
| 319 |
ObjectMove[] moves = patt.reInitialize(mPatternOrdinal, mCategory, mPattern);
|
|
| 319 | 320 |
ObjectControl control = act.getControl(); |
| 320 | 321 |
if( control!=null ) control.initializeObject(moves); |
| 321 | 322 |
} |
| ... | ... | |
| 345 | 346 |
} |
| 346 | 347 |
} |
| 347 | 348 |
|
| 348 |
int[][] moves = patt.reInitialize(mPatternOrdinal, mCategory, mPattern);
|
|
| 349 |
ObjectMove[] moves = patt.reInitialize(mPatternOrdinal, mCategory, mPattern);
|
|
| 349 | 350 |
ObjectControl control = act.getControl(); |
| 350 | 351 |
if( control!=null ) control.initializeObject(moves); |
| 351 | 352 |
} |
| src/main/java/org/distorted/solvers/ScreenSetupPosition.java | ||
|---|---|---|
| 32 | 32 |
import org.distorted.helpers.TransparentImageButton; |
| 33 | 33 |
import org.distorted.main.MainActivity; |
| 34 | 34 |
import org.distorted.main.R; |
| 35 |
import org.distorted.objectlib.helpers.ObjectMove; |
|
| 35 | 36 |
import org.distorted.objectlib.helpers.OperatingSystemInterface; |
| 36 | 37 |
import org.distorted.objectlib.main.ObjectControl; |
| 37 | 38 |
import org.distorted.objectlib.main.TwistyObject; |
| ... | ... | |
| 535 | 536 |
|
| 536 | 537 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 537 | 538 |
|
| 538 |
public void setSolved(final int[][] moves, final int phaseNumber, final int[][] subphases)
|
|
| 539 |
public void setSolved(final ObjectMove[] moves, final int phaseNumber, final int[][] subphases)
|
|
| 539 | 540 |
{
|
| 540 | 541 |
final SolverActivity act = mWeakAct.get(); |
| 541 | 542 |
|
| src/main/java/org/distorted/solvers/ScreenSolutionMultiphased.java | ||
|---|---|---|
| 27 | 27 |
import org.distorted.library.type.Static4D; |
| 28 | 28 |
import org.distorted.main.R; |
| 29 | 29 |
import org.distorted.objectlib.helpers.MovesFinished; |
| 30 |
import org.distorted.objectlib.helpers.ObjectMove; |
|
| 30 | 31 |
import org.distorted.objectlib.main.ObjectControl; |
| 31 | 32 |
import org.distorted.objectlib.main.TwistyObject; |
| 32 | 33 |
|
| ... | ... | |
| 48 | 49 |
private TextView mMovesText, mMovesPhase; |
| 49 | 50 |
private String[] mPhaseNames; |
| 50 | 51 |
private int mNumPhases; |
| 51 |
private int[][][] mMoves;
|
|
| 52 |
private ObjectMove[][] mMoves;
|
|
| 52 | 53 |
private int[][] mCubitsNotInvolved; |
| 53 | 54 |
private int mNumMoves,mCurrMove,mCurrPhase; |
| 54 | 55 |
private boolean mCanMove; |
| ... | ... | |
| 255 | 256 |
|
| 256 | 257 |
if( mCurrMove>0 ) |
| 257 | 258 |
{
|
| 258 |
int[][] moves = transformMoves(mMoves[mCurrPhase],0,mCurrMove, false);
|
|
| 259 |
ObjectMove[] moves = transformMoves(mMoves[mCurrPhase],0,mCurrMove, false);
|
|
| 259 | 260 |
control.applyScrambles(moves); |
| 260 | 261 |
mCurrMove = 0; |
| 261 | 262 |
} |
| ... | ... | |
| 264 | 265 |
mCurrPhase--; |
| 265 | 266 |
mNumMoves = mMoves[mCurrPhase]==null ? 0 : mMoves[mCurrPhase].length; |
| 266 | 267 |
mCurrMove = 0; |
| 267 |
int[][] moves = transformMoves(mMoves[mCurrPhase],0,mNumMoves, false);
|
|
| 268 |
ObjectMove[] moves = transformMoves(mMoves[mCurrPhase],0,mNumMoves, false);
|
|
| 268 | 269 |
control.applyScrambles(moves); |
| 269 | 270 |
} |
| 270 | 271 |
else |
| ... | ... | |
| 272 | 273 |
mCurrPhase = mNumPhases-1; |
| 273 | 274 |
mNumMoves = mMoves[mCurrPhase]==null ? 0 : mMoves[mCurrPhase].length; |
| 274 | 275 |
mCurrMove = mNumMoves; |
| 275 |
int[][] moves = transformMoves(mMoves, true);
|
|
| 276 |
ObjectMove[] moves = transformMoves(mMoves, true);
|
|
| 276 | 277 |
control.applyScrambles(moves); |
| 277 | 278 |
} |
| 278 | 279 |
|
| ... | ... | |
| 289 | 290 |
if( mCurrPhase<mNumPhases-1 ) |
| 290 | 291 |
{
|
| 291 | 292 |
glowCubits(mCubitsNotInvolved[mCurrPhase]); |
| 292 |
int[][] moves = transformMoves(mMoves[mCurrPhase],mCurrMove,mNumMoves, true);
|
|
| 293 |
ObjectMove[] moves = transformMoves(mMoves[mCurrPhase],mCurrMove,mNumMoves, true);
|
|
| 293 | 294 |
control.applyScrambles(moves); |
| 294 | 295 |
mCurrPhase++; |
| 295 | 296 |
mNumMoves = mMoves[mCurrPhase]==null ? 0 : mMoves[mCurrPhase].length; |
| ... | ... | |
| 298 | 299 |
else if( mCurrMove<mNumMoves ) |
| 299 | 300 |
{
|
| 300 | 301 |
glowCubits(mCubitsNotInvolved[mCurrPhase]); |
| 301 |
int[][] moves = transformMoves(mMoves[mCurrPhase],mCurrMove,mNumMoves, true);
|
|
| 302 |
ObjectMove[] moves = transformMoves(mMoves[mCurrPhase],mCurrMove,mNumMoves, true);
|
|
| 302 | 303 |
control.applyScrambles(moves); |
| 303 | 304 |
mCurrMove = mNumMoves; |
| 304 | 305 |
} |
| ... | ... | |
| 307 | 308 |
mCurrPhase = 0; |
| 308 | 309 |
mNumMoves = mMoves[mCurrPhase]==null ? 0 : mMoves[mCurrPhase].length; |
| 309 | 310 |
mCurrMove = 0; |
| 310 |
int[][] moves = transformMoves(mMoves, false);
|
|
| 311 |
ObjectMove[] moves = transformMoves(mMoves, false);
|
|
| 311 | 312 |
control.applyScrambles(moves); |
| 312 | 313 |
} |
| 313 | 314 |
|
| ... | ... | |
| 344 | 345 |
|
| 345 | 346 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 346 | 347 |
|
| 347 |
private int[][] transformMoves(int[][] moves, int start, int end, boolean front)
|
|
| 348 |
private ObjectMove[] transformMoves(ObjectMove[] moves, int start, int end, boolean front)
|
|
| 348 | 349 |
{
|
| 349 |
int mult = front ? 1:-1; |
|
| 350 | 350 |
int len = end-start; |
| 351 |
int[][] ret = new int[len][];
|
|
| 351 |
ObjectMove[] ret = new ObjectMove[len];
|
|
| 352 | 352 |
|
| 353 | 353 |
for(int m=0; m<len; m++) |
| 354 | 354 |
{
|
| 355 |
int[] mv = moves[front ? start+m : end-1-m]; |
|
| 356 |
int[] rt = new int[3]; |
|
| 357 |
rt[0] = mv[0]; |
|
| 358 |
rt[1] = (1<<mv[1]); |
|
| 359 |
rt[2] = mult*mv[2]; |
|
| 360 |
ret[m] = rt; |
|
| 355 |
ObjectMove mv = moves[front ? start+m : end-1-m]; |
|
| 356 |
ret[m] = new ObjectMove( mv.getAxis(), mv.getRowBitmap(), front ? mv.getAngle() : -mv.getAngle() ); |
|
| 361 | 357 |
} |
| 362 | 358 |
|
| 363 | 359 |
return ret; |
| ... | ... | |
| 365 | 361 |
|
| 366 | 362 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 367 | 363 |
|
| 368 |
private int[][] transformMoves(int[][][] moves, boolean front)
|
|
| 364 |
private ObjectMove[] transformMoves(ObjectMove[][] moves, boolean front)
|
|
| 369 | 365 |
{
|
| 370 | 366 |
int len = moves.length; |
| 371 | 367 |
int totalLen = 0; |
| 372 |
for (int[][] move : moves) totalLen += (move==null ? 0 : move.length);
|
|
| 368 |
for( ObjectMove[] move : moves ) totalLen += (move==null ? 0 : move.length);
|
|
| 373 | 369 |
|
| 374 |
int[][] ret = new int[totalLen][]; |
|
| 375 |
int mult = front ? 1:-1; |
|
| 370 |
ObjectMove[] ret = new ObjectMove[totalLen]; |
|
| 376 | 371 |
int index = 0; |
| 377 | 372 |
|
| 378 | 373 |
for(int m=0; m<len; m++) |
| 379 | 374 |
{
|
| 380 |
int[][] mv = moves[front ? m : len-1-m];
|
|
| 375 |
ObjectMove[] mv = moves[front ? m : len-1-m];
|
|
| 381 | 376 |
int l = (mv==null ? 0 : mv.length); |
| 382 | 377 |
|
| 383 | 378 |
for(int p=0; p<l; p++) |
| 384 | 379 |
{
|
| 385 |
int[] mve = mv[front ? p : l-1-p]; |
|
| 386 |
int[] rt = new int[3]; |
|
| 387 |
rt[0] = mve[0]; |
|
| 388 |
rt[1] = (1<<mve[1]); |
|
| 389 |
rt[2] = mult*mve[2]; |
|
| 390 |
ret[index++] = rt; |
|
| 380 |
ObjectMove mve = mv[front ? p : l-1-p]; |
|
| 381 |
ret[index++] = new ObjectMove( mve.getAxis(), mve.getRowBitmap(), front ? mve.getAngle() : -mve.getAngle() ); |
|
| 391 | 382 |
} |
| 392 | 383 |
} |
| 393 | 384 |
|
| ... | ... | |
| 451 | 442 |
if( mCurrMove>0 ) |
| 452 | 443 |
{
|
| 453 | 444 |
mCanMove = false; |
| 454 |
int[] move = mMoves[mCurrPhase][--mCurrMove];
|
|
| 445 |
ObjectMove move = mMoves[mCurrPhase][--mCurrMove];
|
|
| 455 | 446 |
ObjectControl control = act.getControl(); |
| 456 | 447 |
control.blockTouch(MOVES_PLACE_0); |
| 457 |
control.addRotation(this, move[0], (1<<move[1]), -move[2], MILLIS_PER_DEGREE);
|
|
| 448 |
control.addRotation(this, move.getAxis(), move.getRowBitmap(), -move.getAngle(), MILLIS_PER_DEGREE);
|
|
| 458 | 449 |
} |
| 459 | 450 |
else if( mCurrPhase>0 ) |
| 460 | 451 |
{
|
| ... | ... | |
| 468 | 459 |
mCurrPhase = mNumPhases-1; |
| 469 | 460 |
mNumMoves = mMoves[mCurrPhase]==null ? 0 : mMoves[mCurrPhase].length; |
| 470 | 461 |
mCurrMove = mNumMoves; |
| 471 |
int[][] moves = transformMoves(mMoves, true);
|
|
| 462 |
ObjectMove[] moves = transformMoves(mMoves, true);
|
|
| 472 | 463 |
ObjectControl control = act.getControl(); |
| 473 | 464 |
control.applyScrambles(moves); |
| 474 | 465 |
glowCubits(mCubitsNotInvolved[mCurrPhase]); |
| ... | ... | |
| 489 | 480 |
if( mCurrMove<mNumMoves ) |
| 490 | 481 |
{
|
| 491 | 482 |
mCanMove = false; |
| 492 |
int[] move = mMoves[mCurrPhase][mCurrMove++];
|
|
| 483 |
ObjectMove move = mMoves[mCurrPhase][mCurrMove++];
|
|
| 493 | 484 |
ObjectControl control = act.getControl(); |
| 494 | 485 |
control.blockTouch(MOVES_PLACE_1); |
| 495 |
control.addRotation(this, move[0], (1<<move[1]), move[2], MILLIS_PER_DEGREE);
|
|
| 486 |
control.addRotation(this, move.getAxis(), move.getRowBitmap(), move.getAngle(), MILLIS_PER_DEGREE);
|
|
| 496 | 487 |
if( mCurrMove==mNumMoves && mCurrPhase==mNumPhases-1 ) glowCubits(mCubitsNotInvolved[mCurrPhase]); |
| 497 | 488 |
} |
| 498 | 489 |
else if( mCurrPhase<mNumPhases-1 ) |
| ... | ... | |
| 507 | 498 |
mCurrPhase = 0; |
| 508 | 499 |
mNumMoves = mMoves[mCurrPhase]==null ? 0 : mMoves[mCurrPhase].length; |
| 509 | 500 |
mCurrMove = 0; |
| 510 |
int[][] moves = transformMoves(mMoves, false);
|
|
| 501 |
ObjectMove[] moves = transformMoves(mMoves, false);
|
|
| 511 | 502 |
ObjectControl control = act.getControl(); |
| 512 | 503 |
control.applyScrambles(moves); |
| 513 | 504 |
} |
| ... | ... | |
| 522 | 513 |
{
|
| 523 | 514 |
mPhaseNames = names; |
| 524 | 515 |
mNumPhases = names.length; |
| 525 |
mMoves = new int[mNumPhases][][];
|
|
| 516 |
mMoves = new ObjectMove[mNumPhases][];
|
|
| 526 | 517 |
mCubitsNotInvolved = new int[mNumPhases][]; |
| 527 | 518 |
mCanMove = true; |
| 528 | 519 |
if( mAct!=null ) setSolution(null,0,null); |
| ... | ... | |
| 530 | 521 |
|
| 531 | 522 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 532 | 523 |
|
| 533 |
public void setSolution(int[][] moves, int phase, int[][] subphases)
|
|
| 524 |
public void setSolution(ObjectMove[] moves, int phase, int[][] subphases)
|
|
| 534 | 525 |
{
|
| 535 | 526 |
SolverActivity act=mAct.get(); |
| 536 | 527 |
|
| src/main/java/org/distorted/solvers/ScreenSolutionSinglephased.java | ||
|---|---|---|
| 20 | 20 |
import org.distorted.helpers.TransparentImageButton; |
| 21 | 21 |
import org.distorted.main.R; |
| 22 | 22 |
import org.distorted.objectlib.helpers.MovesFinished; |
| 23 |
import org.distorted.objectlib.helpers.ObjectMove; |
|
| 23 | 24 |
import org.distorted.objectlib.main.ObjectControl; |
| 24 | 25 |
|
| 25 | 26 |
import java.lang.ref.WeakReference; |
| ... | ... | |
| 32 | 33 |
|
| 33 | 34 |
private TransparentImageButton mPrevButton, mNextButton, mBackButton; |
| 34 | 35 |
private TextView mMovesText; |
| 35 |
private int[][] mMoves;
|
|
| 36 |
private ObjectMove[] mMoves;
|
|
| 36 | 37 |
private int mCurrMove, mNumMoves; |
| 37 | 38 |
private boolean mCanRotate; |
| 38 | 39 |
private float mButtonSize; |
| ... | ... | |
| 190 | 191 |
} |
| 191 | 192 |
else |
| 192 | 193 |
{
|
| 193 |
int axis = mMoves[mCurrMove-1][0];
|
|
| 194 |
int rowBitmap = mMoves[mCurrMove-1][1];
|
|
| 195 |
int bareAngle = mMoves[mCurrMove-1][2];
|
|
| 194 |
int axis = mMoves[mCurrMove-1].getAxis();
|
|
| 195 |
int rowBitmap = mMoves[mCurrMove-1].getRowBitmap();
|
|
| 196 |
int bareAngle = mMoves[mCurrMove-1].getAngle();
|
|
| 196 | 197 |
|
| 197 | 198 |
if( bareAngle!=0 ) |
| 198 | 199 |
{
|
| ... | ... | |
| 226 | 227 |
} |
| 227 | 228 |
else |
| 228 | 229 |
{
|
| 229 |
int axis = mMoves[mCurrMove][0];
|
|
| 230 |
int rowBitmap = mMoves[mCurrMove][1];
|
|
| 231 |
int bareAngle = mMoves[mCurrMove][2];
|
|
| 230 |
int axis = mMoves[mCurrMove].getAxis();
|
|
| 231 |
int rowBitmap = mMoves[mCurrMove].getRowBitmap();
|
|
| 232 |
int bareAngle = mMoves[mCurrMove].getAngle();
|
|
| 232 | 233 |
|
| 233 | 234 |
if( bareAngle!=0 ) |
| 234 | 235 |
{
|
| ... | ... | |
| 249 | 250 |
|
| 250 | 251 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 251 | 252 |
|
| 252 |
void setSolution(int[][] moves)
|
|
| 253 |
void setSolution(ObjectMove[] moves)
|
|
| 253 | 254 |
{
|
| 254 | 255 |
mCanRotate= true; |
| 255 | 256 |
mCurrMove = 0; |
Also available in: Unified diff
compiles now