change NativesDir into LaunchOptions
This commit is contained in:
@@ -42,15 +42,11 @@ public final class HMCLGameLauncher extends DefaultLauncher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public HMCLGameLauncher(GameRepository repository, Version version, AuthInfo authInfo, LaunchOptions options, ProcessListener listener) {
|
public HMCLGameLauncher(GameRepository repository, Version version, AuthInfo authInfo, LaunchOptions options, ProcessListener listener) {
|
||||||
this(repository, version, authInfo, options, listener, false, null, true);
|
this(repository, version, authInfo, options, listener, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public HMCLGameLauncher(GameRepository repository, Version version, AuthInfo authInfo, LaunchOptions options, ProcessListener listener, boolean customized_natives, String customized_natives_path) {
|
public HMCLGameLauncher(GameRepository repository, Version version, AuthInfo authInfo, LaunchOptions options, ProcessListener listener, boolean daemon) {
|
||||||
this(repository, version, authInfo, options, listener, customized_natives, customized_natives_path, true);
|
super(repository, version, authInfo, options, listener, daemon);
|
||||||
}
|
|
||||||
|
|
||||||
public HMCLGameLauncher(GameRepository repository, Version version, AuthInfo authInfo, LaunchOptions options, ProcessListener listener, boolean customized_natives, String customized_natives_path, boolean daemon) {
|
|
||||||
super(repository, version, authInfo, options, listener, customized_natives, customized_natives_path, daemon);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -306,7 +306,9 @@ public class HMCLGameRepository extends DefaultGameRepository {
|
|||||||
.setServerIp(vs.getServerIp())
|
.setServerIp(vs.getServerIp())
|
||||||
.setWrapper(vs.getWrapper())
|
.setWrapper(vs.getWrapper())
|
||||||
.setPrecalledCommand(vs.getPreLaunchCommand())
|
.setPrecalledCommand(vs.getPreLaunchCommand())
|
||||||
.setNoGeneratedJVMArgs(vs.isNoJVMArgs());
|
.setNoGeneratedJVMArgs(vs.isNoJVMArgs())
|
||||||
|
.setNativesDirType(vs.getNativesDirType())
|
||||||
|
.setNativesDir(vs.getNativesDir());
|
||||||
if (config().hasProxy()) {
|
if (config().hasProxy()) {
|
||||||
builder.setProxy(ProxyManager.getProxy());
|
builder.setProxy(ProxyManager.getProxy());
|
||||||
if (config().hasProxyAuth()) {
|
if (config().hasProxyAuth()) {
|
||||||
|
|||||||
@@ -178,10 +178,7 @@ public final class LauncherHelper {
|
|||||||
repository.getLaunchOptions(selectedVersion, profile.getGameDir(), !setting.isNotCheckJVM()),
|
repository.getLaunchOptions(selectedVersion, profile.getGameDir(), !setting.isNotCheckJVM()),
|
||||||
launcherVisibility == LauncherVisibility.CLOSE
|
launcherVisibility == LauncherVisibility.CLOSE
|
||||||
? null // Unnecessary to start listening to game process output when close launcher immediately after game launched.
|
? null // Unnecessary to start listening to game process output when close launcher immediately after game launched.
|
||||||
: new HMCLProcessListener(repository, selectedVersion, authInfo, launchingLatch, gameVersion.isPresent()),
|
: new HMCLProcessListener(repository, selectedVersion, authInfo, launchingLatch, gameVersion.isPresent())
|
||||||
NativesDirectoryType.CUSTOM.equals(setting.getNativesDirType()),
|
|
||||||
setting.getNativesDir()
|
|
||||||
// TODO: yaoxi-std ADD custom natives path checking
|
|
||||||
);
|
);
|
||||||
}).thenComposeAsync(launcher -> { // launcher is prev task's result
|
}).thenComposeAsync(launcher -> { // launcher is prev task's result
|
||||||
if (scriptFile == null) {
|
if (scriptFile == null) {
|
||||||
|
|||||||
@@ -38,9 +38,6 @@
|
|||||||
<MultiFileItem fx:id="gameDirItem" title="%settings.game.working_directory" chooserTitle="%settings.game.working_directory.choose"
|
<MultiFileItem fx:id="gameDirItem" title="%settings.game.working_directory" chooserTitle="%settings.game.working_directory.choose"
|
||||||
hasSubtitle="true" customText="%settings.custom" directory="true" />
|
hasSubtitle="true" customText="%settings.custom" directory="true" />
|
||||||
|
|
||||||
<MultiFileItem fx:id="nativesDirItem" title="%settings.game.natives_directory" chooserTitle="%settings.game.natives_directory.choose"
|
|
||||||
hasSubtitle="true" customText="%settings.custom" directory="true" />
|
|
||||||
|
|
||||||
<BorderPane> <!-- Max Memory -->
|
<BorderPane> <!-- Max Memory -->
|
||||||
<left>
|
<left>
|
||||||
<VBox>
|
<VBox>
|
||||||
@@ -131,6 +128,9 @@
|
|||||||
fx:id="txtPrecallingCommand" StackPane.margin="$insets"/>
|
fx:id="txtPrecallingCommand" StackPane.margin="$insets"/>
|
||||||
<JFXTextField labelFloat="true" promptText="%settings.advanced.server_ip" styleClass="fit-width"
|
<JFXTextField labelFloat="true" promptText="%settings.advanced.server_ip" styleClass="fit-width"
|
||||||
fx:id="txtServerIP" StackPane.margin="$insets"/>
|
fx:id="txtServerIP" StackPane.margin="$insets"/>
|
||||||
|
|
||||||
|
<MultiFileItem fx:id="nativesDirItem" title="%settings.game.natives_directory" chooserTitle="%settings.game.natives_directory.choose"
|
||||||
|
hasSubtitle="true" customText="%settings.custom" directory="true" />
|
||||||
<BorderPane>
|
<BorderPane>
|
||||||
<left>
|
<left>
|
||||||
<Label BorderPane.alignment="CENTER_LEFT" text="%settings.advanced.no_jvm_args"/>
|
<Label BorderPane.alignment="CENTER_LEFT" text="%settings.advanced.no_jvm_args"/>
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ public class LaunchOptions implements Serializable {
|
|||||||
private String proxyPass;
|
private String proxyPass;
|
||||||
private boolean noGeneratedJVMArgs;
|
private boolean noGeneratedJVMArgs;
|
||||||
private String preLaunchCommand;
|
private String preLaunchCommand;
|
||||||
|
private NativesDirectoryType nativesDirType;
|
||||||
|
private String nativesDir;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The game directory
|
* The game directory
|
||||||
@@ -200,6 +202,21 @@ public class LaunchOptions implements Serializable {
|
|||||||
return preLaunchCommand;
|
return preLaunchCommand;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 0 - ./minecraft/versions/<version>/natives
|
||||||
|
* 1 - custom natives directory
|
||||||
|
*/
|
||||||
|
public NativesDirectoryType getNativesDirType(){
|
||||||
|
return nativesDirType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Path to the natives directory, optional
|
||||||
|
*/
|
||||||
|
public String getNativesDir(){
|
||||||
|
return nativesDir;
|
||||||
|
}
|
||||||
|
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
|
|
||||||
private final LaunchOptions options = new LaunchOptions();
|
private final LaunchOptions options = new LaunchOptions();
|
||||||
@@ -352,6 +369,14 @@ public class LaunchOptions implements Serializable {
|
|||||||
return options.preLaunchCommand;
|
return options.preLaunchCommand;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public NativesDirectoryType getNativesDirType(){
|
||||||
|
return options.nativesDirType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNativesDir(){
|
||||||
|
return options.nativesDir;
|
||||||
|
}
|
||||||
|
|
||||||
public Builder setGameDir(File gameDir) {
|
public Builder setGameDir(File gameDir) {
|
||||||
options.gameDir = gameDir;
|
options.gameDir = gameDir;
|
||||||
return this;
|
return this;
|
||||||
@@ -454,5 +479,15 @@ public class LaunchOptions implements Serializable {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Builder setNativesDirType(NativesDirectoryType nativesDirType){
|
||||||
|
options.nativesDirType = nativesDirType;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setNativesDir(String nativesDir){
|
||||||
|
options.nativesDir = nativesDir;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package org.jackhuang.hmcl.game;
|
|||||||
|
|
||||||
public enum NativesDirectoryType {
|
public enum NativesDirectoryType {
|
||||||
/**
|
/**
|
||||||
* .minecraft/versions/<version name>/natives;
|
* .minecraft/versions/<version name/natives>
|
||||||
*/
|
*/
|
||||||
VERSION_FOLDER,
|
VERSION_FOLDER,
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import org.jackhuang.hmcl.game.Arguments;
|
|||||||
import org.jackhuang.hmcl.game.GameRepository;
|
import org.jackhuang.hmcl.game.GameRepository;
|
||||||
import org.jackhuang.hmcl.game.LaunchOptions;
|
import org.jackhuang.hmcl.game.LaunchOptions;
|
||||||
import org.jackhuang.hmcl.game.Library;
|
import org.jackhuang.hmcl.game.Library;
|
||||||
|
import org.jackhuang.hmcl.game.NativesDirectoryType;
|
||||||
import org.jackhuang.hmcl.game.Version;
|
import org.jackhuang.hmcl.game.Version;
|
||||||
import org.jackhuang.hmcl.util.Lang;
|
import org.jackhuang.hmcl.util.Lang;
|
||||||
import org.jackhuang.hmcl.util.Log4jLevel;
|
import org.jackhuang.hmcl.util.Log4jLevel;
|
||||||
@@ -66,15 +67,11 @@ public class DefaultLauncher extends Launcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public DefaultLauncher(GameRepository repository, Version version, AuthInfo authInfo, LaunchOptions options, ProcessListener listener) {
|
public DefaultLauncher(GameRepository repository, Version version, AuthInfo authInfo, LaunchOptions options, ProcessListener listener) {
|
||||||
this(repository, version, authInfo, options, listener, false, null, true);
|
this(repository, version, authInfo, options, listener, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DefaultLauncher(GameRepository repository, Version version, AuthInfo authInfo, LaunchOptions options, ProcessListener listener, boolean customized_natives, String customized_natives_path) {
|
public DefaultLauncher(GameRepository repository, Version version, AuthInfo authInfo, LaunchOptions options, ProcessListener listener, boolean daemon) {
|
||||||
this(repository, version, authInfo, options, listener, customized_natives, customized_natives_path, true);
|
super(repository, version, authInfo, options, listener, daemon);
|
||||||
}
|
|
||||||
|
|
||||||
public DefaultLauncher(GameRepository repository, Version version, AuthInfo authInfo, LaunchOptions options, ProcessListener listener, boolean customized_natives, String customized_natives_path, boolean daemon) {
|
|
||||||
super(repository, version, authInfo, options, listener, customized_natives, customized_natives_path, daemon);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private CommandBuilder generateCommandLine(File nativeFolder) throws IOException {
|
private CommandBuilder generateCommandLine(File nativeFolder) throws IOException {
|
||||||
@@ -304,8 +301,12 @@ public class DefaultLauncher extends Launcher {
|
|||||||
@Override
|
@Override
|
||||||
public ManagedProcess launch() throws IOException, InterruptedException {
|
public ManagedProcess launch() throws IOException, InterruptedException {
|
||||||
File nativeFolder = null;
|
File nativeFolder = null;
|
||||||
if (!customized_natives) nativeFolder = repository.getNativeDirectory(version.getId());
|
if (options.getNativesDirType() == NativesDirectoryType.VERSION_FOLDER) {
|
||||||
else nativeFolder = new File(customized_natives_path);
|
nativeFolder = repository.getNativeDirectory(version.getId());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
nativeFolder = new File(options.getNativesDir());
|
||||||
|
}
|
||||||
|
|
||||||
// To guarantee that when failed to generate launch command line, we will not call pre-launch command
|
// To guarantee that when failed to generate launch command line, we will not call pre-launch command
|
||||||
List<String> rawCommandLine = generateCommandLine(nativeFolder).asList();
|
List<String> rawCommandLine = generateCommandLine(nativeFolder).asList();
|
||||||
@@ -314,7 +315,9 @@ public class DefaultLauncher extends Launcher {
|
|||||||
throw new IllegalStateException("Illegal command line " + rawCommandLine);
|
throw new IllegalStateException("Illegal command line " + rawCommandLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!customized_natives) decompressNatives(nativeFolder);
|
if (options.getNativesDirType() == NativesDirectoryType.VERSION_FOLDER) {
|
||||||
|
decompressNatives(nativeFolder);
|
||||||
|
}
|
||||||
|
|
||||||
File runDirectory = repository.getRunDirectory(version.getId());
|
File runDirectory = repository.getRunDirectory(version.getId());
|
||||||
|
|
||||||
@@ -355,10 +358,16 @@ public class DefaultLauncher extends Launcher {
|
|||||||
boolean isWindows = OperatingSystem.WINDOWS == OperatingSystem.CURRENT_OS;
|
boolean isWindows = OperatingSystem.WINDOWS == OperatingSystem.CURRENT_OS;
|
||||||
|
|
||||||
File nativeFolder = null;
|
File nativeFolder = null;
|
||||||
if (!customized_natives) nativeFolder = repository.getNativeDirectory(version.getId());
|
if (options.getNativesDirType() == NativesDirectoryType.VERSION_FOLDER) {
|
||||||
else nativeFolder = new File(customized_natives_path);
|
nativeFolder = repository.getNativeDirectory(version.getId());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
nativeFolder = new File(options.getNativesDir());
|
||||||
|
}
|
||||||
|
|
||||||
if (!customized_natives) decompressNatives(nativeFolder);
|
if (options.getNativesDirType() == NativesDirectoryType.VERSION_FOLDER) {
|
||||||
|
decompressNatives(nativeFolder);
|
||||||
|
}
|
||||||
|
|
||||||
if (isWindows && !FileUtils.getExtension(scriptFile).equals("bat"))
|
if (isWindows && !FileUtils.getExtension(scriptFile).equals("bat"))
|
||||||
throw new IllegalArgumentException("The extension of " + scriptFile + " is not 'bat' in Windows");
|
throw new IllegalArgumentException("The extension of " + scriptFile + " is not 'bat' in Windows");
|
||||||
|
|||||||
@@ -38,30 +38,22 @@ public abstract class Launcher {
|
|||||||
protected final LaunchOptions options;
|
protected final LaunchOptions options;
|
||||||
protected final ProcessListener listener;
|
protected final ProcessListener listener;
|
||||||
protected final boolean daemon;
|
protected final boolean daemon;
|
||||||
protected final boolean customized_natives;
|
|
||||||
protected final String customized_natives_path;
|
|
||||||
|
|
||||||
public Launcher(GameRepository repository, Version version, AuthInfo authInfo, LaunchOptions options) {
|
public Launcher(GameRepository repository, Version version, AuthInfo authInfo, LaunchOptions options) {
|
||||||
this(repository, version, authInfo, options, null);
|
this(repository, version, authInfo, options, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Launcher(GameRepository repository, Version version, AuthInfo authInfo, LaunchOptions options, ProcessListener listener) {
|
public Launcher(GameRepository repository, Version version, AuthInfo authInfo, LaunchOptions options, ProcessListener listener) {
|
||||||
this(repository, version, authInfo, options, listener, false, null, true);
|
this(repository, version, authInfo, options, listener, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Launcher(GameRepository repository, Version version, AuthInfo authInfo, LaunchOptions options, ProcessListener listener, boolean customized_natives, String customized_natives_path) {
|
public Launcher(GameRepository repository, Version version, AuthInfo authInfo, LaunchOptions options, ProcessListener listener, boolean daemon) {
|
||||||
this(repository, version, authInfo, options, listener, customized_natives, customized_natives_path, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Launcher(GameRepository repository, Version version, AuthInfo authInfo, LaunchOptions options, ProcessListener listener, boolean customized_natives, String customized_natives_path, boolean daemon) {
|
|
||||||
this.repository = repository;
|
this.repository = repository;
|
||||||
this.version = version;
|
this.version = version;
|
||||||
this.authInfo = authInfo;
|
this.authInfo = authInfo;
|
||||||
this.options = options;
|
this.options = options;
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
this.daemon = daemon;
|
this.daemon = daemon;
|
||||||
this.customized_natives = customized_natives;
|
|
||||||
this.customized_natives_path = customized_natives_path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user