Revision ff4a2a13
Added by Leszek Koltunski almost 2 years ago
| src/main/java/org/distorted/bandaged/BandagedRenderer.java | ||
|---|---|---|
| 304 | 304 |
try |
| 305 | 305 |
{
|
| 306 | 306 |
JsonWriter writer = JsonWriter.getInstance(); |
| 307 |
String json = writer.createObjectString(object,24,0);
|
|
| 307 |
String json = writer.createObjectString(object); |
|
| 308 | 308 |
writer.write(filename,json); |
| 309 | 309 |
return true; |
| 310 | 310 |
} |
| src/main/java/org/distorted/config/ConfigScreenPane.java | ||
|---|---|---|
| 9 | 9 |
|
| 10 | 10 |
package org.distorted.config; |
| 11 | 11 |
|
| 12 |
import static org.distorted.objects.RubikObjectCategories.DIFF_IDS; |
|
| 13 |
import static org.distorted.objects.RubikObjectCategories.DIFF_IMAGES; |
|
| 14 |
|
|
| 12 | 15 |
import java.io.InputStream; |
| 13 | 16 |
|
| 14 | 17 |
import android.graphics.PorterDuff; |
| ... | ... | |
| 26 | 29 |
|
| 27 | 30 |
public class ConfigScreenPane |
| 28 | 31 |
{
|
| 29 |
private static final int[] IDS = |
|
| 30 |
{
|
|
| 31 |
R.id.configDifficulty0, |
|
| 32 |
R.id.configDifficulty1, |
|
| 33 |
R.id.configDifficulty2, |
|
| 34 |
R.id.configDifficulty3, |
|
| 35 |
R.id.configDifficulty4 |
|
| 36 |
}; |
|
| 37 |
|
|
| 38 |
private static final int[] IMAGES = |
|
| 39 |
{
|
|
| 40 |
R.drawable.difficulty1, |
|
| 41 |
R.drawable.difficulty2, |
|
| 42 |
R.drawable.difficulty3, |
|
| 43 |
R.drawable.difficulty4, |
|
| 44 |
R.drawable.difficulty5, |
|
| 45 |
}; |
|
| 46 |
|
|
| 47 |
private static final int NUM_IDS = IDS.length; |
|
| 32 |
private static final int NUM_IDS = DIFF_IDS.length; |
|
| 48 | 33 |
private static final float PADDING_RATIO = 0.016f; |
| 49 | 34 |
private static final float TEXT_RATIO = 0.025f; |
| 50 | 35 |
|
| ... | ... | |
| 66 | 51 |
{
|
| 67 | 52 |
reader.parseJsonFileMetadata(stream); |
| 68 | 53 |
name = reader.getObjectName(); |
| 69 |
author = reader.getInventor();
|
|
| 54 |
author = reader.getAuthor();
|
|
| 70 | 55 |
year = reader.getYearOfInvention(); |
| 71 |
difficulty = (int)reader.getComplexity();
|
|
| 56 |
difficulty = (int)reader.getDifficulty();
|
|
| 72 | 57 |
} |
| 73 | 58 |
catch(Exception ex) |
| 74 | 59 |
{
|
| ... | ... | |
| 91 | 76 |
|
| 92 | 77 |
for(int i=0; i<NUM_IDS; i++) |
| 93 | 78 |
{
|
| 94 |
ImageView image = layout.findViewById(IDS[i]); |
|
| 95 |
image.setImageResource(IMAGES[i]); |
|
| 79 |
ImageView image = layout.findViewById(DIFF_IDS[i]);
|
|
| 80 |
image.setImageResource(DIFF_IMAGES[i]);
|
|
| 96 | 81 |
image.setColorFilter( difficulty==i ? 0xffff0000 : 0xffffffff, PorterDuff.Mode.MULTIPLY ); |
| 97 | 82 |
} |
| 98 | 83 |
} |
| src/main/java/org/distorted/dialogs/RubikDialogUpdateView.java | ||
|---|---|---|
| 197 | 197 |
File file = new File(act.getFilesDir(), objectName); |
| 198 | 198 |
InputStream stream = new FileInputStream(file); |
| 199 | 199 |
JsonReader reader = new JsonReader(); |
| 200 |
reader.readNumScramblesAndPrice(stream);
|
|
| 200 |
reader.parseJsonFileMetadata(stream);
|
|
| 201 | 201 |
stream.close(); |
| 202 | 202 |
|
| 203 | 203 |
mInfo.mNumScrambles = reader.getNumScrambles(); |
| 204 | 204 |
mInfo.mPrice = reader.getPrice(); |
| 205 |
float diff = reader.getDifficulty(); |
|
| 206 |
int category = reader.getCategory(); |
|
| 207 |
int year = reader.getYearOfInvention(); |
|
| 208 |
String author = reader.getAuthor(); |
|
| 209 |
|
|
| 205 | 210 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "Read from JSON numScrambles="+mInfo.mNumScrambles+" price="+mInfo.mPrice);
|
| 206 | 211 |
|
| 207 | 212 |
if( mInfo.mExtrasStream!=null ) |
| ... | ... | |
| 218 | 223 |
|
| 219 | 224 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "1");
|
| 220 | 225 |
|
| 221 |
boolean success = RubikObjectList.addDownloadedObject(act, mInfo.mObjectShortName, mInfo.mNumScrambles, mInfo.mPrice, |
|
| 222 |
mInfo.mObjectMinorVersion, mInfo.mExtrasMinorVersion, mIconSaved, oSuccess, eSuccess);
|
|
| 226 |
boolean success = RubikObjectList.addDownloadedObject(act, mInfo.mObjectShortName, mInfo.mNumScrambles, mInfo.mPrice, mInfo.mObjectMinorVersion,
|
|
| 227 |
mInfo.mExtrasMinorVersion, mIconSaved, oSuccess, eSuccess, diff, category, year, author);
|
|
| 223 | 228 |
if( success ) |
| 224 | 229 |
{
|
| 225 | 230 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "2");
|
| src/main/java/org/distorted/helpers/ObjectGridCreator.java | ||
|---|---|---|
| 235 | 235 |
} |
| 236 | 236 |
|
| 237 | 237 |
LayoutInflater layoutInflater = (LayoutInflater)act.getSystemService(Context.LAYOUT_INFLATER_SERVICE); |
| 238 |
int obj = 0; |
|
| 238 | 239 |
|
| 239 | 240 |
for(int object : objects) |
| 240 | 241 |
{
|
| 241 | 242 |
View v = createView(act,layoutInflater,object,mPadding ); |
| 242 |
int row = object/colCount; |
|
| 243 |
int row = obj/colCount; |
|
| 244 |
obj++; |
|
| 245 |
GridLayout.Spec rs = rowSpecs[row]; |
|
| 246 |
GridLayout.Spec cs = colSpecs[nextInRow[row]]; |
|
| 243 | 247 |
|
| 244 |
GridLayout.LayoutParams params = new GridLayout.LayoutParams(rowSpecs[row],colSpecs[nextInRow[row]]);
|
|
| 248 |
GridLayout.LayoutParams params = new GridLayout.LayoutParams(rs,cs);
|
|
| 245 | 249 |
params.bottomMargin = mMargin; |
| 246 | 250 |
params.topMargin = mMargin; |
| 247 | 251 |
params.leftMargin = mMargin; |
| src/main/java/org/distorted/objects/RubikObject.java | ||
|---|---|---|
| 42 | 42 |
private final int mSolverOrdinal; |
| 43 | 43 |
private final int mObjectOrdinal; |
| 44 | 44 |
private final boolean mIsLocal; |
| 45 |
private final int mCategory, mYear; |
|
| 46 |
private final float mDifficulty; |
|
| 47 |
private final String mAuthor; |
|
| 45 | 48 |
|
| 46 | 49 |
private boolean mIsFree; |
| 47 | 50 |
private int mJsonID, mMeshID, mExtrasID; |
| ... | ... | |
| 65 | 68 |
mJsonID = meta.objectJson(); |
| 66 | 69 |
mMeshID = meta.mesh(); |
| 67 | 70 |
mExtrasID = meta.extrasJson(); |
| 71 |
mDifficulty = meta.getDifficulty(); |
|
| 72 |
mCategory = meta.getCategory(); |
|
| 73 |
mYear = meta.getYearOfInvention(); |
|
| 74 |
mAuthor = meta.getAuthor(); |
|
| 68 | 75 |
mIsLocal = false; |
| 69 | 76 |
|
| 70 | 77 |
int patternOrdinal = RubikPatternList.getOrdinal(mObjectOrdinal); |
| ... | ... | |
| 90 | 97 |
mIsFree = mPrice==0; |
| 91 | 98 |
mObjectVersion = object.objectVersion; |
| 92 | 99 |
mExtrasVersion = object.extrasVersion; |
| 100 |
mDifficulty = object.difficulty; |
|
| 101 |
mCategory = object.category; |
|
| 102 |
mYear = object.year; |
|
| 103 |
mAuthor = object.author; |
|
| 93 | 104 |
|
| 94 | 105 |
mPatterns = null; |
| 95 | 106 |
mExtrasOrdinal = -1; |
| ... | ... | |
| 285 | 296 |
return null; |
| 286 | 297 |
} |
| 287 | 298 |
|
| 299 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 300 |
|
|
| 301 |
public int getCategory() |
|
| 302 |
{
|
|
| 303 |
return mCategory; |
|
| 304 |
} |
|
| 305 |
|
|
| 306 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 307 |
|
|
| 308 |
public float getDifficulty() |
|
| 309 |
{
|
|
| 310 |
return mDifficulty; |
|
| 311 |
} |
|
| 312 |
|
|
| 313 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 314 |
|
|
| 315 |
public int getYearOfInvention() |
|
| 316 |
{
|
|
| 317 |
return mYear; |
|
| 318 |
} |
|
| 319 |
|
|
| 320 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 321 |
|
|
| 322 |
public String getAuthor() |
|
| 323 |
{
|
|
| 324 |
return mAuthor; |
|
| 325 |
} |
|
| 326 |
|
|
| 288 | 327 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 289 | 328 |
|
| 290 | 329 |
public boolean hasExtras() |
| src/main/java/org/distorted/objects/RubikObjectCategories.java | ||
|---|---|---|
| 11 | 11 |
|
| 12 | 12 |
import static org.distorted.main.MainSettingsPopup.*; |
| 13 | 13 |
|
| 14 |
import org.distorted.main.R; |
|
| 15 |
|
|
| 16 |
import java.util.Arrays; |
|
| 17 |
|
|
| 14 | 18 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 15 | 19 |
|
| 16 | 20 |
public class RubikObjectCategories |
| 17 | 21 |
{
|
| 22 |
public static final int[] DIFF_IDS = |
|
| 23 |
{
|
|
| 24 |
R.id.configDifficulty0, |
|
| 25 |
R.id.configDifficulty1, |
|
| 26 |
R.id.configDifficulty2, |
|
| 27 |
R.id.configDifficulty3, |
|
| 28 |
R.id.configDifficulty4 |
|
| 29 |
}; |
|
| 30 |
|
|
| 31 |
public static final int[] DIFF_IMAGES = |
|
| 32 |
{
|
|
| 33 |
R.drawable.difficulty1, |
|
| 34 |
R.drawable.difficulty2, |
|
| 35 |
R.drawable.difficulty3, |
|
| 36 |
R.drawable.difficulty4, |
|
| 37 |
R.drawable.difficulty5, |
|
| 38 |
}; |
|
| 39 |
|
|
| 40 |
public static final int[] CATEGORY_IMAGES = |
|
| 41 |
{
|
|
| 42 |
R.drawable.difficulty1, |
|
| 43 |
R.drawable.difficulty2, |
|
| 44 |
R.drawable.difficulty3, |
|
| 45 |
R.drawable.difficulty4, |
|
| 46 |
R.drawable.difficulty5, |
|
| 47 |
}; |
|
| 48 |
|
|
| 18 | 49 |
private final int mNumCategories; |
| 19 | 50 |
private int[][] mObjectIndices; |
| 20 | 51 |
private int[] mIconIDs; |
| ... | ... | |
| 43 | 74 |
} |
| 44 | 75 |
} |
| 45 | 76 |
|
| 77 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 78 |
|
|
| 79 |
private void buildSortStr(String[] data) |
|
| 80 |
{
|
|
| 81 |
int numObjects = data.length; |
|
| 82 |
String[] sorted = new String[numObjects]; |
|
| 83 |
System.arraycopy(data, 0, sorted, 0, numObjects); |
|
| 84 |
|
|
| 85 |
Arrays.sort(sorted); |
|
| 86 |
|
|
| 87 |
String[] categories = new String[numObjects]; |
|
| 88 |
int numCategories = 0; |
|
| 89 |
|
|
| 90 |
for(int o=0; o<numObjects; o++) |
|
| 91 |
if( o==0 || !sorted[o-1].equals(sorted[o]) ) |
|
| 92 |
{
|
|
| 93 |
categories[numCategories] = sorted[o]; |
|
| 94 |
numCategories++; |
|
| 95 |
} |
|
| 96 |
|
|
| 97 |
int lastChange = -1; |
|
| 98 |
int curr = 0; |
|
| 99 |
int[] numInCategory = new int[numCategories]; |
|
| 100 |
|
|
| 101 |
for(int o=0; o<numObjects; o++) |
|
| 102 |
if( o==numObjects-1 || !sorted[o].equals(sorted[o+1]) ) |
|
| 103 |
{
|
|
| 104 |
numInCategory[curr] = o-lastChange; |
|
| 105 |
curr++; |
|
| 106 |
lastChange = o; |
|
| 107 |
} |
|
| 108 |
|
|
| 109 |
mObjectIndices = new int[numCategories][]; |
|
| 110 |
|
|
| 111 |
for(int c=0; c<numCategories; c++) |
|
| 112 |
{
|
|
| 113 |
mObjectIndices[c] = new int[numInCategory[c]]; |
|
| 114 |
|
|
| 115 |
String cat = categories[c]; |
|
| 116 |
int index = 0; |
|
| 117 |
|
|
| 118 |
for(int o=0; o<numObjects; o++) |
|
| 119 |
if( data[o].equals(cat) ) mObjectIndices[c][index++] = o; |
|
| 120 |
} |
|
| 121 |
} |
|
| 122 |
|
|
| 123 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 124 |
|
|
| 125 |
private void buildSortInt(int[] data) |
|
| 126 |
{
|
|
| 127 |
int numObjects = data.length; |
|
| 128 |
int[] sorted = new int[numObjects]; |
|
| 129 |
System.arraycopy(data, 0, sorted, 0, numObjects); |
|
| 130 |
|
|
| 131 |
Arrays.sort(sorted); |
|
| 132 |
|
|
| 133 |
int[] categories = new int[numObjects]; |
|
| 134 |
int numCategories = 0; |
|
| 135 |
|
|
| 136 |
for(int o=0; o<numObjects; o++) |
|
| 137 |
if( o==0 || sorted[o-1]!=sorted[o] ) |
|
| 138 |
{
|
|
| 139 |
categories[numCategories] = sorted[o]; |
|
| 140 |
numCategories++; |
|
| 141 |
} |
|
| 142 |
|
|
| 143 |
int lastChange = -1; |
|
| 144 |
int curr = 0; |
|
| 145 |
int[] numInCategory = new int[numCategories]; |
|
| 146 |
|
|
| 147 |
for(int o=0; o<numObjects; o++) |
|
| 148 |
if( o==numObjects-1 || sorted[o]!=sorted[o+1] ) |
|
| 149 |
{
|
|
| 150 |
numInCategory[curr] = o-lastChange; |
|
| 151 |
curr++; |
|
| 152 |
lastChange = o; |
|
| 153 |
} |
|
| 154 |
|
|
| 155 |
mObjectIndices = new int[numCategories][]; |
|
| 156 |
|
|
| 157 |
for(int c=0; c<numCategories; c++) |
|
| 158 |
{
|
|
| 159 |
mObjectIndices[c] = new int[numInCategory[c]]; |
|
| 160 |
|
|
| 161 |
int cat = categories[c]; |
|
| 162 |
int index = 0; |
|
| 163 |
|
|
| 164 |
for(int o=0; o<numObjects; o++) |
|
| 165 |
if( data[o]==cat ) mObjectIndices[c][index++] = o; |
|
| 166 |
} |
|
| 167 |
} |
|
| 168 |
|
|
| 169 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 170 |
|
|
| 171 |
private void buildSortFloat(float[] data) |
|
| 172 |
{
|
|
| 173 |
int numObjects = data.length; |
|
| 174 |
float[] sorted = new float[numObjects]; |
|
| 175 |
System.arraycopy(data, 0, sorted, 0, numObjects); |
|
| 176 |
|
|
| 177 |
Arrays.sort(sorted); |
|
| 178 |
|
|
| 179 |
float[] categories = new float[numObjects]; |
|
| 180 |
int numCategories = 0; |
|
| 181 |
|
|
| 182 |
for(int o=0; o<numObjects; o++) |
|
| 183 |
if( o==0 || sorted[o-1]!=sorted[o] ) |
|
| 184 |
{
|
|
| 185 |
categories[numCategories] = sorted[o]; |
|
| 186 |
numCategories++; |
|
| 187 |
} |
|
| 188 |
|
|
| 189 |
int lastChange = -1; |
|
| 190 |
int curr = 0; |
|
| 191 |
int[] numInCategory = new int[numCategories]; |
|
| 192 |
|
|
| 193 |
for(int o=0; o<numObjects; o++) |
|
| 194 |
if( o==numObjects-1 || sorted[o]!=sorted[o+1] ) |
|
| 195 |
{
|
|
| 196 |
numInCategory[curr] = o-lastChange; |
|
| 197 |
curr++; |
|
| 198 |
lastChange = o; |
|
| 199 |
} |
|
| 200 |
|
|
| 201 |
mObjectIndices = new int[numCategories][]; |
|
| 202 |
|
|
| 203 |
for(int c=0; c<numCategories; c++) |
|
| 204 |
{
|
|
| 205 |
mObjectIndices[c] = new int[numInCategory[c]]; |
|
| 206 |
|
|
| 207 |
float cat = categories[c]; |
|
| 208 |
int index = 0; |
|
| 209 |
|
|
| 210 |
for(int o=0; o<numObjects; o++) |
|
| 211 |
if( data[o]==cat ) mObjectIndices[c][index++] = o; |
|
| 212 |
} |
|
| 213 |
} |
|
| 214 |
|
|
| 46 | 215 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 47 | 216 |
|
| 48 | 217 |
private void buildSortCategory() |
| 49 | 218 |
{
|
| 219 |
int numObjects = RubikObjectList.getNumObjects(); |
|
| 220 |
int[] cats = new int[numObjects]; |
|
| 50 | 221 |
|
| 222 |
for(int o=0; o<numObjects; o++) |
|
| 223 |
{
|
|
| 224 |
RubikObject obj = RubikObjectList.getObject(o); |
|
| 225 |
cats[o] = obj==null ? 0 : obj.getCategory(); |
|
| 226 |
} |
|
| 227 |
|
|
| 228 |
buildSortInt(cats); |
|
| 51 | 229 |
} |
| 52 | 230 |
|
| 53 | 231 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 54 | 232 |
|
| 55 | 233 |
private void buildSortDifficulty() |
| 56 | 234 |
{
|
| 235 |
int numObjects = RubikObjectList.getNumObjects(); |
|
| 236 |
float[] diffs = new float[numObjects]; |
|
| 237 |
|
|
| 238 |
for(int o=0; o<numObjects; o++) |
|
| 239 |
{
|
|
| 240 |
RubikObject obj = RubikObjectList.getObject(o); |
|
| 241 |
diffs[o] = obj==null ? 0 : obj.getDifficulty(); |
|
| 242 |
} |
|
| 57 | 243 |
|
| 244 |
buildSortFloat(diffs); |
|
| 58 | 245 |
} |
| 59 | 246 |
|
| 60 | 247 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 61 | 248 |
|
| 62 | 249 |
private void buildSortAuthor() |
| 63 | 250 |
{
|
| 251 |
int numObjects = RubikObjectList.getNumObjects(); |
|
| 252 |
String[] auths = new String[numObjects]; |
|
| 253 |
|
|
| 254 |
for(int o=0; o<numObjects; o++) |
|
| 255 |
{
|
|
| 256 |
RubikObject obj = RubikObjectList.getObject(o); |
|
| 257 |
auths[o] = obj==null ? "" : obj.getAuthor(); |
|
| 258 |
} |
|
| 64 | 259 |
|
| 260 |
buildSortStr(auths); |
|
| 65 | 261 |
} |
| 66 | 262 |
|
| 67 | 263 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 68 | 264 |
|
| 69 | 265 |
private void buildSortYear() |
| 70 | 266 |
{
|
| 267 |
int numObjects = RubikObjectList.getNumObjects(); |
|
| 268 |
int[] years = new int[numObjects]; |
|
| 71 | 269 |
|
| 270 |
for(int o=0; o<numObjects; o++) |
|
| 271 |
{
|
|
| 272 |
RubikObject obj = RubikObjectList.getObject(o); |
|
| 273 |
years[o] = obj==null ? 0 : obj.getYearOfInvention(); |
|
| 274 |
} |
|
| 275 |
|
|
| 276 |
buildSortInt(years); |
|
| 72 | 277 |
} |
| 73 | 278 |
|
| 74 | 279 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 75 | 280 |
|
| 76 | 281 |
private void buildIconsCategory() |
| 77 | 282 |
{
|
| 283 |
mIconIDs = new int[mNumCategories]; |
|
| 78 | 284 |
|
| 285 |
for(int t=0; t<mNumCategories; t++) |
|
| 286 |
{
|
|
| 287 |
int obj = mObjectIndices[t][0]; |
|
| 288 |
RubikObject object = RubikObjectList.getObject(obj); |
|
| 289 |
int category = object==null ? 0 : object.getCategory(); |
|
| 290 |
mIconIDs[t] = CATEGORY_IMAGES[category%5]; //TODO |
|
| 291 |
} |
|
| 79 | 292 |
} |
| 80 | 293 |
|
| 81 | 294 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 82 | 295 |
|
| 83 | 296 |
private void buildIconsDifficulty() |
| 84 | 297 |
{
|
| 298 |
mIconIDs = new int[mNumCategories]; |
|
| 85 | 299 |
|
| 300 |
for(int t=0; t<mNumCategories; t++) |
|
| 301 |
{
|
|
| 302 |
int obj = mObjectIndices[t][0]; |
|
| 303 |
RubikObject object = RubikObjectList.getObject(obj); |
|
| 304 |
int difficulty = object==null ? 0 : (int)object.getDifficulty(); |
|
| 305 |
mIconIDs[t] = DIFF_IMAGES[difficulty]; |
|
| 306 |
} |
|
| 86 | 307 |
} |
| 87 | 308 |
|
| 88 | 309 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 95 | 316 |
{
|
| 96 | 317 |
int obj = mObjectIndices[t][0]; |
| 97 | 318 |
RubikObject object = RubikObjectList.getObject(obj); |
| 98 |
|
|
| 319 |
mTitles[t] = object==null ? "" : object.getAuthor(); |
|
| 99 | 320 |
} |
| 100 | 321 |
} |
| 101 | 322 |
|
| ... | ... | |
| 103 | 324 |
|
| 104 | 325 |
private void buildTitleYear() |
| 105 | 326 |
{
|
| 327 |
mTitles = new String[mNumCategories]; |
|
| 106 | 328 |
|
| 329 |
for(int t=0; t<mNumCategories; t++) |
|
| 330 |
{
|
|
| 331 |
int obj = mObjectIndices[t][0]; |
|
| 332 |
RubikObject object = RubikObjectList.getObject(obj); |
|
| 333 |
int year = object==null ? 0 : object.getYearOfInvention(); |
|
| 334 |
mTitles[t] = String.valueOf(year); |
|
| 335 |
} |
|
| 107 | 336 |
} |
| 108 | 337 |
|
| 109 | 338 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/objects/RubikObjectList.java | ||
|---|---|---|
| 39 | 39 |
String shortName; |
| 40 | 40 |
boolean icon,object,extras; |
| 41 | 41 |
int numScrambles, objectVersion, extrasVersion, price; |
| 42 |
int category, year; |
|
| 43 |
float difficulty; |
|
| 44 |
String author; |
|
| 42 | 45 |
|
| 43 |
DownloadedObject(String sName, int scrambles, int pr, int oVersion, int eVersion, boolean i, boolean o, boolean e) |
|
| 46 |
DownloadedObject(String sName, int scrambles, int pr, int oVersion, int eVersion, boolean i, |
|
| 47 |
boolean o, boolean e, float diff, int cat, int y, String a) |
|
| 44 | 48 |
{
|
| 45 | 49 |
shortName = sName; |
| 46 | 50 |
numScrambles = scrambles; |
| 47 | 51 |
price = pr; |
| 48 | 52 |
objectVersion = oVersion; |
| 49 | 53 |
extrasVersion = eVersion; |
| 54 |
difficulty = diff; |
|
| 55 |
category = cat; |
|
| 56 |
year = y; |
|
| 57 |
author = a; |
|
| 50 | 58 |
|
| 51 | 59 |
icon = i; |
| 52 | 60 |
object = o; |
| ... | ... | |
| 186 | 194 |
// PUBLIC API |
| 187 | 195 |
|
| 188 | 196 |
public static boolean addDownloadedObject(Context context, String shortName, int numScrambles, int price, int objectVersion, |
| 189 |
int extrasVersion, boolean icon, boolean object, boolean extras) |
|
| 197 |
int extrasVersion, boolean icon, boolean object, boolean extras, float diff, int category, int year, String author)
|
|
| 190 | 198 |
{
|
| 191 | 199 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "New downloaded object "+shortName+" icon="+icon+" object="+object+" extras="+extras);
|
| 192 | 200 |
|
| ... | ... | |
| 213 | 221 |
if( !object ) objectVersion=-1; |
| 214 | 222 |
if( !extras ) extrasVersion=-1; |
| 215 | 223 |
|
| 216 |
DownloadedObject obj = new DownloadedObject(shortName,numScrambles,price,objectVersion,extrasVersion,icon,object,extras); |
|
| 224 |
DownloadedObject obj = new DownloadedObject(shortName,numScrambles,price,objectVersion,extrasVersion,icon,object,extras,diff,category,year,author);
|
|
| 217 | 225 |
if ( internalAddDownloadedObject(obj) ) |
| 218 | 226 |
{
|
| 219 | 227 |
if( SHOW_DOWNLOADED_DEBUG ) android.util.Log.e("D", "Adding new downloaded object "+shortName+" icon="+obj.icon+" object="+obj.object+" extras="+obj.extras);
|
| ... | ... | |
| 310 | 318 |
downloadedObjects.append(' ');
|
| 311 | 319 |
downloadedObjects.append(object.extras ? "1":"0"); |
| 312 | 320 |
downloadedObjects.append(' ');
|
| 321 |
downloadedObjects.append(object.difficulty); |
|
| 322 |
downloadedObjects.append(' ');
|
|
| 323 |
downloadedObjects.append(object.category); |
|
| 324 |
downloadedObjects.append(' ');
|
|
| 325 |
downloadedObjects.append(object.year); |
|
| 326 |
downloadedObjects.append(' ');
|
|
| 327 |
downloadedObjects.append(object.author); |
|
| 328 |
downloadedObjects.append(' ');
|
|
| 313 | 329 |
downloadedObjects.append(object.price); |
| 314 | 330 |
} |
| 315 | 331 |
|
| ... | ... | |
| 352 | 368 |
String[] parts = dObj.split(" ");
|
| 353 | 369 |
int length = parts.length; |
| 354 | 370 |
|
| 355 |
if( length==7 || length==8 )
|
|
| 371 |
if( length>=7 )
|
|
| 356 | 372 |
{
|
| 357 | 373 |
String name = parts[0]; |
| 358 | 374 |
String scra = parts[1]; |
| ... | ... | |
| 362 | 378 |
String obje = parts[5]; |
| 363 | 379 |
String extr = parts[6]; |
| 364 | 380 |
|
| 365 |
int price; |
|
| 381 |
int price=0,category=0,year=0; |
|
| 382 |
float diff=0.0f; |
|
| 383 |
String author=""; |
|
| 366 | 384 |
|
| 367 |
if( length==7 ) price=0; |
|
| 368 |
else |
|
| 385 |
if( length>=11 ) |
|
| 386 |
{
|
|
| 387 |
diff = Float.parseFloat(parts[7]); |
|
| 388 |
category = Integer.parseInt(parts[8]); |
|
| 389 |
year = Integer.parseInt(parts[9]); |
|
| 390 |
author = parts[10]; |
|
| 391 |
} |
|
| 392 |
if( length>=12 ) |
|
| 369 | 393 |
{
|
| 370 |
char c = parts[7].charAt(0);
|
|
| 394 |
char c = parts[11].charAt(0);
|
|
| 371 | 395 |
if( c=='t' ) price = 0; |
| 372 | 396 |
else if( c=='f' ) price = ListObjects.DEFAULT_PRICE_OF_OLD_OBJECTS; |
| 373 | 397 |
else price = Integer.parseInt(parts[7]); |
| ... | ... | |
| 381 | 405 |
boolean bObje = obje.equals("1");
|
| 382 | 406 |
boolean bExtr = extr.equals("1");
|
| 383 | 407 |
|
| 384 |
addDownloadedObject(context,name,scrambles,price,oVersion,eVersion,bIcon,bObje,bExtr); |
|
| 408 |
addDownloadedObject(context,name,scrambles,price,oVersion,eVersion,bIcon,bObje,bExtr,diff,category,year,author);
|
|
| 385 | 409 |
} |
| 386 | 410 |
} |
| 387 | 411 |
} |
| src/main/java/org/distorted/purchase/PurchaseScreenPane.java | ||
|---|---|---|
| 189 | 189 |
{
|
| 190 | 190 |
reader.parseJsonFileMetadata(stream); |
| 191 | 191 |
name = reader.getObjectName(); |
| 192 |
author = reader.getInventor();
|
|
| 192 |
author = reader.getAuthor();
|
|
| 193 | 193 |
year = reader.getYearOfInvention(); |
| 194 |
difficulty = (int)reader.getComplexity();
|
|
| 194 |
difficulty = (int)reader.getDifficulty();
|
|
| 195 | 195 |
} |
| 196 | 196 |
catch(Exception ex) |
| 197 | 197 |
{
|
Also available in: Unified diff
progress with new sorting methods.