Project

General

Profile

« Previous | Next » 

Revision 00af5060

Added by Leszek Koltunski about 3 years ago

Always use only (max) 10 levels - (max) 9 'initial' Levels + Full Scramble.

View differences:

src/main/java/org/distorted/states/RubikStatePlay.java
45 45

  
46 46
public class RubikStatePlay extends RubikStateBase
47 47
  {
48
  private static final int LEVELS_SHOWN = 10;
49
  public  static final int DEF_OBJECT= ObjectList.CUBE.ordinal();
50
  public  static final int DEF_SIZE  =  3;
48
  public static final int LEVELS_SHOWN = 10;
49
  public static final int DEF_OBJECT= ObjectList.CUBE.ordinal();
50
  public static final int DEF_SIZE  =  3;
51 51

  
52 52
  private static final int[] BUTTON_LABELS = { R.string.scores, R.string.patterns, R.string.solver, R.string.tutorials, R.string.about };
53 53
  private static final int NUM_BUTTONS = BUTTON_LABELS.length;
54
  private static final float LAST_BUTTON = 1.4f;
54 55

  
55 56
  private ImageButton mObjButton, mMenuButton, mSolveButton;
56 57
  private Button mPlayButton;
......
173 174
          final int levelsShown = Math.min(maxLevel,LEVELS_SHOWN);
174 175

  
175 176
          mPlayPopup.showAsDropDown(view, margin, margin);
176
          mPlayPopup.update(view, mPlayLayoutWidth, (int)(levelsShown*(mMenuItemSize+margin)+2*margin));
177
          mPlayPopup.update(view, mPlayLayoutWidth, (int)(levelsShown*(mMenuItemSize+margin)+3*margin+mMenuItemSize*(LAST_BUTTON-1.0f)));
177 178

  
178 179
          mPlayPopup.setFocusable(true);
179 180
          mPlayPopup.update();
......
493 494
    {
494 495
    int sizeIndex = ObjectList.getSizeIndex(mObject,mSize);
495 496
    int maxLevel = ObjectList.getMaxLevel(mObject, sizeIndex);
496
    String[] levels = new String[maxLevel];
497
    int numLevel = Math.min(maxLevel, LEVELS_SHOWN);
498
    String[] levels = new String[numLevel];
497 499

  
498
    for(int i=0; i<maxLevel; i++)
500
    for(int i=0; i<numLevel-1; i++)
499 501
      {
500 502
      levels[i] = act.getString(R.string.lv_placeholder,i+1);
501 503
      }
502 504

  
503
    if( mLevelValue>maxLevel ) mLevelValue=1;
505
    levels[numLevel-1] = act.getString(R.string.level_full);
506

  
507
    if( mLevelValue>maxLevel || mLevelValue<1 ||
508
       (mLevelValue<maxLevel || mLevelValue>LEVELS_SHOWN ) )
509
      {
510
      mLevelValue=1;
511
      }
504 512

  
505 513
    float width = act.getScreenWidthInPixels();
506 514
    int margin  = (int)(width*RubikActivity.MARGIN);
......
510 518
    pM.setMargins(margin, 0, margin, margin);
511 519
    LinearLayout.LayoutParams pT = new LinearLayout.LayoutParams( mPlayLayoutWidth - 2*padding, (int)mMenuItemSize);
512 520
    pT.setMargins(margin, margin, margin, margin);
513
    LinearLayout.LayoutParams pB = new LinearLayout.LayoutParams( mPlayLayoutWidth - 2*padding, (int)mMenuItemSize);
521
    LinearLayout.LayoutParams pB = new LinearLayout.LayoutParams( mPlayLayoutWidth - 2*padding, (int)(mMenuItemSize*LAST_BUTTON) );
514 522
    pB.setMargins(margin, margin, margin, 2*margin);
515 523

  
516 524
    mPlayLayout.removeAllViews();
517 525

  
518 526
    RubikScores scores = RubikScores.getInstance();
519 527

  
520
    for(int i=0; i<maxLevel; i++)
528
    for(int i=0; i<numLevel; i++)
521 529
      {
522
      final int but = i;
530
      final int scrambles = i<numLevel-1 ? i+1 : maxLevel;
523 531
      Button button = new Button(act);
524
      button.setLayoutParams(i==0 ? pT : (i==maxLevel-1 ? pB : pM));
532
      button.setLayoutParams(i==0 ? pT : (i==numLevel-1 ? pB : pM));
525 533
      button.setText(levels[i]);
526 534
      button.setTextSize(TypedValue.COMPLEX_UNIT_PX, mMenuTextSize);
527 535

  
......
534 542
        public void onClick(View v)
535 543
          {
536 544
          mPlayPopup.dismiss();
537
          mLevelValue = but+1;
545
          mLevelValue = scrambles;
538 546
          act.getPreRender().scrambleObject(mLevelValue);
539 547
          }
540 548
        });

Also available in: Unified diff