Revision d7f9a1a7
Added by Leszek Koltunski 21 days ago
src/main/java/org/distorted/dialogs/DialogPattern.java | ||
---|---|---|
87 | 87 |
return; |
88 | 88 |
} |
89 | 89 |
|
90 |
android.util.Log.e("D", "prepareBody: object "+mArgument); |
|
91 |
|
|
92 | 90 |
final PatternActivity pact = (PatternActivity)getContext(); |
93 | 91 |
int width = pact!=null ? pact.getScreenWidthInPixels() : 100; |
94 | 92 |
final ObjectControl control = pact!=null ? pact.getControl() : null; |
src/main/java/org/distorted/dialogs/DialogSolvers.java | ||
---|---|---|
21 | 21 |
import androidx.fragment.app.FragmentActivity; |
22 | 22 |
|
23 | 23 |
import org.distorted.main.R; |
24 |
import org.distorted.objectlib.metadata.ListObjects; |
|
25 | 24 |
import org.distorted.solvers.SolverActivity; |
26 | 25 |
import org.distorted.objectlib.solvers.verifiers.ImplementedVerifierList; |
27 | 26 |
import org.distorted.solvers.SolverDescriptions; |
... | ... | |
85 | 84 |
pB.setMargins(0,2*margin,0,0); |
86 | 85 |
|
87 | 86 |
SolverActivity sact = (SolverActivity) getContext(); |
88 |
int objectOrdinal = ListObjects.getObjectOrdinal(mArgument); |
|
89 |
ListObjects list = ListObjects.getObject(objectOrdinal); |
|
90 |
int[] solverOrdinals = ImplementedVerifierList.getSolverOrdinals(list); |
|
87 |
int[] solverOrdinals = ImplementedVerifierList.getSolverOrdinals(mArgument); |
|
91 | 88 |
int len = solverOrdinals==null ? 0 : solverOrdinals.length; |
92 | 89 |
|
93 | 90 |
for(int o=0; o<len; o++ ) |
src/main/java/org/distorted/objects/RubikObject.java | ||
---|---|---|
81 | 81 |
int patternOrdinal = RubikPatternList.getOrdinal(mObjectIndex); |
82 | 82 |
mPatterns = RubikPatternList.getPatterns(patternOrdinal); |
83 | 83 |
|
84 |
ListObjects list = ListObjects.getObject(mObjectOrdinal); |
|
85 |
int[] solverOrdinals= ImplementedVerifierList.getSolverOrdinals(list); |
|
84 |
int[] solverOrdinals= ImplementedVerifierList.getSolverOrdinals(mUpperName); |
|
86 | 85 |
mNumSolvers = solverOrdinals==null ? 0 : solverOrdinals.length; |
87 | 86 |
mExtrasOrdinal = -1; |
88 | 87 |
|
src/main/java/org/distorted/solvers/ScreenSetupPosition.java | ||
---|---|---|
9 | 9 |
|
10 | 10 |
package org.distorted.solvers; |
11 | 11 |
|
12 |
import static org.distorted.objectlib.metadata.ListObjects.*; |
|
13 |
|
|
14 | 12 |
import android.content.SharedPreferences; |
15 | 13 |
import android.graphics.Bitmap; |
16 | 14 |
import android.graphics.Canvas; |
... | ... | |
36 | 34 |
import org.distorted.objectlib.helpers.OperatingSystemInterface; |
37 | 35 |
import org.distorted.objectlib.main.ObjectControl; |
38 | 36 |
import org.distorted.objectlib.main.TwistyObject; |
39 |
import org.distorted.objectlib.metadata.ListObjects; |
|
40 | 37 |
import org.distorted.objectlib.shape.*; |
41 | 38 |
import org.distorted.objectlib.solvers.verifiers.ResultScreen; |
42 | 39 |
import org.distorted.objectlib.solvers.verifiers.SolverAbstract; |
... | ... | |
65 | 62 |
private int mNumBitmapRows; |
66 | 63 |
private float mBitmapSize; |
67 | 64 |
private WeakReference<SolverActivity> mWeakAct; |
68 |
private ListObjects mObject;
|
|
65 |
private String mObjectUpperName;
|
|
69 | 66 |
private String[] mPhaseNames; |
70 | 67 |
private Timer mTimer; |
71 | 68 |
private SolverAbstract mSolver; |
... | ... | |
92 | 89 |
mSolving = false; |
93 | 90 |
mPhaseNames = null; |
94 | 91 |
|
95 |
mObject = act.getObjectList();
|
|
92 |
mObjectUpperName = act.getObjectName();
|
|
96 | 93 |
control.solveOnly(); |
97 |
generateFaceColors(mObject); |
|
94 |
generateFaceColors(mObjectUpperName);
|
|
98 | 95 |
|
99 | 96 |
mNumBitmapRows = mNumColors>8 ? 2 : 1; |
100 | 97 |
mBitmapSize = computeBitmapSize(width,heigh); |
... | ... | |
181 | 178 |
// This doesn't quite work in many cases, but in case of the solvers that will pop up in foreseeable |
182 | 179 |
// future it should be ok. |
183 | 180 |
|
184 |
public void generateFaceColors(ListObjects object)
|
|
181 |
public void generateFaceColors(String upper)
|
|
185 | 182 |
{ |
186 | 183 |
mColorMode = MODE_NORMAL; |
187 | 184 |
|
188 |
if( object==PYRA_3 || |
|
189 |
object==PYRA_4 || |
|
190 |
object==PYRA_5 || |
|
191 |
object==PDUO_2 || |
|
192 |
object==JING_2 || |
|
193 |
object==MORP_2 || |
|
194 |
object==MORP_3 || |
|
195 |
object==MORP_4 ) |
|
185 |
|
|
186 |
if( upper.startsWith("PYRA") || upper.startsWith("PDUO") || upper.startsWith("JING") || |
|
187 |
upper.startsWith("MORP") ) |
|
196 | 188 |
{ |
197 | 189 |
mNumColors = ShapeTetrahedron.NUM_FACES; |
198 | 190 |
mFaceColors = ShapeTetrahedron.FACE_COLORS; |
199 | 191 |
} |
200 |
else if( object==DIAM_2 || |
|
201 |
object==DIAM_3 || |
|
202 |
object==DIAM_4 || |
|
203 |
object==TRAJ_3 || |
|
204 |
object==TRAJ_4 || |
|
205 |
object==PDIA_3 ) |
|
192 |
else if( upper.startsWith("DIAM") || upper.startsWith("TRAJ") || upper.startsWith("PDIA") ) |
|
206 | 193 |
{ |
207 | 194 |
mNumColors = ShapeOctahedron.NUM_FACES; |
208 | 195 |
mFaceColors = ShapeOctahedron.FACE_COLORS; |
209 | 196 |
} |
210 |
else if( object==CRYS_3 || |
|
211 |
object==STAR_3 || |
|
212 |
object==PENT_2 || |
|
213 |
object==KILO_3 || |
|
214 |
object==KILO_5 || |
|
215 |
object==MEGA_3 || |
|
216 |
object==MEGA_5 ) |
|
197 |
else if( upper.startsWith("CRYS") || upper.startsWith("STAR") || upper.startsWith("PENT") || |
|
198 |
upper.startsWith("KILO") || upper.startsWith("MEGA") ) |
|
217 | 199 |
{ |
218 | 200 |
mNumColors = ShapeDodecahedron.NUM_FACES; |
219 | 201 |
mFaceColors = ShapeDodecahedron.FACE_COLORS; |
220 | 202 |
} |
221 |
else if( object==BALL_4 )
|
|
203 |
else if( upper.startsWith("BALL") )
|
|
222 | 204 |
{ |
223 | 205 |
mNumColors = ShapeDiamond.NUM_FACES; |
224 | 206 |
mFaceColors = ShapeDiamond.FACE_COLORS; |
225 | 207 |
} |
226 |
else if( object==ICOS_2 )
|
|
208 |
else if( upper.startsWith("ICOS") )
|
|
227 | 209 |
{ |
228 | 210 |
mNumColors = ShapeIcosahedron.NUM_FACES; |
229 | 211 |
mFaceColors = ShapeIcosahedron.FACE_COLORS; |
230 | 212 |
} |
231 |
else if( object==DIN4_3 )
|
|
213 |
else if( upper.startsWith("DIN4") )
|
|
232 | 214 |
{ |
233 | 215 |
mNumColors = 4; |
234 | 216 |
mFaceColors = new int[] { ShapeColors.COLOR_YELLOW, ShapeColors.COLOR_RED, ShapeColors.COLOR_BLUE, ShapeColors.COLOR_WHITE}; |
... | ... | |
292 | 274 |
|
293 | 275 |
private void pressSolve(SolverActivity act) |
294 | 276 |
{ |
295 |
int[] solverOrdinals = ImplementedVerifierList.getSolverOrdinals(mObject); |
|
277 |
int[] solverOrdinals = ImplementedVerifierList.getSolverOrdinals(mObjectUpperName);
|
|
296 | 278 |
|
297 | 279 |
if( solverOrdinals!=null ) |
298 | 280 |
{ |
... | ... | |
314 | 296 |
} |
315 | 297 |
else // more than one solver - pop up a choosing dialog |
316 | 298 |
{ |
317 |
String upperName = mObject.name(); |
|
318 | 299 |
Bundle bundle = new Bundle(); |
319 |
bundle.putString("argument", upperName );
|
|
300 |
bundle.putString("argument", mObjectUpperName );
|
|
320 | 301 |
DialogSolvers dialog = new DialogSolvers(); |
321 | 302 |
dialog.setArguments(bundle); |
322 | 303 |
dialog.show( act.getSupportFragmentManager(), DialogSolvers.getDialogTag()); |
... | ... | |
326 | 307 |
} |
327 | 308 |
else displayErrorDialog(act.getString(R.string.solver_generic_not_implemented)); |
328 | 309 |
} |
329 |
else displayErrorDialog("No solvers found for object "+mObject.name() );
|
|
310 |
else displayErrorDialog("No solvers found for object "+mObjectUpperName );
|
|
330 | 311 |
} |
331 | 312 |
|
332 | 313 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
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.metadata.ListObjects; |
|
30 | 29 |
import org.distorted.objectlib.solvers.verifiers.SolverAbstract; |
31 | 30 |
import org.distorted.objects.RubikObject; |
32 | 31 |
import org.distorted.objects.RubikObjectList; |
... | ... | |
227 | 226 |
|
228 | 227 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
229 | 228 |
|
230 |
public ListObjects getObjectList()
|
|
229 |
public String getObjectName()
|
|
231 | 230 |
{ |
232 |
return ListObjects.getObject(mObjectOrdinal); |
|
231 |
RubikObject object = RubikObjectList.getObject(mObjectOrdinal); |
|
232 |
return object !=null ? object.getUpperName() : "NULL"; |
|
233 | 233 |
} |
234 | 234 |
|
235 | 235 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/solvers/SolverObjectLibInterface.java | ||
---|---|---|
16 | 16 |
import org.distorted.objectlib.helpers.BlockController; |
17 | 17 |
import org.distorted.objectlib.helpers.ObjectLibInterface; |
18 | 18 |
import org.distorted.objectlib.main.ObjectControl; |
19 |
import org.distorted.objectlib.metadata.ListObjects; |
|
20 | 19 |
import org.distorted.objects.RubikObject; |
21 | 20 |
import org.distorted.objects.RubikObjectList; |
22 | 21 |
import org.distorted.objectlib.solvers.verifiers.ImplementedVerifierList; |
... | ... | |
173 | 172 |
SolverActivity act = mAct.get(); |
174 | 173 |
ScreenSetupPosition solver = (ScreenSetupPosition) ScreenList.SVER.getScreenClass(); |
175 | 174 |
int color = solver.getCurrentColor(); |
176 |
ListObjects currObject = act.getObjectList();
|
|
177 |
mLastCubitColor = ImplementedVerifierList.cubitIsLocked(currObject,cubit);
|
|
175 |
String objectUpperName = act.getObjectName();
|
|
176 |
mLastCubitColor = ImplementedVerifierList.cubitIsLocked(objectUpperName,cubit);
|
|
178 | 177 |
mLastCubit = cubit; |
179 | 178 |
mLastCubitFace = face; |
180 | 179 |
ObjectControl control = act.getControl(); |
Also available in: Unified diff
bugfix: do not use ListObjects in the app anywhere except the RubikObjectList and RubikObject.
In particular, stop using it in the Solver part of the app. Now after this bugfix we can rearrange the objects in the ListObjects at will.