Revision 84d746d7
Added by Leszek Koltunski almost 3 years ago
src/main/java/org/distorted/dialogs/RubikDialogTutorial.java | ||
---|---|---|
100 | 100 |
|
101 | 101 |
for(int i=0; i<numObjects; i++) |
102 | 102 |
{ |
103 |
RubikObject object = RubikObjectList.getObject(i); |
|
103 |
int oOrdinal = RubikObjectList.getObjectOrdinal(i); |
|
104 |
RubikObject object = RubikObjectList.getObject(oOrdinal); |
|
104 | 105 |
ImageView imageView = new ImageView(act); |
105 | 106 |
imageView.setLayoutParams(paramsView); |
106 | 107 |
if( object!=null ) object.setIconTo(act,imageView); |
src/main/java/org/distorted/dialogs/RubikDialogTutorialView.java | ||
---|---|---|
188 | 188 |
|
189 | 189 |
Bundle bundle = new Bundle(); |
190 | 190 |
bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, message); |
191 |
bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, object==null ? "NULL" : object.getName() ); |
|
191 |
bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, object==null ? "NULL" : object.getLowerName() );
|
|
192 | 192 |
analytics.logEvent(FirebaseAnalytics.Event.TUTORIAL_BEGIN, bundle); |
193 | 193 |
} |
194 | 194 |
} |
src/main/java/org/distorted/dialogs/RubikDialogUpdateView.java | ||
---|---|---|
36 | 36 |
import org.distorted.main.R; |
37 | 37 |
import org.distorted.external.RubikNetwork; |
38 | 38 |
import org.distorted.external.RubikUpdates; |
39 |
import org.distorted.objectlib.json.JsonReader; |
|
39 | 40 |
import org.distorted.objects.RubikObjectList; |
41 |
import org.distorted.screens.RubikScreenPlay; |
|
42 |
import org.distorted.screens.ScreenList; |
|
40 | 43 |
|
41 | 44 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
42 | 45 |
|
... | ... | |
121 | 124 |
Activity act = mAct.get(); |
122 | 125 |
RubikFiles files = RubikFiles.getInstance(); |
123 | 126 |
mIconSaved = files.saveIcon(act,mInfo.mIcon, name); |
127 |
|
|
128 |
android.util.Log.e("D", "Saving icon "+name+" to a file "+mIconSaved); |
|
124 | 129 |
} |
125 | 130 |
} |
126 | 131 |
|
... | ... | |
156 | 161 |
String name = mInfo.mObjectShortName + "_object.json"; |
157 | 162 |
Activity act = mAct.get(); |
158 | 163 |
oSuccess = files.saveFile(act,mInfo.mObjectStream, name); |
164 |
|
|
165 |
android.util.Log.e("D", "Saving JSON "+name+" to a file "+oSuccess); |
|
166 |
|
|
167 |
JsonReader reader = JsonReader.getInstance(); |
|
168 |
reader.parseJsonFileMetadata(act,name); |
|
169 |
mInfo.mNumScrambles = reader.getNumScrambles(); |
|
170 |
|
|
171 |
android.util.Log.e("D", "Read from JSON numScrambles="+mInfo.mNumScrambles); |
|
159 | 172 |
} |
160 | 173 |
|
161 | 174 |
if( mInfo.mExtrasStream!=null ) |
... | ... | |
163 | 176 |
String name = mInfo.mObjectShortName + "_extras.json"; |
164 | 177 |
Activity act = mAct.get(); |
165 | 178 |
eSuccess = files.saveFile(act,mInfo.mExtrasStream, name); |
179 |
|
|
180 |
android.util.Log.e("D", "Saving Extras "+name+" to a file "+eSuccess); |
|
166 | 181 |
} |
167 | 182 |
|
168 | 183 |
if( mIconSaved || oSuccess || eSuccess ) |
169 | 184 |
{ |
170 | 185 |
mBar.setProgress(75); |
171 | 186 |
mDescription.setText(R.string.configuring); |
172 |
RubikObjectList.addDownloadedObject(mInfo.mObjectShortName,mIconSaved,oSuccess,eSuccess); |
|
173 |
mBar.setProgress(100); |
|
174 |
mDescription.setText(R.string.success); |
|
187 |
RubikObjectList.addDownloadedObject(mInfo.mObjectShortName,mInfo.mNumScrambles, mInfo.mObjectMinorVersion, |
|
188 |
mInfo.mExtrasMinorVersion, mIconSaved, oSuccess, eSuccess); |
|
175 | 189 |
|
176 | 190 |
RubikNetwork network = RubikNetwork.getInstance(); |
177 | 191 |
network.updateDone(mInfo.mObjectShortName); |
192 |
|
|
193 |
RubikScreenPlay play = (RubikScreenPlay)ScreenList.PLAY.getScreenClass(); |
|
194 |
play.recreatePopup(); |
|
195 |
|
|
196 |
mBar.setProgress(100); |
|
197 |
mDescription.setText(R.string.success); |
|
178 | 198 |
} |
179 | 199 |
else |
180 | 200 |
{ |
src/main/java/org/distorted/external/RubikFiles.java | ||
---|---|---|
66 | 66 |
} |
67 | 67 |
catch(FileNotFoundException ex) |
68 | 68 |
{ |
69 |
// ignore
|
|
69 |
android.util.Log.e("D", "file "+name+" not found: "+ex.getMessage());
|
|
70 | 70 |
} |
71 | 71 |
|
72 | 72 |
return null; |
src/main/java/org/distorted/external/RubikNetwork.java | ||
---|---|---|
713 | 713 |
String url = mUpdates.getCompletedURL(c); |
714 | 714 |
icon = downloadIcon(url); |
715 | 715 |
downloaded = true; |
716 |
|
|
717 |
android.util.Log.e("D", "Downloading icon "+url); |
|
716 | 718 |
} |
717 | 719 |
if( icon!=null ) |
718 | 720 |
{ |
... | ... | |
736 | 738 |
String url = mUpdates.getStartedURL(s); |
737 | 739 |
icon = downloadIcon(url); |
738 | 740 |
downloaded = true; |
741 |
|
|
742 |
android.util.Log.e("D", "Downloading icon "+url); |
|
739 | 743 |
} |
740 | 744 |
if( icon!=null ) |
741 | 745 |
{ |
... | ... | |
754 | 758 |
|
755 | 759 |
try |
756 | 760 |
{ |
761 |
android.util.Log.e("D", "Downloading JSON "+url); |
|
762 |
|
|
757 | 763 |
java.net.URL connectURL = new URL(url); |
758 | 764 |
HttpURLConnection conn = (HttpURLConnection) connectURL.openConnection(); |
759 | 765 |
conn.setDoInput(true); |
src/main/java/org/distorted/external/RubikScores.java | ||
---|---|---|
168 | 168 |
|
169 | 169 |
if( object!=null ) |
170 | 170 |
{ |
171 |
builderObj.append(object.getName()); |
|
171 |
builderObj.append(object.getUpperName());
|
|
172 | 172 |
builderLvl.append(key%MULT); |
173 | 173 |
builderTim.append(value.record); |
174 | 174 |
} |
... | ... | |
346 | 346 |
|
347 | 347 |
if( obj!=null && value!=null && value.record<NO_RECORD ) |
348 | 348 |
{ |
349 |
builder.append(obj.getName()); |
|
349 |
builder.append(obj.getUpperName());
|
|
350 | 350 |
builder.append("="); |
351 | 351 |
builder.append(value.record); |
352 | 352 |
builder.append(","); |
src/main/java/org/distorted/external/RubikUpdates.java | ||
---|---|---|
41 | 41 |
public final int mIconPresent; |
42 | 42 |
public final boolean mUpdateObject; |
43 | 43 |
public final boolean mUpdateExtras; |
44 |
|
|
45 |
public int mNumScrambles; |
|
44 | 46 |
public Bitmap mIcon; |
45 | 47 |
public InputStream mObjectStream; |
46 | 48 |
public InputStream mExtrasStream; |
... | ... | |
59 | 61 |
mUpdateExtras = updateE; |
60 | 62 |
|
61 | 63 |
mIcon = null; |
64 |
mNumScrambles = 0; |
|
62 | 65 |
} |
63 | 66 |
} |
64 | 67 |
|
... | ... | |
115 | 118 |
int objOrdinal = RubikObjectList.getOrdinal(shortName.toUpperCase()); |
116 | 119 |
boolean updateO=true, updateE=true; |
117 | 120 |
|
121 |
android.util.Log.e("D", "downloaded object "+shortName+" oMinor="+oMinor+" eMinor="+eMinor); |
|
122 |
|
|
118 | 123 |
if( objOrdinal>=0 ) |
119 | 124 |
{ |
120 | 125 |
int localObjectMinor = RubikObjectList.getLocalObjectMinor(objOrdinal); |
121 | 126 |
int localExtrasMinor = RubikObjectList.getLocalExtrasMinor(objOrdinal); |
122 | 127 |
updateO = localObjectMinor<oMinor; |
123 | 128 |
updateE = localExtrasMinor<eMinor; |
129 |
|
|
130 |
|
|
131 |
android.util.Log.e("D", "object exists locally, localObjectMinor="+localObjectMinor+" localExtrasMinor="+localExtrasMinor); |
|
132 |
|
|
124 | 133 |
} |
125 | 134 |
if( updateO || updateE ) |
126 | 135 |
{ |
127 | 136 |
UpdateInfo info = new UpdateInfo(shortName,longName,description,oMinor,eMinor,oPercent,oIcon,updateO,updateE); |
128 |
if(oPercent>=100) mCompleted.add(info); |
|
129 |
else mStarted.add(info); |
|
137 |
if(oPercent>=100) |
|
138 |
{ |
|
139 |
android.util.Log.e("D", "object added to completed"); |
|
140 |
|
|
141 |
mCompleted.add(info); |
|
142 |
} |
|
143 |
else |
|
144 |
{ |
|
145 |
android.util.Log.e("D", "object added to started"); |
|
146 |
|
|
147 |
mStarted.add(info); |
|
148 |
} |
|
130 | 149 |
} |
131 | 150 |
} |
132 | 151 |
} |
src/main/java/org/distorted/main/RubikActivity.java | ||
---|---|---|
459 | 459 |
if( reportChange && oldObject!=null ) |
460 | 460 |
{ |
461 | 461 |
RubikObject robject = RubikObjectList.getObject(newObject); |
462 |
String newName = robject==null ? "NULL" : robject.getName(); |
|
462 |
String newName = robject==null ? "NULL" : robject.getUpperName();
|
|
463 | 463 |
float fps = view.getRenderer().getFPS(); |
464 | 464 |
fps = (int)(fps+0.5f); |
465 | 465 |
StringBuilder name = new StringBuilder(); |
src/main/java/org/distorted/main/RubikObjectLibInterface.java | ||
---|---|---|
105 | 105 |
int level = play.getLevel(); |
106 | 106 |
String name = scores.getName(); |
107 | 107 |
RubikObject obj = RubikObjectList.getObject(object); |
108 |
String objName = obj==null ? "NULL" : obj.getName(); |
|
108 |
String objName = obj==null ? "NULL" : obj.getUpperName();
|
|
109 | 109 |
|
110 | 110 |
String record = objName+" level "+level+" time "+mNewRecord+" isNew: "+mIsNewRecord+" scrambleNum: "+scrambleNum; |
111 | 111 |
|
src/main/java/org/distorted/objects/RubikObject.java | ||
---|---|---|
23 | 23 |
|
24 | 24 |
import android.app.Activity; |
25 | 25 |
import android.content.res.Resources; |
26 |
import android.graphics.Bitmap; |
|
27 |
import android.graphics.drawable.BitmapDrawable; |
|
26 | 28 |
import android.graphics.drawable.Drawable; |
27 | 29 |
import android.widget.ImageButton; |
28 | 30 |
import android.widget.ImageView; |
29 | 31 |
|
30 | 32 |
import org.distorted.dmesh.ObjectMesh; |
33 |
import org.distorted.external.RubikFiles; |
|
31 | 34 |
import org.distorted.jsons.ObjectJson; |
32 | 35 |
import org.distorted.objectlib.json.JsonWriter; |
33 | 36 |
import org.distorted.objectlib.main.ObjectType; |
... | ... | |
39 | 42 |
|
40 | 43 |
public class RubikObject |
41 | 44 |
{ |
42 |
private final String mName; |
|
43 |
private final int mNumScramble; |
|
44 |
private final int mJsonID, mMeshID, mExtrasID; |
|
45 |
private final String mLowerName, mUpperName; |
|
45 | 46 |
private final int mIconID; |
46 | 47 |
private final String[][] mPatterns; |
47 |
private final int mObjectMinor, mExtrasMinor; |
|
48 | 48 |
|
49 |
private int mJsonID, mMeshID, mExtrasID; |
|
50 |
private int mObjectMinor, mExtrasMinor; |
|
51 |
private int mNumScramble; |
|
49 | 52 |
private int mMeshState; |
50 | 53 |
private int mExtrasOrdinal; |
51 | 54 |
private Drawable mIconD; |
... | ... | |
56 | 59 |
{ |
57 | 60 |
int ordinal= type.ordinal(); |
58 | 61 |
|
59 |
mName = type.name(); |
|
62 |
mUpperName = type.name(); |
|
63 |
mLowerName = type.name().toLowerCase(); |
|
60 | 64 |
mNumScramble = type.getNumScramble(); |
61 | 65 |
|
62 | 66 |
mIconID = type.getIconID(); |
... | ... | |
75 | 79 |
|
76 | 80 |
mIconD = null; |
77 | 81 |
} |
78 |
/* |
|
82 |
|
|
79 | 83 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
80 | 84 |
|
81 | 85 |
RubikObject(RubikObjectList.DownloadedObject object) |
82 | 86 |
{ |
83 |
mName = object.shortName; |
|
84 |
mMeshID = 0; |
|
87 |
android.util.Log.e("D", "new downloaded RubikObject "+object.shortName+" added"); |
|
88 |
|
|
89 |
|
|
90 |
mLowerName = object.shortName; |
|
91 |
mUpperName = object.shortName.toUpperCase(); |
|
92 |
mNumScramble = object.numScrambles; |
|
93 |
mObjectMinor = object.objectMinor; |
|
94 |
mExtrasMinor = object.extrasMinor; |
|
95 |
|
|
85 | 96 |
mPatterns = null; |
86 | 97 |
mMeshState = MESH_NICE; |
87 | 98 |
mExtrasOrdinal = -1; |
88 | 99 |
|
89 |
|
|
90 |
|
|
91 |
mNumScramble = type.getNumScramble(); |
|
92 |
mObjectMinor = ? |
|
93 |
mExtrasMinor = ? |
|
94 |
mIconID = type.getIconID(); |
|
95 |
mJsonID = ObjectJson.getObjectJsonID(mOrdinal); |
|
96 |
mExtrasID = ObjectJson.getExtrasJsonID(mOrdinal); |
|
100 |
mMeshID = 0; |
|
101 |
mIconID = -1; |
|
102 |
mJsonID = -1; |
|
103 |
mExtrasID = -1; |
|
97 | 104 |
} |
98 | 105 |
|
99 | 106 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
100 | 107 |
|
101 |
public void updateObject(RubikObjectList.DownloadedObject object)
|
|
108 |
public boolean updateObject(RubikObjectList.DownloadedObject object)
|
|
102 | 109 |
{ |
110 |
boolean changed = false; |
|
103 | 111 |
|
112 |
if( object.objectMinor>JsonWriter.VERSION_OBJECT_MINOR ) |
|
113 |
{ |
|
114 |
android.util.Log.e("D", "Updating RubikObject's "+object.shortName+" main JSON"); |
|
115 |
|
|
116 |
mObjectMinor = object.objectMinor; |
|
117 |
mNumScramble = object.numScrambles; |
|
118 |
mMeshID = 0; |
|
119 |
mJsonID = -1; |
|
120 |
changed = true; |
|
121 |
} |
|
122 |
|
|
123 |
if( object.extrasMinor>JsonWriter.VERSION_EXTRAS_MINOR ) |
|
124 |
{ |
|
125 |
android.util.Log.e("D", "Updating RubikObject's "+object.shortName+" extras JSON"); |
|
126 |
|
|
127 |
mExtrasMinor = object.extrasMinor; |
|
128 |
mExtrasID = -1; |
|
129 |
changed = true; |
|
130 |
} |
|
131 |
|
|
132 |
return changed; |
|
104 | 133 |
} |
105 |
*/ |
|
134 |
|
|
106 | 135 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
107 | 136 |
|
108 | 137 |
private void createIconDrawable(Activity act) |
109 | 138 |
{ |
110 |
mIconD = act.getDrawable(mIconID); |
|
139 |
if( mIconID>0 ) |
|
140 |
{ |
|
141 |
mIconD = act.getDrawable(mIconID); |
|
142 |
} |
|
143 |
else |
|
144 |
{ |
|
145 |
RubikFiles files = RubikFiles.getInstance(); |
|
146 |
Bitmap bmp = files.getIcon(act,mLowerName+".png"); |
|
147 |
mIconD = new BitmapDrawable(act.getResources(), bmp); |
|
148 |
} |
|
111 | 149 |
} |
112 | 150 |
|
113 | 151 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
141 | 179 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
142 | 180 |
// PUBLIC API |
143 | 181 |
|
144 |
public String getName() |
|
182 |
public String getLowerName() |
|
183 |
{ |
|
184 |
return mLowerName; |
|
185 |
} |
|
186 |
|
|
187 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
188 |
|
|
189 |
public String getUpperName() |
|
145 | 190 |
{ |
146 |
return mName; |
|
191 |
return mUpperName;
|
|
147 | 192 |
} |
148 | 193 |
|
149 | 194 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
187 | 232 |
|
188 | 233 |
public InputStream getObjectStream(Activity act) |
189 | 234 |
{ |
190 |
if( mJsonID!=0 )
|
|
235 |
if( mJsonID>0 )
|
|
191 | 236 |
{ |
192 | 237 |
Resources res = act.getResources(); |
193 | 238 |
return res.openRawResource(mJsonID); |
194 | 239 |
} |
240 |
if( mJsonID<0 ) |
|
241 |
{ |
|
242 |
RubikFiles files = RubikFiles.getInstance(); |
|
243 |
return files.openFile(act,mLowerName+"_object.json"); |
|
244 |
} |
|
245 |
|
|
195 | 246 |
return null; |
196 | 247 |
} |
197 | 248 |
|
... | ... | |
199 | 250 |
|
200 | 251 |
public InputStream getMeshStream(Activity act) |
201 | 252 |
{ |
202 |
if( mMeshID!=0 )
|
|
253 |
if( mMeshID>0 )
|
|
203 | 254 |
{ |
204 | 255 |
Resources res = act.getResources(); |
205 | 256 |
return res.openRawResource(mMeshID); |
206 | 257 |
} |
258 |
|
|
207 | 259 |
return null; |
208 | 260 |
} |
209 | 261 |
|
... | ... | |
211 | 263 |
|
212 | 264 |
public InputStream getExtrasStream(Activity act) |
213 | 265 |
{ |
214 |
if( mExtrasID!=0 )
|
|
266 |
if( mExtrasID>0 )
|
|
215 | 267 |
{ |
216 | 268 |
Resources res = act.getResources(); |
217 | 269 |
return res.openRawResource(mExtrasID); |
218 | 270 |
} |
271 |
if( mExtrasID<0 ) |
|
272 |
{ |
|
273 |
RubikFiles files = RubikFiles.getInstance(); |
|
274 |
return files.openFile(act,mLowerName+"_extras.json"); |
|
275 |
} |
|
276 |
|
|
219 | 277 |
return null; |
220 | 278 |
} |
221 | 279 |
|
src/main/java/org/distorted/objects/RubikObjectList.java | ||
---|---|---|
49 | 49 |
{ |
50 | 50 |
String shortName; |
51 | 51 |
boolean icon,object,extras; |
52 |
int numScrambles, objectMinor, extrasMinor; |
|
52 | 53 |
|
53 |
DownloadedObject(String sName, boolean i, boolean o, boolean e) |
|
54 |
DownloadedObject(String sName, int scrambles, int oMinor, int eMinor, boolean i, boolean o, boolean e)
|
|
54 | 55 |
{ |
55 | 56 |
shortName = sName; |
57 |
|
|
58 |
numScrambles= scrambles; |
|
59 |
objectMinor = oMinor; |
|
60 |
extrasMinor = eMinor; |
|
61 |
|
|
56 | 62 |
icon = i; |
57 | 63 |
object = o; |
58 | 64 |
extras = e; |
... | ... | |
98 | 104 |
mObjects.add(obj); |
99 | 105 |
mNumObjects++; |
100 | 106 |
|
107 |
android.util.Log.e("D", "creating local object "+type.name() ); |
|
108 |
|
|
101 | 109 |
if( obj.hasExtras() ) |
102 | 110 |
{ |
111 |
android.util.Log.e("D", "has extras "+mNumExtras ); |
|
112 |
|
|
113 |
|
|
103 | 114 |
obj.setExtrasOrdinal(mNumExtras); |
104 | 115 |
mNumExtras++; |
116 |
} |
|
117 |
else |
|
118 |
{ |
|
119 |
android.util.Log.e("D", "no extras"); |
|
120 |
|
|
105 | 121 |
} |
106 | 122 |
} |
107 | 123 |
} |
108 | 124 |
|
109 | 125 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
110 | 126 |
|
111 |
private static void internalAddDownloadedObject(DownloadedObject object)
|
|
127 |
private static boolean internalAddDownloadedObject(DownloadedObject object)
|
|
112 | 128 |
{ |
113 |
/* |
|
114 |
boolean existsAlready = false; |
|
115 | 129 |
String name = object.shortName; |
116 | 130 |
|
117 | 131 |
for(RubikObject ro : mObjects ) |
118 |
if( ro.getName().equals(name) ) |
|
132 |
if( ro.getLowerName().equals(name) )
|
|
119 | 133 |
{ |
120 |
ro.updateObject(object); |
|
121 |
existsAlready = true; |
|
122 |
break; |
|
134 |
return ro.updateObject(object); |
|
123 | 135 |
} |
124 | 136 |
|
125 |
if( !existsAlready ) |
|
137 |
RubikObject obj = new RubikObject(object); |
|
138 |
mObjects.add(obj); |
|
139 |
mNumObjects++; |
|
140 |
|
|
141 |
|
|
142 |
android.util.Log.e("D", "creating downloaded object "+obj.getUpperName() ); |
|
143 |
|
|
144 |
if( obj.hasExtras() ) |
|
126 | 145 |
{ |
127 |
RubikObject obj = new RubikObject(object); |
|
128 |
mObjects.add(obj); |
|
129 |
mNumObjects++; |
|
146 |
android.util.Log.e("D", "has extras "+mNumExtras ); |
|
130 | 147 |
|
131 |
if( obj.getExtrasJsonID()!=0 ) |
|
132 |
{ |
|
133 |
obj.setExtrasOrdinal(mNumExtras); |
|
134 |
mNumExtras++; |
|
135 |
} |
|
148 |
obj.setExtrasOrdinal(mNumExtras); |
|
149 |
mNumExtras++; |
|
150 |
} |
|
151 |
else |
|
152 |
{ |
|
153 |
android.util.Log.e("D", "no extras"); |
|
136 | 154 |
} |
137 |
*/ |
|
155 |
|
|
156 |
return true; |
|
138 | 157 |
} |
139 | 158 |
|
140 | 159 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
167 | 186 |
|
168 | 187 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
169 | 188 |
|
170 |
public static void addDownloadedObject(String shortName, boolean icon, boolean object, boolean extras) |
|
189 |
public static void addDownloadedObject(String shortName, int numScrambles, int objectMinor, int extrasMinor, |
|
190 |
boolean icon, boolean object, boolean extras) |
|
171 | 191 |
{ |
172 | 192 |
for( DownloadedObject obj : mDownloadedObjects ) |
173 | 193 |
{ |
... | ... | |
177 | 197 |
obj.object|= object; |
178 | 198 |
obj.extras|= extras; |
179 | 199 |
|
180 |
android.util.Log.e("D", "UPDATING "+shortName);
|
|
200 |
android.util.Log.e("D", "Updating downloaded object "+shortName);
|
|
181 | 201 |
|
182 | 202 |
return; |
183 | 203 |
} |
184 | 204 |
} |
185 | 205 |
|
186 |
DownloadedObject extra = new DownloadedObject(shortName,icon,object,extras); |
|
187 |
mDownloadedObjects.add(extra); |
|
188 |
|
|
189 |
internalAddDownloadedObject(extra); |
|
206 |
DownloadedObject extra = new DownloadedObject(shortName,numScrambles,objectMinor,extrasMinor,icon,object,extras); |
|
207 |
if ( internalAddDownloadedObject(extra) ) |
|
208 |
{ |
|
209 |
android.util.Log.e("D", "Adding new downloaded object "+shortName); |
|
210 |
mDownloadedObjects.add(extra); |
|
211 |
} |
|
190 | 212 |
} |
191 | 213 |
|
192 | 214 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
208 | 230 |
public static void savePreferences(SharedPreferences.Editor editor) |
209 | 231 |
{ |
210 | 232 |
RubikObject obj = getObject(mObject); |
211 |
if( obj!=null ) editor.putString("rol_objName", obj.getName() ); |
|
233 |
if( obj!=null ) editor.putString("rol_objName", obj.getUpperName() );
|
|
212 | 234 |
|
213 | 235 |
int numDownloaded = mDownloadedObjects.size(); |
214 | 236 |
|
... | ... | |
223 | 245 |
DownloadedObject object = mDownloadedObjects.get(i); |
224 | 246 |
downloadedObjects.append(object.shortName); |
225 | 247 |
downloadedObjects.append(' '); |
248 |
downloadedObjects.append(object.numScrambles); |
|
249 |
downloadedObjects.append(' '); |
|
250 |
downloadedObjects.append(object.objectMinor); |
|
251 |
downloadedObjects.append(' '); |
|
252 |
downloadedObjects.append(object.extrasMinor); |
|
253 |
downloadedObjects.append(' '); |
|
226 | 254 |
downloadedObjects.append(object.icon ? "1":"0"); |
227 | 255 |
downloadedObjects.append(' '); |
228 | 256 |
downloadedObjects.append(object.object ? "1":"0"); |
... | ... | |
230 | 258 |
downloadedObjects.append(object.extras ? "1":"0"); |
231 | 259 |
} |
232 | 260 |
|
233 |
editor.putString("rol_downloaded", downloadedObjects.toString() ); |
|
261 |
String objects = downloadedObjects.toString(); |
|
262 |
android.util.Log.e("D", "saving: "+objects); |
|
263 |
|
|
264 |
editor.putString("rol_downloaded", objects ); |
|
234 | 265 |
} |
235 | 266 |
} |
236 | 267 |
|
... | ... | |
244 | 275 |
|
245 | 276 |
if( obj!=null ) |
246 | 277 |
{ |
247 |
String name = obj.getName(); |
|
278 |
String name = obj.getUpperName();
|
|
248 | 279 |
editor.putInt("rol_"+name, obj.getMeshState() ); |
249 | 280 |
} |
250 | 281 |
} |
... | ... | |
255 | 286 |
public static void restorePreferences(SharedPreferences preferences) |
256 | 287 |
{ |
257 | 288 |
RubikObject object = getObject(DEF_OBJECT); |
258 |
String defName = object==null ? "CUBE_3" : object.getName(); |
|
289 |
String defName = object==null ? "CUBE_3" : object.getUpperName();
|
|
259 | 290 |
String objName= preferences.getString("rol_objName",defName); |
260 | 291 |
mObject = getOrdinal(objName); |
261 | 292 |
|
... | ... | |
273 | 304 |
{ |
274 | 305 |
String[] parts = dObj.split(" "); |
275 | 306 |
|
276 |
if( parts.length==4 )
|
|
307 |
if( parts.length==7 )
|
|
277 | 308 |
{ |
278 | 309 |
String name = parts[0]; |
279 |
String icon = parts[1]; |
|
280 |
String obje = parts[2]; |
|
281 |
String extr = parts[3]; |
|
310 |
String scra = parts[1]; |
|
311 |
String objM = parts[2]; |
|
312 |
String extM = parts[3]; |
|
313 |
String icon = parts[4]; |
|
314 |
String obje = parts[5]; |
|
315 |
String extr = parts[6]; |
|
316 |
|
|
317 |
int scrambles = Integer.parseInt(scra); |
|
318 |
int oMinor = Integer.parseInt(objM); |
|
319 |
int eMinor = Integer.parseInt(extM); |
|
282 | 320 |
|
283 | 321 |
boolean bIcon = icon.equals("1"); |
284 | 322 |
boolean bObje = obje.equals("1"); |
285 | 323 |
boolean bExtr = extr.equals("1"); |
286 | 324 |
|
287 |
android.util.Log.e("D", "adding: "+name); |
|
288 |
|
|
289 |
addDownloadedObject(name,bIcon,bObje,bExtr); |
|
325 |
addDownloadedObject(name,scrambles,oMinor,eMinor,bIcon,bObje,bExtr); |
|
290 | 326 |
} |
291 | 327 |
} |
292 | 328 |
} |
... | ... | |
302 | 338 |
|
303 | 339 |
if( obj!=null ) |
304 | 340 |
{ |
305 |
String name = obj.getName(); |
|
341 |
String name = obj.getUpperName();
|
|
306 | 342 |
int meshState= preferences.getInt("rol_"+name,MESH_NICE); |
307 | 343 |
obj.setMeshState(meshState); |
308 | 344 |
} |
... | ... | |
353 | 389 |
{ |
354 | 390 |
if( mThis==null ) mThis = new RubikObjectList(); |
355 | 391 |
|
392 |
String lowerName = name.toLowerCase(); |
|
393 |
|
|
356 | 394 |
for(int i=0; i<mNumObjects; i++) |
357 | 395 |
{ |
358 | 396 |
RubikObject obj = mObjects.get(i); |
359 |
|
|
360 |
if( obj.getName().equals(name) ) return i; |
|
397 |
if( obj.getLowerName().equals(lowerName) ) return i; |
|
361 | 398 |
} |
362 | 399 |
|
363 | 400 |
return -1; |
src/main/java/org/distorted/screens/RubikScreenPlay.java | ||
---|---|---|
698 | 698 |
return mLevelValue; |
699 | 699 |
} |
700 | 700 |
|
701 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
702 |
|
|
703 |
public void recreatePopup() |
|
704 |
{ |
|
705 |
mObjectPopup = null; |
|
706 |
} |
|
707 |
|
|
701 | 708 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
702 | 709 |
|
703 | 710 |
public boolean shouldReactToEndOfScrambling() |
Also available in: Unified diff
Downloaded Objects more or less work now.