Project

General

Profile

Download (25.2 KB) Statistics
| Branch: | Revision:

distorted-objectlib / src / main / java / org / distorted / objectlib / main / ObjectList.java @ 4e1dc313

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.objectlib.main;
21

    
22
///////////////////////////////////////////////////////////////////////////////////////////////////
23

    
24
/*
25
  CUBE_2 ( 0, new int[] {2 , 12, 12, R.raw.cube2, R.drawable.ui_small_cube2, R.drawable.ui_medium_cube2, R.drawable.ui_big_cube2, R.drawable.ui_huge_cube2} ),
26
  CUBE_3 ( 0, new int[] {3 , 16, 17, R.raw.cube3, R.drawable.ui_small_cube3, R.drawable.ui_medium_cube3, R.drawable.ui_big_cube3, R.drawable.ui_huge_cube3} ),
27
  CUBE_4 ( 0, new int[] {4 , 20, 24, R.raw.cube4, R.drawable.ui_small_cube4, R.drawable.ui_medium_cube4, R.drawable.ui_big_cube4, R.drawable.ui_huge_cube4} ),
28
  CUBE_5 ( 0, new int[] {5 , 24, 28, R.raw.cube5, R.drawable.ui_small_cube5, R.drawable.ui_medium_cube5, R.drawable.ui_big_cube5, R.drawable.ui_huge_cube5} ),
29
  JING_2 ( 1, new int[] {2 , 11, 11, R.raw.jing , R.drawable.ui_small_jing2, R.drawable.ui_medium_jing2, R.drawable.ui_big_jing2, R.drawable.ui_huge_jing2} ),
30
  PYRA_3 ( 1, new int[] {3 , 10, 10, R.raw.pyra3, R.drawable.ui_small_pyra3, R.drawable.ui_medium_pyra3, R.drawable.ui_big_pyra3, R.drawable.ui_huge_pyra3} ),
31
  PYRA_4 ( 1, new int[] {4 , 14, 17, R.raw.pyra4, R.drawable.ui_small_pyra4, R.drawable.ui_medium_pyra4, R.drawable.ui_big_pyra4, R.drawable.ui_huge_pyra4} ),
32
  PYRA_5 ( 1, new int[] {5 , 20, 23, R.raw.pyra5, R.drawable.ui_small_pyra5, R.drawable.ui_medium_pyra5, R.drawable.ui_big_pyra5, R.drawable.ui_huge_pyra5} ),
33
  KILO_3 ( 2, new int[] {3 , 18, 18, R.raw.kilo3, R.drawable.ui_small_kilo3, R.drawable.ui_medium_kilo3, R.drawable.ui_big_kilo3, R.drawable.ui_huge_kilo3} ),
34
  KILO_5 ( 2, new int[] {5 , 33, 33, R.raw.kilo5, R.drawable.ui_small_kilo5, R.drawable.ui_medium_kilo5, R.drawable.ui_big_kilo5, R.drawable.ui_huge_kilo5} ),
35
  MEGA_3 ( 2, new int[] {3 , 21, 21, R.raw.mega3, R.drawable.ui_small_mega3, R.drawable.ui_medium_mega3, R.drawable.ui_big_mega3, R.drawable.ui_huge_mega3} ),
36
  MEGA_5 ( 2, new int[] {5 , 35, 37, R.raw.mega5, R.drawable.ui_small_mega5, R.drawable.ui_medium_mega5, R.drawable.ui_big_mega5, R.drawable.ui_huge_mega5} ),
37
  ULTI_2 ( 3, new int[] {2 , 18, 18, R.raw.ulti , R.drawable.ui_small_ulti , R.drawable.ui_medium_ulti , R.drawable.ui_big_ulti , R.drawable.ui_huge_ulti } ),
38
  DIAM_2 ( 3, new int[] {2 , 10, 12, R.raw.diam2, R.drawable.ui_small_diam2, R.drawable.ui_medium_diam2, R.drawable.ui_big_diam2, R.drawable.ui_huge_diam2} ),
39
  DIAM_3 ( 3, new int[] {3 , 18, 24, R.raw.diam3, R.drawable.ui_small_diam3, R.drawable.ui_medium_diam3, R.drawable.ui_big_diam3, R.drawable.ui_huge_diam3} ),
40
  DIAM_4 ( 3, new int[] {4 , 32, 32, R.raw.diam4, R.drawable.ui_small_diam4, R.drawable.ui_medium_diam4, R.drawable.ui_big_diam4, R.drawable.ui_huge_diam4} ),
41
  DINO_3 ( 4, new int[] {3 , 10, 10, R.raw.dino , R.drawable.ui_small_dino , R.drawable.ui_medium_dino , R.drawable.ui_big_dino , R.drawable.ui_huge_dino } ),
42
  DIN4_3 ( 4, new int[] {3 ,  7,  7, R.raw.dino , R.drawable.ui_small_din4 , R.drawable.ui_medium_din4 , R.drawable.ui_big_din4 , R.drawable.ui_huge_din4 } ),
43
  REDI_3 ( 4, new int[] {3 , 14, 16, R.raw.redi , R.drawable.ui_small_redi , R.drawable.ui_medium_redi , R.drawable.ui_big_redi , R.drawable.ui_huge_redi } ),
44
  HELI_3 ( 4, new int[] {3 , 18, 20, R.raw.heli , R.drawable.ui_small_heli , R.drawable.ui_medium_heli , R.drawable.ui_big_heli , R.drawable.ui_huge_heli } ),
45
  SKEW_2 ( 5, new int[] {2 , 11, 11, R.raw.skew2, R.drawable.ui_small_skew2, R.drawable.ui_medium_skew2, R.drawable.ui_big_skew2, R.drawable.ui_huge_skew2} ),
46
  SKEW_3 ( 5, new int[] {3 , 17, 21, R.raw.skew3, R.drawable.ui_small_skew3, R.drawable.ui_medium_skew3, R.drawable.ui_big_skew3, R.drawable.ui_huge_skew3} ),
47
  IVY_2  ( 5, new int[] {2 ,  8,  8, R.raw.ivy  , R.drawable.ui_small_ivy  , R.drawable.ui_medium_ivy  , R.drawable.ui_big_ivy  , R.drawable.ui_huge_ivy  } ),
48
  REX_3  ( 5, new int[] {3 , 16, 19, R.raw.rex  , R.drawable.ui_small_rex  , R.drawable.ui_medium_rex  , R.drawable.ui_big_rex  , R.drawable.ui_huge_rex  } ),
49
  BAN1_3 ( 6, new int[] {3 , 16, 16, R.raw.ban1 , R.drawable.ui_small_ban1 , R.drawable.ui_medium_ban1 , R.drawable.ui_big_ban1 , R.drawable.ui_huge_ban1 } ),
50
  BAN2_3 ( 6, new int[] {3 , 16, 16, R.raw.ban2 , R.drawable.ui_small_ban2 , R.drawable.ui_medium_ban2 , R.drawable.ui_big_ban2 , R.drawable.ui_huge_ban2 } ),
51
  BAN3_3 ( 6, new int[] {3 , 16, 16, R.raw.ban3 , R.drawable.ui_small_ban3 , R.drawable.ui_medium_ban3 , R.drawable.ui_big_ban3 , R.drawable.ui_huge_ban3 } ),
52
  BAN4_3 ( 6, new int[] {3 , 16, 16, R.raw.ban4 , R.drawable.ui_small_ban4 , R.drawable.ui_medium_ban4 , R.drawable.ui_big_ban4 , R.drawable.ui_huge_ban4 } ),
53
  SQU1_3 ( 7, new int[] {3 , 24, 24, R.raw.squa1, R.drawable.ui_small_squa1, R.drawable.ui_medium_squa1, R.drawable.ui_big_squa1, R.drawable.ui_huge_squa1} ),
54
  SQU2_3 ( 7, new int[] {3 , 24, 24, R.raw.squa2, R.drawable.ui_small_squa2, R.drawable.ui_medium_squa2, R.drawable.ui_big_squa2, R.drawable.ui_huge_squa2} ),
55
  MIRR_2 ( 7, new int[] {2 , 12, 12, R.raw.mirr2, R.drawable.ui_small_mirr2, R.drawable.ui_medium_mirr2, R.drawable.ui_big_mirr2, R.drawable.ui_huge_mirr2} ),
56
  MIRR_3 ( 7, new int[] {3 , 16, 17, R.raw.mirr3, R.drawable.ui_small_mirr3, R.drawable.ui_medium_mirr3, R.drawable.ui_big_mirr3, R.drawable.ui_huge_mirr3} ),
57
  ;
58
*/
59

    
60
import android.content.res.Resources;
61

    
62
import org.distorted.library.main.DistortedEffects;
63
import org.distorted.library.main.DistortedTexture;
64
import org.distorted.library.mesh.MeshSquare;
65
import org.distorted.library.type.Static4D;
66
import org.distorted.objectlib.R;
67
import org.distorted.objectlib.objects.TwistyBandaged2Bar;
68
import org.distorted.objectlib.objects.TwistyBandaged3Plate;
69
import org.distorted.objectlib.objects.TwistyBandagedEvil;
70
import org.distorted.objectlib.objects.TwistyBandagedFused;
71
import org.distorted.objectlib.objects.TwistyCube;
72
import org.distorted.objectlib.objects.TwistyDiamond;
73
import org.distorted.objectlib.objects.TwistyDino4;
74
import org.distorted.objectlib.objects.TwistyDino6;
75
import org.distorted.objectlib.objects.TwistyHelicopter;
76
import org.distorted.objectlib.objects.TwistyIvy;
77
import org.distorted.objectlib.objects.TwistyJing;
78
import org.distorted.objectlib.objects.TwistyKilominx;
79
import org.distorted.objectlib.objects.TwistyMegaminx;
80
import org.distorted.objectlib.objects.TwistyMirror;
81
import org.distorted.objectlib.objects.TwistyPyraminx;
82
import org.distorted.objectlib.objects.TwistyRedi;
83
import org.distorted.objectlib.objects.TwistyRex;
84
import org.distorted.objectlib.objects.TwistySkewb;
85
import org.distorted.objectlib.objects.TwistySquare1;
86
import org.distorted.objectlib.objects.TwistySquare2;
87
import org.distorted.objectlib.objects.TwistyUltimate;
88

    
89
public enum ObjectList
90
  {
91
  ///////////////////// Size // DB Level // NumScrambles // Mesh // small icon // medium icon // big icon // huge icon
92

    
93
  CUBE (
94
         new int[][] {
95
                       {2 , 12, 12, R.drawable.ui_small_cube2, R.drawable.ui_medium_cube2, R.drawable.ui_big_cube2, R.drawable.ui_huge_cube2} ,
96
                       {3 , 16, 17, R.drawable.ui_small_cube3, R.drawable.ui_medium_cube3, R.drawable.ui_big_cube3, R.drawable.ui_huge_cube3} ,
97
                       {4 , 20, 24, R.drawable.ui_small_cube4, R.drawable.ui_medium_cube4, R.drawable.ui_big_cube4, R.drawable.ui_huge_cube4} ,
98
                       {5 , 24, 28, R.drawable.ui_small_cube5, R.drawable.ui_medium_cube5, R.drawable.ui_big_cube5, R.drawable.ui_huge_cube5}
99
                     },
100
         0
101
       ),
102

    
103
  JING (
104
         new int[][] {
105
                       {2 , 11, 11, R.drawable.ui_small_jing2, R.drawable.ui_medium_jing2, R.drawable.ui_big_jing2, R.drawable.ui_huge_jing2} ,
106
                     },
107
         1
108
       ),
109

    
110
  PYRA (
111
         new int[][] {
112
                       {3 , 10, 10, R.drawable.ui_small_pyra3, R.drawable.ui_medium_pyra3, R.drawable.ui_big_pyra3, R.drawable.ui_huge_pyra3} ,
113
                       {4 , 15, 17, R.drawable.ui_small_pyra4, R.drawable.ui_medium_pyra4, R.drawable.ui_big_pyra4, R.drawable.ui_huge_pyra4} ,
114
                       {5 , 20, 23, R.drawable.ui_small_pyra5, R.drawable.ui_medium_pyra5, R.drawable.ui_big_pyra5, R.drawable.ui_huge_pyra5}
115
                     },
116
         1
117
       ),
118

    
119
  KILO (
120
         new int[][] {
121
                       {3 , 18, 18, R.drawable.ui_small_kilo3, R.drawable.ui_medium_kilo3, R.drawable.ui_big_kilo3, R.drawable.ui_huge_kilo3} ,
122
                       {5 , 33, 33, R.drawable.ui_small_kilo5, R.drawable.ui_medium_kilo5, R.drawable.ui_big_kilo5, R.drawable.ui_huge_kilo5} ,
123
                     },
124
         2
125
       ),
126

    
127
  MEGA (
128
         new int[][] {
129
                       {3 , 21, 21, R.drawable.ui_small_mega3, R.drawable.ui_medium_mega3, R.drawable.ui_big_mega3, R.drawable.ui_huge_mega3} ,
130
                       {5 , 35, 37, R.drawable.ui_small_mega5, R.drawable.ui_medium_mega5, R.drawable.ui_big_mega5, R.drawable.ui_huge_mega5} ,
131
                     },
132
         2
133
       ),
134

    
135
  ULTI (
136
         new int[][] {
137
                       {2 , 18, 18, R.drawable.ui_small_ulti, R.drawable.ui_medium_ulti, R.drawable.ui_big_ulti, R.drawable.ui_huge_ulti} ,
138
                     },
139
         3
140
       ),
141

    
142
  DIAM (
143
         new int[][] {
144
                       {2 , 10, 12, R.drawable.ui_small_diam2, R.drawable.ui_medium_diam2, R.drawable.ui_big_diam2, R.drawable.ui_huge_diam2} ,
145
                       {3 , 18, 24, R.drawable.ui_small_diam3, R.drawable.ui_medium_diam3, R.drawable.ui_big_diam3, R.drawable.ui_huge_diam3} ,
146
                       {4 , 32, 32, R.drawable.ui_small_diam4, R.drawable.ui_medium_diam4, R.drawable.ui_big_diam4, R.drawable.ui_huge_diam4} ,
147
                     },
148
         3
149
       ),
150

    
151
  DINO (
152
         new int[][] {
153
                       {3 , 10, 10, R.drawable.ui_small_dino, R.drawable.ui_medium_dino, R.drawable.ui_big_dino, R.drawable.ui_huge_dino} ,
154
                     },
155
         4
156
       ),
157

    
158
  DIN4 (
159
         new int[][] {
160
                       {3 , 7, 7, R.drawable.ui_small_din4, R.drawable.ui_medium_din4, R.drawable.ui_big_din4, R.drawable.ui_huge_din4} ,
161
                     },
162
         4
163
       ),
164

    
165
  REDI (
166
         new int[][] {
167
                       {3 , 14, 16, R.drawable.ui_small_redi, R.drawable.ui_medium_redi, R.drawable.ui_big_redi, R.drawable.ui_huge_redi} ,
168
                     },
169
         4
170
       ),
171

    
172
  HELI (
173
         new int[][] {
174
                       {3 , 18, 20, R.drawable.ui_small_heli, R.drawable.ui_medium_heli, R.drawable.ui_big_heli, R.drawable.ui_huge_heli} ,
175
                     },
176
         4
177
       ),
178

    
179
  SKEW (
180
         new int[][] {
181
                       {2 , 11, 11, R.drawable.ui_small_skew2, R.drawable.ui_medium_skew2, R.drawable.ui_big_skew2, R.drawable.ui_huge_skew2} ,
182
                       {3 , 17, 21, R.drawable.ui_small_skew3, R.drawable.ui_medium_skew3, R.drawable.ui_big_skew3, R.drawable.ui_huge_skew3} ,
183
                     },
184
         5
185
       ),
186

    
187
  IVY  (
188
         new int[][] {
189
                       {2 , 8, 8, R.drawable.ui_small_ivy, R.drawable.ui_medium_ivy, R.drawable.ui_big_ivy, R.drawable.ui_huge_ivy} ,
190
                     },
191
         5
192
       ),
193

    
194
  REX  (
195
         new int[][] {
196
                       {3 , 16, 19, R.drawable.ui_small_rex, R.drawable.ui_medium_rex, R.drawable.ui_big_rex, R.drawable.ui_huge_rex} ,
197
                     },
198
         5
199
       ),
200

    
201
  BAN1 (
202
         new int[][] {
203
                       {3 , 16, 16, R.drawable.ui_small_ban1, R.drawable.ui_medium_ban1, R.drawable.ui_big_ban1, R.drawable.ui_huge_ban1} ,
204
                     },
205
         6
206
       ),
207

    
208
  BAN2 (
209
         new int[][] {
210
                       {3 , 16, 16, R.drawable.ui_small_ban2, R.drawable.ui_medium_ban2, R.drawable.ui_big_ban2, R.drawable.ui_huge_ban2} ,
211
                     },
212
         6
213
       ),
214

    
215
  BAN3 (
216
         new int[][] {
217
                       {3 , 16, 16, R.drawable.ui_small_ban3, R.drawable.ui_medium_ban3, R.drawable.ui_big_ban3, R.drawable.ui_huge_ban3} ,
218
                     },
219
         6
220
       ),
221

    
222
  BAN4 (
223
         new int[][] {
224
                       {3 , 16, 16, R.drawable.ui_small_ban4, R.drawable.ui_medium_ban4, R.drawable.ui_big_ban4, R.drawable.ui_huge_ban4} ,
225
                     },
226
         6
227
       ),
228

    
229
  SQU1 (
230
         new int[][] {
231
                       {3 , 24, 24, R.drawable.ui_small_squa1, R.drawable.ui_medium_squa1, R.drawable.ui_big_squa1, R.drawable.ui_huge_squa1} ,
232
                     },
233
         7
234
       ),
235

    
236
  SQU2 (
237
         new int[][] {
238
                       {3 , 24, 24, R.drawable.ui_small_squa2, R.drawable.ui_medium_squa2, R.drawable.ui_big_squa2, R.drawable.ui_huge_squa2} ,
239
                     },
240
         7
241
       ),
242

    
243
  MIRR (
244
         new int[][] {
245
                       {2 , 12, 12, R.drawable.ui_small_mirr2, R.drawable.ui_medium_mirr2, R.drawable.ui_big_mirr2, R.drawable.ui_huge_mirr2} ,
246
                       {3 , 16, 17, R.drawable.ui_small_mirr3, R.drawable.ui_medium_mirr3, R.drawable.ui_big_mirr3, R.drawable.ui_huge_mirr3} ,
247
                     },
248
         7
249
       ),
250
  ;
251

    
252
  public static final int NUM_OBJECTS = values().length;
253
  public static final int MAX_NUM_OBJECTS;
254
  public static final int MAX_LEVEL;
255
  public static final int MAX_SCRAMBLE;
256
  public static final int MAX_OBJECT_SIZE;
257

    
258
  private final int[] mObjectSizes, mDBLevels, mNumScrambles, mSmallIconIDs, mMediumIconIDs, mBigIconIDs, mHugeIconIDs;
259
  private final int mRow, mNumSizes;
260

    
261
  private static final ObjectList[] objects;
262
  private static int mNumAll;
263
  private static int[] mIndices;
264
  private static int mColCount, mRowCount;
265

    
266
  static
267
    {
268
    mNumAll = 0;
269
    int num, i = 0;
270
    objects = new ObjectList[NUM_OBJECTS];
271
    int maxNum     = Integer.MIN_VALUE;
272
    int maxLevel   = Integer.MIN_VALUE;
273
    int maxScramble= Integer.MIN_VALUE;
274
    int maxSize    = Integer.MIN_VALUE;
275

    
276
    for(ObjectList object: ObjectList.values())
277
      {
278
      objects[i] = object;
279
      i++;
280
      num = object.mObjectSizes.length;
281
      mNumAll += num;
282
      if( num> maxNum ) maxNum = num;
283

    
284
      for(int j=0; j<num; j++)
285
        {
286
        if( object.mNumScrambles[j]> maxScramble ) maxScramble= object.mNumScrambles[j];
287
        if( object.mDBLevels[j]    > maxLevel    ) maxLevel   = object.mDBLevels[j];
288
        if( object.mObjectSizes[j] > maxSize     ) maxSize    = object.mObjectSizes[j];
289
        }
290
      }
291

    
292
    MAX_NUM_OBJECTS = maxNum;
293
    MAX_LEVEL       = maxLevel;
294
    MAX_SCRAMBLE    = maxScramble;
295
    MAX_OBJECT_SIZE = maxSize;
296
    }
297

    
298
///////////////////////////////////////////////////////////////////////////////////////////////////
299

    
300
  private static void setUpColAndRow()
301
    {
302
    mIndices = new int[NUM_OBJECTS];
303
    mRowCount= 0;
304

    
305
    for(int obj=0; obj<NUM_OBJECTS; obj++)
306
      {
307
      mIndices[obj] = objects[obj].mRow;
308
      if( mIndices[obj]>=mRowCount ) mRowCount = mIndices[obj]+1;
309
      }
310

    
311
    mColCount = 0;
312

    
313
    for(int row=0; row<mRowCount; row++)
314
      {
315
      int numObjects = computeNumObjectsInRow(row);
316
      if( numObjects>mColCount ) mColCount = numObjects;
317
      }
318
    }
319

    
320
///////////////////////////////////////////////////////////////////////////////////////////////////
321

    
322
  private static int computeNumObjectsInRow(int row)
323
    {
324
    int num=0;
325

    
326
    for(int object=0; object<NUM_OBJECTS; object++)
327
      {
328
      if( objects[object].mRow == row )
329
        {
330
        num += objects[object].mNumSizes;
331
        }
332
      }
333

    
334
    return num;
335
    }
336

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

    
339
  public static int getColumnCount()
340
    {
341
    if( mIndices==null ) setUpColAndRow();
342

    
343
    return mColCount;
344
    }
345

    
346
///////////////////////////////////////////////////////////////////////////////////////////////////
347

    
348
  public static int getRowCount()
349
    {
350
    if( mIndices==null ) setUpColAndRow();
351

    
352
    return mRowCount;
353
    }
354

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

    
357
  public static int[] getIndices()
358
    {
359
    if( mIndices==null ) setUpColAndRow();
360

    
361
    return mIndices;
362
    }
363

    
364
///////////////////////////////////////////////////////////////////////////////////////////////////
365

    
366
  public static ObjectList getObject(int ordinal)
367
    {
368
    return ordinal>=0 && ordinal<NUM_OBJECTS ? objects[ordinal] : CUBE;
369
    }
370

    
371
///////////////////////////////////////////////////////////////////////////////////////////////////
372

    
373
  public static int pack(int object, int sizeIndex)
374
    {
375
    int ret = 0;
376
    for(int i=0; i<object; i++) ret += objects[i].mObjectSizes.length;
377

    
378
    return ret+sizeIndex;
379
    }
380

    
381
///////////////////////////////////////////////////////////////////////////////////////////////////
382

    
383
  public static int unpackSizeIndex(int number)
384
    {
385
    int num;
386

    
387
    for(int i=0; i<NUM_OBJECTS; i++)
388
      {
389
      num = objects[i].mObjectSizes.length;
390
      if( number<num ) return number;
391
      number -= num;
392
      }
393

    
394
    return -1;
395
    }
396

    
397
///////////////////////////////////////////////////////////////////////////////////////////////////
398

    
399
  public static int unpackObject(int number)
400
    {
401
    int num;
402

    
403
    for(int i=0; i<NUM_OBJECTS; i++)
404
      {
405
      num = objects[i].mObjectSizes.length;
406
      if( number<num ) return i;
407
      number -= num;
408
      }
409

    
410
    return -1;
411
    }
412

    
413
///////////////////////////////////////////////////////////////////////////////////////////////////
414

    
415
  public static int unpackObjectFromString(String obj)
416
    {
417
    int u = obj.indexOf('_');
418
    int l = obj.length();
419

    
420
    if( u>0 )
421
      {
422
      String name = obj.substring(0,u);
423
      int size = Integer.parseInt( obj.substring(u+1,l) );
424

    
425
      for(int i=0; i<NUM_OBJECTS; i++)
426
        {
427
        if( objects[i].name().equals(name) )
428
          {
429
          int sizeIndex = getSizeIndex(i,size);
430
          return pack(i,sizeIndex);
431
          }
432
        }
433
      }
434

    
435
    return -1;
436
    }
437

    
438
///////////////////////////////////////////////////////////////////////////////////////////////////
439

    
440
  public static String getObjectList()
441
    {
442
    String name;
443
    StringBuilder list = new StringBuilder();
444
    int len;
445
    int[] sizes;
446

    
447
    for(int i=0; i<NUM_OBJECTS; i++)
448
      {
449
      sizes = objects[i].mObjectSizes;
450
      len   = sizes.length;
451
      name  = objects[i].name();
452

    
453
      for(int j=0; j<len; j++)
454
        {
455
        if( i>0 || j>0 ) list.append(',');
456
        list.append(name);
457
        list.append('_');
458
        list.append(sizes[j]);
459
        }
460
      }
461

    
462
    return list.toString();
463
    }
464

    
465
///////////////////////////////////////////////////////////////////////////////////////////////////
466

    
467
  public static int getTotal()
468
    {
469
    return mNumAll;
470
    }
471

    
472
///////////////////////////////////////////////////////////////////////////////////////////////////
473

    
474
  public static int getDBLevel(int ordinal, int sizeIndex)
475
    {
476
    if( ordinal>=0 && ordinal<NUM_OBJECTS )
477
      {
478
      int num = objects[ordinal].mObjectSizes.length;
479
      return sizeIndex>=0 && sizeIndex<num ? objects[ordinal].mDBLevels[sizeIndex] : 0;
480
      }
481

    
482
    return 0;
483
    }
484

    
485
///////////////////////////////////////////////////////////////////////////////////////////////////
486

    
487
  public static int getNumScramble(int ordinal, int sizeIndex)
488
    {
489
    if( ordinal>=0 && ordinal<NUM_OBJECTS )
490
      {
491
      int num = objects[ordinal].mObjectSizes.length;
492
      return sizeIndex>=0 && sizeIndex<num ? objects[ordinal].mNumScrambles[sizeIndex] : 0;
493
      }
494

    
495
    return 0;
496
    }
497

    
498
///////////////////////////////////////////////////////////////////////////////////////////////////
499

    
500
  public static int getOrdinal(String name)
501
    {
502
    for(int i=0; i<NUM_OBJECTS; i++)
503
      {
504
      if(objects[i].name().equals(name)) return i;
505
      }
506

    
507
    return -1;
508
    }
509

    
510
///////////////////////////////////////////////////////////////////////////////////////////////////
511

    
512
  public static int getSizeIndex(int ordinal, int size)
513
    {
514
    if( ordinal>=0 && ordinal<NUM_OBJECTS )
515
      {
516
      int[] sizes = objects[ordinal].getSizes();
517
      int len = sizes.length;
518

    
519
      for(int i=0; i<len; i++)
520
        {
521
        if( sizes[i]==size ) return i;
522
        }
523
      }
524

    
525
    return -1;
526
    }
527

    
528
///////////////////////////////////////////////////////////////////////////////////////////////////
529

    
530
  ObjectList(int[][] info, int row)
531
    {
532
    mNumSizes = info.length;
533

    
534
    mObjectSizes  = new int[mNumSizes];
535
    mDBLevels     = new int[mNumSizes];
536
    mNumScrambles = new int[mNumSizes];
537
    mSmallIconIDs = new int[mNumSizes];
538
    mMediumIconIDs= new int[mNumSizes];
539
    mBigIconIDs   = new int[mNumSizes];
540
    mHugeIconIDs  = new int[mNumSizes];
541

    
542
    for(int i=0; i<mNumSizes; i++)
543
      {
544
      mObjectSizes[i]  = info[i][0];
545
      mDBLevels[i]     = info[i][1];
546
      mNumScrambles[i] = info[i][2];
547
      mSmallIconIDs[i] = info[i][3];
548
      mMediumIconIDs[i]= info[i][4];
549
      mBigIconIDs[i]   = info[i][5];
550
      mHugeIconIDs[i]  = info[i][6];
551
      }
552

    
553
    mRow  = row;
554
    }
555

    
556
///////////////////////////////////////////////////////////////////////////////////////////////////
557

    
558
  public int[] getSizes()
559
    {
560
    return mObjectSizes;
561
    }
562

    
563
///////////////////////////////////////////////////////////////////////////////////////////////////
564

    
565
  public int[] getIconIDs(int size)
566
    {
567
    switch(size)
568
      {
569
      case 0: return mSmallIconIDs;
570
      case 1: return mMediumIconIDs;
571
      case 2: return mBigIconIDs;
572
      case 3: return mHugeIconIDs;
573
      }
574

    
575
    return mSmallIconIDs;
576
    }
577

    
578
///////////////////////////////////////////////////////////////////////////////////////////////////
579

    
580
  public TwistyObject create(int size, Static4D quat, int[][] moves, Resources res, int scrWidth)
581
    {
582
    DistortedTexture texture = new DistortedTexture();
583
    DistortedEffects effects = new DistortedEffects();
584
    MeshSquare mesh          = new MeshSquare(20,20);   // mesh of the node, not of the cubits
585

    
586
    switch(ordinal())
587
      {
588
      case  0: return new TwistyCube          (size, quat, texture, mesh, effects, moves, res, scrWidth);
589
      case  1: return new TwistyJing          (size, quat, texture, mesh, effects, moves, res, scrWidth);
590
      case  2: return new TwistyPyraminx      (size, quat, texture, mesh, effects, moves, res, scrWidth);
591
      case  3: return new TwistyKilominx      (size, quat, texture, mesh, effects, moves, res, scrWidth);
592
      case  4: return new TwistyMegaminx      (size, quat, texture, mesh, effects, moves, res, scrWidth);
593
      case  5: return new TwistyUltimate      (size, quat, texture, mesh, effects, moves, res, scrWidth);
594
      case  6: return new TwistyDiamond       (size, quat, texture, mesh, effects, moves, res, scrWidth);
595
      case  7: return new TwistyDino6         (size, quat, texture, mesh, effects, moves, res, scrWidth);
596
      case  8: return new TwistyDino4         (size, quat, texture, mesh, effects, moves, res, scrWidth);
597
      case  9: return new TwistyRedi          (size, quat, texture, mesh, effects, moves, res, scrWidth);
598
      case 10: return new TwistyHelicopter    (size, quat, texture, mesh, effects, moves, res, scrWidth);
599
      case 11: return new TwistySkewb         (size, quat, texture, mesh, effects, moves, res, scrWidth);
600
      case 12: return new TwistyIvy           (size, quat, texture, mesh, effects, moves, res, scrWidth);
601
      case 13: return new TwistyRex           (size, quat, texture, mesh, effects, moves, res, scrWidth);
602
      case 14: return new TwistyBandagedFused (size, quat, texture, mesh, effects, moves, res, scrWidth);
603
      case 15: return new TwistyBandaged2Bar  (size, quat, texture, mesh, effects, moves, res, scrWidth);
604
      case 16: return new TwistyBandaged3Plate(size, quat, texture, mesh, effects, moves, res, scrWidth);
605
      case 17: return new TwistyBandagedEvil  (size, quat, texture, mesh, effects, moves, res, scrWidth);
606
      case 18: return new TwistySquare1       (size, quat, texture, mesh, effects, moves, res, scrWidth);
607
      case 19: return new TwistySquare2       (size, quat, texture, mesh, effects, moves, res, scrWidth);
608
      case 20: return new TwistyMirror        (size, quat, texture, mesh, effects, moves, res, scrWidth);
609
      }
610

    
611
    return null;
612
    }
613
  }
(9-9/20)