1 |
3bedda30
|
leszek
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
// Copyright 2023 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.util.TypedValue;
|
13 |
|
|
import android.view.View;
|
14 |
|
|
import android.widget.Button;
|
15 |
|
|
import android.widget.LinearLayout;
|
16 |
|
|
import android.widget.TextView;
|
17 |
|
|
|
18 |
|
|
import org.distorted.main.R;
|
19 |
2f53a016
|
leszek
|
import org.distorted.objectlib.helpers.OperatingSystemInterface;
|
20 |
3bedda30
|
leszek
|
import org.distorted.objectlib.main.TwistyObject;
|
21 |
94ce8e53
|
leszek
|
import org.distorted.objectlib.solvers.verifiers.SolverAbstract;
|
22 |
3a768e35
|
leszek
|
import org.distorted.objectlib.solvers.verifiers.ImplementedVerifierList;
|
23 |
7e9d918b
|
leszek
|
import org.distorted.solvers.ScreenList;
|
24 |
|
|
import org.distorted.solvers.ScreenSetupPosition;
|
25 |
|
|
import org.distorted.solvers.SolverActivity;
|
26 |
3bedda30
|
leszek
|
|
27 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
28 |
|
|
|
29 |
8477cf44
|
leszek
|
public class DialogSolverView
|
30 |
3bedda30
|
leszek
|
{
|
31 |
|
|
private final View mView;
|
32 |
|
|
|
33 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
34 |
|
|
|
35 |
8477cf44
|
leszek
|
public DialogSolverView(final SolverActivity act, final DialogSolvers dialog,
|
36 |
|
|
int solverOrdinal, int title, int desc, int padding,
|
37 |
|
|
int fontSize, LinearLayout.LayoutParams pView,
|
38 |
|
|
LinearLayout.LayoutParams pText, LinearLayout.LayoutParams pButt)
|
39 |
3bedda30
|
leszek
|
{
|
40 |
|
|
mView = act.getLayoutInflater().inflate(R.layout.dialog_solvers_pane, null);
|
41 |
|
|
mView.setLayoutParams(pView);
|
42 |
|
|
mView.setPadding(padding,padding,padding,padding);
|
43 |
|
|
|
44 |
|
|
TextView titleView = mView.findViewById(R.id.solvers_pane_title);
|
45 |
|
|
titleView.setText(title);
|
46 |
|
|
TextView descView = mView.findViewById(R.id.solvers_pane_description);
|
47 |
|
|
descView.setText(desc);
|
48 |
|
|
|
49 |
|
|
titleView.setLayoutParams(pText);
|
50 |
|
|
Button button = mView.findViewById(R.id.solvers_pane_button);
|
51 |
|
|
|
52 |
|
|
button.setOnClickListener( new View.OnClickListener()
|
53 |
|
|
{
|
54 |
|
|
@Override
|
55 |
|
|
public void onClick(View v)
|
56 |
|
|
{
|
57 |
|
|
dialog.dismiss();
|
58 |
3a768e35
|
leszek
|
ImplementedVerifierList list = ImplementedVerifierList.getSolver(solverOrdinal);
|
59 |
2f53a016
|
leszek
|
OperatingSystemInterface os = act.getInterface();
|
60 |
3bedda30
|
leszek
|
TwistyObject object = act.getObject();
|
61 |
94ce8e53
|
leszek
|
SolverAbstract solver = list.create(os,object);
|
62 |
a742d66b
|
leszek
|
ScreenSetupPosition screen = (ScreenSetupPosition)ScreenList.SVER.getScreenClass();
|
63 |
94ce8e53
|
leszek
|
|
64 |
|
|
if( solver!=null )
|
65 |
|
|
{
|
66 |
50bb18a1
|
leszek
|
act.setSolver(solver);
|
67 |
94ce8e53
|
leszek
|
int[] result = solver.validatePosition(object);
|
68 |
|
|
if( result[0]>=0 ) solver.solve(screen,result);
|
69 |
|
|
else screen.displayImpossibleDialog(result,solver.getFaceColors());
|
70 |
|
|
}
|
71 |
|
|
else screen.displayErrorDialog(act.getString(R.string.solver_generic_not_implemented));
|
72 |
3bedda30
|
leszek
|
}
|
73 |
|
|
});
|
74 |
|
|
|
75 |
|
|
button.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize);
|
76 |
|
|
button.setLayoutParams(pButt);
|
77 |
|
|
}
|
78 |
|
|
|
79 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
80 |
|
|
|
81 |
|
|
public View getView()
|
82 |
|
|
{
|
83 |
|
|
return mView;
|
84 |
|
|
}
|
85 |
|
|
}
|