mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-01-30 14:39:56 +08:00
feat: process priority settings.
This commit is contained in:
parent
3972683583
commit
2de5c36df5
@ -307,7 +307,8 @@ public class HMCLGameRepository extends DefaultGameRepository {
|
||||
.setPrecalledCommand(vs.getPreLaunchCommand())
|
||||
.setNoGeneratedJVMArgs(vs.isNoJVMArgs())
|
||||
.setNativesDirType(vs.getNativesDirType())
|
||||
.setNativesDir(vs.getNativesDir());
|
||||
.setNativesDir(vs.getNativesDir())
|
||||
.setProcessPriority(vs.getProcessPriority());
|
||||
if (config().hasProxy()) {
|
||||
builder.setProxy(ProxyManager.getProxy());
|
||||
if (config().hasProxyAuth()) {
|
||||
|
@ -23,6 +23,7 @@ import javafx.beans.InvalidationListener;
|
||||
import javafx.beans.property.*;
|
||||
import org.jackhuang.hmcl.game.GameDirectoryType;
|
||||
import org.jackhuang.hmcl.game.NativesDirectoryType;
|
||||
import org.jackhuang.hmcl.game.ProcessPriority;
|
||||
import org.jackhuang.hmcl.util.Lang;
|
||||
import org.jackhuang.hmcl.util.StringUtils;
|
||||
import org.jackhuang.hmcl.util.platform.JavaVersion;
|
||||
@ -475,6 +476,20 @@ public final class VersionSetting implements Cloneable {
|
||||
gameDirProperty.set(gameDir);
|
||||
}
|
||||
|
||||
private final ObjectProperty<ProcessPriority> processPriorityProperty = new SimpleObjectProperty<>(this, "processPriority", ProcessPriority.NORMAL);
|
||||
|
||||
public ObjectProperty<ProcessPriority> processPriorityProperty() {
|
||||
return processPriorityProperty;
|
||||
}
|
||||
|
||||
public ProcessPriority getProcessPriority() {
|
||||
return processPriorityProperty.get();
|
||||
}
|
||||
|
||||
public void setProcessPriority(ProcessPriority processPriority) {
|
||||
processPriorityProperty.set(processPriority);
|
||||
}
|
||||
|
||||
// launcher settings
|
||||
|
||||
/**
|
||||
@ -556,6 +571,7 @@ public final class VersionSetting implements Cloneable {
|
||||
heightProperty.addListener(listener);
|
||||
gameDirTypeProperty.addListener(listener);
|
||||
gameDirProperty.addListener(listener);
|
||||
processPriorityProperty.addListener(listener);
|
||||
launcherVisibilityProperty.addListener(listener);
|
||||
defaultJavaPathProperty.addListener(listener);
|
||||
nativesDirProperty.addListener(listener);
|
||||
@ -586,6 +602,7 @@ public final class VersionSetting implements Cloneable {
|
||||
versionSetting.setHeight(getHeight());
|
||||
versionSetting.setGameDirType(getGameDirType());
|
||||
versionSetting.setGameDir(getGameDir());
|
||||
versionSetting.setProcessPriority(getProcessPriority());
|
||||
versionSetting.setLauncherVisibility(getLauncherVisibility());
|
||||
versionSetting.setNativesDir(getNativesDir());
|
||||
return versionSetting;
|
||||
@ -617,6 +634,7 @@ public final class VersionSetting implements Cloneable {
|
||||
obj.addProperty("showLogs", src.isShowLogs());
|
||||
obj.addProperty("gameDir", src.getGameDir());
|
||||
obj.addProperty("launcherVisibility", src.getLauncherVisibility().ordinal());
|
||||
obj.addProperty("processPriority", src.getProcessPriority().ordinal());
|
||||
obj.addProperty("gameDirType", src.getGameDirType().ordinal());
|
||||
obj.addProperty("defaultJavaPath", src.getDefaultJavaPath());
|
||||
obj.addProperty("nativesDir", src.getNativesDir());
|
||||
@ -656,8 +674,9 @@ public final class VersionSetting implements Cloneable {
|
||||
vs.setNotCheckGame(Optional.ofNullable(obj.get("notCheckGame")).map(JsonElement::getAsBoolean).orElse(false));
|
||||
vs.setNotCheckJVM(Optional.ofNullable(obj.get("notCheckJVM")).map(JsonElement::getAsBoolean).orElse(false));
|
||||
vs.setShowLogs(Optional.ofNullable(obj.get("showLogs")).map(JsonElement::getAsBoolean).orElse(false));
|
||||
vs.setLauncherVisibility(LauncherVisibility.values()[Optional.ofNullable(obj.get("launcherVisibility")).map(JsonElement::getAsInt).orElse(1)]);
|
||||
vs.setGameDirType(GameDirectoryType.values()[Optional.ofNullable(obj.get("gameDirType")).map(JsonElement::getAsInt).orElse(0)]);
|
||||
vs.setLauncherVisibility(LauncherVisibility.values()[Optional.ofNullable(obj.get("launcherVisibility")).map(JsonElement::getAsInt).orElse(LauncherVisibility.HIDE.ordinal())]);
|
||||
vs.setProcessPriority(ProcessPriority.values()[Optional.ofNullable(obj.get("processPriority")).map(JsonElement::getAsInt).orElse(ProcessPriority.NORMAL.ordinal())]);
|
||||
vs.setGameDirType(GameDirectoryType.values()[Optional.ofNullable(obj.get("gameDirType")).map(JsonElement::getAsInt).orElse(GameDirectoryType.ROOT_FOLDER.ordinal())]);
|
||||
vs.setDefaultJavaPath(Optional.ofNullable(obj.get("defaultJavaPath")).map(JsonElement::getAsString).orElse(null));
|
||||
vs.setNativesDirType(NativesDirectoryType.values()[Optional.ofNullable(obj.get("nativesDirType")).map(JsonElement::getAsInt).orElse(0)]);
|
||||
|
||||
|
@ -36,6 +36,7 @@ import javafx.scene.layout.VBox;
|
||||
import javafx.stage.FileChooser;
|
||||
import org.jackhuang.hmcl.game.GameDirectoryType;
|
||||
import org.jackhuang.hmcl.game.NativesDirectoryType;
|
||||
import org.jackhuang.hmcl.game.ProcessPriority;
|
||||
import org.jackhuang.hmcl.setting.LauncherVisibility;
|
||||
import org.jackhuang.hmcl.setting.Profile;
|
||||
import org.jackhuang.hmcl.setting.Profiles;
|
||||
@ -94,6 +95,7 @@ public final class VersionSettingsPage extends StackPane implements DecoratorPag
|
||||
private final MultiFileItem<JavaVersion> javaItem;
|
||||
private final MultiFileItem<GameDirectoryType> gameDirItem;
|
||||
private final MultiFileItem<NativesDirectoryType> nativesDirItem;
|
||||
private final JFXComboBox<ProcessPriority> cboProcessPriority;
|
||||
private final JFXToggleButton chkShowLogs;
|
||||
private final ImagePickerItem iconPickerItem;
|
||||
private final JFXCheckBox chkEnableSpecificSettings;
|
||||
@ -252,6 +254,18 @@ public final class VersionSettingsPage extends StackPane implements DecoratorPag
|
||||
advancedSettingsPane = new ComponentList();
|
||||
advancedSettingsPane.setDepth(1);
|
||||
{
|
||||
BorderPane processPriorityPane = new BorderPane();
|
||||
{
|
||||
Label label = new Label(i18n("settings.advanced.process_priority"));
|
||||
processPriorityPane.setLeft(label);
|
||||
BorderPane.setAlignment(label, Pos.CENTER_LEFT);
|
||||
|
||||
cboProcessPriority = new JFXComboBox<>();
|
||||
processPriorityPane.setRight(cboProcessPriority);
|
||||
BorderPane.setAlignment(cboProcessPriority, Pos.CENTER_RIGHT);
|
||||
FXUtils.setLimitWidth(cboProcessPriority, 300);
|
||||
}
|
||||
|
||||
txtJVMArgs = new JFXTextField();
|
||||
txtJVMArgs.setLabelFloat(true);
|
||||
txtJVMArgs.setPromptText(i18n("settings.advanced.jvm_args"));
|
||||
@ -333,7 +347,7 @@ public final class VersionSettingsPage extends StackPane implements DecoratorPag
|
||||
FXUtils.setLimitHeight(chkNoJVMCheck, 20);
|
||||
}
|
||||
|
||||
advancedSettingsPane.getContent().setAll(txtJVMArgs, txtGameArgs, txtMetaspace, txtWrapper, txtPrecallingCommand, txtServerIP, nativesDirItem, noJVMArgsPane, noGameCheckPane, noJVMCheckPane);
|
||||
advancedSettingsPane.getContent().setAll(processPriorityPane, txtJVMArgs, txtGameArgs, txtMetaspace, txtWrapper, txtPrecallingCommand, txtServerIP, nativesDirItem, noJVMArgsPane, noGameCheckPane, noJVMCheckPane);
|
||||
}
|
||||
|
||||
rootPane.getChildren().setAll(iconPickerItemWrapper, settingsTypePane, componentList, advancedHintPane, advancedSettingsPane);
|
||||
@ -348,6 +362,9 @@ public final class VersionSettingsPage extends StackPane implements DecoratorPag
|
||||
|
||||
cboLauncherVisibility.getItems().setAll(LauncherVisibility.values());
|
||||
cboLauncherVisibility.setConverter(stringConverter(e -> i18n("settings.advanced.launcher_visibility." + e.name().toLowerCase())));
|
||||
|
||||
cboProcessPriority.getItems().setAll(ProcessPriority.values());
|
||||
cboProcessPriority.setConverter(stringConverter(e -> i18n("settings.advanced.process_priority." + e.name().toLowerCase())));
|
||||
}
|
||||
|
||||
private void initialize() {
|
||||
@ -433,6 +450,7 @@ public final class VersionSettingsPage extends StackPane implements DecoratorPag
|
||||
FXUtils.unbindBoolean(chkNoJVMArgs, lastVersionSetting.noJVMArgsProperty());
|
||||
FXUtils.unbindBoolean(chkShowLogs, lastVersionSetting.showLogsProperty());
|
||||
FXUtils.unbindEnum(cboLauncherVisibility);
|
||||
FXUtils.unbindEnum(cboProcessPriority);
|
||||
|
||||
lastVersionSetting.usesGlobalProperty().removeListener(specificSettingsListener);
|
||||
lastVersionSetting.javaDirProperty().removeListener(javaListener);
|
||||
@ -467,6 +485,7 @@ public final class VersionSettingsPage extends StackPane implements DecoratorPag
|
||||
FXUtils.bindBoolean(chkNoJVMArgs, versionSetting.noJVMArgsProperty());
|
||||
FXUtils.bindBoolean(chkShowLogs, versionSetting.showLogsProperty());
|
||||
FXUtils.bindEnum(cboLauncherVisibility, versionSetting.launcherVisibilityProperty());
|
||||
FXUtils.bindEnum(cboProcessPriority, versionSetting.processPriorityProperty());
|
||||
|
||||
versionSetting.usesGlobalProperty().addListener(specificSettingsListener);
|
||||
if (versionId != null)
|
||||
|
@ -463,6 +463,12 @@ settings.advanced.natives_directory.choose=Choose Local Library Path
|
||||
settings.advanced.natives_directory.default=Standerd (.minecraft/versions/<version name>/natives/)
|
||||
settings.advanced.no_jvm_args=No Default JVM Args
|
||||
settings.advanced.precall_command=Pre-Launch command (will be executed before game starts)
|
||||
settings.advanced.process_priority=Process Priority
|
||||
settings.advanced.process_priority.low=Low
|
||||
settings.advanced.process_priority.below_normal=Below Normal
|
||||
settings.advanced.process_priority.normal=Normal
|
||||
settings.advanced.process_priority.above_normal=Above Normal
|
||||
settings.advanced.process_priority.high=High
|
||||
settings.advanced.server_ip=Server Address
|
||||
settings.advanced.wrapper_launcher=Wrapper Launcher (i.e. optirun...)
|
||||
|
||||
|
@ -468,6 +468,12 @@ settings.advanced.natives_directory.choose=选择本地库路径
|
||||
settings.advanced.natives_directory.default=预设(.minecraft/versions/<版本名>/natives/)
|
||||
settings.advanced.no_jvm_args=不添加默认的 JVM 参数
|
||||
settings.advanced.precall_command=启动前执行命令(不必填写,将在游戏启动前调用)
|
||||
settings.advanced.process_priority=进程优先级
|
||||
settings.advanced.process_priority.low=低(节省游戏占用资源,可能会造成游戏卡顿)
|
||||
settings.advanced.process_priority.below_normal=较低(节省游戏占用资源,可能会造成游戏卡顿)
|
||||
settings.advanced.process_priority.normal=中(平衡)
|
||||
settings.advanced.process_priority.above_normal=较高(优先保证游戏运行,但可能会导致其他程序卡顿)
|
||||
settings.advanced.process_priority.high=高(优先保证游戏运行,但可能会导致其他程序卡顿)
|
||||
settings.advanced.server_ip=直入服务器 IP 地址(不必填写,启动游戏后直接进入对应服务器)
|
||||
settings.advanced.wrapper_launcher=前置指令(不必填写,如 optirun)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user