Project

General

Profile

« Previous | Next » 

Revision 2011391d

Added by Leszek Koltunski about 2 years ago

Interface: properly support object which have numScrambles less than 8.

View differences:

src/main/java/org/distorted/screens/RubikScreenPlay.java
69 69
  private int mUpperBarHeight;
70 70
  private boolean mShouldReactToEndOfScrambling;
71 71
  private float mScreenWidth;
72
  private int mOldNumScramble;
72 73

  
73 74
///////////////////////////////////////////////////////////////////////////////////////////////////
74 75

  
......
89 90
    mMenuTextSize     = (int)(mScreenWidth*RubikActivity.MENU_MAIN_TEXT_SIZE);
90 91

  
91 92
    mObjectPopup = null;
93
    mOldNumScramble = 1000; // used to remember which 'level' buttons are visible; initially all visible
92 94

  
93 95
    // TOP ////////////////////////////
94 96
    LinearLayout layoutTop = act.findViewById(R.id.upperBar);
......
161 163
          {
162 164
          View popupView = mMenuPopup.getContentView();
163 165
          popupView.setSystemUiVisibility(RubikActivity.FLAGS);
164
          setupLevelColors(act);
166
          setupLevelButtonVisibilityAndColor(act);
165 167
          displayPopup(act,view,mMenuPopup,mMenuLayoutWidth,mMenuLayoutHeight,(int)(-mMenuLayoutWidth/2 + width/6),0);
166 168
          }
167 169
        }
......
207 209
              {
208 210
              RubikObjectList.setCurrObject(ordinal);
209 211
              act.changeObject(ordinal,true);
210
              if( mMenuPopup!=null ) setupLevelColors(act);
212
              if( mMenuPopup!=null ) setupLevelButtonVisibilityAndColor(act);
211 213
              mMovesController.clearMoves(act);
212 214
              }
213 215
            else
......
481 483

  
482 484
///////////////////////////////////////////////////////////////////////////////////////////////////
483 485

  
484
  private void setupLevelColors(RubikActivity act)
486
  private void setupLevelButtonVisibilityAndColor(RubikActivity act)
485 487
    {
486 488
    int currObject = RubikObjectList.getCurrObject();
489
    RubikObject object = RubikObjectList.getObject(currObject);
490
    int numScramble = object==null ? 1 : object.getNumScramble();
487 491
    RubikScores scores = RubikScores.getInstance();
488 492
    Resources res = act.getResources();
489 493
    ColorStateList colorG = ColorStateList.valueOf(res.getColor(R.color.green));
......
494 498
      boolean isSolved = scores.isSolved(currObject,level);
495 499
      mLevel[level].setBackgroundTintList( isSolved ? colorG : colorD);
496 500
      }
501

  
502
    if( numScramble<=LEVELS_SHOWN || mOldNumScramble<=LEVELS_SHOWN )
503
      {
504
      if( numScramble<mOldNumScramble )
505
        {
506
        int max = Math.min(LEVELS_SHOWN,mOldNumScramble-1);
507
        for(int level=numScramble; level<=max; level++) mLevel[level].setVisibility(View.INVISIBLE);
508
        mLevel[numScramble-1].setText(R.string.levelM);
509
        }
510
      if( numScramble>mOldNumScramble )
511
        {
512
        int max = Math.min(LEVELS_SHOWN,numScramble-1);
513
        mLevel[mOldNumScramble-1].setText( String.valueOf(mOldNumScramble) );
514

  
515
        for(int level=mOldNumScramble; level<=max; level++)
516
          {
517
          mLevel[level].setVisibility(View.VISIBLE);
518
          if( level<max ) mLevel[level].setText( String.valueOf(level+1) );
519
          else            mLevel[level].setText( R.string.levelM );
520
          }
521
        }
522
      }
523

  
524
    mOldNumScramble = numScramble;
497 525
    }
498 526

  
499 527
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff