Project

General

Profile

« Previous | Next » 

Revision 1c90c64a

Added by Leszek Koltunski about 4 years ago

Incorporate myRecords into the Scores dialog.

View differences:

src/main/java/org/distorted/scores/RubikScores.java
20 20
package org.distorted.scores;
21 21

  
22 22
import android.content.SharedPreferences;
23

  
24
import org.distorted.magic.R;
23 25
import org.distorted.object.RubikObjectList;
24 26

  
25 27
import static org.distorted.object.RubikObjectList.MAX_SIZE;
......
31 33

  
32 34
public class RubikScores
33 35
  {
34
  private static final long NO_RECORD = Integer.MAX_VALUE;
36
  public static final long NO_RECORD = Long.MAX_VALUE;
35 37
  private static RubikScores mThis;
36 38

  
37 39
  private long[][][] mRecords;
......
39 41
  private boolean mNameIsVerified;
40 42
  private int mNumRuns;
41 43
  private int mNumPlays;
44
  private int mCountryID;
42 45

  
43 46
///////////////////////////////////////////////////////////////////////////////////////////////////
44 47

  
......
53 56
          mRecords[i][j][k] = NO_RECORD;
54 57
          }
55 58

  
56
    mName = "";
59
    mName = "YOU";
57 60
    mNameIsVerified = false;
58 61
    mNumPlays= -1;
59 62
    mNumRuns = -1;
63
    mCountryID = R.drawable.unk;
60 64
    }
61 65

  
62 66
///////////////////////////////////////////////////////////////////////////////////////////////////
......
116 120
    {
117 121
    String recordStr, subStr, nameStr, sizeStr, timeStr;
118 122
    int start, end, equals, underscore;
119
    int object, size, time;
123
    int object, size;
124
    long time;
120 125

  
121 126
    for(int scramble=0; scramble<MAX_SCRAMBLE; scramble++)
122 127
      {
......
143 148

  
144 149
          object = RubikObjectList.getOrdinal(nameStr);
145 150
          size   = RubikObjectList.getSize(object,Integer.parseInt(sizeStr));
146
          time   = Integer.parseInt(timeStr);
151
          time   = Long.parseLong(timeStr);
147 152

  
148 153
          if( object>=0 && object< NUM_OBJECTS && size>=0 && size<MAX_SIZE )
149 154
            {
150 155
            mRecords[object][size][scramble] = time;
151 156

  
152
            if( time<Integer.MAX_VALUE )
157
            if( time<NO_RECORD )
153 158
              {
154 159
              android.util.Log.e("solv", "Set record for: object="+object+" size="+size+" scramble="+scramble+" time: "+time);
155 160
              }
......
162 167
        }
163 168
      }
164 169

  
165
    mName           = preferences.getString("scores_name"  , "");
170
    mName           = preferences.getString("scores_name"  , "YOU" );
166 171
    mNameIsVerified = preferences.getBoolean("scores_isVerified", false);
167 172
    mNumPlays       = preferences.getInt("scores_numPlays", 0);
168 173
    mNumRuns        = preferences.getInt("scores_numRuns" , 0);
......
199 204
    }
200 205

  
201 206
///////////////////////////////////////////////////////////////////////////////////////////////////
207
// TODO
202 208

  
203 209
  public void setName(String newName)
204 210
    {
......
206 212
    }
207 213

  
208 214
///////////////////////////////////////////////////////////////////////////////////////////////////
215
// TODO
209 216

  
210 217
  public void verifyName()
211 218
    {
212 219
    mNameIsVerified = true;
213 220
    }
214 221

  
222
///////////////////////////////////////////////////////////////////////////////////////////////////
223
// TODO
224

  
225
  public void setCountry(int country)
226
    {
227
    mCountryID = country;
228
    }
229

  
215 230
///////////////////////////////////////////////////////////////////////////////////////////////////
216 231

  
217 232
  public long getRecord(int object, int size, int scramble)
218 233
    {
219 234
    int maxsize = RubikObjectList.getObject(object).getSizes().length;
220 235

  
221
    if( object>=0 && object<NUM_OBJECTS && size>=0 && size<maxsize && scramble>=1 && scramble<=MAX_SCRAMBLE )
236
    if( object>=0 && object<NUM_OBJECTS && size>=0 && size<maxsize && scramble>=0 && scramble<MAX_SCRAMBLE )
222 237
      {
223 238
      return mRecords[object][size][scramble];
224 239
      }
......
227 242
    }
228 243

  
229 244
///////////////////////////////////////////////////////////////////////////////////////////////////
245
// TODO
246

  
247
  public boolean isVerified()
248
    {
249
    return mNameIsVerified;
250
    }
251

  
252
///////////////////////////////////////////////////////////////////////////////////////////////////
253
// TODO
230 254

  
231 255
  public int getNumPlays()
232 256
    {
......
249 273

  
250 274
///////////////////////////////////////////////////////////////////////////////////////////////////
251 275

  
252
  public boolean isVerified()
276
  public int getCountryID()
253 277
    {
254
    return mNameIsVerified;
278
    return mCountryID;
255 279
    }
256 280
  }

Also available in: Unified diff