cpu Affinity

This commit is contained in:
xkeyC 2023-11-21 21:25:59 +08:00
parent faec463478
commit d8dbbc5fbd
3 changed files with 28 additions and 5 deletions

View File

@ -526,11 +526,32 @@ class HomeUIModel extends BaseUIModel {
return (map["status"] == "ok" || map["status"] == "operational");
}
doLaunchGame(String launchExe, List<String> args, String installPath) async {
doLaunchGame(String launchExe, List<String> args, String installPath,
int? processorAffinity) async {
_isGameRunning[installPath] = true;
notifyListeners();
try {
await Process.run(launchExe, args);
if (processorAffinity == null) {
ProcessResult result = await Process.run(launchExe, args);
dPrint('Exit code: ${result.exitCode}');
dPrint('stdout: ${result.stdout}');
dPrint('stderr: ${result.stderr}');
} else {
ProcessResult result = await Process.run("cmd.exe", [
'/C',
'Start',
'"StarCitizen"',
'/High',
'/Affinity',
'$processorAffinity',
launchExe,
...args
]);
dPrint('Exit code: ${result.exitCode}');
dPrint('stdout: ${result.stdout}');
dPrint('stderr: ${result.stderr}');
}
final launchFile = File("$installPath\\loginData.json");
if (await launchFile.exists()) {
await launchFile.delete();

View File

@ -228,11 +228,13 @@ class LoginDialogModel extends BaseUIModel {
await SystemHelper.getCpuAffinity(inputGameLaunchECore);
// TODO
homeUIModel.doLaunchGame(
'$installPath\\$executable',
["-no_login_dialog", ...launchOptions.toString().split(" ")],
installPath);
installPath,
processorAffinity);
await Future.delayed(const Duration(seconds: 1));
Navigator.pop(context!);
}
String getChannelID() {

View File

@ -19,7 +19,7 @@ class SettingUI extends BaseUI<SettingUIModel> {
onTap: model.onResetAutoLogin),
const SizedBox(height: 12),
makeSettingsItem(const Icon(FontAwesomeIcons.microchip),
"启动游戏时忽略能效核心( 适用于Intel 12 ~ 14th处理器 ",
"启动游戏时忽略能效核心( 适用于Intel 12+ 处理器 ",
subTitle:
"已设置的核心数量:${model.inputGameLaunchECore} 设置需要忽略的处理器的能效心数量盒子将在使用启动游戏功能时为您修改游戏所运行的CPU参数当为 0 时不启用此功能 ",
onTap: model.setGameLaunchECore),