Project

General

Profile

« Previous | Next » 

Revision 962b8ff6

Added by Leszek Koltunski 2 months ago

progress with configurable stickers

View differences:

src/main/java/org/distorted/objectlib/json/JsonReader.java
82 82
  private float mSize;
83 83
  private int mScrambleType, mNumScrambles;
84 84
  private int mPrice;
85
  private int[] mColor;
85
  private int[] mColorTable;
86 86
  private int mInternalColor;
87 87
  private boolean mResetMaps;
88 88
  private String mTutorialObject;
......
848 848
    {
849 849
    mNumFaceColors = object.length()-1;
850 850

  
851
    mColor = new int[mNumFaceColors];
852
    for(int i=0; i<mNumFaceColors; i++) mColor[i] = object.getInt(i);
851
    mColorTable = new int[mNumFaceColors];
852
    for(int i=0; i<mNumFaceColors; i++) mColorTable[i] = object.getInt(i);
853 853

  
854 854
    mInternalColor = object.getInt(mNumFaceColors);
855 855
    }
......
1302 1302
    return mNumFaces;
1303 1303
    }
1304 1304

  
1305
///////////////////////////////////////////////////////////////////////////////////////////////////
1306

  
1307
  public int getNumFaceColors()
1308
    {
1309
    return mNumFaceColors;
1310
    }
1311

  
1312 1305
///////////////////////////////////////////////////////////////////////////////////////////////////
1313 1306

  
1314 1307
  public int[] getNumLayers()
......
1325 1318

  
1326 1319
///////////////////////////////////////////////////////////////////////////////////////////////////
1327 1320

  
1328
  public int getColor(int face)
1321
  public int[] getColorTable()
1329 1322
    {
1330
    return mColor[face];
1323
    return mColorTable;
1331 1324
    }
1332 1325

  
1333 1326
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objectlib/json/JsonWriter.java
610 610
  private JSONArray generateColors(TwistyObject object)
611 611
    {
612 612
    JSONArray jsonColors = new JSONArray();
613
    int numFaceColors = object.getNumFaceColors();
614
    for(int i=0; i<numFaceColors; i++) jsonColors.put(object.getColor(i));
613
    int[] colorTable = object.getColorTable();
614
    int numFaceColors = colorTable.length;
615
    for(int i=0; i<numFaceColors; i++) jsonColors.put(colorTable[i]);
615 616

  
616 617
    jsonColors.put(object.getInternalColor());
617 618

  
src/main/java/org/distorted/objectlib/main/ObjectControl.java
816 816
      mPreRender.resetAllTextureMaps();
817 817
      }
818 818

  
819
///////////////////////////////////////////////////////////////////////////////////////////////////
820

  
821
    public void recreateColors()
822
      {
823
      TwistyObject object = mPreRender.getObject();
824
      object.recreateFaceColors();
825
      }
826

  
819 827
///////////////////////////////////////////////////////////////////////////////////////////////////
820 828

  
821 829
    public void recreateSticker(float borders, float corners)
src/main/java/org/distorted/objectlib/main/TwistyJson.java
411 411

  
412 412
///////////////////////////////////////////////////////////////////////////////////////////////////
413 413

  
414
  public int getNumFaceColors()
414
  public int[] getColorTable()
415 415
    {
416
    return mReader.getNumFaceColors();
417
    }
418

  
419
///////////////////////////////////////////////////////////////////////////////////////////////////
420

  
421
  public int getColor(int face)
422
    {
423
    return mReader.getColor(face);
416
    return mReader.getColorTable();
424 417
    }
425 418

  
426 419
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objectlib/main/TwistyObject.java
146 146
  private int mNumAxis;
147 147
  private boolean mThereAreDeciders;
148 148
  private TwistyLayerRotations mRotation;
149
  private int[] mColorTable;
149 150

  
150 151
///////////////////////////////////////////////////////////////////////////////////////////////////
151 152

  
......
226 227
      mNumCuts[i] = (mCuts==null || mCuts[i]==null ? 0 : mCuts[i].length);
227 228
      }
228 229

  
230
    recreateFaceColors();
229 231
    mMinimalCubiesInRow = getMinimalCubiesInRow();
230 232
    mNumCubits = mOrigPos.length;
231
    mNumFaceColors = getNumFaceColors();
233

  
232 234
    mBelongs = new boolean[mNumCubits];
233 235

  
234 236
    int scramblingType = getScrambleType();
......
281 283
    mNode = new DistortedNode(mTexture,mEffects,mMesh);
282 284
    }
283 285

  
286
///////////////////////////////////////////////////////////////////////////////////////////////////
287

  
288
  public void recreateFaceColors()
289
    {
290
    int[] tmp = getColorTable();
291
    mNumFaceColors = tmp.length;
292
    mColorTable = new int[mNumFaceColors];
293
    for(int i=0; i<mNumFaceColors; i++) mColorTable[i] = tmp[i];
294
    }
295

  
284 296
///////////////////////////////////////////////////////////////////////////////////////////////////
285 297
// in degrees so that everything can be treated modulo 360
286 298

  
......
1239 1251
// figure out the whole face to which (cubit,face) belongs, repaint all (cubit,face) pairs to
1240 1252
// the new color.
1241 1253

  
1242
  void repaintPuzzleFace(int cubit, int face, int color, float borders, float corners)
1254
  void repaintPuzzleFace(int cubit, int face, int newColor, float borders, float corners)
1243 1255
    {
1244 1256
    int oldColorIndex = getCubitFaceColor(cubit,face);
1245
    int oldColor = getColor(oldColorIndex);
1257
    int oldColor = mColorTable[oldColorIndex];
1246 1258

  
1247
    if( oldColor!=color )
1259
    if( oldColor!=newColor )
1248 1260
      {
1249
      changeColorInTexture(borders,corners,oldColor,color);
1261
      changeColorInTexture(borders,corners,oldColor,newColor);
1262
      mColorTable[oldColorIndex] = newColor;
1250 1263
      setTexture();
1251 1264
      }
1252 1265
    }
......
1650 1663
        if( texture<mNumTextures-mNumOverrides )
1651 1664
          {
1652 1665
          ObjectSticker sticker = retSticker(texture/mNumFaceColors);
1653
          int color = getColor(texture%mNumFaceColors);
1666
          int color = mColorTable[texture%mNumFaceColors];
1654 1667
          factory.drawRoundedPolygons(canvas, paint, col*mTexHeight, (mNumTexRows-row)*mTexHeight, color, mTexHeight, sticker,borders,corners);
1655 1668
          }
1656 1669
        else if( texture>mNumTextures-mNumOverrides && texture<=mNumTextures )
......
1678 1691
        {
1679 1692
        if( texture<mNumTextures-mNumOverrides )
1680 1693
          {
1681
          int color = getColor(texture%mNumFaceColors);
1694
          int color = mColorTable[texture%mNumFaceColors];
1682 1695

  
1683 1696
          if( color==oldColor )
1684 1697
            {
......
2063 2076
  public abstract int getNumCubitVariants(int[] numLayers);
2064 2077
  public abstract float[][] getCubitPositions(int[] numLayers);
2065 2078
  public abstract Static4D getCubitQuats(int cubit, int[] numLayers);
2066
  public abstract int getNumFaceColors();
2067 2079
  public abstract float getScreenRatio();
2068
  public abstract int getColor(int face);
2080
  public abstract int[] getColorTable();
2069 2081
  public abstract String getShortName();
2070 2082

  
2071 2083
  // not only for JSON
src/main/java/org/distorted/objectlib/objects/TwistyMirror.java
63 63
///////////////////////////////////////////////////////////////////////////////////////////////////
64 64

  
65 65
  @Override
66
  public int getColor(int face)
66
  public int[] getColorTable()
67 67
    {
68
    return FACE_COLORS[face];
69
    }
70

  
71
///////////////////////////////////////////////////////////////////////////////////////////////////
72

  
73
  @Override
74
  public int getNumFaceColors()
75
    {
76
    return 1;
68
    return FACE_COLORS;
77 69
    }
78 70

  
79 71
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objectlib/objects/TwistyMirrorJing.java
87 87
///////////////////////////////////////////////////////////////////////////////////////////////////
88 88

  
89 89
  @Override
90
  public int getColor(int face)
90
  public int[] getColorTable()
91 91
    {
92
    return FACE_COLORS[face];
93
    }
94

  
95
///////////////////////////////////////////////////////////////////////////////////////////////////
96

  
97
  @Override
98
  public int getNumFaceColors()
99
    {
100
    return 1;
92
    return FACE_COLORS;
101 93
    }
102 94

  
103 95
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objectlib/objects/TwistyMirrorPyraminx.java
84 84
///////////////////////////////////////////////////////////////////////////////////////////////////
85 85

  
86 86
  @Override
87
  public int getColor(int face)
87
  public int[] getColorTable()
88 88
    {
89
    return FACE_COLORS[face];
90
    }
91

  
92
///////////////////////////////////////////////////////////////////////////////////////////////////
93

  
94
  @Override
95
  public int getNumFaceColors()
96
    {
97
    return 1;
89
    return FACE_COLORS;
98 90
    }
99 91

  
100 92
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objectlib/objects/TwistyMirrorSkewb.java
85 85
///////////////////////////////////////////////////////////////////////////////////////////////////
86 86

  
87 87
  @Override
88
  public int getColor(int face)
88
  public int[] getColorTable()
89 89
    {
90
    return FACE_COLORS[face];
91
    }
92

  
93
///////////////////////////////////////////////////////////////////////////////////////////////////
94

  
95
  @Override
96
  public int getNumFaceColors()
97
    {
98
    return 1;
90
    return FACE_COLORS;
99 91
    }
100 92

  
101 93
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objectlib/shape/ShapeDiamond.java
62 62

  
63 63
///////////////////////////////////////////////////////////////////////////////////////////////////
64 64

  
65
  public int getNumFaceColors()
65
  public int[] getColorTable()
66 66
    {
67
    return FACE_COLORS.length;
68
    }
69

  
70
///////////////////////////////////////////////////////////////////////////////////////////////////
71

  
72
  public int getColor(int face)
73
    {
74
    return FACE_COLORS[face];
67
    return FACE_COLORS;
75 68
    }
76 69

  
77 70
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objectlib/shape/ShapeDodecahedron.java
61 61

  
62 62
///////////////////////////////////////////////////////////////////////////////////////////////////
63 63

  
64
  public int getNumFaceColors()
64
  public int[] getColorTable()
65 65
    {
66
    return FACE_COLORS.length;
67
    }
68

  
69
///////////////////////////////////////////////////////////////////////////////////////////////////
70

  
71
  public int getColor(int face)
72
    {
73
    return FACE_COLORS[face];
66
    return FACE_COLORS;
74 67
    }
75 68

  
76 69
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objectlib/shape/ShapeHexahedron.java
48 48

  
49 49
///////////////////////////////////////////////////////////////////////////////////////////////////
50 50

  
51
  public int getNumFaceColors()
51
  public int[] getColorTable()
52 52
    {
53
    return FACE_COLORS.length;
54
    }
55

  
56
///////////////////////////////////////////////////////////////////////////////////////////////////
57

  
58
  public int getColor(int face)
59
    {
60
    return FACE_COLORS[face];
53
    return FACE_COLORS;
61 54
    }
62 55

  
63 56
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objectlib/shape/ShapeIcosahedron.java
70 70

  
71 71
///////////////////////////////////////////////////////////////////////////////////////////////////
72 72

  
73
  public int getNumFaceColors()
73
  public int[] getColorTable()
74 74
    {
75
    return FACE_COLORS.length;
76
    }
77

  
78
///////////////////////////////////////////////////////////////////////////////////////////////////
79

  
80
  public int getColor(int face)
81
    {
82
    return FACE_COLORS[face];
75
    return FACE_COLORS;
83 76
    }
84 77

  
85 78
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objectlib/shape/ShapeOctahedron.java
49 49

  
50 50
///////////////////////////////////////////////////////////////////////////////////////////////////
51 51

  
52
  public int getNumFaceColors()
52
  public int[] getColorTable()
53 53
    {
54
    return FACE_COLORS.length;
55
    }
56

  
57
///////////////////////////////////////////////////////////////////////////////////////////////////
58

  
59
  public int getColor(int face)
60
    {
61
    return FACE_COLORS[face];
54
    return FACE_COLORS;
62 55
    }
63 56

  
64 57
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objectlib/shape/ShapeTetrahedron.java
47 47

  
48 48
///////////////////////////////////////////////////////////////////////////////////////////////////
49 49

  
50
  public int getNumFaceColors()
50
  public int[] getColorTable()
51 51
    {
52
    return FACE_COLORS.length;
53
    }
54

  
55
///////////////////////////////////////////////////////////////////////////////////////////////////
56

  
57
  public int getColor(int face)
58
    {
59
    return FACE_COLORS[face];
52
    return FACE_COLORS;
60 53
    }
61 54

  
62 55
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff