Project

General

Profile

« Previous | Next » 

Revision 7c0cc7a5

Added by Leszek Koltunski about 4 hours ago

  • ID 7c0cc7a597005ba1c5fb09dd798b8021d03022f2
  • Parent cbde5100

progress with remembering solves

View differences:

src/main/java/org/distorted/dialogs/DialogAbandon.java
19 19
import org.distorted.main.R;
20 20
import org.distorted.play.PlayActivity;
21 21
import org.distorted.play.ScreenList;
22
import org.distorted.play.ScreenSolving;
22 23

  
23 24
///////////////////////////////////////////////////////////////////////////////////////////////////
24 25

  
......
48 49

  
49 50
    if( act!=null )
50 51
      {
51
      act.rememberSolve();
52
      ScreenSolving solving = (ScreenSolving)ScreenList.SOLV.getScreenClass();
53
      int time = solving.stopTimerAndGetRecord();
54
      act.rememberSolve(time);
52 55
      ScreenList.goBack(act);
53 56
      }
54 57
    }
src/main/java/org/distorted/helpers/RubikRememberedSolves.java
110 110
        JSONArray levels = new JSONArray(contents);
111 111
        JSONArray lvl = levels.getJSONArray(level);
112 112
        JSONObject data = createData(elapsed,rot,quats);
113
        if( lvl.length()>=MAXSOLVES ) lvl.remove(0);
113
        if( lvl.length()>=MAXSOLVES || level==0) lvl.remove(0);
114 114
        lvl.put(data);
115 115
        return levels.toString();
116 116
        }
src/main/java/org/distorted/main/MainObjectPopup.java
26 26

  
27 27
import org.distorted.helpers.RubikRememberedSolves;
28 28
import org.distorted.helpers.RubikScores;
29
import org.distorted.library.type.Static4D;
29 30
import org.distorted.objects.RubikObject;
30 31
import org.distorted.objects.RubikObjectList;
31 32
import org.json.JSONArray;
32 33
import org.json.JSONException;
34
import org.json.JSONObject;
33 35

  
34 36
///////////////////////////////////////////////////////////////////////////////////////////////////
35 37

  
......
277 279
              }
278 280
            catch(JSONException jex)
279 281
              {
280
              android.util.Log.e("D", "exception trying to parse file: "+jex.getMessage() );
282
              android.util.Log.e("D", "Exception 1 trying to parse file: "+jex.getMessage() );
281 283
              }
282 284
            }
283 285

  
284
          if( numSolves>0 )
286
          if( numSolves>0 && ll>=0 )
285 287
            {
286 288
            MainSolvesPopup popup = new MainSolvesPopup(act,object,mObjectOrdinal,scrambles,ll,json,height);
287 289
            popup.show(v);
288 290
            }
289
          else act.switchToPlay(object,mObjectOrdinal,scrambles,ll,0,null,null);
291
          else
292
            {
293
            if( numSolves>0 )
294
              {
295
              RubikRememberedSolves solves = RubikRememberedSolves.getInstance();
296

  
297
              try
298
                {
299
                JSONObject obj = json.getJSONObject(0);
300
                Static4D rotQuat = solves.getRotQuat(obj);
301
                int[] quats = solves.getQuats(obj);
302
                act.switchToPlay(object,mObjectOrdinal,scrambles,ll,1,rotQuat,quats);
303
                }
304
              catch(JSONException jex)
305
                {
306
                android.util.Log.e("D", "Exception 2 trying to parse file: "+jex.getMessage() );
307
                }
308
              }
309
            else
310
              {
311
              act.switchToPlay(object,mObjectOrdinal,scrambles,ll,0,null,null);
312
              }
313
            }
290 314
          }
291 315
        });
292 316
      }
src/main/java/org/distorted/play/PlayActivity.java
344 344

  
345 345
///////////////////////////////////////////////////////////////////////////////////////////////////
346 346

  
347
    public void rememberSolve()
347
    public void rememberSolve(int time)
348 348
      {
349 349
      ObjectControl control = getControl();
350 350
      TwistyObject object = control.getObject();
351 351

  
352 352
      int level = mLevel==LEVELS_SHOWN ? mLevel : mLevel+1;
353
      ScreenSolving solving = (ScreenSolving)ScreenList.SOLV.getScreenClass();
354
      int time = solving.stopTimerAndGetRecord();
355 353
      String name = object.getShortName();
356 354
      int numCubits = object.getNumCubits();
357 355
      int[] quats = new int[numCubits];
src/main/java/org/distorted/play/ScreenFree.java
79 79
      @Override
80 80
      public void onClick(View v)
81 81
        {
82
        act.rememberSolve();
82
        act.rememberSolve(1);  // has to be >0. See PlayActivity.mModeResume
83 83
        act.finish();
84 84
        }
85 85
      });

Also available in: Unified diff