feat: option to use system glfw/OpenAL. Closes #958.

This commit is contained in:
huanghongxun
2021-08-29 04:26:12 +08:00
parent 6ee39aa302
commit c23b9511b8
7 changed files with 111 additions and 3 deletions

View File

@@ -56,6 +56,8 @@ public class LaunchOptions implements Serializable {
private NativesDirectoryType nativesDirType;
private String nativesDir;
private ProcessPriority processPriority = ProcessPriority.NORMAL;
private boolean useNativeGLFW;
private boolean useNativeOpenAL;
/**
* The game directory
@@ -225,6 +227,14 @@ public class LaunchOptions implements Serializable {
return processPriority;
}
public boolean isUseNativeGLFW() {
return useNativeGLFW;
}
public boolean isUseNativeOpenAL() {
return useNativeOpenAL;
}
public static class Builder {
private final LaunchOptions options = new LaunchOptions();
@@ -385,6 +395,14 @@ public class LaunchOptions implements Serializable {
return options.nativesDir;
}
public boolean isUseNativeGLFW() {
return options.useNativeGLFW;
}
public boolean isUseNativeOpenAL() {
return options.useNativeOpenAL;
}
public Builder setGameDir(File gameDir) {
options.gameDir = gameDir;
return this;
@@ -502,5 +520,15 @@ public class LaunchOptions implements Serializable {
return this;
}
public Builder setUseNativeGLFW(boolean useNativeGLFW) {
options.useNativeGLFW = useNativeGLFW;
return this;
}
public Builder setUseNativeOpenAL(boolean useNativeOpenAL) {
options.useNativeOpenAL = useNativeOpenAL;
return this;
}
}
}

View File

@@ -303,6 +303,14 @@ public class DefaultLauncher extends Launcher {
String ext = FileUtils.getExtension(destFile);
if (ext.equals("sha1") || ext.equals("git"))
return false;
if (options.isUseNativeGLFW() && FileUtils.getName(destFile).toLowerCase(Locale.ROOT).contains("glfw")) {
return false;
}
if (options.isUseNativeOpenAL() && FileUtils.getName(destFile).toLowerCase(Locale.ROOT).contains("openal")) {
return false;
}
return library.getExtract().shouldExtract(path);
})
.setReplaceExistentFile(false).unzip();