From e874dea93e84c88ab56d3e26cf82e619bb980b58 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Wed, 18 Dec 2019 14:22:58 -0500 Subject: [PATCH] v0.8.0: changed default settings file --- .../main/java/com/watabou/utils/GameSettings.java | 3 +-- .../shatteredpixeldungeon/android/AndroidGame.java | 2 ++ .../desktop/DesktopLauncher.java | 14 +++++++++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/SPD-classes/src/main/java/com/watabou/utils/GameSettings.java b/SPD-classes/src/main/java/com/watabou/utils/GameSettings.java index 035e1f542..70ff3c0ba 100644 --- a/SPD-classes/src/main/java/com/watabou/utils/GameSettings.java +++ b/SPD-classes/src/main/java/com/watabou/utils/GameSettings.java @@ -26,8 +26,7 @@ import com.badlogic.gdx.Preferences; public class GameSettings { - //TODO might want to rename this file. this is the auto-generated name for android atm - public static final String DEFAULT_PREFS_FILE = "ShatteredPixelDungeon"; + public static final String DEFAULT_PREFS_FILE = "settings.xml"; private static Preferences prefs; diff --git a/android/src/main/java/com/shatteredpixel/shatteredpixeldungeon/android/AndroidGame.java b/android/src/main/java/com/shatteredpixel/shatteredpixeldungeon/android/AndroidGame.java index e57054e45..356c31093 100644 --- a/android/src/main/java/com/shatteredpixel/shatteredpixeldungeon/android/AndroidGame.java +++ b/android/src/main/java/com/shatteredpixel/shatteredpixeldungeon/android/AndroidGame.java @@ -69,6 +69,8 @@ public class AndroidGame extends AndroidApplication { // grab preferences directly using our instance first // so that we don't need to rely on Gdx.app, which isn't initialized yet. + // Note that we use a different prefs name on android for legacy purposes, + // this is the default prefs filename given to an android app (.xml is automatically added to it) SPDSettings.set(instance.getPreferences("ShatteredPixelDungeon")); //set desired orientation (if it exists) before initializing the app. diff --git a/desktop/src/main/java/com/shatteredpixel/shatteredpixeldungeon/desktop/DesktopLauncher.java b/desktop/src/main/java/com/shatteredpixel/shatteredpixeldungeon/desktop/DesktopLauncher.java index 6eb96fb94..f67abbfac 100644 --- a/desktop/src/main/java/com/shatteredpixel/shatteredpixeldungeon/desktop/DesktopLauncher.java +++ b/desktop/src/main/java/com/shatteredpixel/shatteredpixeldungeon/desktop/DesktopLauncher.java @@ -25,7 +25,9 @@ import com.badlogic.gdx.Files; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application; import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration; +import com.badlogic.gdx.backends.lwjgl3.Lwjgl3FileHandle; import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Preferences; +import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.utils.SharedLibraryLoader; import com.shatteredpixel.shatteredpixeldungeon.SPDSettings; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; @@ -100,8 +102,6 @@ public class DesktopLauncher { config.setTitle( title ); - //TODO this is currently the same location and filenames as the old desktop codebase - // If I want to move it now would be the time String basePath = ""; if (SharedLibraryLoader.isWindows) { if (System.getProperties().getProperty("os.name").equals("Windows XP")) { @@ -114,8 +114,16 @@ public class DesktopLauncher { } else if (SharedLibraryLoader.isLinux) { basePath = ".shatteredpixel/shattered-pixel-dungeon/"; } + + //copy over prefs from old file location from legacy desktop codebase + FileHandle oldPrefs = new Lwjgl3FileHandle(basePath + "pd-prefs", Files.FileType.External); + FileHandle newPrefs = new Lwjgl3FileHandle(basePath + SPDSettings.DEFAULT_PREFS_FILE, Files.FileType.External); + if (oldPrefs.exists() && !newPrefs.exists()){ + oldPrefs.copyTo(newPrefs); + } + config.setPreferencesConfig( basePath, Files.FileType.External ); - SPDSettings.set( new Lwjgl3Preferences( "pd-prefs", basePath) ); + SPDSettings.set( new Lwjgl3Preferences( SPDSettings.DEFAULT_PREFS_FILE, basePath) ); FileUtils.setDefaultFileProperties( Files.FileType.External, basePath ); config.setWindowSizeLimits( 960, 640, -1, -1 );