Project

General

Profile

« Previous | Next » 

Revision a7d8c3cd

Added by Leszek Koltunski over 2 years ago

Progress replacing the enum ObjetType with the class RubikObjectList.

View differences:

src/main/java/org/distorted/network/RubikNetwork.java
34 34
import androidx.fragment.app.FragmentActivity;
35 35

  
36 36
import org.distorted.library.main.DistortedLibrary;
37
import org.distorted.objectlib.main.ObjectType;
37
import org.distorted.objects.RubikObject;
38
import org.distorted.objects.RubikObjectList;
38 39

  
39 40
import static org.distorted.screens.RubikScreenPlay.MAX_LEVEL;
40
import static org.distorted.objectlib.main.ObjectType.NUM_OBJECTS;
41 41

  
42 42
///////////////////////////////////////////////////////////////////////////////////////////////////
43 43

  
......
108 108
  private static int mMode = IDLE;
109 109
  private static Receiver mReceiver;
110 110
  private static String mVersion;
111
  private static int mNumObjects;
111 112

  
112 113
///////////////////////////////////////////////////////////////////////////////////////////////////
113 114

  
114 115
  private static void initializeStatics()
115 116
    {
116
    if( mCountry==null ) mCountry = new String[NUM_OBJECTS][MAX_LEVEL][MAX_PLACES];
117
    if( mName==null    ) mName    = new String[NUM_OBJECTS][MAX_LEVEL][MAX_PLACES];
118
    if( mTime==null    ) mTime    = new  float[NUM_OBJECTS][MAX_LEVEL][MAX_PLACES];
119
    if( mPlaces==null  ) mPlaces  = new int[NUM_OBJECTS][MAX_LEVEL];
117
    int newNum = RubikObjectList.getNumObjects();
118

  
119
    if( mCountry==null || newNum!=mNumObjects ) mCountry = new String[newNum][MAX_LEVEL][MAX_PLACES];
120
    if( mName==null    || newNum!=mNumObjects ) mName    = new String[newNum][MAX_LEVEL][MAX_PLACES];
121
    if( mTime==null    || newNum!=mNumObjects ) mTime    = new  float[newNum][MAX_LEVEL][MAX_PLACES];
122
    if( mPlaces==null  || newNum!=mNumObjects ) mPlaces  = new int[newNum][MAX_LEVEL];
123

  
124
    mNumObjects = newNum;
120 125
    }
121 126

  
122 127
///////////////////////////////////////////////////////////////////////////////////////////////////
......
165 170
      return false;
166 171
      }
167 172

  
168
    for(int i=0; i<NUM_OBJECTS; i++)
173
    for(int i=0; i<mNumObjects; i++)
169 174
      for(int j=0; j<MAX_LEVEL; j++)
170 175
        {
171 176
        mPlaces[i][j] = 0;
......
204 209

  
205 210
    if( s5>s4 && s4>s3 && s3>s2 && s2>s1 && s1>0 )
206 211
      {
207
      int object = ObjectType.getOrdinal( row.substring(0,s1) );
212
      int object = RubikObjectList.getOrdinal( row.substring(0,s1) );
208 213

  
209
      if( object>=0 && object<NUM_OBJECTS )
214
      if( object>=0 && object<mNumObjects )
210 215
        {
211 216
        int level      = Integer.parseInt( row.substring(s1+1,s2) );
212 217
        String name    = row.substring(s2+1, s3);
......
463 468
  private static String getObjectList()
464 469
    {
465 470
    StringBuilder list = new StringBuilder();
466
    ObjectType[] objects = ObjectType.values();
467 471

  
468
    for(int i=0; i<NUM_OBJECTS; i++)
472
    for(int i=0; i<mNumObjects; i++)
469 473
      {
470
      if( i>0 ) list.append(',');
471
      list.append(objects[i].name());
474
      RubikObject object = RubikObjectList.getObject(i);
475

  
476
      if( object!=null )
477
        {
478
        if( i>0 ) list.append(',');
479
        list.append(object.getName());
480
        }
472 481
      }
473 482

  
474 483
    return list.toString();

Also available in: Unified diff