Project

General

Profile

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

magiccube / src / main / java / org / distorted / screens / RubikScreenPlay.java @ 88d28110

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.objectlib.main.ObjectControl;
39
import org.distorted.objectlib.main.ObjectType;
40

    
41
import org.distorted.main.R;
42
import org.distorted.main.RubikActivity;
43
import org.distorted.dialogs.RubikDialogAbout;
44
import org.distorted.dialogs.RubikDialogPattern;
45
import org.distorted.dialogs.RubikDialogScores;
46
import org.distorted.dialogs.RubikDialogTutorial;
47
import org.distorted.helpers.TransparentButton;
48
import org.distorted.helpers.TransparentImageButton;
49
import org.distorted.network.RubikScores;
50

    
51
import static org.distorted.objectlib.main.ObjectType.NUM_OBJECTS;
52

    
53
///////////////////////////////////////////////////////////////////////////////////////////////////
54

    
55
public class RubikScreenPlay extends RubikScreenBase
56
  {
57
  public static final int NUM_COLUMNS  = 4;
58
  public static final int LEVELS_SHOWN = 10;
59
  public static int MAX_LEVEL;
60
  public static final ObjectType DEF_OBJECT= ObjectType.CUBE_3;
61

    
62
  private static final int[] BUTTON_LABELS = { R.string.scores,
63
                                               R.string.patterns,
64
                                               R.string.solver,
65
                                               R.string.tutorials,
66
                                               R.string.about };
67

    
68
  private static final int NUM_BUTTONS = BUTTON_LABELS.length;
69
  private static final float LAST_BUTTON = 1.5f;
70
  private static final int[] mLocation = new int[2];
71

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

    
83
  static
84
    {
85
    ObjectType[] types = ObjectType.values();
86
    int max = Integer.MIN_VALUE;
87

    
88
    for (ObjectType type : types)
89
      {
90
      int cur = getDBLevel(type);
91
      if( cur>max ) max = cur;
92
      }
93

    
94
    MAX_LEVEL = max;
95
    }
96

    
97
///////////////////////////////////////////////////////////////////////////////////////////////////
98

    
99
  void leaveScreen(RubikActivity act)
100
    {
101

    
102
    }
103

    
104
///////////////////////////////////////////////////////////////////////////////////////////////////
105

    
106
  void enterScreen(final RubikActivity act)
107
    {
108
    float width = act.getScreenWidthInPixels();
109
    mUpperBarHeight = act.getHeightUpperBar();
110

    
111
    mMenuTextSize = width*RubikActivity.MENU_MED_TEXT_SIZE;
112
    mButtonSize   = width*RubikActivity.BUTTON_TEXT_SIZE;
113
    mMenuItemSize = width*RubikActivity.MENU_ITEM_SIZE;
114

    
115
    mRowCount = (NUM_OBJECTS + NUM_COLUMNS-1) / NUM_COLUMNS;
116
    mColCount = NUM_COLUMNS;
117

    
118
    // TOP ////////////////////////////
119
    LinearLayout layoutTop = act.findViewById(R.id.upperBar);
120
    layoutTop.removeAllViews();
121

    
122
    setupObjectButton(act,width);
123
    layoutTop.addView(mObjButton);
124

    
125
    setupMenuButton(act,width);
126
    layoutTop.addView(mMenuButton);
127

    
128
    setupPlayButton(act,width);
129
    layoutTop.addView(mPlayButton);
130

    
131
    setupSolveButton(act,width);
132
    createBottomPane(act,width,mSolveButton);
133
    }
134

    
135
//////////////////////////////////////////////////////////////////////////////////////////////////
136

    
137
  private void setupObjectButton(final RubikActivity act, final float width)
138
    {
139
    final int margin  = (int)(width*RubikActivity.MARGIN);
140
    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);
141

    
142
    mObjButton = new TransparentImageButton(act, icon, width,LinearLayout.LayoutParams.MATCH_PARENT);
143

    
144
    mObjButton.setOnClickListener( new View.OnClickListener()
145
      {
146
      @Override
147
      public void onClick(View view)
148
        {
149
        if( mObjectPopup==null )
150
          {
151
          float width = act.getScreenWidthInPixels();
152
          float height= act.getScreenHeightInPixels();
153
          setupObjectWindow(act,width,height);
154
          }
155

    
156
        if( act.getControl().isUINotBlocked())
157
          {
158
          int rowCount = Math.min(mMaxRowCount,mRowCount);
159
          View popupView = mObjectPopup.getContentView();
160
          popupView.setSystemUiVisibility(RubikActivity.FLAGS);
161
          displayPopup(act,view,mObjectPopup,mObjectSize*mColCount,mObjectSize*rowCount,margin,margin);
162
          }
163
        }
164
      });
165
    }
166

    
167
///////////////////////////////////////////////////////////////////////////////////////////////////
168

    
169
  private void setupPlayButton(final RubikActivity act, final float width)
170
    {
171
    final int margin = (int)(width*RubikActivity.MARGIN);
172

    
173
    mPlayButton = new TransparentButton(act, R.string.play, mButtonSize, width);
174

    
175
    mPlayButton.setOnClickListener( new View.OnClickListener()
176
      {
177
      @Override
178
      public void onClick(View view)
179
        {
180
         if( mPlayPopup==null )
181
          {
182
          float width = act.getScreenWidthInPixels();
183
          setupPlayWindow(act,width);
184
          }
185

    
186
        if( act.getControl().isUINotBlocked())
187
          {
188
          float height= act.getScreenHeightInPixels();
189
          final int maxHeight= (int)(0.9f*(height-mUpperBarHeight) );
190
          View popupView = mPlayPopup.getContentView();
191
          popupView.setSystemUiVisibility(RubikActivity.FLAGS);
192
          final int dbLevel = getDBLevel(mObject);
193
          final int levelsShown = Math.min(dbLevel,LEVELS_SHOWN);
194
          final int popupHeight = (int)(levelsShown*(mMenuItemSize+margin)+3*margin+mMenuItemSize*(LAST_BUTTON-1.0f));
195
          final int realHeight = Math.min(popupHeight,maxHeight);
196
          displayPopup(act,view,mPlayPopup,mPlayLayoutWidth,realHeight,margin,margin);
197
          }
198
        }
199
      });
200
    }
201

    
202
///////////////////////////////////////////////////////////////////////////////////////////////////
203

    
204
  private void setupMenuButton(final RubikActivity act, final float width)
205
    {
206
    final int margin = (int)(width*RubikActivity.MARGIN);
207
    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);
208

    
209
    mMenuButton = new TransparentImageButton(act, icon, width,LinearLayout.LayoutParams.MATCH_PARENT);
210

    
211
    mMenuButton.setOnClickListener( new View.OnClickListener()
212
      {
213
      @Override
214
      public void onClick(View view)
215
        {
216
        if( mMenuPopup==null )
217
          {
218
          float width = act.getScreenWidthInPixels();
219
          setupMenuWindow(act,width);
220
          }
221

    
222
        if( act.getControl().isUINotBlocked())
223
          {
224
          View popupView = mMenuPopup.getContentView();
225
          popupView.setSystemUiVisibility(RubikActivity.FLAGS);
226
          displayPopup(act,view,mMenuPopup,mMenuLayoutWidth,mMenuLayoutHeight,(int)(-width/12),margin);
227
          }
228
        }
229
      });
230
    }
231

    
232
///////////////////////////////////////////////////////////////////////////////////////////////////
233

    
234
  private void setupObjectWindow(final RubikActivity act, final float width, final float height)
235
    {
236
    int icon = RubikActivity.getDrawable(R.drawable.s_cube_2,R.drawable.m_cube_2, R.drawable.b_cube_2, R.drawable.h_cube_2);
237

    
238
    BitmapDrawable bd = (BitmapDrawable) act.getResources().getDrawable(icon);
239
    int cubeWidth = bd.getIntrinsicWidth();
240
    int margin = (int)(width*RubikActivity.LARGE_MARGIN);
241
    mObjectSize = (int)(cubeWidth + 2*margin + 0.5f);
242
    mMaxRowCount = (int)(0.9f*(height-mUpperBarHeight)/mObjectSize);
243
    GridLayout objectGrid = new GridLayout(act);
244
    mObjectPopup = new PopupWindow(act);
245
    mObjectPopup.setFocusable(true);
246

    
247
    if( mMaxRowCount<mRowCount )
248
      {
249
      ScrollView scrollView = new ScrollView(act);
250
      scrollView.addView(objectGrid);
251
      mObjectPopup.setContentView(scrollView);
252
      }
253
    else
254
      {
255
      mObjectPopup.setContentView(objectGrid);
256
      }
257

    
258
    GridLayout.Spec[] rowSpecs = new GridLayout.Spec[mRowCount];
259
    GridLayout.Spec[] colSpecs = new GridLayout.Spec[mColCount];
260

    
261
    objectGrid.setColumnCount(mColCount);
262
    objectGrid.setRowCount(mRowCount);
263

    
264
    int[] nextInRow = new int[mRowCount];
265

    
266
    for(int row=0; row<mRowCount; row++)
267
      {
268
      rowSpecs[row] = GridLayout.spec(row);
269
      nextInRow[row]= 0;
270
      }
271
    for(int col=0; col<mColCount; col++)
272
      {
273
      colSpecs[col] = GridLayout.spec(col);
274
      }
275

    
276
    for(int object = 0; object< NUM_OBJECTS; object++)
277
      {
278
      final ObjectType type = ObjectType.getObject(object);
279
      int iconSize = RubikActivity.getDrawableSize();
280
      int icons = type.getIconID(iconSize);
281
      int row = object/NUM_COLUMNS;
282

    
283
      ImageButton button = new ImageButton(act);
284
      button.setBackgroundResource(icons);
285
      button.setOnClickListener( new View.OnClickListener()
286
        {
287
        @Override
288
        public void onClick(View v)
289
          {
290
          if( act.getControl().isUINotBlocked() && ScreenList.getCurrentScreen()== ScreenList.PLAY )
291
            {
292
            mObject = type;
293
            act.changeObject(type, true);
294
            if( mPlayLayout!=null ) adjustLevels(act);
295
            mMovesController.clearMoves(act);
296
            }
297

    
298
          mObjectPopup.dismiss();
299
          }
300
        });
301

    
302
      GridLayout.LayoutParams params = new GridLayout.LayoutParams(rowSpecs[row],colSpecs[nextInRow[row]]);
303
      params.bottomMargin = margin;
304
      params.topMargin    = margin;
305
      params.leftMargin   = margin;
306
      params.rightMargin  = margin;
307

    
308
      nextInRow[row]++;
309

    
310
      objectGrid.addView(button, params);
311
      }
312
    }
313

    
314
///////////////////////////////////////////////////////////////////////////////////////////////////
315

    
316
  private void setupMenuWindow(final RubikActivity act, final float width)
317
    {
318
    LayoutInflater layoutInflater = (LayoutInflater)act.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
319
    final View layout = layoutInflater.inflate(R.layout.popup_menu, null);
320
    LinearLayout menuLayout = layout.findViewById(R.id.menuGrid);
321

    
322
    mMenuPopup = new PopupWindow(act);
323
    mMenuPopup.setContentView(layout);
324
    mMenuPopup.setFocusable(true);
325
    int margin  = (int)(width*RubikActivity.MARGIN);
326
    int padding = (int)(width*RubikActivity.PADDING);
327

    
328
    mMenuLayoutWidth = (int)(width/2);
329
    mMenuLayoutHeight= (int)(2*margin + NUM_BUTTONS*(mMenuItemSize+margin));
330

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

    
333
    for(int i=0; i<NUM_BUTTONS; i++)
334
      {
335
      final int but = i;
336
      Button button = new Button(act);
337
      button.setLayoutParams(p);
338
      button.setText(BUTTON_LABELS[i]);
339
      button.setTextSize(TypedValue.COMPLEX_UNIT_PX, mMenuTextSize);
340

    
341
      button.setOnClickListener( new View.OnClickListener()
342
        {
343
        @Override
344
        public void onClick(View v)
345
          {
346
          mMenuPopup.dismiss();
347
          MenuAction(act,but);
348
          }
349
        });
350

    
351
      menuLayout.addView(button);
352
      }
353
    }
354

    
355
///////////////////////////////////////////////////////////////////////////////////////////////////
356

    
357
  private void setupPlayWindow(final RubikActivity act, final float width)
358
    {
359
    LayoutInflater layoutInflater = (LayoutInflater)act.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
360
    final View layout = layoutInflater.inflate(R.layout.popup_play, null);
361
    mPlayLayout = layout.findViewById(R.id.playGrid);
362

    
363
    mPlayLayoutWidth = (int)(width*0.4f);
364

    
365
    mPlayPopup = new PopupWindow(act);
366
    mPlayPopup.setContentView(layout);
367
    mPlayPopup.setFocusable(true);
368

    
369
    adjustLevels(act);
370
    }
371

    
372
///////////////////////////////////////////////////////////////////////////////////////////////////
373

    
374
  private void MenuAction(RubikActivity act, int button)
375
    {
376
    switch(button)
377
      {
378
      case 0: Bundle sBundle = new Bundle();
379
              sBundle.putInt("tab", mObject.ordinal() );
380
              sBundle.putBoolean("submitting", false);
381
              RubikDialogScores scores = new RubikDialogScores();
382
              scores.setArguments(sBundle);
383
              scores.show(act.getSupportFragmentManager(), null);
384
              break;
385
      case 1: RubikDialogPattern pDiag = new RubikDialogPattern();
386
              pDiag.show( act.getSupportFragmentManager(), RubikDialogPattern.getDialogTag() );
387
              break;
388
      case 2: ScreenList.switchScreen(act, ScreenList.SVER);
389
              break;
390
      case 3: RubikDialogTutorial tDiag = new RubikDialogTutorial();
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.getControl().solveObject();
412
        mMovesController.clearMoves(act);
413
        }
414
      });
415
    }
416

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

    
419
  public void savePreferences(SharedPreferences.Editor editor)
420
    {
421
    editor.putString("statePlay_objName", mObject.name() );
422

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

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

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

    
442
///////////////////////////////////////////////////////////////////////////////////////////////////
443

    
444
  public void restorePreferences(SharedPreferences preferences)
445
    {
446
    String objName= preferences.getString("statePlay_objName", DEF_OBJECT.name() );
447
    int ordinal = ObjectType.getOrdinal(objName);
448
    mObject = ordinal>=0 && ordinal<NUM_OBJECTS ? ObjectType.values()[ordinal] : DEF_OBJECT;
449
    }
450

    
451
///////////////////////////////////////////////////////////////////////////////////////////////////
452

    
453
  public boolean setObject(RubikActivity act, ObjectType obj)
454
    {
455
    if( mObject!=obj )
456
      {
457
      mObject = obj;
458
      if( mPlayLayout!=null ) adjustLevels(act);
459
      return true;
460
      }
461

    
462
    return false;
463
    }
464

    
465
///////////////////////////////////////////////////////////////////////////////////////////////////
466
// work around lame bugs in Android's version <= 10 pop-up and split-screen modes
467

    
468
  private void displayPopup(RubikActivity act, View view, PopupWindow window, int w, int h, int xoff, int yoff)
469
    {
470
    View topLayout = act.findViewById(R.id.relativeLayout);
471
    boolean isFullScreen;
472

    
473
    if( topLayout!=null )
474
      {
475
      topLayout.getLocationOnScreen(mLocation);
476
      isFullScreen = (mLocation[1]==0);
477
      }
478
    else
479
      {
480
      isFullScreen = true;
481
      }
482

    
483
    // if on Android 11 or we are fullscreen
484
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R || isFullScreen )
485
      {
486
      window.showAsDropDown(view, xoff, yoff, Gravity.CENTER);
487
      window.update(view, w, h);
488
      }
489
    else  // Android 10 or below in pop-up mode or split-screen mode
490
      {
491
      view.getLocationOnScreen(mLocation);
492
      int width  = view.getWidth();
493
      int height = view.getHeight();
494
      int x = mLocation[0]+(width-w)/2;
495
      int y = mLocation[1]+height+yoff;
496

    
497
      window.showAsDropDown(view);
498
      window.update(x,y,w,h);
499
      }
500
    }
501

    
502
///////////////////////////////////////////////////////////////////////////////////////////////////
503

    
504
  public void adjustSolvedIcons()
505
    {
506
    int dbLevel = getDBLevel(mObject);
507
    int numLevel = Math.min(dbLevel, LEVELS_SHOWN);
508
    RubikScores scores = RubikScores.getInstance();
509

    
510
    for(int i=0; i<numLevel; i++)
511
      {
512
      int level = i<numLevel-1 ? i+1 : dbLevel;
513
      Button button = (Button)mPlayLayout.getChildAt(i);
514
      int icon = scores.isSolved(mObject.ordinal(), level-1) ? R.drawable.ui_solved : R.drawable.ui_notsolved;
515
      button.setCompoundDrawablesWithIntrinsicBounds(icon,0,0,0);
516
      }
517
    }
518

    
519
///////////////////////////////////////////////////////////////////////////////////////////////////
520

    
521
  private void adjustLevels(final RubikActivity act)
522
    {
523
    int dbLevel = getDBLevel(mObject);
524
    int numScrambles = mObject.getNumScramble();
525
    int numLevel = Math.min(dbLevel, LEVELS_SHOWN);
526
    String[] levels = new String[numLevel];
527

    
528
    for(int i=0; i<numLevel-1; i++)
529
      {
530
      levels[i] = act.getString(R.string.lv_placeholder,i+1);
531
      }
532

    
533
    if( numLevel>0 )
534
      {
535
      levels[numLevel-1] = act.getString(R.string.level_full);
536
      }
537

    
538
    if( mLevelValue>dbLevel || mLevelValue<1 ||
539
       (mLevelValue<dbLevel || mLevelValue>LEVELS_SHOWN ) )
540
      {
541
      mLevelValue=1;
542
      }
543

    
544
    float width  = act.getScreenWidthInPixels();
545
    int margin   = (int)(width*RubikActivity.MARGIN);
546
    int padding  = (int)(width*RubikActivity.PADDING);
547
    int butWidth = mPlayLayoutWidth - 2*padding;
548
    int butHeight= (int)mMenuItemSize;
549
    int lastButH = (int)(mMenuItemSize*LAST_BUTTON) ;
550

    
551
    LinearLayout.LayoutParams pM = new LinearLayout.LayoutParams( butWidth, butHeight );
552
    pM.setMargins(margin, 0, margin, margin);
553
    LinearLayout.LayoutParams pT = new LinearLayout.LayoutParams( butWidth, butHeight );
554
    pT.setMargins(margin, margin, margin, margin);
555
    LinearLayout.LayoutParams pB = new LinearLayout.LayoutParams( butWidth, lastButH  );
556
    pB.setMargins(margin, margin, margin, 2*margin);
557

    
558
    mPlayLayout.removeAllViews();
559

    
560
    RubikScores scores = RubikScores.getInstance();
561

    
562
    for(int i=0; i<numLevel; i++)
563
      {
564
      final int level     = i<numLevel-1 ? i+1 : dbLevel;
565
      final int scrambles = i<numLevel-1 ? i+1 : numScrambles;
566
      Button button = new Button(act);
567
      button.setLayoutParams(i==0 ? pT : (i==numLevel-1 ? pB : pM));
568
      button.setText(levels[i]);
569
      button.setTextSize(TypedValue.COMPLEX_UNIT_PX, mMenuTextSize);
570

    
571
      int icon = scores.isSolved(mObject.ordinal(), level-1) ? R.drawable.ui_solved : R.drawable.ui_notsolved;
572
      button.setCompoundDrawablesWithIntrinsicBounds(icon,0,0,0);
573

    
574
      button.setOnClickListener( new View.OnClickListener()
575
        {
576
        @Override
577
        public void onClick(View v)
578
          {
579
          ObjectControl control = act.getControl();
580

    
581
          if(control.isUINotBlocked())
582
            {
583
            if( mPlayPopup!=null ) mPlayPopup.dismiss();
584
            mLevelValue = level;
585
            control.scrambleObject(scrambles);
586
            }
587
          }
588
        });
589

    
590
      mPlayLayout.addView(button);
591
      }
592
    }
593

    
594
///////////////////////////////////////////////////////////////////////////////////////////////////
595
// historically older versions of the app had lower 'maxScrambles' in case of several objects and
596
// those got remembered in the server-side DB already, so we need to keep using them. This function
597
// provides a map between 'maxScramble' of an object and its 'dbLevel'. All new objects will have
598
// those two values the same.
599

    
600
  public static int getDBLevel(ObjectType object)
601
    {
602
    switch(object)
603
      {
604
      case CUBE_3: return 16;
605
      case CUBE_4: return 20;
606
      case CUBE_5: return 24;
607
      case PYRA_4: return 15;
608
      case PYRA_5: return 20;
609
      case MEGA_5: return 35;
610
      case DIAM_2: return 10;
611
      case DIAM_3: return 18;
612
      case REDI_3: return 14;
613
      case HELI_3: return 18;
614
      case SKEW_3: return 17;
615
      case REX_3 : return 16;
616
      case MIRR_3: return 16;
617
      default    : return object.getNumScramble();
618
      }
619
    }
620

    
621
///////////////////////////////////////////////////////////////////////////////////////////////////
622

    
623
  public int getLevel()
624
    {
625
    return mLevelValue;
626
    }
627

    
628
///////////////////////////////////////////////////////////////////////////////////////////////////
629

    
630
  public ObjectType getObject()
631
    {
632
    return mObject;
633
    }
634
  }
(5-5/10)