v3.3.0: fixed deprecated platform checking logic

This commit is contained in:
Evan Debenham
2025-10-26 13:19:42 -04:00
parent b9f900923c
commit 62f5d398ca
3 changed files with 15 additions and 10 deletions

View File

@@ -23,6 +23,7 @@ package com.watabou.utils;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input; import com.badlogic.gdx.Input;
import com.badlogic.gdx.utils.Os;
import com.badlogic.gdx.utils.SharedLibraryLoader; import com.badlogic.gdx.utils.SharedLibraryLoader;
import com.watabou.noosa.Game; import com.watabou.noosa.Game;
@@ -35,15 +36,15 @@ public class DeviceCompat {
} }
public static boolean isAndroid(){ public static boolean isAndroid(){
return SharedLibraryLoader.isAndroid; return SharedLibraryLoader.os == Os.Android;
} }
public static boolean isiOS(){ public static boolean isiOS(){
return SharedLibraryLoader.isIos; return SharedLibraryLoader.os == Os.IOS;
} }
public static boolean isDesktop(){ public static boolean isDesktop(){
return SharedLibraryLoader.isWindows || SharedLibraryLoader.isMac || SharedLibraryLoader.isLinux; return SharedLibraryLoader.os == Os.Windows || SharedLibraryLoader.os == Os.MacOsX || SharedLibraryLoader.os == Os.Linux;
} }
public static boolean hasHardKeyboard(){ public static boolean hasHardKeyboard(){

View File

@@ -21,6 +21,7 @@
package com.shatteredpixel.shatteredpixeldungeon.desktop; package com.shatteredpixel.shatteredpixeldungeon.desktop;
import com.badlogic.gdx.utils.Os;
import com.badlogic.gdx.utils.SharedLibraryLoader; import com.badlogic.gdx.utils.SharedLibraryLoader;
import java.io.BufferedReader; import java.io.BufferedReader;
@@ -36,7 +37,7 @@ public class DesktopLaunchValidator {
public static boolean verifyValidJVMState(String[] args){ public static boolean verifyValidJVMState(String[] args){
//mac computers require the -XstartOnFirstThread JVM argument //mac computers require the -XstartOnFirstThread JVM argument
if (SharedLibraryLoader.isMac){ if (SharedLibraryLoader.os == Os.MacOsX){
// If XstartOnFirstThread is present and enabled, we can return true // If XstartOnFirstThread is present and enabled, we can return true
if ("1".equals(System.getenv("JAVA_STARTED_ON_FIRST_THREAD_" + if ("1".equals(System.getenv("JAVA_STARTED_ON_FIRST_THREAD_" +

View File

@@ -26,6 +26,8 @@ import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration; import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3FileHandle; import com.badlogic.gdx.backends.lwjgl3.Lwjgl3FileHandle;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Preferences; import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Preferences;
import com.badlogic.gdx.utils.Architecture;
import com.badlogic.gdx.utils.Os;
import com.badlogic.gdx.utils.SharedLibraryLoader; import com.badlogic.gdx.utils.SharedLibraryLoader;
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings; import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
@@ -54,10 +56,11 @@ public class DesktopLauncher {
//detection for FreeBSD (which is equivalent to linux for us) //detection for FreeBSD (which is equivalent to linux for us)
//TODO might want to merge request this to libGDX //TODO might want to merge request this to libGDX
if (System.getProperty("os.name").contains("FreeBSD")) { if (System.getProperty("os.name").contains("FreeBSD")) {
SharedLibraryLoader.isLinux = true; SharedLibraryLoader.os = Os.Linux;
//this overrides incorrect values set in SharedLibraryLoader's static initializer //this overrides incorrect values set in SharedLibraryLoader's static initializer
SharedLibraryLoader.isIos = false; if (System.getProperty("os.arch").contains("64") || System.getProperty("os.arch").startsWith("armv8")){
SharedLibraryLoader.is64Bit = System.getProperty("os.arch").contains("64") || System.getProperty("os.arch").startsWith("armv8"); SharedLibraryLoader.bitness = Architecture.Bitness._64;
}
} }
final String title; final String title;
@@ -145,17 +148,17 @@ public class DesktopLauncher {
String basePath = ""; String basePath = "";
Files.FileType baseFileType = null; Files.FileType baseFileType = null;
if (SharedLibraryLoader.isWindows) { if (SharedLibraryLoader.os == Os.Windows) {
if (System.getProperties().getProperty("os.name").equals("Windows XP")) { if (System.getProperties().getProperty("os.name").equals("Windows XP")) {
basePath = "Application Data/." + vendor + "/" + title + "/"; basePath = "Application Data/." + vendor + "/" + title + "/";
} else { } else {
basePath = "AppData/Roaming/." + vendor + "/" + title + "/"; basePath = "AppData/Roaming/." + vendor + "/" + title + "/";
} }
baseFileType = Files.FileType.External; baseFileType = Files.FileType.External;
} else if (SharedLibraryLoader.isMac) { } else if (SharedLibraryLoader.os == Os.MacOsX) {
basePath = "Library/Application Support/" + title + "/"; basePath = "Library/Application Support/" + title + "/";
baseFileType = Files.FileType.External; baseFileType = Files.FileType.External;
} else if (SharedLibraryLoader.isLinux) { } else if (SharedLibraryLoader.os == Os.Linux) {
String XDGHome = System.getenv("XDG_DATA_HOME"); String XDGHome = System.getenv("XDG_DATA_HOME");
if (XDGHome == null) XDGHome = System.getProperty("user.home") + "/.local/share"; if (XDGHome == null) XDGHome = System.getProperty("user.home") + "/.local/share";