v0.8.0: improved file handling and added proper file location support to desktop

This commit is contained in:
Evan Debenham
2019-10-27 19:08:21 -04:00
parent b3d4515b32
commit addb991631
4 changed files with 75 additions and 14 deletions

View File

@@ -21,11 +21,16 @@
package com.shatteredpixel.shatteredpixeldungeon.desktop;
import com.badlogic.gdx.Files;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import com.badlogic.gdx.backends.lwjgl.LwjglPreferences;
import com.badlogic.gdx.utils.SharedLibraryLoader;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.watabou.noosa.Game;
import com.watabou.utils.FileUtils;
import com.watabou.utils.GameSettings;
import java.io.PrintWriter;
import java.io.StringWriter;
@@ -74,6 +79,23 @@ public class DesktopLauncher {
config.foregroundFPS = 0;
config.backgroundFPS = -1;
//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
if (SharedLibraryLoader.isWindows) {
if (System.getProperties().getProperty("os.name").equals("Windows XP")) {
config.preferencesDirectory = "Application Data/.shatteredpixel/Shattered Pixel Dungeon/";
} else {
config.preferencesDirectory = "AppData/Roaming/.shatteredpixel/Shattered Pixel Dungeon/";
}
} else if (SharedLibraryLoader.isMac) {
config.preferencesDirectory = "Library/Application Support/Shattered Pixel Dungeon/";
} else if (SharedLibraryLoader.isLinux) {
config.preferencesDirectory = ".shatteredpixel/shattered-pixel-dungeon/";
}
GameSettings.set( new LwjglPreferences( "pd-prefs", config.preferencesDirectory) );
FileUtils.setDefaultFileProperties( Files.FileType.External, config.preferencesDirectory );
new LwjglApplication(new ShatteredPixelDungeon(new DesktopPlatformSupport()), config);
}
}