Project

General

Profile

« Previous | Next » 

Revision 740fade2

Added by Leszek Koltunski 5 months ago

Fix the association between a RubikObject and its solvers and patterns.

Before, if we rearranged the objects order in the main screen, this would break down.

View differences:

src/main/java/org/distorted/dialogs/RubikDialogPattern.java
21 21
import org.distorted.objectlib.main.ObjectControl;
22 22
import org.distorted.objectlib.patterns.RubikPattern;
23 23
import org.distorted.objectlib.patterns.RubikPatternList;
24
import org.distorted.objects.RubikObject;
25
import org.distorted.objects.RubikObjectList;
24 26
import org.distorted.patternui.PatternActivity;
25 27
import org.distorted.patternui.ScreenList;
26 28
import org.distorted.patternui.ScreenPattern;
......
73 75
      return;
74 76
      }
75 77

  
76
    mPatternOrdinal = RubikPatternList.getOrdinal(objectOrdinal);
78
    RubikObject object = RubikObjectList.getObject(objectOrdinal);
79
    int objectIndex = object==null ? -1 : object.getIndex();
80

  
81
    mPatternOrdinal = RubikPatternList.getOrdinal(objectIndex);
77 82

  
78 83
    if( mPatternOrdinal<0 )
79 84
      {
src/main/java/org/distorted/objects/RubikObject.java
46 46
  private final float mDifficulty;
47 47
  private final String mAuthor;
48 48
  private final boolean mAdjColors;
49
  private final int mObjectIndex;
49 50

  
50 51
  private boolean mIsFree;
51 52
  private int mJsonID, mMeshID, mExtrasID;
......
75 76
    mAuthor      = meta.getAuthor();
76 77
    mIsLocal     = false;
77 78
    mAdjColors   = meta.supportsAdjustableStickerColors();
79
    mObjectIndex = ListObjects.getObjectIndex(mUpperName);
78 80

  
79
    int patternOrdinal  = RubikPatternList.getOrdinal(mObjectOrdinal);
81
    int patternOrdinal  = RubikPatternList.getOrdinal(mObjectIndex);
80 82
    mPatterns = RubikPatternList.getPatterns(patternOrdinal);
81 83

  
82
    mSolverOrdinal = ImplementedSolversList.getSolverOrdinal(mObjectOrdinal);
84
    mSolverOrdinal = ImplementedSolversList.getSolverOrdinal(mObjectIndex);
83 85
    mExtrasOrdinal = -1;
84 86

  
85 87
    mObjectVersion = meta.objectVersion();
......
104 106
    mYear          = object.year;
105 107
    mAuthor        = object.author;
106 108
    mAdjColors     = object.adjColors;
109
    mObjectIndex   = -1;
107 110

  
108 111
    mPatterns      = null;
109 112
    mExtrasOrdinal = -1;
......
313 316
    return mCategory;
314 317
    }
315 318

  
319
///////////////////////////////////////////////////////////////////////////////////////////////////
320

  
321
  public int getIndex()
322
    {
323
    return mObjectIndex;
324
    }
325

  
316 326
///////////////////////////////////////////////////////////////////////////////////////////////////
317 327

  
318 328
  public float getDifficulty()
src/main/java/org/distorted/solverui/SolverActivity.java
61 61

  
62 62
      Bundle b = getIntent().getExtras();
63 63
      mObjectOrdinal = b!=null ? b.getInt("obj") : 0;
64
      mSolverOrdinal = ImplementedSolversList.getSolverOrdinal(mObjectOrdinal);
64
      RubikObject object = RubikObjectList.getObject(mObjectOrdinal);
65
      int objectIndex = object==null ? -1 : object.getIndex();
66
      mSolverOrdinal = ImplementedSolversList.getSolverOrdinal(objectIndex);
65 67
      mDisplayMessageDialog = true;
66 68

  
67 69
      computeScreenDimensions();

Also available in: Unified diff