From 7ca293bcc511de75c1716ff10b9ec60c4ea7fd0f Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Thu, 9 May 2019 18:45:47 -0400 Subject: [PATCH] v0.7.3: adjusted window saving to block restoring to a different scene type --- .../shatteredpixeldungeon/scenes/PixelScene.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/PixelScene.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/PixelScene.java index ad8da616c..20b0bdcf0 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/PixelScene.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/PixelScene.java @@ -136,9 +136,11 @@ public class PixelScene extends Scene { //FIXME this system currently only works for a subset of windows private static ArrayList> savedWindows = new ArrayList<>(); + private static Class savedClass = null; public void saveWindows(){ savedWindows.clear(); + savedClass = getClass(); for (Gizmo g : members){ if (g instanceof Window){ savedWindows.add((Class) g.getClass()); @@ -147,7 +149,7 @@ public class PixelScene extends Scene { } public void restoreWindows(){ - if (!savedWindows.isEmpty()){ + if (getClass().equals(savedClass)){ for (Class w : savedWindows){ try{ add(w.newInstance()); @@ -155,8 +157,8 @@ public class PixelScene extends Scene { //window has no public zero-arg constructor, just eat the exception } } - savedWindows.clear(); } + savedWindows.clear(); } @Override