Revision 8f44228f
Added by Leszek Koltunski over 1 year ago
src/main/java/org/distorted/objectlib/helpers/ObjectSignature.java | ||
---|---|---|
114 | 114 |
prepareAllCycles(); |
115 | 115 |
} |
116 | 116 |
|
117 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
118 |
// BAN*** objects when read from JSON |
|
119 |
|
|
120 |
public ObjectSignature(int size, long[] signature) |
|
121 |
{ |
|
122 |
setUpSignature(signature); |
|
123 |
|
|
124 |
mLayer = new int[] {size,size,size}; |
|
125 |
|
|
126 |
prepareCubitTouch(); |
|
127 |
prepareAllCycles(); |
|
128 |
} |
|
129 |
|
|
117 | 130 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
118 | 131 |
// other objects created from JSON (version2) |
119 | 132 |
|
src/main/java/org/distorted/objectlib/json/JsonReader.java | ||
---|---|---|
9 | 9 |
|
10 | 10 |
package org.distorted.objectlib.json; |
11 | 11 |
|
12 |
import static org.distorted.objectlib.objects.TwistyBandagedCuboid.OBJECT_NAME; |
|
13 |
import static org.distorted.objectlib.scrambling.ScrambleStateBandagedCuboid.MAX_SUPPORTED_SIZE; |
|
14 |
|
|
12 | 15 |
import java.io.BufferedReader; |
13 | 16 |
import java.io.File; |
14 | 17 |
import java.io.FileInputStream; |
... | ... | |
24 | 27 |
import org.distorted.objectlib.helpers.ObjectStickerOverride; |
25 | 28 |
import org.distorted.objectlib.helpers.ObjectVertexEffects; |
26 | 29 |
import org.distorted.objectlib.main.Cubit; |
27 |
import org.distorted.objectlib.objects.TwistyBandagedCuboid; |
|
28 | 30 |
import org.distorted.objectlib.scrambling.ScrambleEdgeGenerator; |
29 | 31 |
import org.json.JSONArray; |
30 | 32 |
import org.json.JSONException; |
... | ... | |
81 | 83 |
private ObjectStickerOverride[] mStickerOverrides; |
82 | 84 |
private float mPillowCoeff; |
83 | 85 |
|
86 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
87 |
|
|
88 |
public static ObjectSignature produceSignature(String shortName, String longName, long[] signature) |
|
89 |
{ |
|
90 |
// 'BAN*_*' ( or future possible 'BA**_*' ) objects |
|
91 |
if( shortName.charAt(0)=='B' && shortName.charAt(1)=='A' && shortName.charAt(4)=='_' ) |
|
92 |
{ |
|
93 |
char second = shortName.charAt(2); |
|
94 |
char third = shortName.charAt(3); |
|
95 |
|
|
96 |
if( (second=='N' || (second>='0' && second<='9')) && (third>='0' && third<='9') ) |
|
97 |
{ |
|
98 |
int size = shortName.charAt(5) - '0'; |
|
99 |
if( size>=2 && size<=MAX_SUPPORTED_SIZE ) return new ObjectSignature(size,signature); |
|
100 |
} |
|
101 |
} |
|
102 |
|
|
103 |
if( longName.equals(OBJECT_NAME) ) new ObjectSignature(shortName,signature); |
|
104 |
|
|
105 |
return new ObjectSignature(signature); |
|
106 |
} |
|
107 |
|
|
84 | 108 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
85 | 109 |
|
86 | 110 |
private void parseMetadata(JSONObject metadata) throws JSONException |
... | ... | |
101 | 125 |
int size = sigArray.length(); |
102 | 126 |
long[] signature = new long[size]; |
103 | 127 |
for(int i=0; i<size; i++) signature[i] = sigArray.getLong(i); |
104 |
|
|
105 |
switch( TwistyBandagedCuboid.getType(mShortName,mLongName) ) |
|
106 |
{ |
|
107 |
case 0: mSignature = new ObjectSignature(signature); break; |
|
108 |
case 1: mSignature = new ObjectSignature(mShortName,signature); break; |
|
109 |
case 2: mSignature = new ObjectSignature("333",signature); break; |
|
110 |
case 3: mSignature = new ObjectSignature("444",signature); break; |
|
111 |
} |
|
128 |
mSignature = produceSignature(mShortName,mLongName,signature); |
|
112 | 129 |
} |
113 | 130 |
catch(JSONException ex) |
114 | 131 |
{ |
src/main/java/org/distorted/objectlib/objects/TwistyBandagedCuboid.java | ||
---|---|---|
30 | 30 |
|
31 | 31 |
public class TwistyBandagedCuboid extends TwistyBandagedAbstract |
32 | 32 |
{ |
33 |
private static final String OBJECT_NAME = "LOCAL_BANDAGED";
|
|
33 |
public static final String OBJECT_NAME = "LOCAL_BANDAGED";
|
|
34 | 34 |
|
35 | 35 |
private static final int CUBIT_111 = 0; |
36 | 36 |
private static final int CUBIT_211 = 1; |
... | ... | |
229 | 229 |
private int[] mTypeVariantMap; |
230 | 230 |
private Static4D[] mInitQuats; |
231 | 231 |
|
232 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
233 |
|
|
234 |
public static int getType(String shortName, String longName) |
|
235 |
{ |
|
236 |
if( shortName.equals(ObjectType.BAN1_3.name()) || |
|
237 |
shortName.equals(ObjectType.BAN2_3.name()) || |
|
238 |
shortName.equals(ObjectType.BAN3_3.name()) || |
|
239 |
shortName.equals(ObjectType.BAN4_3.name()) ) return 2; |
|
240 |
|
|
241 |
if( shortName.equals(ObjectType.BAN5_4.name()) || |
|
242 |
shortName.equals(ObjectType.BAN6_4.name()) ) return 3; |
|
243 |
|
|
244 |
if( longName.equals(OBJECT_NAME) ) return 1; |
|
245 |
|
|
246 |
return 0; |
|
247 |
} |
|
248 |
|
|
249 | 232 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
250 | 233 |
|
251 | 234 |
public TwistyBandagedCuboid(InitData data, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream) |
Also available in: Unified diff
Make the JSON reader capable of handling possible future 'BAN*_*' objects.