Revision 50bb18a1
Added by Leszek Koltunski 8 days ago
src/main/java/org/distorted/dialogs/DialogInterrupt.java | ||
---|---|---|
1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
2 |
// Copyright 2020 Leszek Koltunski // |
|
3 |
// // |
|
4 |
// This file is part of Magic Cube. // |
|
5 |
// // |
|
6 |
// Magic Cube is proprietary software licensed under an EULA which you should have received // |
|
7 |
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html // |
|
8 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
9 |
|
|
10 |
package org.distorted.dialogs; |
|
11 |
|
|
12 |
import android.app.Dialog; |
|
13 |
import android.view.View; |
|
14 |
import android.widget.TextView; |
|
15 |
|
|
16 |
import androidx.fragment.app.FragmentActivity; |
|
17 |
|
|
18 |
import org.distorted.main.R; |
|
19 |
import org.distorted.solvers.SolverActivity; |
|
20 |
|
|
21 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
22 |
|
|
23 |
public class DialogInterrupt extends DialogAbstract |
|
24 |
{ |
|
25 |
public int getResource() { return R.layout.dialog_message; } |
|
26 |
public int getTitleResource() { return -1; } |
|
27 |
public boolean hasArgument() { return false; } |
|
28 |
public int getPositive() { return R.string.interrupt; } |
|
29 |
public int getNegative() { return -1; } |
|
30 |
public void negativeAction() { } |
|
31 |
public static String getDialogTag() { return "DialogInterrupt"; } |
|
32 |
|
|
33 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
34 |
|
|
35 |
public void positiveAction() |
|
36 |
{ |
|
37 |
final SolverActivity act = (SolverActivity)getContext(); |
|
38 |
if( act!=null ) act.interruptSolve(); |
|
39 |
} |
|
40 |
|
|
41 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
42 |
|
|
43 |
public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size) |
|
44 |
{ |
|
45 |
TextView mess = view.findViewById(R.id.dialog_message); |
|
46 |
mess.setText(R.string.solving); |
|
47 |
} |
|
48 |
} |
src/main/java/org/distorted/dialogs/DialogMessage.java | ||
---|---|---|
21 | 21 |
|
22 | 22 |
public class DialogMessage extends DialogAbstract |
23 | 23 |
{ |
24 |
public int getResource() { return R.layout.dialog_message; } |
|
25 |
public int getTitleResource() { return -1; } |
|
26 |
public boolean hasArgument() { return true; } |
|
27 |
public int getPositive() { return R.string.ok; } |
|
28 |
public int getNegative() { return -1; } |
|
29 |
public void negativeAction() { } |
|
30 |
public void positiveAction() { } |
|
24 |
public int getResource() { return R.layout.dialog_message; } |
|
25 |
public int getTitleResource() { return -1; } |
|
26 |
public boolean hasArgument() { return true; } |
|
27 |
public int getPositive() { return R.string.ok; } |
|
28 |
public int getNegative() { return -1; } |
|
29 |
public void negativeAction() { } |
|
30 |
public void positiveAction() { } |
|
31 |
public static String getDialogTag() { return "DialogBandageMessage"; } |
|
31 | 32 |
|
32 | 33 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
33 | 34 |
|
... | ... | |
37 | 38 |
mess.setText(mArgument); |
38 | 39 |
} |
39 | 40 |
|
40 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
41 |
|
|
42 |
public static String getDialogTag() |
|
43 |
{ |
|
44 |
return "DialogBandageMessage"; |
|
45 |
} |
|
46 | 41 |
} |
src/main/java/org/distorted/dialogs/DialogSolverView.java | ||
---|---|---|
63 | 63 |
|
64 | 64 |
if( solver!=null ) |
65 | 65 |
{ |
66 |
act.setSolver(solver); |
|
66 | 67 |
int[] result = solver.validatePosition(object); |
67 | 68 |
if( result[0]>=0 ) solver.solve(screen,result); |
68 | 69 |
else screen.displayImpossibleDialog(result,solver.getFaceColors()); |
src/main/java/org/distorted/solvers/ScreenSetupPosition.java | ||
---|---|---|
10 | 10 |
package org.distorted.solvers; |
11 | 11 |
|
12 | 12 |
import static org.distorted.objectlib.metadata.ListObjects.*; |
13 |
import static org.distorted.objectlib.solvers.verifiers.SolverTablebase.*; |
|
14 | 13 |
|
15 | 14 |
import android.content.SharedPreferences; |
16 |
import android.content.res.Resources; |
|
17 | 15 |
import android.graphics.Bitmap; |
18 | 16 |
import android.graphics.Canvas; |
19 | 17 |
import android.graphics.Paint; |
... | ... | |
25 | 23 |
import android.widget.LinearLayout; |
26 | 24 |
|
27 | 25 |
import androidx.core.content.ContextCompat; |
26 |
import androidx.fragment.app.FragmentManager; |
|
28 | 27 |
|
28 |
import org.distorted.dialogs.DialogInterrupt; |
|
29 | 29 |
import org.distorted.dialogs.DialogSolverError; |
30 | 30 |
import org.distorted.dialogs.DialogSolverImpossible; |
31 | 31 |
import org.distorted.dialogs.DialogSolvers; |
... | ... | |
42 | 42 |
import org.distorted.objectlib.solvers.verifiers.SolvingList; |
43 | 43 |
|
44 | 44 |
import java.lang.ref.WeakReference; |
45 |
import java.util.Timer; |
|
46 |
import java.util.TimerTask; |
|
45 | 47 |
|
46 | 48 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
47 | 49 |
|
... | ... | |
51 | 53 |
private static final int MODE_NORMAL = 0; |
52 | 54 |
private static final int MODE_DINO_4 = 1; |
53 | 55 |
|
54 |
private static final int[][] colorsHex = |
|
55 |
{ |
|
56 |
{R.string.color_yellow1,R.string.color_yellow2,R.string.color_yellow3,R.string.color_yellow4,R.string.color_yellow5,R.string.color_yellow6,R.string.color_yellow7 }, |
|
57 |
{R.string.color_white1 ,R.string.color_white2 ,R.string.color_white3 ,R.string.color_white4 ,R.string.color_white5 ,R.string.color_white6 ,R.string.color_white7 }, |
|
58 |
{R.string.color_blue1 ,R.string.color_blue2 ,R.string.color_blue3 ,R.string.color_blue4 ,R.string.color_blue5 ,R.string.color_blue6 ,R.string.color_blue7 }, |
|
59 |
{R.string.color_green1 ,R.string.color_green2 ,R.string.color_green3 ,R.string.color_green4 ,R.string.color_green5 ,R.string.color_green6 ,R.string.color_green7 }, |
|
60 |
{R.string.color_red1 ,R.string.color_red2 ,R.string.color_red3 ,R.string.color_red4 ,R.string.color_red5 ,R.string.color_red6 ,R.string.color_red7 }, |
|
61 |
{R.string.color_orange1,R.string.color_orange2,R.string.color_orange3,R.string.color_orange4,R.string.color_orange5,R.string.color_orange6,R.string.color_orange7 }, |
|
62 |
}; |
|
63 |
private static final int[][] colorsTet = |
|
64 |
{ |
|
65 |
{R.string.color_green1 ,R.string.color_green2 ,R.string.color_green3 ,R.string.color_green4 ,R.string.color_green5 ,R.string.color_green6 ,R.string.color_green7 }, |
|
66 |
{R.string.color_yellow1,R.string.color_yellow2,R.string.color_yellow3,R.string.color_yellow4,R.string.color_yellow5,R.string.color_yellow6,R.string.color_yellow7 }, |
|
67 |
{R.string.color_blue1 ,R.string.color_blue2 ,R.string.color_blue3 ,R.string.color_blue4 ,R.string.color_blue5 ,R.string.color_blue6 ,R.string.color_blue7 }, |
|
68 |
{R.string.color_red1 ,R.string.color_red2 ,R.string.color_red3 ,R.string.color_red4 ,R.string.color_red5 ,R.string.color_red6 ,R.string.color_red7 }, |
|
69 |
}; |
|
70 |
private static final int[][] colorsOct = |
|
71 |
{ |
|
72 |
{R.string.color_violet1,R.string.color_violet2,R.string.color_violet3,R.string.color_violet4,R.string.color_violet5,R.string.color_violet6,R.string.color_violet7 }, |
|
73 |
{R.string.color_grey1 ,R.string.color_grey2 ,R.string.color_grey3 ,R.string.color_grey4 ,R.string.color_grey5 ,R.string.color_grey6 ,R.string.color_grey7 }, |
|
74 |
{R.string.color_blue1 ,R.string.color_blue2 ,R.string.color_blue3 ,R.string.color_blue4 ,R.string.color_blue5 ,R.string.color_blue6 ,R.string.color_blue7 }, |
|
75 |
{R.string.color_red1 ,R.string.color_red2 ,R.string.color_red3 ,R.string.color_red4 ,R.string.color_red5 ,R.string.color_red6 ,R.string.color_red7 }, |
|
76 |
{R.string.color_orange1,R.string.color_orange2,R.string.color_orange3,R.string.color_orange4,R.string.color_orange5,R.string.color_orange6,R.string.color_orange7 }, |
|
77 |
{R.string.color_green1 ,R.string.color_green2 ,R.string.color_green3 ,R.string.color_green4 ,R.string.color_green5 ,R.string.color_green6 ,R.string.color_green7 }, |
|
78 |
{R.string.color_white1 ,R.string.color_white2 ,R.string.color_white3 ,R.string.color_white4 ,R.string.color_white5 ,R.string.color_white6 ,R.string.color_white7 }, |
|
79 |
{R.string.color_yellow1,R.string.color_yellow2,R.string.color_yellow3,R.string.color_yellow4,R.string.color_yellow5,R.string.color_yellow6,R.string.color_yellow7 }, |
|
80 |
}; |
|
81 |
private static final int[][] colorsDi4 = |
|
82 |
{ |
|
83 |
{R.string.color_yellow1,R.string.color_yellow2,R.string.color_yellow3,R.string.color_yellow4,R.string.color_yellow5,R.string.color_yellow6,R.string.color_yellow7 }, |
|
84 |
{R.string.color_white1 ,R.string.color_white2 ,R.string.color_white3 ,R.string.color_white4 ,R.string.color_white5 ,R.string.color_white6 ,R.string.color_white7 }, |
|
85 |
{R.string.color_blue1 ,R.string.color_blue2 ,R.string.color_blue3 ,R.string.color_blue4 ,R.string.color_blue5 ,R.string.color_blue6 ,R.string.color_blue7 }, |
|
86 |
{R.string.color_red1 ,R.string.color_red2 ,R.string.color_red3 ,R.string.color_red4 ,R.string.color_red5 ,R.string.color_red6 ,R.string.color_red7 }, |
|
87 |
}; |
|
88 |
|
|
89 | 56 |
private static Bitmap[] mBitmap; |
90 | 57 |
private ImageButton[] mColorButton; |
91 | 58 |
private TransparentImageButton mResetButton,mBackButton, mSolveButton; |
... | ... | |
99 | 66 |
private WeakReference<SolverActivity> mWeakAct; |
100 | 67 |
private int mObjectOrdinal; |
101 | 68 |
private String[] mPhaseNames; |
69 |
private Timer mTimer; |
|
70 |
private SolverAbstract mSolver; |
|
102 | 71 |
|
103 | 72 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
104 | 73 |
|
... | ... | |
320 | 289 |
|
321 | 290 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
322 | 291 |
|
323 |
private boolean pressSolve(SolverActivity act)
|
|
292 |
private void pressSolve(SolverActivity act)
|
|
324 | 293 |
{ |
325 | 294 |
int[] solverOrdinals = SolvingList.getSolverOrdinals(mObjectOrdinal); |
326 | 295 |
|
... | ... | |
339 | 308 |
{ |
340 | 309 |
if( solverOrdinals.length==1 ) // just one solver - simply launch it |
341 | 310 |
{ |
311 |
mSolver = solver; |
|
342 | 312 |
solver.solve(this,result); |
343 |
return true; |
|
344 | 313 |
} |
345 | 314 |
else // more than one solver - pop up a choosing dialog |
346 | 315 |
{ |
... | ... | |
348 | 317 |
String upperName = objList.name(); |
349 | 318 |
Bundle bundle = new Bundle(); |
350 | 319 |
bundle.putString("argument", upperName ); |
351 |
DialogSolvers solv = new DialogSolvers(); |
|
352 |
solv.setArguments(bundle); |
|
353 |
solv.show( act.getSupportFragmentManager(), DialogSolvers.getDialogTag()); |
|
354 |
return false; |
|
320 |
DialogSolvers dialog = new DialogSolvers(); |
|
321 |
dialog.setArguments(bundle); |
|
322 |
dialog.show( act.getSupportFragmentManager(), DialogSolvers.getDialogTag()); |
|
355 | 323 |
} |
356 | 324 |
} |
357 |
else |
|
358 |
{ |
|
359 |
displayImpossibleDialog(result,solver.getFaceColors()); |
|
360 |
return false; |
|
361 |
} |
|
362 |
} |
|
363 |
else |
|
364 |
{ |
|
365 |
displayErrorDialog(act.getString(R.string.solver_generic_not_implemented)); |
|
366 |
return false; |
|
325 |
else displayImpossibleDialog(result,solver.getFaceColors()); |
|
367 | 326 |
} |
327 |
else displayErrorDialog(act.getString(R.string.solver_generic_not_implemented)); |
|
368 | 328 |
} |
369 |
else // no solvers? Impossible! |
|
370 |
{ |
|
371 |
displayErrorDialog("No solvers found for object "+mObjectOrdinal); |
|
372 |
return false; |
|
373 |
} |
|
329 |
else displayErrorDialog("No solvers found for object "+mObjectOrdinal); |
|
374 | 330 |
} |
375 | 331 |
|
376 | 332 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
378 | 334 |
public void fail(String result) {} |
379 | 335 |
public void setPhaseNames(String[] names) { mPhaseNames = names; } |
380 | 336 |
|
337 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
338 |
|
|
339 |
void setSolver(SolverAbstract solver ) |
|
340 |
{ |
|
341 |
mSolver = solver; |
|
342 |
} |
|
343 |
|
|
381 | 344 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
382 | 345 |
|
383 | 346 |
public void startedSolving() |
384 | 347 |
{ |
348 |
if( !mSolving ) |
|
349 |
{ |
|
350 |
mSolving = true; |
|
351 |
mTimer = new Timer(); |
|
385 | 352 |
|
353 |
mTimer.schedule(new TimerTask() |
|
354 |
{ |
|
355 |
@Override |
|
356 |
public void run() |
|
357 |
{ |
|
358 |
if( mSolving ) showInterruptDialog(); |
|
359 |
} |
|
360 |
}, 2000); |
|
361 |
} |
|
386 | 362 |
} |
387 | 363 |
|
388 | 364 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
389 | 365 |
|
390 | 366 |
public void stoppedSolving() |
391 | 367 |
{ |
368 |
mSolving = false; |
|
369 |
|
|
370 |
if( mTimer!=null ) |
|
371 |
{ |
|
372 |
mTimer.cancel(); |
|
373 |
mTimer = null; |
|
374 |
} |
|
392 | 375 |
|
376 |
final SolverActivity act = mWeakAct.get(); |
|
377 |
FragmentManager mana = act.getSupportFragmentManager(); |
|
378 |
DialogInterrupt diag = (DialogInterrupt) mana.findFragmentByTag(DialogInterrupt.getDialogTag()); |
|
379 |
|
|
380 |
if( diag!=null ) diag.dismiss(); |
|
393 | 381 |
} |
394 | 382 |
|
383 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
384 |
|
|
385 |
void interrupt() |
|
386 |
{ |
|
387 |
final SolverActivity act = mWeakAct.get(); |
|
388 |
FragmentManager mana = act.getSupportFragmentManager(); |
|
389 |
DialogInterrupt diag = (DialogInterrupt) mana.findFragmentByTag(DialogInterrupt.getDialogTag()); |
|
390 |
|
|
391 |
if( diag!=null ) diag.dismiss(); |
|
392 |
|
|
393 |
if( mSolver!=null ) mSolver.interrupt(); |
|
394 |
} |
|
395 |
|
|
396 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
397 |
|
|
398 |
private void showInterruptDialog() |
|
399 |
{ |
|
400 |
final SolverActivity act = mWeakAct.get(); |
|
401 |
|
|
402 |
act.runOnUiThread(new Runnable() |
|
403 |
{ |
|
404 |
@Override |
|
405 |
public void run() |
|
406 |
{ |
|
407 |
DialogInterrupt dialog = new DialogInterrupt(); |
|
408 |
dialog.show(act.getSupportFragmentManager(), null ); |
|
409 |
} |
|
410 |
}); |
|
411 |
} |
|
412 |
|
|
395 | 413 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
396 | 414 |
|
397 | 415 |
private void setupColorButtons(final SolverActivity act) |
... | ... | |
450 | 468 |
@Override |
451 | 469 |
public void onClick(View v) |
452 | 470 |
{ |
453 |
if( !mSolving && pressSolve(act) ) mSolving = true;
|
|
471 |
if( !mSolving ) pressSolve(act);
|
|
454 | 472 |
} |
455 | 473 |
}); |
456 | 474 |
} |
... | ... | |
515 | 533 |
return mCurrentColor; |
516 | 534 |
} |
517 | 535 |
|
518 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
519 |
|
|
520 |
public void setSolved(final String moves) |
|
521 |
{ |
|
522 |
mSolving = false; |
|
523 |
final SolverActivity act = mWeakAct.get(); |
|
524 |
|
|
525 |
if( act!=null ) |
|
526 |
{ |
|
527 |
act.runOnUiThread(new Runnable() |
|
528 |
{ |
|
529 |
@Override |
|
530 |
public void run() |
|
531 |
{ |
|
532 |
ScreenList.switchScreen(act, ScreenList.SOLU); |
|
533 |
ScreenSolutionSinglephased solution = (ScreenSolutionSinglephased) ScreenList.SOLU.getScreenClass(); |
|
534 |
solution.setSolution(moves); |
|
535 |
if( !moves.isEmpty() ) act.doNotShowDialogAnymore(); |
|
536 |
} |
|
537 |
}); |
|
538 |
} |
|
539 |
} |
|
540 |
|
|
541 | 536 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
542 | 537 |
|
543 | 538 |
public void setSolved(final int[][] moves, final int phaseNumber, final int[][] subphases) |
544 | 539 |
{ |
545 |
mSolving = false; |
|
546 | 540 |
final SolverActivity act = mWeakAct.get(); |
547 | 541 |
|
548 | 542 |
if( act!=null ) |
... | ... | |
579 | 573 |
|
580 | 574 |
public void displayErrorDialog(String message) |
581 | 575 |
{ |
582 |
mSolving = false; |
|
583 | 576 |
SolverActivity act = mWeakAct.get(); |
584 | 577 |
|
585 | 578 |
if( act!=null ) |
... | ... | |
596 | 589 |
|
597 | 590 |
public void displayImpossibleDialog(String message) |
598 | 591 |
{ |
599 |
mSolving = false; |
|
600 | 592 |
SolverActivity act = mWeakAct.get(); |
601 | 593 |
|
602 | 594 |
if( act!=null ) |
... | ... | |
613 | 605 |
|
614 | 606 |
public void displayImpossibleDialog(int[] errorCode, int[] faceColors) |
615 | 607 |
{ |
616 |
mSolving = false; |
|
617 | 608 |
SolverActivity act = mWeakAct.get(); |
618 | 609 |
|
619 | 610 |
if( act!=null ) |
620 | 611 |
{ |
621 |
String message = error(act.getResources(),errorCode,faceColors); |
|
612 |
String message = SolverErrors.error(act.getResources(),errorCode,faceColors);
|
|
622 | 613 |
displayImpossibleDialog(message); |
623 | 614 |
} |
624 | 615 |
} |
625 |
|
|
626 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
627 |
|
|
628 |
int getHexColor(int color,int variant) { return colorsHex[color][variant]; } |
|
629 |
int getTetColor(int color,int variant) { return colorsTet[color][variant]; } |
|
630 |
int getOctColor(int color,int variant) { return colorsOct[color][variant]; } |
|
631 |
int getDi4Color(int color,int variant) { return colorsDi4[color][variant]; } |
|
632 |
|
|
633 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
634 |
|
|
635 |
String hexCornerMissingError(Resources res, int face0, int face1, int face2) |
|
636 |
{ |
|
637 |
int j0 = getHexColor(face0,3); |
|
638 |
int j1 = getHexColor(face1,3); |
|
639 |
int j2 = getHexColor(face2,4); |
|
640 |
|
|
641 |
String c0 = res.getString(j0); |
|
642 |
String c1 = res.getString(j1); |
|
643 |
String c2 = res.getString(j2); |
|
644 |
|
|
645 |
return res.getString(R.string.solver_generic_missing_corner,c0,c1,c2); |
|
646 |
} |
|
647 |
|
|
648 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
649 |
|
|
650 |
String hexCenterMissingError(Resources res, int face) |
|
651 |
{ |
|
652 |
int color = getHexColor(face,2); |
|
653 |
String clr= res.getString(color); |
|
654 |
return res.getString(R.string.solver_generic_missing_center,clr); |
|
655 |
} |
|
656 |
|
|
657 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
658 |
|
|
659 |
String hexEdgeMissingError(Resources res, int face0, int face1) |
|
660 |
{ |
|
661 |
int j0 = getHexColor(face0,3); |
|
662 |
int j1 = getHexColor(face1,6); |
|
663 |
|
|
664 |
String c0 = res.getString(j0); |
|
665 |
String c1 = res.getString(j1); |
|
666 |
|
|
667 |
return res.getString(R.string.solver_generic_missing_edge,c0,c1); |
|
668 |
} |
|
669 |
|
|
670 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
671 |
|
|
672 |
String hexEdgeTwistedError(Resources res, int color0, int color1) |
|
673 |
{ |
|
674 |
int j0 = getHexColor(color0,3); |
|
675 |
int j1 = getHexColor(color1,6); |
|
676 |
|
|
677 |
String c0 = res.getString(j0); |
|
678 |
String c1 = res.getString(j1); |
|
679 |
|
|
680 |
return res.getString(R.string.solver_generic_twisted_edge,c0,c1); |
|
681 |
} |
|
682 |
|
|
683 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
684 |
|
|
685 |
String hexCornerTwistedError(Resources res, int color0, int color1, int color2) |
|
686 |
{ |
|
687 |
int j0 = getHexColor(color0,3); |
|
688 |
int j1 = getHexColor(color1,3); |
|
689 |
int j2 = getHexColor(color2,5); |
|
690 |
|
|
691 |
String c0 = res.getString(j0); |
|
692 |
String c1 = res.getString(j1); |
|
693 |
String c2 = res.getString(j2); |
|
694 |
|
|
695 |
return res.getString(R.string.solver_generic_twisted_corner,c0,c1,c2); |
|
696 |
} |
|
697 |
|
|
698 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
699 |
|
|
700 |
String hexEdgeMonoError(Resources res, int color) |
|
701 |
{ |
|
702 |
int j0 = getHexColor(color,3); |
|
703 |
int j1 = getHexColor(color,6); |
|
704 |
String c0 = res.getString(j0); |
|
705 |
String c1 = res.getString(j1); |
|
706 |
|
|
707 |
return res.getString(R.string.solver_generic_edge_mono,c0,c1); |
|
708 |
} |
|
709 |
|
|
710 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
711 |
|
|
712 |
String hexEdgeTwiceError(Resources res, int color0, int color1) |
|
713 |
{ |
|
714 |
int j0 = getHexColor(color0,3); |
|
715 |
int j1 = getHexColor(color1,6); |
|
716 |
String c0 = res.getString(j0); |
|
717 |
String c1 = res.getString(j1); |
|
718 |
|
|
719 |
return res.getString(R.string.solver_generic_edge_twice,c0,c1); |
|
720 |
} |
|
721 |
|
|
722 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
723 |
|
|
724 |
String octCenterMissingError(Resources res, int face) |
|
725 |
{ |
|
726 |
int index = getOctColor(face,2); |
|
727 |
String color = res.getString(index); |
|
728 |
return res.getString(R.string.solver_generic_missing_center,color); |
|
729 |
} |
|
730 |
|
|
731 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
732 |
|
|
733 |
String octCornerMissingError(Resources res, int f1, int f2) |
|
734 |
{ |
|
735 |
int i1 = getOctColor(f1,3); |
|
736 |
int i2 = getOctColor(f2,4); |
|
737 |
String c1 = res.getString(i1); |
|
738 |
String c2 = res.getString(i2); |
|
739 |
return res.getString(R.string.solver_generic_missing_corner2,c1,c2); |
|
740 |
} |
|
741 |
|
|
742 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
743 |
|
|
744 |
String tetCornerMissingError(Resources res, int color0, int color1, int color2) |
|
745 |
{ |
|
746 |
int j0 = getTetColor(color0,3); |
|
747 |
int j1 = getTetColor(color1,3); |
|
748 |
int j2 = getTetColor(color2,4); |
|
749 |
|
|
750 |
String c0 = res.getString(j0); |
|
751 |
String c1 = res.getString(j1); |
|
752 |
String c2 = res.getString(j2); |
|
753 |
|
|
754 |
return res.getString(R.string.solver_generic_missing_corner,c0,c1,c2); |
|
755 |
} |
|
756 |
|
|
757 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
758 |
|
|
759 |
String tetEdgeMissingError(Resources res, int face0, int face1) |
|
760 |
{ |
|
761 |
int j0 = getTetColor(face0,3); |
|
762 |
int j1 = getTetColor(face1,6); |
|
763 |
|
|
764 |
String c0 = res.getString(j0); |
|
765 |
String c1 = res.getString(j1); |
|
766 |
|
|
767 |
return res.getString(R.string.solver_generic_missing_edge,c0,c1); |
|
768 |
} |
|
769 |
|
|
770 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
771 |
|
|
772 |
String tetCenterMissingError(Resources res, int face) |
|
773 |
{ |
|
774 |
int j = getTetColor(face,2); |
|
775 |
String c = res.getString(j); |
|
776 |
return res.getString(R.string.solver_generic_missing_center,c); |
|
777 |
} |
|
778 |
|
|
779 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
780 |
|
|
781 |
String tetVertexMissingError(Resources res, int color0, int color1, int color2) |
|
782 |
{ |
|
783 |
int j0 = getTetColor(color0,3); |
|
784 |
int j1 = getTetColor(color1,3); |
|
785 |
int j2 = getTetColor(color2,4); |
|
786 |
|
|
787 |
String c0 = res.getString(j0); |
|
788 |
String c1 = res.getString(j1); |
|
789 |
String c2 = res.getString(j2); |
|
790 |
|
|
791 |
return res.getString(R.string.solver_generic_missing_vertex,c0,c1,c2); |
|
792 |
} |
|
793 |
|
|
794 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
795 |
|
|
796 |
String di4EdgeThreeError(Resources res, int color) |
|
797 |
{ |
|
798 |
int j0 = getDi4Color(color,7); |
|
799 |
String c0 = res.getString(j0); |
|
800 |
return res.getString(R.string.solver_generic_edge_three,c0); |
|
801 |
} |
|
802 |
|
|
803 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
804 |
|
|
805 |
public String error(Resources res, int[] err, int[] faceColors) |
|
806 |
{ |
|
807 |
switch(err[0]) |
|
808 |
{ |
|
809 |
case ERROR_HEX_CORNER_MISSING : return hexCornerMissingError(res,err[1],err[2],err[3]); |
|
810 |
case ERROR_HEX_CENTER_MISSING : return hexCenterMissingError(res,err[1]); |
|
811 |
case ERROR_HEX_EDGE_MISSING : return hexEdgeMissingError(res,err[1],err[2]); |
|
812 |
case ERROR_HEX_EDGE_TWISTED : return hexEdgeTwistedError(res,err[1],err[2]); |
|
813 |
case ERROR_HEX_EDGE_MONOCHROMATIC: return hexEdgeMonoError(res,err[1]); |
|
814 |
case ERROR_HEX_EDGE_TWICE : return hexEdgeTwiceError(res,err[1],err[2]); |
|
815 |
case ERROR_HEX_CORNER_TWISTED : return hexCornerTwistedError(res,err[1],err[2],err[3]); |
|
816 |
|
|
817 |
case ERROR_TET_CORNER_MISSING : return tetCornerMissingError(res,err[1],err[2],err[3]); |
|
818 |
case ERROR_TET_VERTEX_MISSING : return tetVertexMissingError(res,err[1],err[2],err[3]); |
|
819 |
case ERROR_TET_EDGE_MISSING : return tetEdgeMissingError(res,faceColors[err[1]],faceColors[err[2]]); |
|
820 |
case ERROR_TET_CENTER_MISSING : return tetCenterMissingError(res,err[1]); |
|
821 |
|
|
822 |
case ERROR_OCT_CENTER_MISSING : return octCenterMissingError(res,err[1]); |
|
823 |
case ERROR_OCT_CORNER_MISSING : return octCornerMissingError(res,err[1],err[2]); |
|
824 |
|
|
825 |
case ERROR_DI4_EDGE_THREE : return di4EdgeThreeError(res,err[1]); |
|
826 |
|
|
827 |
case ERROR_CORNERS_CANNOT : return res.getString(R.string.solver_generic_corners_cannot); |
|
828 |
case ERROR_EDGE_CANNOT : return res.getString(R.string.solver_generic_edges_cannot); |
|
829 |
case ERROR_CORNER_TWISTED : return res.getString(R.string.solver_generic_corner_twist); |
|
830 |
case ERROR_CORNER_TWIST_90 : return res.getString(R.string.solver_generic_corner_twist) + " (90)"; |
|
831 |
case ERROR_CORNER_TWIST_180 : return res.getString(R.string.solver_generic_corner_twist) + " (180)"; |
|
832 |
case ERROR_EDGE_TWISTED : return res.getString(R.string.solver_generic_edge_twist); |
|
833 |
case ERROR_TWO_CENTERS : return res.getString(R.string.solver_generic_two_centers); |
|
834 |
case ERROR_TWO_CORNERS : return res.getString(R.string.solver_generic_two_corners); |
|
835 |
case ERROR_TWO_EDGES : return res.getString(R.string.solver_generic_two_edges); |
|
836 |
case ERROR_FREE_CORNERS_NOT_EVEN : return res.getString(R.string.solver_generic_free_corners_odd); |
|
837 |
case ERROR_FREE_CORNERS_ROTATED : return res.getString(R.string.solver_generic_free_corners_rotated); |
|
838 |
case ERROR_VERTICES_CANNOT : return res.getString(R.string.solver_generic_vertices_cannot); |
|
839 |
case ERROR_C_V_DONT_MATCH : return res.getString(R.string.solver_generic_c_v_dont_match); |
|
840 |
case ERROR_TWO_CORNERS_TWO_EDGES : return res.getString(R.string.solver_two_corners_two_edges); |
|
841 |
} |
|
842 |
|
|
843 |
return null; |
|
844 |
} |
|
845 | 616 |
} |
src/main/java/org/distorted/solvers/ScreenSolutionSinglephased.java | ||
---|---|---|
21 | 21 |
import org.distorted.main.R; |
22 | 22 |
import org.distorted.objectlib.helpers.MovesFinished; |
23 | 23 |
import org.distorted.objectlib.main.ObjectControl; |
24 |
import org.distorted.objectlib.patterns.RubikPattern; |
|
25 | 24 |
|
26 | 25 |
import java.lang.ref.WeakReference; |
27 | 26 |
|
... | ... | |
248 | 247 |
} |
249 | 248 |
} |
250 | 249 |
|
251 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
252 |
|
|
253 |
void setSolution(String moves) |
|
254 |
{ |
|
255 |
mCanRotate= true; |
|
256 |
mCurrMove = 0; |
|
257 |
mNumMoves = moves.length()/4; |
|
258 |
mMoves = new int[mNumMoves][3]; |
|
259 |
|
|
260 |
RubikPattern.parseMoves(mMoves,mNumMoves,moves); |
|
261 |
|
|
262 |
SolverActivity act = mAct.get(); |
|
263 |
mMovesText.setText(act.getString(R.string.mo_placeholder,mCurrMove,mNumMoves)); |
|
264 |
} |
|
265 |
|
|
266 | 250 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
267 | 251 |
|
268 | 252 |
void setSolution(int[][] moves) |
src/main/java/org/distorted/solvers/SolverActivity.java | ||
---|---|---|
26 | 26 |
import org.distorted.objectlib.main.InitAssets; |
27 | 27 |
import org.distorted.objectlib.main.ObjectControl; |
28 | 28 |
import org.distorted.objectlib.main.TwistyObject; |
29 |
import org.distorted.objectlib.solvers.verifiers.SolverAbstract; |
|
29 | 30 |
import org.distorted.objects.RubikObject; |
30 | 31 |
import org.distorted.objects.RubikObjectList; |
31 | 32 |
import org.distorted.os.OSInterface; |
... | ... | |
207 | 208 |
return view.getObjectControl(); |
208 | 209 |
} |
209 | 210 |
|
211 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
212 |
|
|
213 |
public void interruptSolve() |
|
214 |
{ |
|
215 |
ScreenSetupPosition screen = (ScreenSetupPosition) ScreenList.SVER.getScreenClass(); |
|
216 |
screen.interrupt(); |
|
217 |
} |
|
218 |
|
|
219 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
220 |
|
|
221 |
public void setSolver(SolverAbstract solver) |
|
222 |
{ |
|
223 |
ScreenSetupPosition screen = (ScreenSetupPosition) ScreenList.SVER.getScreenClass(); |
|
224 |
screen.setSolver(solver); |
|
225 |
} |
|
226 |
|
|
210 | 227 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
211 | 228 |
|
212 | 229 |
public int getObjectOrdinal() |
src/main/java/org/distorted/solvers/SolverErrors.java | ||
---|---|---|
1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
2 |
// Copyright 2024 Leszek Koltunski // |
|
3 |
// // |
|
4 |
// This file is part of Magic Cube. // |
|
5 |
// // |
|
6 |
// Magic Cube is proprietary software licensed under an EULA which you should have received // |
|
7 |
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html // |
|
8 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
9 |
|
|
10 |
package org.distorted.solvers; |
|
11 |
|
|
12 |
import static org.distorted.objectlib.solvers.verifiers.SolverAbstract.*; |
|
13 |
|
|
14 |
import android.content.res.Resources; |
|
15 |
|
|
16 |
import org.distorted.main.R; |
|
17 |
|
|
18 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
19 |
|
|
20 |
public class SolverErrors |
|
21 |
{ |
|
22 |
private static final int[][] colorsHex = |
|
23 |
{ |
|
24 |
{R.string.color_yellow1,R.string.color_yellow2,R.string.color_yellow3,R.string.color_yellow4,R.string.color_yellow5,R.string.color_yellow6,R.string.color_yellow7 }, |
|
25 |
{R.string.color_white1 ,R.string.color_white2 ,R.string.color_white3 ,R.string.color_white4 ,R.string.color_white5 ,R.string.color_white6 ,R.string.color_white7 }, |
|
26 |
{R.string.color_blue1 ,R.string.color_blue2 ,R.string.color_blue3 ,R.string.color_blue4 ,R.string.color_blue5 ,R.string.color_blue6 ,R.string.color_blue7 }, |
|
27 |
{R.string.color_green1 ,R.string.color_green2 ,R.string.color_green3 ,R.string.color_green4 ,R.string.color_green5 ,R.string.color_green6 ,R.string.color_green7 }, |
|
28 |
{R.string.color_red1 ,R.string.color_red2 ,R.string.color_red3 ,R.string.color_red4 ,R.string.color_red5 ,R.string.color_red6 ,R.string.color_red7 }, |
|
29 |
{R.string.color_orange1,R.string.color_orange2,R.string.color_orange3,R.string.color_orange4,R.string.color_orange5,R.string.color_orange6,R.string.color_orange7 }, |
|
30 |
}; |
|
31 |
private static final int[][] colorsTet = |
|
32 |
{ |
|
33 |
{R.string.color_green1 ,R.string.color_green2 ,R.string.color_green3 ,R.string.color_green4 ,R.string.color_green5 ,R.string.color_green6 ,R.string.color_green7 }, |
|
34 |
{R.string.color_yellow1,R.string.color_yellow2,R.string.color_yellow3,R.string.color_yellow4,R.string.color_yellow5,R.string.color_yellow6,R.string.color_yellow7 }, |
|
35 |
{R.string.color_blue1 ,R.string.color_blue2 ,R.string.color_blue3 ,R.string.color_blue4 ,R.string.color_blue5 ,R.string.color_blue6 ,R.string.color_blue7 }, |
|
36 |
{R.string.color_red1 ,R.string.color_red2 ,R.string.color_red3 ,R.string.color_red4 ,R.string.color_red5 ,R.string.color_red6 ,R.string.color_red7 }, |
|
37 |
}; |
|
38 |
private static final int[][] colorsOct = |
|
39 |
{ |
|
40 |
{R.string.color_violet1,R.string.color_violet2,R.string.color_violet3,R.string.color_violet4,R.string.color_violet5,R.string.color_violet6,R.string.color_violet7 }, |
|
41 |
{R.string.color_grey1 ,R.string.color_grey2 ,R.string.color_grey3 ,R.string.color_grey4 ,R.string.color_grey5 ,R.string.color_grey6 ,R.string.color_grey7 }, |
|
42 |
{R.string.color_blue1 ,R.string.color_blue2 ,R.string.color_blue3 ,R.string.color_blue4 ,R.string.color_blue5 ,R.string.color_blue6 ,R.string.color_blue7 }, |
|
43 |
{R.string.color_red1 ,R.string.color_red2 ,R.string.color_red3 ,R.string.color_red4 ,R.string.color_red5 ,R.string.color_red6 ,R.string.color_red7 }, |
|
44 |
{R.string.color_orange1,R.string.color_orange2,R.string.color_orange3,R.string.color_orange4,R.string.color_orange5,R.string.color_orange6,R.string.color_orange7 }, |
|
45 |
{R.string.color_green1 ,R.string.color_green2 ,R.string.color_green3 ,R.string.color_green4 ,R.string.color_green5 ,R.string.color_green6 ,R.string.color_green7 }, |
|
46 |
{R.string.color_white1 ,R.string.color_white2 ,R.string.color_white3 ,R.string.color_white4 ,R.string.color_white5 ,R.string.color_white6 ,R.string.color_white7 }, |
|
47 |
{R.string.color_yellow1,R.string.color_yellow2,R.string.color_yellow3,R.string.color_yellow4,R.string.color_yellow5,R.string.color_yellow6,R.string.color_yellow7 }, |
|
48 |
}; |
|
49 |
private static final int[][] colorsDi4 = |
|
50 |
{ |
|
51 |
{R.string.color_yellow1,R.string.color_yellow2,R.string.color_yellow3,R.string.color_yellow4,R.string.color_yellow5,R.string.color_yellow6,R.string.color_yellow7 }, |
|
52 |
{R.string.color_white1 ,R.string.color_white2 ,R.string.color_white3 ,R.string.color_white4 ,R.string.color_white5 ,R.string.color_white6 ,R.string.color_white7 }, |
|
53 |
{R.string.color_blue1 ,R.string.color_blue2 ,R.string.color_blue3 ,R.string.color_blue4 ,R.string.color_blue5 ,R.string.color_blue6 ,R.string.color_blue7 }, |
|
54 |
{R.string.color_red1 ,R.string.color_red2 ,R.string.color_red3 ,R.string.color_red4 ,R.string.color_red5 ,R.string.color_red6 ,R.string.color_red7 }, |
|
55 |
}; |
|
56 |
|
|
57 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
58 |
|
|
59 |
private static int getHexColor(int color,int variant) { return colorsHex[color][variant]; } |
|
60 |
private static int getTetColor(int color,int variant) { return colorsTet[color][variant]; } |
|
61 |
private static int getOctColor(int color,int variant) { return colorsOct[color][variant]; } |
|
62 |
private static int getDi4Color(int color,int variant) { return colorsDi4[color][variant]; } |
|
63 |
|
|
64 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
65 |
|
|
66 |
private static String hexCornerMissingError(Resources res, int face0, int face1, int face2) |
|
67 |
{ |
|
68 |
int j0 = getHexColor(face0,3); |
|
69 |
int j1 = getHexColor(face1,3); |
|
70 |
int j2 = getHexColor(face2,4); |
|
71 |
|
|
72 |
String c0 = res.getString(j0); |
|
73 |
String c1 = res.getString(j1); |
|
74 |
String c2 = res.getString(j2); |
|
75 |
|
|
76 |
return res.getString(R.string.solver_generic_missing_corner,c0,c1,c2); |
|
77 |
} |
|
78 |
|
|
79 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
80 |
|
|
81 |
private static String hexCenterMissingError(Resources res, int face) |
|
82 |
{ |
|
83 |
int color = getHexColor(face,2); |
|
84 |
String clr= res.getString(color); |
|
85 |
return res.getString(R.string.solver_generic_missing_center,clr); |
|
86 |
} |
|
87 |
|
|
88 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
89 |
|
|
90 |
private static String hexEdgeMissingError(Resources res, int face0, int face1) |
|
91 |
{ |
|
92 |
int j0 = getHexColor(face0,3); |
|
93 |
int j1 = getHexColor(face1,6); |
|
94 |
|
|
95 |
String c0 = res.getString(j0); |
|
96 |
String c1 = res.getString(j1); |
|
97 |
|
|
98 |
return res.getString(R.string.solver_generic_missing_edge,c0,c1); |
|
99 |
} |
|
100 |
|
|
101 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
102 |
|
|
103 |
private static String hexEdgeTwistedError(Resources res, int color0, int color1) |
|
104 |
{ |
|
105 |
int j0 = getHexColor(color0,3); |
|
106 |
int j1 = getHexColor(color1,6); |
|
107 |
|
|
108 |
String c0 = res.getString(j0); |
|
109 |
String c1 = res.getString(j1); |
|
110 |
|
|
111 |
return res.getString(R.string.solver_generic_twisted_edge,c0,c1); |
|
112 |
} |
|
113 |
|
|
114 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
115 |
|
|
116 |
private static String hexCornerTwistedError(Resources res, int color0, int color1, int color2) |
|
117 |
{ |
|
118 |
int j0 = getHexColor(color0,3); |
|
119 |
int j1 = getHexColor(color1,3); |
|
120 |
int j2 = getHexColor(color2,5); |
|
121 |
|
|
122 |
String c0 = res.getString(j0); |
|
123 |
String c1 = res.getString(j1); |
|
124 |
String c2 = res.getString(j2); |
|
125 |
|
|
126 |
return res.getString(R.string.solver_generic_twisted_corner,c0,c1,c2); |
|
127 |
} |
|
128 |
|
|
129 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
130 |
|
|
131 |
private static String hexEdgeMonoError(Resources res, int color) |
|
132 |
{ |
|
133 |
int j0 = getHexColor(color,3); |
|
134 |
int j1 = getHexColor(color,6); |
|
135 |
String c0 = res.getString(j0); |
|
136 |
String c1 = res.getString(j1); |
|
137 |
|
|
138 |
return res.getString(R.string.solver_generic_edge_mono,c0,c1); |
|
139 |
} |
|
140 |
|
|
141 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
142 |
|
|
143 |
private static String hexEdgeTwiceError(Resources res, int color0, int color1) |
|
144 |
{ |
|
145 |
int j0 = getHexColor(color0,3); |
|
146 |
int j1 = getHexColor(color1,6); |
|
147 |
String c0 = res.getString(j0); |
|
148 |
String c1 = res.getString(j1); |
|
149 |
|
|
150 |
return res.getString(R.string.solver_generic_edge_twice,c0,c1); |
|
151 |
} |
|
152 |
|
|
153 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
154 |
|
|
155 |
private static String octCenterMissingError(Resources res, int face) |
|
156 |
{ |
|
157 |
int index = getOctColor(face,2); |
|
158 |
String color = res.getString(index); |
|
159 |
return res.getString(R.string.solver_generic_missing_center,color); |
|
160 |
} |
|
161 |
|
|
162 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
163 |
|
|
164 |
private static String octCornerMissingError(Resources res, int f1, int f2) |
|
165 |
{ |
|
166 |
int i1 = getOctColor(f1,3); |
|
167 |
int i2 = getOctColor(f2,4); |
|
168 |
String c1 = res.getString(i1); |
|
169 |
String c2 = res.getString(i2); |
|
170 |
return res.getString(R.string.solver_generic_missing_corner2,c1,c2); |
|
171 |
} |
|
172 |
|
|
173 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
174 |
|
|
175 |
private static String tetCornerMissingError(Resources res, int color0, int color1, int color2) |
|
176 |
{ |
|
177 |
int j0 = getTetColor(color0,3); |
|
178 |
int j1 = getTetColor(color1,3); |
|
179 |
int j2 = getTetColor(color2,4); |
|
180 |
|
|
181 |
String c0 = res.getString(j0); |
|
182 |
String c1 = res.getString(j1); |
|
183 |
String c2 = res.getString(j2); |
|
184 |
|
|
185 |
return res.getString(R.string.solver_generic_missing_corner,c0,c1,c2); |
|
186 |
} |
|
187 |
|
|
188 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
189 |
|
|
190 |
private static String tetEdgeMissingError(Resources res, int face0, int face1) |
|
191 |
{ |
|
192 |
int j0 = getTetColor(face0,3); |
|
193 |
int j1 = getTetColor(face1,6); |
|
194 |
|
|
195 |
String c0 = res.getString(j0); |
|
196 |
String c1 = res.getString(j1); |
|
197 |
|
|
198 |
return res.getString(R.string.solver_generic_missing_edge,c0,c1); |
|
199 |
} |
|
200 |
|
|
201 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
202 |
|
|
203 |
private static String tetCenterMissingError(Resources res, int face) |
|
204 |
{ |
|
205 |
int j = getTetColor(face,2); |
|
206 |
String c = res.getString(j); |
|
207 |
return res.getString(R.string.solver_generic_missing_center,c); |
|
208 |
} |
|
209 |
|
|
210 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
211 |
|
|
212 |
private static String tetVertexMissingError(Resources res, int color0, int color1, int color2) |
|
213 |
{ |
|
214 |
int j0 = getTetColor(color0,3); |
|
215 |
int j1 = getTetColor(color1,3); |
|
216 |
int j2 = getTetColor(color2,4); |
|
217 |
|
|
218 |
String c0 = res.getString(j0); |
|
219 |
String c1 = res.getString(j1); |
|
220 |
String c2 = res.getString(j2); |
|
221 |
|
|
222 |
return res.getString(R.string.solver_generic_missing_vertex,c0,c1,c2); |
|
223 |
} |
|
224 |
|
|
225 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
226 |
|
|
227 |
private static String di4EdgeThreeError(Resources res, int color) |
|
228 |
{ |
|
229 |
int j0 = getDi4Color(color,7); |
|
230 |
String c0 = res.getString(j0); |
|
231 |
return res.getString(R.string.solver_generic_edge_three,c0); |
|
232 |
} |
|
233 |
|
|
234 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
235 |
|
|
236 |
public static String error(Resources res, int[] err, int[] faceColors) |
|
237 |
{ |
|
238 |
switch(err[0]) |
|
239 |
{ |
|
240 |
case ERROR_HEX_CORNER_MISSING : return hexCornerMissingError(res,err[1],err[2],err[3]); |
|
241 |
case ERROR_HEX_CENTER_MISSING : return hexCenterMissingError(res,err[1]); |
|
242 |
case ERROR_HEX_EDGE_MISSING : return hexEdgeMissingError(res,err[1],err[2]); |
|
243 |
case ERROR_HEX_EDGE_TWISTED : return hexEdgeTwistedError(res,err[1],err[2]); |
|
244 |
case ERROR_HEX_EDGE_MONOCHROMATIC: return hexEdgeMonoError(res,err[1]); |
|
245 |
case ERROR_HEX_EDGE_TWICE : return hexEdgeTwiceError(res,err[1],err[2]); |
|
246 |
case ERROR_HEX_CORNER_TWISTED : return hexCornerTwistedError(res,err[1],err[2],err[3]); |
|
247 |
|
|
248 |
case ERROR_TET_CORNER_MISSING : return tetCornerMissingError(res,err[1],err[2],err[3]); |
|
249 |
case ERROR_TET_VERTEX_MISSING : return tetVertexMissingError(res,err[1],err[2],err[3]); |
|
250 |
case ERROR_TET_EDGE_MISSING : return tetEdgeMissingError(res,faceColors[err[1]],faceColors[err[2]]); |
|
251 |
case ERROR_TET_CENTER_MISSING : return tetCenterMissingError(res,err[1]); |
|
252 |
|
|
253 |
case ERROR_OCT_CENTER_MISSING : return octCenterMissingError(res,err[1]); |
|
254 |
case ERROR_OCT_CORNER_MISSING : return octCornerMissingError(res,err[1],err[2]); |
|
255 |
|
|
256 |
case ERROR_DI4_EDGE_THREE : return di4EdgeThreeError(res,err[1]); |
|
257 |
|
|
258 |
case ERROR_CORNERS_CANNOT : return res.getString(R.string.solver_generic_corners_cannot); |
|
259 |
case ERROR_EDGE_CANNOT : return res.getString(R.string.solver_generic_edges_cannot); |
|
260 |
case ERROR_CORNER_TWISTED : return res.getString(R.string.solver_generic_corner_twist); |
|
261 |
case ERROR_CORNER_TWIST_90 : return res.getString(R.string.solver_generic_corner_twist) + " (90)"; |
|
262 |
case ERROR_CORNER_TWIST_180 : return res.getString(R.string.solver_generic_corner_twist) + " (180)"; |
|
263 |
case ERROR_EDGE_TWISTED : return res.getString(R.string.solver_generic_edge_twist); |
|
264 |
case ERROR_TWO_CENTERS : return res.getString(R.string.solver_generic_two_centers); |
|
265 |
case ERROR_TWO_CORNERS : return res.getString(R.string.solver_generic_two_corners); |
|
266 |
case ERROR_TWO_EDGES : return res.getString(R.string.solver_generic_two_edges); |
|
267 |
case ERROR_FREE_CORNERS_NOT_EVEN : return res.getString(R.string.solver_generic_free_corners_odd); |
|
268 |
case ERROR_FREE_CORNERS_ROTATED : return res.getString(R.string.solver_generic_free_corners_rotated); |
|
269 |
case ERROR_VERTICES_CANNOT : return res.getString(R.string.solver_generic_vertices_cannot); |
|
270 |
case ERROR_C_V_DONT_MATCH : return res.getString(R.string.solver_generic_c_v_dont_match); |
|
271 |
case ERROR_TWO_CORNERS_TWO_EDGES : return res.getString(R.string.solver_two_corners_two_edges); |
|
272 |
} |
|
273 |
|
|
274 |
return null; |
|
275 |
} |
|
276 |
} |
Also available in: Unified diff
a dialog to interrupt too long solves