Project

General

Profile

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

magiccube / src / main / java / org / distorted / objectlb / ObjectList.java @ e01c0d02

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.objectlb;
21

    
22
import android.content.res.Resources;
23

    
24
import org.distorted.objects.TwistyBandaged2Bar;
25
import org.distorted.objects.TwistyBandaged3Plate;
26
import org.distorted.objects.TwistyBandagedEvil;
27
import org.distorted.objects.TwistyBandagedFused;
28
import org.distorted.objects.TwistyCube;
29
import org.distorted.objects.TwistyDiamond;
30
import org.distorted.objects.TwistyDino4;
31
import org.distorted.objects.TwistyDino6;
32
import org.distorted.objects.TwistyHelicopter;
33
import org.distorted.objects.TwistyIvy;
34
import org.distorted.objects.TwistyJing;
35
import org.distorted.objects.TwistyKilominx;
36
import org.distorted.objects.TwistyMegaminx;
37
import org.distorted.objects.TwistyMirror;
38
import org.distorted.objects.TwistyPyraminx;
39
import org.distorted.objects.TwistyRedi;
40
import org.distorted.objects.TwistyRex;
41
import org.distorted.objects.TwistySkewb;
42
import org.distorted.objects.TwistySquare1;
43
import org.distorted.objects.TwistySquare2;
44
import org.distorted.objects.TwistyUltimate;
45
import org.distorted.library.main.DistortedEffects;
46
import org.distorted.library.main.DistortedTexture;
47
import org.distorted.library.mesh.MeshSquare;
48
import org.distorted.library.type.Static4D;
49
import org.distorted.main.R;
50
import org.distorted.main.RubikActivity;
51

    
52
///////////////////////////////////////////////////////////////////////////////////////////////////
53

    
54
/*
55
  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} ),
56
  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} ),
57
  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} ),
58
  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} ),
59
  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} ),
60
  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} ),
61
  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} ),
62
  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} ),
63
  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} ),
64
  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} ),
65
  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} ),
66
  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} ),
67
  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 } ),
68
  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} ),
69
  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} ),
70
  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} ),
71
  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 } ),
72
  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 } ),
73
  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 } ),
74
  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 } ),
75
  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} ),
76
  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} ),
77
  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  } ),
78
  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  } ),
79
  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 } ),
80
  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 } ),
81
  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 } ),
82
  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 } ),
83
  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} ),
84
  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} ),
85
  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} ),
86
  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} ),
87
  ;
88
*/
89

    
90

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

    
95
  CUBE (
96
         new int[][] {
97
                       {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} ,
98
                       {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} ,
99
                       {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} ,
100
                       {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}
101
                     },
102
         0
103
       ),
104

    
105
  JING (
106
         new int[][] {
107
                       {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} ,
108
                     },
109
         1
110
       ),
111

    
112
  PYRA (
113
         new int[][] {
114
                       {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} ,
115
                       {4 , 15, 17, R.raw.pyra4, R.drawable.ui_small_pyra4, R.drawable.ui_medium_pyra4, R.drawable.ui_big_pyra4, R.drawable.ui_huge_pyra4} ,
116
                       {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}
117
                     },
118
         1
119
       ),
120

    
121
  KILO (
122
         new int[][] {
123
                       {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} ,
124
                       {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} ,
125
                     },
126
         2
127
       ),
128

    
129
  MEGA (
130
         new int[][] {
131
                       {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} ,
132
                       {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} ,
133
                     },
134
         2
135
       ),
136

    
137
  ULTI (
138
         new int[][] {
139
                       {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} ,
140
                     },
141
         3
142
       ),
143

    
144
  DIAM (
145
         new int[][] {
146
                       {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} ,
147
                       {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} ,
148
                       {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} ,
149
                     },
150
         3
151
       ),
152

    
153
  DINO (
154
         new int[][] {
155
                       {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} ,
156
                     },
157
         4
158
       ),
159

    
160
  DIN4 (
161
         new int[][] {
162
                       {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} ,
163
                     },
164
         4
165
       ),
166

    
167
  REDI (
168
         new int[][] {
169
                       {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} ,
170
                     },
171
         4
172
       ),
173

    
174
  HELI (
175
         new int[][] {
176
                       {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} ,
177
                     },
178
         4
179
       ),
180

    
181
  SKEW (
182
         new int[][] {
183
                       {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} ,
184
                       {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} ,
185
                     },
186
         5
187
       ),
188

    
189
  IVY  (
190
         new int[][] {
191
                       {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} ,
192
                     },
193
         5
194
       ),
195

    
196
  REX  (
197
         new int[][] {
198
                       {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} ,
199
                     },
200
         5
201
       ),
202

    
203
  BAN1 (
204
         new int[][] {
205
                       {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} ,
206
                     },
207
         6
208
       ),
209

    
210
  BAN2 (
211
         new int[][] {
212
                       {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} ,
213
                     },
214
         6
215
       ),
216

    
217
  BAN3 (
218
         new int[][] {
219
                       {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} ,
220
                     },
221
         6
222
       ),
223

    
224
  BAN4 (
225
         new int[][] {
226
                       {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} ,
227
                     },
228
         6
229
       ),
230

    
231
  SQU1 (
232
         new int[][] {
233
                       {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} ,
234
                     },
235
         7
236
       ),
237

    
238
  SQU2 (
239
         new int[][] {
240
                       {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} ,
241
                     },
242
         7
243
       ),
244

    
245
  MIRR (
246
         new int[][] {
247
                       {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} ,
248
                       {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} ,
249
                     },
250
         7
251
       ),
252
  ;
253

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

    
260
  private final int[] mObjectSizes, mDBLevels, mNumScrambles, mSmallIconIDs, mMediumIconIDs, mBigIconIDs, mHugeIconIDs, mResourceIDs;
261
  private final int mRow, mNumSizes;
262

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

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

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

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

    
294
    MAX_NUM_OBJECTS = maxNum;
295
    MAX_LEVEL       = maxLevel;
296
    MAX_SCRAMBLE    = maxScramble;
297
    MAX_OBJECT_SIZE = maxSize;
298
    }
299

    
300
///////////////////////////////////////////////////////////////////////////////////////////////////
301

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

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

    
313
    mColCount = 0;
314

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

    
322
///////////////////////////////////////////////////////////////////////////////////////////////////
323

    
324
  private static int computeNumObjectsInRow(int row)
325
    {
326
    int num=0;
327

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

    
336
    return num;
337
    }
338

    
339
///////////////////////////////////////////////////////////////////////////////////////////////////
340

    
341
  public static int getColumnCount()
342
    {
343
    if( mIndices==null ) setUpColAndRow();
344

    
345
    return mColCount;
346
    }
347

    
348
///////////////////////////////////////////////////////////////////////////////////////////////////
349

    
350
  public static int getRowCount()
351
    {
352
    if( mIndices==null ) setUpColAndRow();
353

    
354
    return mRowCount;
355
    }
356

    
357
///////////////////////////////////////////////////////////////////////////////////////////////////
358

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

    
363
    return mIndices;
364
    }
365

    
366
///////////////////////////////////////////////////////////////////////////////////////////////////
367

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

    
373
///////////////////////////////////////////////////////////////////////////////////////////////////
374

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

    
380
    return ret+sizeIndex;
381
    }
382

    
383
///////////////////////////////////////////////////////////////////////////////////////////////////
384

    
385
  public static int unpackSizeIndex(int number)
386
    {
387
    int num;
388

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

    
396
    return -1;
397
    }
398

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

    
401
  public static int unpackObject(int number)
402
    {
403
    int num;
404

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

    
412
    return -1;
413
    }
414

    
415
///////////////////////////////////////////////////////////////////////////////////////////////////
416

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

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

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

    
437
    return -1;
438
    }
439

    
440
///////////////////////////////////////////////////////////////////////////////////////////////////
441

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

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

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

    
464
    return list.toString();
465
    }
466

    
467
///////////////////////////////////////////////////////////////////////////////////////////////////
468

    
469
  public static int getTotal()
470
    {
471
    return mNumAll;
472
    }
473

    
474
///////////////////////////////////////////////////////////////////////////////////////////////////
475

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

    
484
    return 0;
485
    }
486

    
487
///////////////////////////////////////////////////////////////////////////////////////////////////
488

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

    
497
    return 0;
498
    }
499

    
500
///////////////////////////////////////////////////////////////////////////////////////////////////
501

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

    
509
    return -1;
510
    }
511

    
512
///////////////////////////////////////////////////////////////////////////////////////////////////
513

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

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

    
527
    return -1;
528
    }
529

    
530
///////////////////////////////////////////////////////////////////////////////////////////////////
531

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

    
536
    mObjectSizes  = new int[mNumSizes];
537
    mDBLevels     = new int[mNumSizes];
538
    mNumScrambles = new int[mNumSizes];
539
    mResourceIDs  = new int[mNumSizes];
540
    mSmallIconIDs = new int[mNumSizes];
541
    mMediumIconIDs= new int[mNumSizes];
542
    mBigIconIDs   = new int[mNumSizes];
543
    mHugeIconIDs  = new int[mNumSizes];
544

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

    
557
    mRow  = row;
558
    }
559

    
560
///////////////////////////////////////////////////////////////////////////////////////////////////
561

    
562
  public int[] getSizes()
563
    {
564
    return mObjectSizes;
565
    }
566

    
567
///////////////////////////////////////////////////////////////////////////////////////////////////
568

    
569
  public int[] getIconIDs()
570
    {
571
    int size = RubikActivity.getDrawableSize();
572

    
573
    switch(size)
574
      {
575
      case 0 : return mSmallIconIDs;
576
      case 1 : return mMediumIconIDs;
577
      case 2 : return mBigIconIDs;
578
      default: return mHugeIconIDs;
579
      }
580
    }
581

    
582
///////////////////////////////////////////////////////////////////////////////////////////////////
583

    
584
  public int[] getResourceIDs()
585
    {
586
    return mResourceIDs;
587
    }
588

    
589
///////////////////////////////////////////////////////////////////////////////////////////////////
590

    
591
  public TwistyObject create(int size, Static4D quat, int[][] moves, Resources res, int scrWidth)
592
    {
593
    DistortedTexture texture = new DistortedTexture();
594
    DistortedEffects effects = new DistortedEffects();
595
    MeshSquare mesh          = new MeshSquare(20,20);   // mesh of the node, not of the cubits
596

    
597
    switch(ordinal())
598
      {
599
      case  0: return new TwistyCube           (size, quat, texture, mesh, effects, moves, res, scrWidth);
600
      case  1: return new TwistyJing           (size, quat, texture, mesh, effects, moves, res, scrWidth);
601
      case  2: return new TwistyPyraminx       (size, quat, texture, mesh, effects, moves, res, scrWidth);
602
      case  3: return new TwistyKilominx       (size, quat, texture, mesh, effects, moves, res, scrWidth);
603
      case  4: return new TwistyMegaminx       (size, quat, texture, mesh, effects, moves, res, scrWidth);
604
      case  5: return new TwistyUltimate       (size, quat, texture, mesh, effects, moves, res, scrWidth);
605
      case  6: return new TwistyDiamond        (size, quat, texture, mesh, effects, moves, res, scrWidth);
606
      case  7: return new TwistyDino6          (size, quat, texture, mesh, effects, moves, res, scrWidth);
607
      case  8: return new TwistyDino4          (size, quat, texture, mesh, effects, moves, res, scrWidth);
608
      case  9: return new TwistyRedi           (size, quat, texture, mesh, effects, moves, res, scrWidth);
609
      case 10: return new TwistyHelicopter     (size, quat, texture, mesh, effects, moves, res, scrWidth);
610
      case 11: return new TwistySkewb          (size, quat, texture, mesh, effects, moves, res, scrWidth);
611
      case 12: return new TwistyIvy            (size, quat, texture, mesh, effects, moves, res, scrWidth);
612
      case 13: return new TwistyRex            (size, quat, texture, mesh, effects, moves, res, scrWidth);
613
      case 14: return new TwistyBandagedFused  (size, quat, texture, mesh, effects, moves, res, scrWidth);
614
      case 15: return new TwistyBandaged2Bar   (size, quat, texture, mesh, effects, moves, res, scrWidth);
615
      case 16: return new TwistyBandaged3Plate (size, quat, texture, mesh, effects, moves, res, scrWidth);
616
      case 17: return new TwistyBandagedEvil   (size, quat, texture, mesh, effects, moves, res, scrWidth);
617
      case 18: return new TwistySquare1        (size, quat, texture, mesh, effects, moves, res, scrWidth);
618
      case 19: return new TwistySquare2        (size, quat, texture, mesh, effects, moves, res, scrWidth);
619
      case 20: return new TwistyMirror         (size, quat, texture, mesh, effects, moves, res, scrWidth);
620
      }
621

    
622
    return null;
623
    }
624
  }
(9-9/21)