diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java index e42f8d706..d8f5a0ed6 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java @@ -245,6 +245,19 @@ public class ShatteredPixelDungeon extends Game { switchScene( c, callback ); } + public static void seamlessResetScene(SceneChangeCallback callback) { + if (scene() instanceof PixelScene){ + ((PixelScene) scene()).saveWindows(); + switchNoFade((Class) sceneClass, callback ); + } else { + resetScene(); + } + } + + public static void seamlessResetScene(){ + seamlessResetScene(null); + } + @Override protected void switchScene() { super.switchScene(); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndLangs.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndLangs.java index 7ced6a1de..8365171bf 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndLangs.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndLangs.java @@ -69,7 +69,7 @@ public class WndLangs extends Window { protected void onClick() { super.onClick(); Messages.setup(langs.get(langIndex)); - ShatteredPixelDungeon.switchNoFade(TitleScene.class, new Game.SceneChangeCallback() { + ShatteredPixelDungeon.seamlessResetScene(new Game.SceneChangeCallback() { @Override public void beforeCreate() { SPDSettings.language(langs.get(langIndex)); @@ -77,7 +77,7 @@ public class WndLangs extends Window { } @Override public void afterCreate() { - Game.scene().add(new WndLangs()); + //do nothing } }); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndSettings.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndSettings.java index e4e1e827d..6e33b8fab 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndSettings.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndSettings.java @@ -114,17 +114,7 @@ public class WndSettings extends WndTabbed { protected void onChange() { if (getSelectedValue() != SPDSettings.scale()) { SPDSettings.scale(getSelectedValue()); - ShatteredPixelDungeon.switchNoFade((Class) ShatteredPixelDungeon.scene().getClass(), new Game.SceneChangeCallback() { - @Override - public void beforeCreate() { - //do nothing - } - - @Override - public void afterCreate() { - Game.scene().add(new WndSettings()); - } - }); + ShatteredPixelDungeon.seamlessResetScene(); } } }; @@ -293,7 +283,7 @@ public class WndSettings extends WndTabbed { @Override protected void onClick() { super.onClick(); - ShatteredPixelDungeon.switchNoFade((Class) ShatteredPixelDungeon.scene().getClass(), new Game.SceneChangeCallback() { + ShatteredPixelDungeon.seamlessResetScene(new Game.SceneChangeCallback() { @Override public void beforeCreate() { SPDSettings.systemFont(checked()); @@ -301,7 +291,7 @@ public class WndSettings extends WndTabbed { @Override public void afterCreate() { - Game.scene().add(new WndSettings()); + //do nothing } }); }