From a29805311881982569955162d18d58ff46528c93 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Fri, 24 Jul 2020 22:41:36 -0400 Subject: [PATCH] v0.8.2: adjusted journal save logic, now uses class arrays --- .../journal/Catalog.java | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/journal/Catalog.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/journal/Catalog.java index 3f678c960..db97cc325 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/journal/Catalog.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/journal/Catalog.java @@ -156,7 +156,6 @@ public enum Catalog { WEAPONS.seen.put( Gloves.class, false); WEAPONS.seen.put( Dagger.class, false); WEAPONS.seen.put( MagesStaff.class, false); - //WEAPONS.seen.put( Boomerang.class, false); WEAPONS.seen.put( Shortsword.class, false); WEAPONS.seen.put( HandAxe.class, false); WEAPONS.seen.put( Spear.class, false); @@ -288,26 +287,26 @@ public enum Catalog { Badges.validateItemsIdentified(); } - private static final String CATALOGS = "catalogs"; + private static final String CATALOG_ITEMS = "catalog_items"; public static void store( Bundle bundle ){ Badges.loadGlobal(); - ArrayList seen = new ArrayList<>(); + ArrayList seen = new ArrayList<>(); //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)) { for (Catalog cat : values()) { if (!Badges.isUnlocked(catalogBadges.get(cat))) { for (Class 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 - if (bundle.contains(CATALOGS)) { - List seen = Arrays.asList(bundle.getStringArray(CATALOGS)); + //includes "catalogs" for pre-0.8.2 saves + if (bundle.contains("catalogs") || bundle.contains(CATALOG_ITEMS)) { + List seenClasses = new ArrayList<>(); + if (bundle.contains(CATALOG_ITEMS)) { + seenClasses = Arrays.asList(bundle.getClassArray(CATALOG_ITEMS)); + } + List 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 (Class item : cat.items()) { - if (seen.contains(item.getSimpleName())) { + if (seenClasses.contains(item) || seenItems.contains(item.getSimpleName())) { cat.seen.put(item, true); } }