v1.4.0: made desktop save DIR variable based on game name/vendor

This commit is contained in:
Evan Debenham
2022-08-09 12:03:21 -04:00
parent 0024f57ce0
commit 8ea20ef9c2
2 changed files with 19 additions and 5 deletions

View File

@@ -19,6 +19,7 @@ task debug(type: JavaExec) {
main = appMainClass
systemProperty 'Specification-Title', appName
systemProperty 'Implementation-Title', appPackageName
systemProperty 'Specification-Version', appVersionName + "-INDEV"
systemProperty 'Implementation-Version', appVersionCode
@@ -37,6 +38,7 @@ task release(type: Jar) {
manifest {
attributes 'Main-Class': appMainClass
attributes 'Specification-Title': appName
attributes 'Implementation-Title': appPackageName
attributes 'Specification-Version': appVersionName
attributes 'Implementation-Version': appVersionCode
}

View File

@@ -45,6 +45,7 @@ import org.lwjgl.util.tinyfd.TinyFileDialogs;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Locale;
public class DesktopLauncher {
@@ -132,25 +133,36 @@ public class DesktopLauncher {
config.setTitle( title );
//if I were implementing this from scratch I would use the full implementation title for saves
// (e.g. /.shatteredpixel/shatteredpixeldungeon), but we have too much existing save
// date to worry about transferring at this point.
String vendor = DesktopLauncher.class.getPackage().getImplementationTitle();
if (vendor == null) {
vendor = System.getProperty("Implementation-Title");
}
vendor = vendor.split("\\.")[1];
String basePath = "";
Files.FileType baseFileType = null;
if (SharedLibraryLoader.isWindows) {
if (System.getProperties().getProperty("os.name").equals("Windows XP")) {
basePath = "Application Data/.shatteredpixel/Shattered Pixel Dungeon/";
basePath = "Application Data/." + vendor + "/" + title + "/";
} else {
basePath = "AppData/Roaming/.shatteredpixel/Shattered Pixel Dungeon/";
basePath = "AppData/Roaming/." + vendor + "/" + title + "/";
}
baseFileType = Files.FileType.External;
} else if (SharedLibraryLoader.isMac) {
basePath = "Library/Application Support/Shattered Pixel Dungeon/";
basePath = "Library/Application Support/" + title + "/";
baseFileType = Files.FileType.External;
} else if (SharedLibraryLoader.isLinux) {
String XDGHome = System.getenv("XDG_DATA_HOME");
if (XDGHome == null) XDGHome = System.getProperty("user.home") + "/.local/share";
basePath = XDGHome + "/.shatteredpixel/shattered-pixel-dungeon/";
String titleLinux = title.toLowerCase(Locale.ROOT).replace(" ", "-");
basePath = XDGHome + "/." + vendor + "/" + titleLinux + "/";
//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("." + vendor + "/" + titleLinux + "/", Files.FileType.External);
FileHandle newBase = new Lwjgl3FileHandle(basePath, Files.FileType.Absolute);
if (oldBase.exists()){
if (!newBase.exists()) {