v0.8.2: adjusted journal save logic, now uses class arrays
This commit is contained in:
parent
a3455335f4
commit
a298053118
|
@ -156,7 +156,6 @@ public enum Catalog {
|
||||||
WEAPONS.seen.put( Gloves.class, false);
|
WEAPONS.seen.put( Gloves.class, false);
|
||||||
WEAPONS.seen.put( Dagger.class, false);
|
WEAPONS.seen.put( Dagger.class, false);
|
||||||
WEAPONS.seen.put( MagesStaff.class, false);
|
WEAPONS.seen.put( MagesStaff.class, false);
|
||||||
//WEAPONS.seen.put( Boomerang.class, false);
|
|
||||||
WEAPONS.seen.put( Shortsword.class, false);
|
WEAPONS.seen.put( Shortsword.class, false);
|
||||||
WEAPONS.seen.put( HandAxe.class, false);
|
WEAPONS.seen.put( HandAxe.class, false);
|
||||||
WEAPONS.seen.put( Spear.class, false);
|
WEAPONS.seen.put( Spear.class, false);
|
||||||
|
@ -288,26 +287,26 @@ public enum Catalog {
|
||||||
Badges.validateItemsIdentified();
|
Badges.validateItemsIdentified();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String CATALOGS = "catalogs";
|
private static final String CATALOG_ITEMS = "catalog_items";
|
||||||
|
|
||||||
public static void store( Bundle bundle ){
|
public static void store( Bundle bundle ){
|
||||||
|
|
||||||
Badges.loadGlobal();
|
Badges.loadGlobal();
|
||||||
|
|
||||||
ArrayList<String> seen = new ArrayList<>();
|
ArrayList<Class> seen = new ArrayList<>();
|
||||||
|
|
||||||
//if we have identified all items of a set, we use the badge to keep track instead.
|
//if we have identified all items of a set, we use the badge to keep track instead.
|
||||||
if (!Badges.isUnlocked(Badges.Badge.ALL_ITEMS_IDENTIFIED)) {
|
if (!Badges.isUnlocked(Badges.Badge.ALL_ITEMS_IDENTIFIED)) {
|
||||||
for (Catalog cat : values()) {
|
for (Catalog cat : values()) {
|
||||||
if (!Badges.isUnlocked(catalogBadges.get(cat))) {
|
if (!Badges.isUnlocked(catalogBadges.get(cat))) {
|
||||||
for (Class<? extends Item> item : cat.items()) {
|
for (Class<? extends Item> item : cat.items()) {
|
||||||
if (cat.seen.get(item)) seen.add(item.getSimpleName());
|
if (cat.seen.get(item)) seen.add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bundle.put( CATALOGS, seen.toArray(new String[0]) );
|
bundle.put( CATALOG_ITEMS, seen.toArray(new Class[0]) );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,13 +334,21 @@ public enum Catalog {
|
||||||
}
|
}
|
||||||
|
|
||||||
//general save/load
|
//general save/load
|
||||||
if (bundle.contains(CATALOGS)) {
|
//includes "catalogs" for pre-0.8.2 saves
|
||||||
List<String> seen = Arrays.asList(bundle.getStringArray(CATALOGS));
|
if (bundle.contains("catalogs") || bundle.contains(CATALOG_ITEMS)) {
|
||||||
|
List<Class> seenClasses = new ArrayList<>();
|
||||||
|
if (bundle.contains(CATALOG_ITEMS)) {
|
||||||
|
seenClasses = Arrays.asList(bundle.getClassArray(CATALOG_ITEMS));
|
||||||
|
}
|
||||||
|
List<String> seenItems = new ArrayList<>();
|
||||||
|
if (bundle.contains("catalogs")) {
|
||||||
|
Journal.saveNeeded = true; //we want to overwrite with the newer storage format
|
||||||
|
seenItems = Arrays.asList(bundle.getStringArray("catalogs"));
|
||||||
|
}
|
||||||
|
|
||||||
//TODO should adjust this to tie into the bundling system's class array
|
|
||||||
for (Catalog cat : values()) {
|
for (Catalog cat : values()) {
|
||||||
for (Class<? extends Item> item : cat.items()) {
|
for (Class<? extends Item> item : cat.items()) {
|
||||||
if (seen.contains(item.getSimpleName())) {
|
if (seenClasses.contains(item) || seenItems.contains(item.getSimpleName())) {
|
||||||
cat.seen.put(item, true);
|
cat.seen.put(item, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user