Project

General

Profile

Download (22.1 KB) Statistics
| Branch: | Tag: | Revision:

magiccube / src / main / java / org / distorted / screens / RubikScreenPlay.java @ 588ace55

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

    
20
package org.distorted.screens;
21

    
22
import android.content.Context;
23
import android.content.SharedPreferences;
24
import android.graphics.drawable.BitmapDrawable;
25
import android.os.Build;
26
import android.os.Bundle;
27
import android.util.TypedValue;
28
import android.view.Gravity;
29
import android.view.LayoutInflater;
30
import android.view.View;
31
import android.widget.Button;
32
import android.widget.GridLayout;
33
import android.widget.ImageButton;
34
import android.widget.LinearLayout;
35
import android.widget.PopupWindow;
36
import android.widget.ScrollView;
37

    
38
import org.distorted.dialogs.RubikDialogAbout;
39
import org.distorted.dialogs.RubikDialogPattern;
40
import org.distorted.dialogs.RubikDialogScores;
41
import org.distorted.dialogs.RubikDialogTutorial;
42
import org.distorted.helpers.TransparentButton;
43
import org.distorted.helpers.TransparentImageButton;
44
import org.distorted.main.R;
45
import org.distorted.main.RubikActivity;
46
import org.distorted.main.RubikPreRender;
47
import org.distorted.objectlib.ObjectList;
48
import org.distorted.network.RubikScores;
49

    
50
///////////////////////////////////////////////////////////////////////////////////////////////////
51

    
52
public class RubikScreenPlay extends RubikScreenBase
53
  {
54
  public static final int LEVELS_SHOWN = 10;
55
  public static final int DEF_OBJECT= ObjectList.CUBE.ordinal();
56
  public static final int DEF_SIZE  =  3;
57

    
58
  private static final int[] BUTTON_LABELS = { R.string.scores,
59
                                               R.string.patterns,
60
                                            //   R.string.control,
61
                                               R.string.solver,
62
                                               R.string.tutorials,
63
                                               R.string.about };
64

    
65
  private static final int NUM_BUTTONS = BUTTON_LABELS.length;
66
  private static final float LAST_BUTTON = 1.5f;
67
  private static final int[] mLocation = new int[2];
68

    
69
  private ImageButton mObjButton, mMenuButton, mSolveButton;
70
  private Button mPlayButton;
71
  private PopupWindow mObjectPopup, mMenuPopup, mPlayPopup;
72
  private int mObject = DEF_OBJECT;
73
  private int mSize   = DEF_SIZE;
74
  private int mObjectSize, mMenuLayoutWidth, mMenuLayoutHeight, mPlayLayoutWidth;
75
  private int mLevelValue;
76
  private float mButtonSize, mMenuItemSize, mMenuTextSize;
77
  private int mColCount, mRowCount, mMaxRowCount;
78
  private LinearLayout mPlayLayout;
79
  private int mUpperBarHeight;
80

    
81
  private boolean mIsFullScreen;
82

    
83
///////////////////////////////////////////////////////////////////////////////////////////////////
84

    
85
  void leaveScreen(RubikActivity act)
86
    {
87

    
88
    }
89

    
90
///////////////////////////////////////////////////////////////////////////////////////////////////
91

    
92
  void enterScreen(final RubikActivity act)
93
    {
94
    float width = act.getScreenWidthInPixels();
95
    float height= act.getScreenHeightInPixels();
96
    mUpperBarHeight = act.getHeightUpperBar();
97

    
98
    mMenuTextSize = width*RubikActivity.MENU_MED_TEXT_SIZE;
99
    mButtonSize   = width*RubikActivity.BUTTON_TEXT_SIZE;
100
    mMenuItemSize = width*RubikActivity.MENU_ITEM_SIZE;
101

    
102
    mRowCount = ObjectList.getRowCount();
103
    mColCount = ObjectList.getColumnCount();
104

    
105
    // TOP ////////////////////////////
106
    LinearLayout layoutTop = act.findViewById(R.id.upperBar);
107
    layoutTop.removeAllViews();
108

    
109
    setupObjectWindow(act,width,height);
110
    setupObjectButton(act,width);
111
    layoutTop.addView(mObjButton);
112

    
113
    setupMenuWindow(act,width);
114
    setupMenuButton(act,width);
115
    layoutTop.addView(mMenuButton);
116

    
117
    setupPlayWindow(act,width);
118
    setupPlayButton(act,width,height);
119
    layoutTop.addView(mPlayButton);
120

    
121
    setupSolveButton(act,width);
122
    createBottomPane(act,width,mSolveButton);
123
    }
124

    
125
///////////////////////////////////////////////////////////////////////////////////////////////////
126

    
127
  private void setupObjectButton(final RubikActivity act, final float width)
128
    {
129
    final int margin  = (int)(width*RubikActivity.MARGIN);
130
    final int icon = RubikActivity.getDrawable(R.drawable.ui_small_cube_menu,R.drawable.ui_medium_cube_menu, R.drawable.ui_big_cube_menu, R.drawable.ui_huge_cube_menu);
131

    
132
    mObjButton = new TransparentImageButton(act, icon, width,LinearLayout.LayoutParams.MATCH_PARENT);
133

    
134
    mObjButton.setOnClickListener( new View.OnClickListener()
135
      {
136
      @Override
137
      public void onClick(View view)
138
        {
139
        if( mObjectPopup!=null && act.getPreRender().isUINotBlocked())
140
          {
141
          int rowCount = Math.min(mMaxRowCount,mRowCount);
142
          View popupView = mObjectPopup.getContentView();
143
          popupView.setSystemUiVisibility(RubikActivity.FLAGS);
144
          displayPopup(act,view,mObjectPopup,mObjectSize*mColCount,mObjectSize*rowCount,margin,margin);
145
          }
146
        }
147
      });
148
    }
149

    
150
///////////////////////////////////////////////////////////////////////////////////////////////////
151

    
152
  private void setupPlayButton(final RubikActivity act, final float width, final float height)
153
    {
154
    final int margin   = (int)(width*RubikActivity.MARGIN);
155
    final int maxHeight= (int)(0.9f*(height-mUpperBarHeight) );
156

    
157
    mPlayButton = new TransparentButton(act, R.string.play, mButtonSize, width);
158

    
159
    mPlayButton.setOnClickListener( new View.OnClickListener()
160
      {
161
      @Override
162
      public void onClick(View view)
163
        {
164
        if( mPlayPopup!=null && act.getPreRender().isUINotBlocked())
165
          {
166
          View popupView = mPlayPopup.getContentView();
167
          popupView.setSystemUiVisibility(RubikActivity.FLAGS);
168
          final int sizeIndex = ObjectList.getSizeIndex(mObject,mSize);
169
          final int dbLevel = ObjectList.getDBLevel(mObject, sizeIndex);
170
          final int levelsShown = Math.min(dbLevel,LEVELS_SHOWN);
171
          final int popupHeight = (int)(levelsShown*(mMenuItemSize+margin)+3*margin+mMenuItemSize*(LAST_BUTTON-1.0f));
172
          final int realHeight = Math.min(popupHeight,maxHeight);
173
          displayPopup(act,view,mPlayPopup,mPlayLayoutWidth,realHeight,margin,margin);
174
          }
175
        }
176
      });
177
    }
178

    
179
///////////////////////////////////////////////////////////////////////////////////////////////////
180

    
181
  private void setupMenuButton(final RubikActivity act, final float width)
182
    {
183
    final int margin  = (int)(width*RubikActivity.MARGIN);
184
    final int icon = RubikActivity.getDrawable(R.drawable.ui_small_menu,R.drawable.ui_medium_menu, R.drawable.ui_big_menu, R.drawable.ui_huge_menu);
185

    
186
    mMenuButton = new TransparentImageButton(act, icon, width,LinearLayout.LayoutParams.MATCH_PARENT);
187

    
188
    mMenuButton.setOnClickListener( new View.OnClickListener()
189
      {
190
      @Override
191
      public void onClick(View view)
192
        {
193
        if( mMenuPopup!=null && act.getPreRender().isUINotBlocked())
194
          {
195
          View popupView = mMenuPopup.getContentView();
196
          popupView.setSystemUiVisibility(RubikActivity.FLAGS);
197
          displayPopup(act,view,mMenuPopup,mMenuLayoutWidth,mMenuLayoutHeight,(int)(-width/12),margin);
198
          }
199
        }
200
      });
201
    }
202

    
203
///////////////////////////////////////////////////////////////////////////////////////////////////
204

    
205
  private void setupObjectWindow(final RubikActivity act, final float width, final float height)
206
    {
207
    int icon = RubikActivity.getDrawable(R.drawable.ui_small_cube2,R.drawable.ui_medium_cube2, R.drawable.ui_big_cube2, R.drawable.ui_huge_cube2);
208

    
209
    BitmapDrawable bd = (BitmapDrawable) act.getResources().getDrawable(icon);
210
    int cubeWidth = bd.getIntrinsicWidth();
211
    int margin = (int)(width*RubikActivity.LARGE_MARGIN);
212
    mObjectSize = (int)(cubeWidth + 2*margin + 0.5f);
213
    mMaxRowCount = (int)(0.9f*(height-mUpperBarHeight)/mObjectSize);
214
    GridLayout objectGrid = new GridLayout(act);
215
    mObjectPopup = new PopupWindow(act);
216
    mObjectPopup.setFocusable(true);
217

    
218
    if( mMaxRowCount<mRowCount )
219
      {
220
      ScrollView scrollView = new ScrollView(act);
221
      scrollView.addView(objectGrid);
222
      mObjectPopup.setContentView(scrollView);
223
      }
224
    else
225
      {
226
      mObjectPopup.setContentView(objectGrid);
227
      }
228

    
229
    int[] indices = ObjectList.getIndices();
230

    
231
    GridLayout.Spec[] rowSpecs = new GridLayout.Spec[mRowCount];
232
    GridLayout.Spec[] colSpecs = new GridLayout.Spec[mColCount];
233

    
234
    objectGrid.setColumnCount(mColCount);
235
    objectGrid.setRowCount(mRowCount);
236

    
237
    int[] nextInRow = new int[mRowCount];
238

    
239
    for(int row=0; row<mRowCount; row++)
240
      {
241
      rowSpecs[row] = GridLayout.spec(row);
242
      nextInRow[row]= 0;
243
      }
244
    for(int col=0; col<mColCount; col++)
245
      {
246
      colSpecs[col] = GridLayout.spec(col);
247
      }
248

    
249
    for(int object=0; object< ObjectList.NUM_OBJECTS; object++)
250
      {
251
      final ObjectList list = ObjectList.getObject(object);
252
      final int[] sizes = list.getSizes();
253
      int iconSize = RubikActivity.getDrawableSize();
254
      int[] icons = list.getIconIDs(iconSize);
255
      int len = sizes.length;
256
      final int obj = object;
257
      int row = indices[object];
258

    
259
      for(int i=0; i<len; i++)
260
        {
261
        final int index = i;
262

    
263
        ImageButton button = new ImageButton(act);
264
        button.setBackgroundResource(icons[i]);
265
        button.setOnClickListener( new View.OnClickListener()
266
          {
267
          @Override
268
          public void onClick(View v)
269
            {
270
            if( act.getPreRender().isUINotBlocked() && ScreenList.getCurrentScreen()== ScreenList.PLAY )
271
              {
272
              mObject = obj;
273
              mSize   = sizes[index];
274
              act.changeObject(list,sizes[index], true);
275
              adjustLevels(act);
276
              mController.clearMoves(act);
277
              }
278

    
279
            mObjectPopup.dismiss();
280
            }
281
          });
282

    
283
        GridLayout.LayoutParams params = new GridLayout.LayoutParams(rowSpecs[row],colSpecs[nextInRow[row]]);
284
        params.bottomMargin = margin;
285
        params.topMargin    = margin;
286
        params.leftMargin   = margin;
287
        params.rightMargin  = margin;
288

    
289
        nextInRow[row]++;
290

    
291
        objectGrid.addView(button, params);
292
        }
293
      }
294
    }
295

    
296
///////////////////////////////////////////////////////////////////////////////////////////////////
297

    
298
  private void setupMenuWindow(final RubikActivity act, final float width)
299
    {
300
    LayoutInflater layoutInflater = (LayoutInflater)act.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
301
    final View layout = layoutInflater.inflate(R.layout.popup_menu, null);
302
    LinearLayout menuLayout = layout.findViewById(R.id.menuGrid);
303

    
304
    mMenuPopup = new PopupWindow(act);
305
    mMenuPopup.setContentView(layout);
306
    mMenuPopup.setFocusable(true);
307
    int margin  = (int)(width*RubikActivity.MARGIN);
308
    int padding = (int)(width*RubikActivity.PADDING);
309

    
310
    mMenuLayoutWidth = (int)(width/2);
311
    mMenuLayoutHeight= (int)(2*margin + NUM_BUTTONS*(mMenuItemSize+margin));
312

    
313
    LinearLayout.LayoutParams p = new LinearLayout.LayoutParams( mMenuLayoutWidth - 2*padding, (int)mMenuItemSize);
314

    
315
    for(int i=0; i<NUM_BUTTONS; i++)
316
      {
317
      final int but = i;
318
      Button button = new Button(act);
319
      button.setLayoutParams(p);
320
      button.setText(BUTTON_LABELS[i]);
321
      button.setTextSize(TypedValue.COMPLEX_UNIT_PX, mMenuTextSize);
322

    
323
      button.setOnClickListener( new View.OnClickListener()
324
        {
325
        @Override
326
        public void onClick(View v)
327
          {
328
          mMenuPopup.dismiss();
329
          MenuAction(act,but);
330
          }
331
        });
332

    
333
      menuLayout.addView(button);
334
      }
335
    }
336

    
337
///////////////////////////////////////////////////////////////////////////////////////////////////
338

    
339
  private void setupPlayWindow(final RubikActivity act, final float width)
340
    {
341
    LayoutInflater layoutInflater = (LayoutInflater)act.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
342
    final View layout = layoutInflater.inflate(R.layout.popup_play, null);
343
    mPlayLayout = layout.findViewById(R.id.playGrid);
344

    
345
    mPlayLayoutWidth = (int)(width*0.4f);
346

    
347
    mPlayPopup = new PopupWindow(act);
348
    mPlayPopup.setContentView(layout);
349
    mPlayPopup.setFocusable(true);
350

    
351
    adjustLevels(act);
352
    }
353

    
354
///////////////////////////////////////////////////////////////////////////////////////////////////
355

    
356
  private void MenuAction(RubikActivity act, int button)
357
    {
358
    switch(button)
359
      {
360
      case 0: RubikScreenPlay play = (RubikScreenPlay) ScreenList.PLAY.getScreenClass();
361
              int object = play.getObject();
362
              int size   = play.getSize();
363
              int sizeIndex = ObjectList.getSizeIndex(object,size);
364
              Bundle sBundle = new Bundle();
365
              sBundle.putInt("tab", ObjectList.pack(object,sizeIndex) );
366
              sBundle.putBoolean("submitting", false);
367
              RubikDialogScores scores = new RubikDialogScores();
368
              scores.setArguments(sBundle);
369
              scores.show(act.getSupportFragmentManager(), null);
370
              break;
371
      case 1: RubikDialogPattern pDiag = new RubikDialogPattern();
372
              Bundle pBundle = new Bundle();
373
              int pOrd = getPatternOrdinal();
374
              pBundle.putInt("tab", pOrd );
375
              pDiag.setArguments(pBundle);
376
              pDiag.show( act.getSupportFragmentManager(), RubikDialogPattern.getDialogTag() );
377
              break;
378
/*
379
      case 2: RubikControl control = RubikControl.getInstance();
380
              //control.animateAll(act);
381
              control.animateRotate(act);
382
              break;
383
 */
384
      case 2: ScreenList.switchScreen(act, ScreenList.SVER);
385
              break;
386
      case 3: RubikDialogTutorial tDiag = new RubikDialogTutorial();
387
              Bundle tBundle = new Bundle();
388
              int tOrd = getTutorialOrdinal();
389
              tBundle.putInt("tab", tOrd );
390
              tDiag.setArguments(tBundle);
391
              tDiag.show( act.getSupportFragmentManager(), RubikDialogTutorial.getDialogTag() );
392
              break;
393
      case 4: RubikDialogAbout aDiag = new RubikDialogAbout();
394
              aDiag.show(act.getSupportFragmentManager(), null);
395
              break;
396
      }
397
    }
398

    
399
///////////////////////////////////////////////////////////////////////////////////////////////////
400

    
401
  void setupSolveButton(final RubikActivity act, final float width)
402
    {
403
    int icon = RubikActivity.getDrawable(R.drawable.ui_small_cube_solve,R.drawable.ui_medium_cube_solve, R.drawable.ui_big_cube_solve, R.drawable.ui_huge_cube_solve);
404
    mSolveButton = new TransparentImageButton(act, icon, width,LinearLayout.LayoutParams.MATCH_PARENT);
405

    
406
    mSolveButton.setOnClickListener( new View.OnClickListener()
407
      {
408
      @Override
409
      public void onClick(View v)
410
        {
411
        act.getPreRender().solveObject();
412
        mController.clearMoves(act);
413
        }
414
      });
415
    }
416

    
417
///////////////////////////////////////////////////////////////////////////////////////////////////
418

    
419
  public void savePreferences(SharedPreferences.Editor editor)
420
    {
421
    editor.putInt("statePlay_object", mObject);
422
    editor.putInt("statePlay_size"  , mSize);
423

    
424
    if( mObjectPopup!=null )
425
      {
426
      mObjectPopup.dismiss();
427
      mObjectPopup = null;
428
      }
429

    
430
    if( mMenuPopup!=null )
431
      {
432
      mMenuPopup.dismiss();
433
      mMenuPopup = null;
434
      }
435

    
436
    if( mPlayPopup!=null )
437
      {
438
      mPlayPopup.dismiss();
439
      mPlayPopup = null;
440
      }
441
    }
442

    
443
///////////////////////////////////////////////////////////////////////////////////////////////////
444

    
445
  public void restorePreferences(SharedPreferences preferences)
446
    {
447
    mObject= preferences.getInt("statePlay_object", DEF_OBJECT);
448
    mSize  = preferences.getInt("statePlay_size"  , DEF_SIZE  );
449

    
450
    int sizeIndex = ObjectList.getSizeIndex(mObject,mSize);
451
    int dbLevel = ObjectList.getDBLevel(mObject, sizeIndex);
452

    
453
    // This means the app has been upgraded to a new version which swapped the
454
    // Object for a new one with larger sizeIndex and now getMaxLevel() returns
455
    // 0. Reset the object to default, otherwise we'll get a crash later on.
456

    
457
    if( dbLevel==0 )
458
      {
459
      mObject = DEF_OBJECT;
460
      mSize   = DEF_SIZE;
461
      }
462
    }
463

    
464
///////////////////////////////////////////////////////////////////////////////////////////////////
465

    
466
  public boolean setObjectAndSize(RubikActivity act, ObjectList obj, int size)
467
    {
468
    if( mObject!=obj.ordinal() || mSize != size )
469
      {
470
      boolean success = false;
471

    
472
      for( int s: obj.getSizes() )
473
        if( s==size )
474
          {
475
          success = true;
476
          break;
477
          }
478

    
479
      if( success )
480
        {
481
        mObject = obj.ordinal();
482
        mSize   = size;
483

    
484
        if( mPlayLayout!=null ) adjustLevels(act);
485
        }
486

    
487
      return success;
488
      }
489

    
490
    return true;
491
    }
492

    
493
///////////////////////////////////////////////////////////////////////////////////////////////////
494
// work around lame bugs in Android's version <= 10 pop-up and split-screen modes
495

    
496
  private void displayPopup(RubikActivity act, View view, PopupWindow window, int w, int h, int xoff, int yoff)
497
    {
498
    View topLayout = act.findViewById(R.id.relativeLayout);
499

    
500
    if( topLayout!=null )
501
      {
502
      topLayout.getLocationOnScreen(mLocation);
503
      mIsFullScreen = (mLocation[1]==0);
504
      }
505
    else
506
      {
507
      mIsFullScreen = true;
508
      }
509

    
510
    // if on Android 11 or we are fullscreen
511
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R || mIsFullScreen )
512
      {
513
      window.showAsDropDown(view, xoff, yoff, Gravity.CENTER);
514
      window.update(view, w, h);
515
      }
516
    else  // Android 10 or below in pop-up mode or split-screen mode
517
      {
518
      view.getLocationOnScreen(mLocation);
519
      int width  = view.getWidth();
520
      int height = view.getHeight();
521
      int x = mLocation[0]+(width-w)/2;
522
      int y = mLocation[1]+height+yoff;
523

    
524
      window.showAsDropDown(view);
525
      window.update(x,y,w,h);
526
      }
527
    }
528

    
529
///////////////////////////////////////////////////////////////////////////////////////////////////
530

    
531
  private void adjustLevels(final RubikActivity act)
532
    {
533
    int sizeIndex = ObjectList.getSizeIndex(mObject,mSize);
534
    int dbLevel = ObjectList.getDBLevel(mObject, sizeIndex);
535
    int numScrambles = ObjectList.getNumScramble(mObject, sizeIndex);
536
    int numLevel = Math.min(dbLevel, LEVELS_SHOWN);
537
    String[] levels = new String[numLevel];
538

    
539
    for(int i=0; i<numLevel-1; i++)
540
      {
541
      levels[i] = act.getString(R.string.lv_placeholder,i+1);
542
      }
543

    
544
    if( numLevel>0 )
545
      {
546
      levels[numLevel-1] = act.getString(R.string.level_full);
547
      }
548

    
549
    if( mLevelValue>dbLevel || mLevelValue<1 ||
550
       (mLevelValue<dbLevel || mLevelValue>LEVELS_SHOWN ) )
551
      {
552
      mLevelValue=1;
553
      }
554

    
555
    float width  = act.getScreenWidthInPixels();
556
    int margin   = (int)(width*RubikActivity.MARGIN);
557
    int padding  = (int)(width*RubikActivity.PADDING);
558
    int butWidth = mPlayLayoutWidth - 2*padding;
559
    int butHeight= (int)mMenuItemSize;
560
    int lastButH = (int)(mMenuItemSize*LAST_BUTTON) ;
561

    
562
    LinearLayout.LayoutParams pM = new LinearLayout.LayoutParams( butWidth, butHeight );
563
    pM.setMargins(margin, 0, margin, margin);
564
    LinearLayout.LayoutParams pT = new LinearLayout.LayoutParams( butWidth, butHeight );
565
    pT.setMargins(margin, margin, margin, margin);
566
    LinearLayout.LayoutParams pB = new LinearLayout.LayoutParams( butWidth, lastButH  );
567
    pB.setMargins(margin, margin, margin, 2*margin);
568

    
569
    mPlayLayout.removeAllViews();
570

    
571
    RubikScores scores = RubikScores.getInstance();
572

    
573
    for(int i=0; i<numLevel; i++)
574
      {
575
      final int level     = i<numLevel-1 ? i+1 : dbLevel;
576
      final int scrambles = i<numLevel-1 ? i+1 : numScrambles;
577
      Button button = new Button(act);
578
      button.setLayoutParams(i==0 ? pT : (i==numLevel-1 ? pB : pM));
579
      button.setText(levels[i]);
580
      button.setTextSize(TypedValue.COMPLEX_UNIT_PX, mMenuTextSize);
581

    
582
      int icon = scores.isSolved(mObject, sizeIndex, level-1) ? R.drawable.ui_solved : R.drawable.ui_notsolved;
583
      button.setCompoundDrawablesWithIntrinsicBounds(icon,0,0,0);
584

    
585
      button.setOnClickListener( new View.OnClickListener()
586
        {
587
        @Override
588
        public void onClick(View v)
589
          {
590
          RubikPreRender pre = act.getPreRender();
591

    
592
          if(pre.isUINotBlocked())
593
            {
594
            if( mPlayPopup!=null ) mPlayPopup.dismiss();
595
            mLevelValue = level;
596
            pre.scrambleObject(scrambles);
597
            }
598
          }
599
        });
600

    
601
      mPlayLayout.addView(button);
602
      }
603
    }
604

    
605
///////////////////////////////////////////////////////////////////////////////////////////////////
606

    
607
  public int getLevel()
608
    {
609
    return mLevelValue;
610
    }
611

    
612
///////////////////////////////////////////////////////////////////////////////////////////////////
613

    
614
  public int getObject()
615
    {
616
    return mObject;
617
    }
618

    
619
///////////////////////////////////////////////////////////////////////////////////////////////////
620

    
621
  public int getSize()
622
    {
623
    return mSize;
624
    }
625
  }
(5-5/10)