v1.3.0: fixed further issues with XDG_DATA_HOME on Linux
This commit is contained in:
@@ -133,22 +133,25 @@ public class DesktopLauncher {
|
|||||||
config.setTitle( title );
|
config.setTitle( title );
|
||||||
|
|
||||||
String basePath = "";
|
String basePath = "";
|
||||||
|
Files.FileType baseFileType = null;
|
||||||
if (SharedLibraryLoader.isWindows) {
|
if (SharedLibraryLoader.isWindows) {
|
||||||
if (System.getProperties().getProperty("os.name").equals("Windows XP")) {
|
if (System.getProperties().getProperty("os.name").equals("Windows XP")) {
|
||||||
basePath = "Application Data/.shatteredpixel/Shattered Pixel Dungeon/";
|
basePath = "Application Data/.shatteredpixel/Shattered Pixel Dungeon/";
|
||||||
} else {
|
} else {
|
||||||
basePath = "AppData/Roaming/.shatteredpixel/Shattered Pixel Dungeon/";
|
basePath = "AppData/Roaming/.shatteredpixel/Shattered Pixel Dungeon/";
|
||||||
}
|
}
|
||||||
|
baseFileType = Files.FileType.External;
|
||||||
} else if (SharedLibraryLoader.isMac) {
|
} else if (SharedLibraryLoader.isMac) {
|
||||||
basePath = "Library/Application Support/Shattered Pixel Dungeon/";
|
basePath = "Library/Application Support/Shattered Pixel Dungeon/";
|
||||||
|
baseFileType = Files.FileType.External;
|
||||||
} else if (SharedLibraryLoader.isLinux) {
|
} else if (SharedLibraryLoader.isLinux) {
|
||||||
String XDGHome = System.getenv().get("XDG_DATA_HOME");
|
String XDGHome = System.getenv("XDG_DATA_HOME");
|
||||||
if (XDGHome == null) XDGHome = ".local/share";
|
if (XDGHome == null) XDGHome = System.getProperty("user.home") + "/.local/share";
|
||||||
basePath = XDGHome + "/.shatteredpixel/shattered-pixel-dungeon/";
|
basePath = XDGHome + "/.shatteredpixel/shattered-pixel-dungeon/";
|
||||||
|
|
||||||
//copy over files from old linux save DIR, pre-1.2.0
|
//copy over files from old linux save DIR, pre-1.2.0
|
||||||
FileHandle oldBase = new Lwjgl3FileHandle(".shatteredpixel/shattered-pixel-dungeon/", Files.FileType.External);
|
FileHandle oldBase = new Lwjgl3FileHandle(".shatteredpixel/shattered-pixel-dungeon/", Files.FileType.External);
|
||||||
FileHandle newBase = new Lwjgl3FileHandle(basePath, Files.FileType.External);
|
FileHandle newBase = new Lwjgl3FileHandle(basePath, Files.FileType.Absolute);
|
||||||
if (oldBase.exists()){
|
if (oldBase.exists()){
|
||||||
if (!newBase.exists()) {
|
if (!newBase.exists()) {
|
||||||
oldBase.copyTo(newBase.parent());
|
oldBase.copyTo(newBase.parent());
|
||||||
@@ -156,11 +159,12 @@ public class DesktopLauncher {
|
|||||||
oldBase.deleteDirectory();
|
oldBase.deleteDirectory();
|
||||||
oldBase.parent().delete(); //only regular delete, in case of saves from other PD versions
|
oldBase.parent().delete(); //only regular delete, in case of saves from other PD versions
|
||||||
}
|
}
|
||||||
|
baseFileType = Files.FileType.Absolute;
|
||||||
}
|
}
|
||||||
|
|
||||||
config.setPreferencesConfig( basePath, Files.FileType.External );
|
config.setPreferencesConfig( basePath, baseFileType );
|
||||||
SPDSettings.set( new Lwjgl3Preferences( SPDSettings.DEFAULT_PREFS_FILE, basePath) );
|
SPDSettings.set( new Lwjgl3Preferences( new Lwjgl3FileHandle(basePath + SPDSettings.DEFAULT_PREFS_FILE, baseFileType) ));
|
||||||
FileUtils.setDefaultFileProperties( Files.FileType.External, basePath );
|
FileUtils.setDefaultFileProperties( baseFileType, basePath );
|
||||||
|
|
||||||
config.setWindowSizeLimits( 720, 400, -1, -1 );
|
config.setWindowSizeLimits( 720, 400, -1, -1 );
|
||||||
Point p = SPDSettings.windowResolution();
|
Point p = SPDSettings.windowResolution();
|
||||||
|
|||||||
Reference in New Issue
Block a user