Revision adbd16d9
Added by Leszek Koltunski almost 2 years ago
src/main/java/org/distorted/screens/RubikScreenPlay.java | ||
---|---|---|
64 | 64 |
public class RubikScreenPlay extends RubikScreenBase implements RubikNetwork.Updatee |
65 | 65 |
{ |
66 | 66 |
public static final int NUM_COLUMNS = 5; |
67 |
public static final int LEVELS_SHOWN = 10;
|
|
67 |
public static final int LEVELS_SHOWN = 8;
|
|
68 | 68 |
|
69 | 69 |
private static final int[] BUTTON_LABELS = { R.string.scores, |
70 | 70 |
R.string.patterns, |
... | ... | |
74 | 74 |
R.string.about }; |
75 | 75 |
private static final int NUM_BUTTONS = BUTTON_LABELS.length; |
76 | 76 |
|
77 |
private static final float LAST_BUTTON = 1.5f;
|
|
77 |
private static final float BIG_BUTTON = 1.5f;
|
|
78 | 78 |
private static final int[] mLocation = new int[2]; |
79 | 79 |
|
80 | 80 |
private TransparentImageButton mObjButton, mMenuButton, mSolveButton, mScrambleButton; |
... | ... | |
194 | 194 |
popupView.setSystemUiVisibility(RubikActivity.FLAGS); |
195 | 195 |
final int object = RubikObjectList.getCurrObject(); |
196 | 196 |
final int dbLevel = RubikObjectList.getDBLevel(object); |
197 |
final int levelsShown = Math.min(dbLevel,LEVELS_SHOWN); |
|
198 |
final int popupHeight = (int)(levelsShown*(mMenuItemSize+margin)+3*margin+mMenuItemSize*(LAST_BUTTON-1.0f));
|
|
197 |
final int levelsShown = Math.min(dbLevel,LEVELS_SHOWN)+1;
|
|
198 |
final int popupHeight = (int)(levelsShown*(mMenuItemSize+margin)+4*margin+2*mMenuItemSize*(BIG_BUTTON-1.0f));
|
|
199 | 199 |
final int realHeight = Math.min(popupHeight,maxHeight); |
200 | 200 |
displayPopup(act,view,mPlayPopup,mPlayLayoutWidth,realHeight,margin,margin); |
201 | 201 |
} |
... | ... | |
237 | 237 |
|
238 | 238 |
private void setupObjectWindow(final RubikActivity act, final float width, final float height) |
239 | 239 |
{ |
240 |
int cubeWidth = (int)(width/9);
|
|
241 |
int margin = (int)(width*RubikActivity.LARGE_MARGIN); |
|
242 |
mObjectSize = (int)(cubeWidth + 2*margin + 0.5f);
|
|
240 |
int cubeSize = (int)(width/9);
|
|
241 |
int margin = (int)(width*RubikActivity.LARGE_MARGIN);
|
|
242 |
mObjectSize = (int)(cubeSize + 2*margin + 0.5f);
|
|
243 | 243 |
mMaxRowCount = (int)((height-1.8f*mUpperBarHeight)/mObjectSize); |
244 | 244 |
|
245 | 245 |
LinearLayout view = (LinearLayout)inflate( act, R.layout.popup_object, null); |
... | ... | |
303 | 303 |
params.leftMargin = margin; |
304 | 304 |
params.rightMargin = margin; |
305 | 305 |
|
306 |
params.width = cubeWidth;
|
|
307 |
params.height= cubeWidth;
|
|
306 |
params.width = cubeSize;
|
|
307 |
params.height= cubeSize;
|
|
308 | 308 |
|
309 | 309 |
nextInRow[row]++; |
310 | 310 |
|
... | ... | |
603 | 603 |
{ |
604 | 604 |
int currObject = RubikObjectList.getCurrObject(); |
605 | 605 |
int dbLevel = RubikObjectList.getDBLevel(currObject); |
606 |
int numLevel= Math.min(dbLevel, LEVELS_SHOWN); |
|
606 |
int numLevel= Math.min(dbLevel, LEVELS_SHOWN)+1;
|
|
607 | 607 |
RubikScores scores = RubikScores.getInstance(); |
608 | 608 |
|
609 | 609 |
for(int i=0; i<numLevel; i++) |
610 | 610 |
{ |
611 |
int level = i<numLevel-1 ? i+1 : dbLevel;
|
|
611 |
int level = i<numLevel-1 ? i : dbLevel; |
|
612 | 612 |
Button button = (Button)mPlayLayout.getChildAt(i); |
613 | 613 |
int icon = scores.isSolved(currObject, level-1) ? R.drawable.ui_solved : R.drawable.ui_notsolved; |
614 | 614 |
button.setCompoundDrawablesWithIntrinsicBounds(icon,0,0,0); |
... | ... | |
624 | 624 |
int dbLevel = RubikObjectList.getDBLevel(currObject); |
625 | 625 |
RubikObject object = RubikObjectList.getObject(currObject); |
626 | 626 |
int numScrambles = object==null ? 0 : object.getNumScramble(); |
627 |
int numLevel = Math.min(dbLevel, LEVELS_SHOWN); |
|
627 |
int numLevel = Math.min(dbLevel, LEVELS_SHOWN)+1;
|
|
628 | 628 |
String[] levels = new String[numLevel]; |
629 | 629 |
|
630 |
for(int i=0; i<numLevel-1; i++) |
|
631 |
{ |
|
632 |
levels[i] = act.getString(R.string.lv_placeholder,i+1); |
|
633 |
} |
|
634 |
|
|
635 |
if( numLevel>0 ) |
|
636 |
{ |
|
637 |
levels[numLevel-1] = act.getString(R.string.level_full); |
|
638 |
} |
|
630 |
levels[0] = act.getString(R.string.free_play); |
|
631 |
for(int i=1; i<numLevel-1; i++) levels[i] = act.getString(R.string.lv_placeholder,i); |
|
632 |
levels[numLevel-1] = act.getString(R.string.level_full); |
|
639 | 633 |
|
640 | 634 |
if( mLevelValue>dbLevel || mLevelValue<1 || |
641 |
(mLevelValue<dbLevel || mLevelValue>LEVELS_SHOWN ) ) |
|
642 |
{ |
|
643 |
mLevelValue=1; |
|
644 |
} |
|
635 |
(mLevelValue<dbLevel || mLevelValue>LEVELS_SHOWN ) ) mLevelValue=1; |
|
645 | 636 |
|
646 | 637 |
float width = act.getScreenWidthInPixels(); |
647 | 638 |
int margin = (int)(width*RubikActivity.SMALL_MARGIN); |
648 | 639 |
int padding = (int)(width*RubikActivity.PADDING); |
649 | 640 |
int butWidth = mPlayLayoutWidth - 2*padding; |
650 | 641 |
int butHeight= (int)mMenuItemSize; |
651 |
int lastButH = (int)(mMenuItemSize*LAST_BUTTON) ;
|
|
642 |
int bigButH = (int)(mMenuItemSize*BIG_BUTTON) ;
|
|
652 | 643 |
|
653 | 644 |
LinearLayout.LayoutParams pM = new LinearLayout.LayoutParams( butWidth, butHeight ); |
654 | 645 |
pM.setMargins(margin, 0, margin, margin); |
655 |
LinearLayout.LayoutParams pT = new LinearLayout.LayoutParams( butWidth, butHeight ); |
|
656 |
pT.setMargins(margin, margin, margin, margin); |
|
657 |
LinearLayout.LayoutParams pB = new LinearLayout.LayoutParams( butWidth, lastButH ); |
|
646 |
LinearLayout.LayoutParams pB = new LinearLayout.LayoutParams( butWidth, bigButH ); |
|
658 | 647 |
pB.setMargins(margin, margin, margin, 2*margin); |
659 | 648 |
|
660 | 649 |
mPlayLayout.removeAllViews(); |
661 | 650 |
|
662 |
RubikScores scores = RubikScores.getInstance(); |
|
663 |
|
|
664 | 651 |
for(int i=0; i<numLevel; i++) |
665 | 652 |
{ |
666 |
final int level = i<numLevel-1 ? i+1 : dbLevel;
|
|
667 |
final int scrambles = i<numLevel-1 ? i+1 : numScrambles;
|
|
653 |
final int level = i<numLevel-1 ? i : dbLevel; |
|
654 |
final int scrambles = i<numLevel-1 ? i : numScrambles; |
|
668 | 655 |
Button button = new Button(act); |
669 |
button.setLayoutParams(i==0 ? pT : (i==numLevel-1 ? pB : pM));
|
|
656 |
button.setLayoutParams(i==0 ? pB : (i==numLevel-1 ? pB : pM));
|
|
670 | 657 |
button.setText(levels[i]); |
671 | 658 |
button.setTextSize(TypedValue.COMPLEX_UNIT_PX, mMenuTextSize); |
672 | 659 |
|
673 |
int icon = scores.isSolved(currObject, level-1) ? R.drawable.ui_solved : R.drawable.ui_notsolved; |
|
674 |
button.setCompoundDrawablesWithIntrinsicBounds(icon,0,0,0); |
|
675 |
|
|
676 | 660 |
button.setOnClickListener( new View.OnClickListener() |
677 | 661 |
{ |
678 | 662 |
@Override |
... | ... | |
683 | 667 |
if(control.isUINotBlocked()) |
684 | 668 |
{ |
685 | 669 |
if( mPlayPopup!=null ) mPlayPopup.dismiss(); |
686 |
mLevelValue = level; |
|
687 |
mShouldReactToEndOfScrambling = true; |
|
688 |
control.scrambleObject(scrambles); |
|
670 |
|
|
671 |
if( level>0 ) |
|
672 |
{ |
|
673 |
mLevelValue = level; |
|
674 |
mShouldReactToEndOfScrambling = true; |
|
675 |
control.scrambleObject(scrambles); |
|
676 |
} |
|
677 |
else |
|
678 |
{ |
|
679 |
ScreenList.switchScreen(act, ScreenList.FREE); |
|
680 |
} |
|
689 | 681 |
} |
690 | 682 |
} |
691 | 683 |
}); |
Also available in: Unified diff
New 'Free Play' screen.