Revision 83018ac4
Added by Leszek Koltunski over 3 years ago
| src/main/java/org/distorted/dialogs/RubikDialogScoresPagerAdapter.java | ||
|---|---|---|
| 40 | 40 |
|
| 41 | 41 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 42 | 42 |
|
| 43 |
private void addSection(int tab, int level, int lastLevel, final RubikDialogScoresView view, final String[] country, final String[] name, final float[] time)
|
|
| 43 |
private void addSection(int tab, int level, final RubikDialogScoresView view, final String[] country, final String[] name, final float[] time) |
|
| 44 | 44 |
{
|
| 45 |
String title = level==lastLevel-1 ? |
|
| 45 |
if( level>RubikScreenPlay.LEVELS_SHOWN ) level=RubikScreenPlay.LEVELS_SHOWN; |
|
| 46 |
|
|
| 47 |
String title = level==RubikScreenPlay.LEVELS_SHOWN ? |
|
| 46 | 48 |
mAct.getString(R.string.levelM) : |
| 47 | 49 |
mAct.getString(R.string.lv_placeholder,level+1); |
| 48 | 50 |
|
| ... | ... | |
| 69 | 71 |
|
| 70 | 72 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 71 | 73 |
|
| 72 |
private void getNext(int currentTab, int[] toDoTab, int[] maxTab, int[] lastTab)
|
|
| 74 |
private void getNext(int currentTab, int[] toDoTab, int[] lastTab) |
|
| 73 | 75 |
{
|
| 74 |
if( toDoTab[currentTab]<maxTab[currentTab] ) |
|
| 76 |
int MAX = RubikScreenPlay.LEVELS_SHOWN+1; |
|
| 77 |
|
|
| 78 |
if( toDoTab[currentTab]<MAX ) |
|
| 75 | 79 |
{
|
| 76 | 80 |
mToDoTab = currentTab; |
| 77 |
mToDoLvl = toDoTab[currentTab]<maxTab[currentTab]-1 ? toDoTab[currentTab] : lastTab[currentTab]-1;
|
|
| 81 |
mToDoLvl = toDoTab[currentTab]<MAX-1 ? toDoTab[currentTab] : lastTab[currentTab]-1;
|
|
| 78 | 82 |
toDoTab[currentTab]++; |
| 79 | 83 |
} |
| 80 | 84 |
else |
| 81 | 85 |
{
|
| 82 | 86 |
for(int tab=0; tab<mNumTabs; tab++) |
| 83 | 87 |
{
|
| 84 |
if( toDoTab[tab]<maxTab[tab] )
|
|
| 88 |
if( toDoTab[tab]<MAX )
|
|
| 85 | 89 |
{
|
| 86 | 90 |
mToDoTab = tab; |
| 87 |
mToDoLvl = toDoTab[tab]<maxTab[tab]-1 ? toDoTab[tab] : lastTab[tab]-1;
|
|
| 91 |
mToDoLvl = toDoTab[tab]<MAX-1 ? toDoTab[tab] : lastTab[tab]-1;
|
|
| 88 | 92 |
toDoTab[tab]++; |
| 89 | 93 |
break; |
| 90 | 94 |
} |
| ... | ... | |
| 98 | 102 |
{
|
| 99 | 103 |
prepareView(); |
| 100 | 104 |
|
| 101 |
int MAX = RubikScreenPlay.LEVELS_SHOWN+1; |
|
| 102 | 105 |
int toDo=0; |
| 103 | 106 |
int[] toDoTab = new int[mNumTabs]; |
| 104 |
int[] maxTab = new int[mNumTabs]; |
|
| 105 | 107 |
int[] lastTab = new int[mNumTabs]; |
| 106 | 108 |
|
| 107 | 109 |
for(int i=0; i<mNumTabs; i++) |
| 108 | 110 |
{
|
| 109 | 111 |
lastTab[i]= RubikObjectList.getDBLevel(i); |
| 110 |
maxTab[i] = Math.min(lastTab[i],MAX); |
|
| 111 | 112 |
toDoTab[i]= 0; |
| 112 |
|
|
| 113 |
toDo += maxTab[i]; |
|
| 113 |
toDo += (RubikScreenPlay.LEVELS_SHOWN+1); |
|
| 114 | 114 |
} |
| 115 | 115 |
|
| 116 | 116 |
while( toDo>0 ) |
| 117 | 117 |
{
|
| 118 | 118 |
toDo--; |
| 119 |
getNext(mViewPager.getCurrentItem(),toDoTab,maxTab,lastTab); |
|
| 120 |
addSection( mToDoTab,mToDoLvl, lastTab[mToDoTab], mViews[mToDoTab], |
|
| 121 |
country[mToDoTab][mToDoLvl],name[mToDoTab][mToDoLvl],time[mToDoTab][mToDoLvl]); |
|
| 119 |
getNext(mViewPager.getCurrentItem(), toDoTab, lastTab); |
|
| 120 |
addSection( mToDoTab, mToDoLvl, mViews[mToDoTab], country[mToDoTab][mToDoLvl], name[mToDoTab][mToDoLvl], time[mToDoTab][mToDoLvl]); |
|
| 122 | 121 |
} |
| 123 | 122 |
} |
| 124 | 123 |
|
| src/main/java/org/distorted/external/RubikScores.java | ||
|---|---|---|
| 238 | 238 |
|
| 239 | 239 |
public synchronized boolean setRecord(int object, int level, long record) |
| 240 | 240 |
{
|
| 241 |
int key = mapKey(object,level)-1; // -1 - historical reasons; previous versions saved it like this.
|
|
| 241 |
int key = mapKey(object,level);
|
|
| 242 | 242 |
MapValue oldValue = mMap.get(key); |
| 243 | 243 |
|
| 244 | 244 |
if( oldValue==null ) |
| src/main/java/org/distorted/main/RubikActivity.java | ||
|---|---|---|
| 127 | 127 |
cutoutHack(); |
| 128 | 128 |
computeBarHeights(); |
| 129 | 129 |
|
| 130 |
RubikInAppMessanging listener = new RubikInAppMessanging(); |
|
| 131 |
FirebaseInAppMessaging.getInstance().addClickListener(listener); |
|
| 130 |
Thread thread = new Thread() |
|
| 131 |
{
|
|
| 132 |
public void run() |
|
| 133 |
{
|
|
| 134 |
RubikInAppMessanging listener = new RubikInAppMessanging(); |
|
| 135 |
FirebaseInAppMessaging.getInstance().addClickListener(listener); |
|
| 136 |
} |
|
| 137 |
}; |
|
| 138 |
|
|
| 139 |
thread.start(); |
|
| 132 | 140 |
} |
| 133 | 141 |
|
| 134 | 142 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/objects/RubikObjectList.java | ||
|---|---|---|
| 152 | 152 |
// those got remembered in the server-side DB already, so we need to keep using them. This function |
| 153 | 153 |
// provides a map between 'maxScramble' of an object and its 'dbLevel'. All new objects will have |
| 154 | 154 |
// those two values the same. |
| 155 |
// |
|
| 156 |
// all of those need to be > RubikStatePlay.LEVELS_SHOWN. |
|
| 155 | 157 |
|
| 156 | 158 |
public static int getDBLevel(int ordinal) |
| 157 | 159 |
{
|
| ... | ... | |
| 170 | 172 |
if( ordinal== ObjectSignatures.SKEW_3 ) return 17; |
| 171 | 173 |
if( ordinal== ObjectSignatures.REX_3 ) return 16; |
| 172 | 174 |
if( ordinal== ObjectSignatures.MIRR_3 ) return 16; |
| 173 |
if( ordinal== ObjectSignatures.IVY_2 ) return 8;
|
|
| 174 |
if( ordinal== ObjectSignatures.DIN4_3 ) return 7;
|
|
| 175 |
if( ordinal== ObjectSignatures.IVY_2 ) return 9;
|
|
| 176 |
if( ordinal== ObjectSignatures.DIN4_3 ) return 9;
|
|
| 175 | 177 |
|
| 176 | 178 |
// in 1.9.6 & 1.9.7 there is a bug with downloadable objects (in this very function!): |
| 177 | 179 |
// All of those have DBLevel equal to CUBE_3's DBlevel (in 1.9.7!), i.e. 17. |
| src/main/java/org/distorted/screens/RubikScreenPlay.java | ||
|---|---|---|
| 509 | 509 |
private void setupLevelColors(RubikActivity act) |
| 510 | 510 |
{
|
| 511 | 511 |
int currObject = RubikObjectList.getCurrObject(); |
| 512 |
int dbLevel = RubikObjectList.getDBLevel(currObject); |
|
| 513 | 512 |
RubikScores scores = RubikScores.getInstance(); |
| 514 | 513 |
Resources res = act.getResources(); |
| 515 | 514 |
ColorStateList colorG = ColorStateList.valueOf(res.getColor(R.color.green)); |
| 516 | 515 |
ColorStateList colorD = ColorStateList.valueOf(res.getColor(R.color.dark_grey)); |
| 517 | 516 |
|
| 518 |
for(int i=0; i<=LEVELS_SHOWN; i++)
|
|
| 517 |
for(int level=0; level<=LEVELS_SHOWN; level++)
|
|
| 519 | 518 |
{
|
| 520 |
int level = i<LEVELS_SHOWN ? i : dbLevel; |
|
| 521 | 519 |
boolean isSolved = scores.isSolved(currObject,level); |
| 522 |
mLevel[i].setBackgroundTintList( isSolved ? colorG : colorD);
|
|
| 520 |
mLevel[level].setBackgroundTintList( isSolved ? colorG : colorD);
|
|
| 523 | 521 |
} |
| 524 | 522 |
} |
| 525 | 523 |
|
| src/main/java/org/distorted/screens/RubikScreenSolving.java | ||
|---|---|---|
| 177 | 177 |
|
| 178 | 178 |
RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass(); |
| 179 | 179 |
int object = RubikObjectList.getCurrObject(); |
| 180 |
int level = play.getLevel(); |
|
| 180 |
int level = play.getLevel()-1;
|
|
| 181 | 181 |
boolean isNew = mScores.setRecord(object, level, mElapsed); |
| 182 | 182 |
|
| 183 | 183 |
return isNew ? mElapsed : -mElapsed; |
Also available in: Unified diff
Correct the MAX level in the leaderboard.