Revision b20e89d2
Added by Leszek Koltunski about 3 years ago
build.gradle | ||
---|---|---|
42 | 42 |
implementation 'com.google.android.play:core:1.10.2' |
43 | 43 |
implementation 'androidx.appcompat:appcompat:1.3.1' |
44 | 44 |
implementation 'com.google.android.material:material:1.4.0' |
45 |
implementation project(path: ':distorted-puzzle-jsons') |
|
46 |
implementation project(path: ':distorted-puzzle-dmesh') |
|
45 | 47 |
} |
src/main/java/org/distorted/dialogs/RubikDialogPattern.java | ||
---|---|---|
94 | 94 |
|
95 | 95 |
for(int i=0; i< RubikPatternList.NUM_OBJECTS; i++) |
96 | 96 |
{ |
97 |
ObjectType list = RubikPatternList.getObject(i);
|
|
97 |
ObjectType type = RubikPatternList.getObject(i);
|
|
98 | 98 |
int iconSize = RubikActivity.getDrawableSize(); |
99 |
int iconID = list.getIconID(iconSize);
|
|
99 |
int iconID = type.getIconID(iconSize);
|
|
100 | 100 |
|
101 | 101 |
ImageView imageView = new ImageView(act); |
102 | 102 |
imageView.setImageResource(iconID); |
src/main/java/org/distorted/dialogs/RubikDialogPatternView.java | ||
---|---|---|
97 | 97 |
RubikPattern pattern = RubikPattern.getInstance(); |
98 | 98 |
int[][] moves = pattern.reInitialize(mTab, groupPosition, childPosition); |
99 | 99 |
ObjectType object = RubikPatternList.getObject(mTab); |
100 |
|
|
101 |
control.changeObject(object); |
|
100 |
ract.changeIfDifferent(object,control); |
|
102 | 101 |
control.initializeObject(moves); |
103 | 102 |
|
104 | 103 |
ScreenList.switchScreen(ract, ScreenList.PATT); |
src/main/java/org/distorted/main/RubikActivity.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.main; |
21 | 21 |
|
22 |
import java.io.InputStream; |
|
22 | 23 |
import java.util.Locale; |
23 | 24 |
|
24 | 25 |
import android.content.Intent; |
... | ... | |
41 | 42 |
|
42 | 43 |
import com.google.firebase.analytics.FirebaseAnalytics; |
43 | 44 |
|
45 |
import org.distorted.dmesh.ObjectMesh; |
|
46 |
import org.distorted.jsons.ObjectJson; |
|
44 | 47 |
import org.distorted.library.main.DistortedLibrary; |
45 | 48 |
|
46 | 49 |
import org.distorted.objectlib.main.ObjectControl; |
... | ... | |
250 | 253 |
|
251 | 254 |
RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass(); |
252 | 255 |
ObjectType object = play.getObject(); |
253 |
view.getObjectControl().changeObject(object);
|
|
256 |
changeIfDifferent(object,view.getObjectControl());
|
|
254 | 257 |
|
255 | 258 |
if( mIsChinese && !mPolicyAccepted ) PrivacyPolicy(); |
256 | 259 |
} |
... | ... | |
266 | 269 |
|
267 | 270 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
268 | 271 |
|
269 |
private String getAppVers() |
|
270 |
{ |
|
271 |
try |
|
272 |
private String getAppVers() |
|
272 | 273 |
{ |
273 |
PackageInfo pInfo = getPackageManager().getPackageInfo( getPackageName(), 0); |
|
274 |
return pInfo.versionName; |
|
275 |
} |
|
276 |
catch (PackageManager.NameNotFoundException e) |
|
277 |
{ |
|
278 |
return "unknown"; |
|
274 |
try |
|
275 |
{ |
|
276 |
PackageInfo pInfo = getPackageManager().getPackageInfo( getPackageName(), 0); |
|
277 |
return pInfo.versionName; |
|
278 |
} |
|
279 |
catch (PackageManager.NameNotFoundException e) |
|
280 |
{ |
|
281 |
return "unknown"; |
|
282 |
} |
|
279 | 283 |
} |
280 |
} |
|
281 | 284 |
|
282 | 285 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
283 | 286 |
|
... | ... | |
435 | 438 |
{ |
436 | 439 |
RubikSurfaceView view = findViewById(R.id.rubikSurfaceView); |
437 | 440 |
ObjectControl control = view.getObjectControl(); |
441 |
TwistyObject oldObject = control.getObject(); |
|
442 |
changeIfDifferent(newObject,control); |
|
438 | 443 |
|
439 |
if( reportChange ) |
|
444 |
if( reportChange && oldObject!=null )
|
|
440 | 445 |
{ |
441 |
TwistyObject oldObject = control.getObject(); |
|
442 |
|
|
443 |
if( oldObject!=null ) |
|
446 |
float fps = view.getRenderer().getFPS(); |
|
447 |
fps = (int)(fps+0.5f); |
|
448 |
StringBuilder name = new StringBuilder(); |
|
449 |
name.append(oldObject.getShortName()); |
|
450 |
name.append(' '); |
|
451 |
name.append(fps); |
|
452 |
name.append(" --> "); |
|
453 |
name.append(newObject.name()); |
|
454 |
|
|
455 |
if( BuildConfig.DEBUG ) |
|
444 | 456 |
{ |
445 |
ObjectType oldType = oldObject.getObjectType(); |
|
446 |
float fps = view.getRenderer().getFPS(); |
|
447 |
fps = (int)(fps+0.5f); |
|
448 |
StringBuilder name = new StringBuilder(); |
|
449 |
name.append(oldType.name()); |
|
450 |
name.append(' '); |
|
451 |
name.append(fps); |
|
452 |
name.append(" --> "); |
|
453 |
name.append(newObject.name()); |
|
454 |
|
|
455 |
if( BuildConfig.DEBUG ) |
|
456 |
{ |
|
457 |
android.util.Log.e("rubik", name.toString()); |
|
458 |
} |
|
459 |
else |
|
460 |
{ |
|
461 |
FirebaseAnalytics analytics = getAnalytics(); |
|
457 |
android.util.Log.e("rubik", name.toString()); |
|
458 |
} |
|
459 |
else |
|
460 |
{ |
|
461 |
FirebaseAnalytics analytics = getAnalytics(); |
|
462 | 462 |
|
463 |
if( analytics!=null ) |
|
464 |
{ |
|
465 |
Bundle bundle = new Bundle(); |
|
466 |
bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, name.toString()); |
|
467 |
analytics.logEvent(FirebaseAnalytics.Event.SELECT_ITEM, bundle); |
|
468 |
} |
|
463 |
if( analytics!=null ) |
|
464 |
{ |
|
465 |
Bundle bundle = new Bundle(); |
|
466 |
bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, name.toString()); |
|
467 |
analytics.logEvent(FirebaseAnalytics.Event.SELECT_ITEM, bundle); |
|
469 | 468 |
} |
470 | 469 |
} |
471 | 470 |
} |
471 |
} |
|
472 |
|
|
473 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
472 | 474 |
|
473 |
control.changeObject(newObject); |
|
475 |
public void changeIfDifferent(ObjectType type,ObjectControl control) |
|
476 |
{ |
|
477 |
InputStream jsonStream = ObjectJson.getStream(type,this); |
|
478 |
InputStream meshStream = ObjectMesh.getStream(type,this); |
|
479 |
control.changeIfDifferent(type.ordinal(),jsonStream,meshStream); |
|
474 | 480 |
} |
475 | 481 |
|
476 | 482 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/main/RubikSurfaceView.java | ||
---|---|---|
108 | 108 |
RubikObjectLibInterface ref = new RubikObjectLibInterface(act); |
109 | 109 |
mObjectController = new ObjectControl(act,ref); |
110 | 110 |
mRenderer = new RubikRenderer(this); |
111 |
ObjectControl.setDmeshMode(true); |
|
112 | 111 |
|
113 | 112 |
final ActivityManager activityManager= (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
114 | 113 |
|
src/main/java/org/distorted/screens/RubikScreenSolver.java | ||
---|---|---|
84 | 84 |
mSolving = false; |
85 | 85 |
|
86 | 86 |
ObjectType currentObject= ImplementedSolversList.getObject(0); |
87 |
|
|
88 |
control.changeObject(currentObject); |
|
87 |
act.changeIfDifferent(currentObject,control); |
|
89 | 88 |
control.solveOnly(); |
90 | 89 |
|
91 | 90 |
RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass(); |
src/main/java/org/distorted/tutorials/TutorialActivity.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.tutorials; |
21 | 21 |
|
22 |
import java.io.InputStream; |
|
23 |
|
|
22 | 24 |
import android.os.Build; |
23 | 25 |
import android.os.Bundle; |
24 | 26 |
import android.util.DisplayMetrics; |
... | ... | |
32 | 34 |
|
33 | 35 |
import com.google.firebase.analytics.FirebaseAnalytics; |
34 | 36 |
|
37 |
import org.distorted.dmesh.ObjectMesh; |
|
38 |
import org.distorted.jsons.ObjectJson; |
|
35 | 39 |
import org.distorted.library.main.DistortedLibrary; |
36 |
import org.distorted.library.main.DistortedScreen; |
|
37 | 40 |
|
38 | 41 |
import org.distorted.objectlib.main.ObjectControl; |
39 | 42 |
import org.distorted.objectlib.main.ObjectType; |
... | ... | |
196 | 199 |
if( mObjectOrdinal>=0 && mObjectOrdinal< ObjectType.NUM_OBJECTS ) |
197 | 200 |
{ |
198 | 201 |
ObjectType obj = ObjectType.getObject(mObjectOrdinal); |
199 |
view.getObjectControl().changeObject(obj);
|
|
202 |
changeIfDifferent(obj,view.getObjectControl());
|
|
200 | 203 |
} |
201 | 204 |
} |
202 |
|
|
205 |
|
|
203 | 206 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
204 | 207 |
|
205 | 208 |
@Override |
... | ... | |
217 | 220 |
errDiag.show(getSupportFragmentManager(), null); |
218 | 221 |
} |
219 | 222 |
|
223 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
224 |
|
|
225 |
private void changeIfDifferent(ObjectType type,ObjectControl control) |
|
226 |
{ |
|
227 |
InputStream jsonStream = ObjectJson.getStream(type,this); |
|
228 |
InputStream meshStream = ObjectMesh.getStream(type,this); |
|
229 |
control.changeIfDifferent(type.ordinal(),jsonStream,meshStream); |
|
230 |
} |
|
231 |
|
|
220 | 232 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
221 | 233 |
|
222 | 234 |
TutorialScreen getState() |
src/main/java/org/distorted/tutorials/TutorialList.java | ||
---|---|---|
515 | 515 |
|
516 | 516 |
public int getIconID() |
517 | 517 |
{ |
518 |
int iconSize = RubikActivity.getDrawableSize();
|
|
518 |
int iconSize = RubikActivity.getDrawableSize(); |
|
519 | 519 |
return mObject.getIconID(iconSize); |
520 | 520 |
} |
521 | 521 |
|
Also available in: Unified diff
Move the main app to the 'J1M1' object creation mode, i.e. create them from the Json files and using the Dmesh fiels as well.
Make it possible for any app descending from the 'objectlib' to use any of the J0M0, J0M1, J1M0, J1M1 modes.