mirror of
https://mirror.ghproxy.com/https://github.com/StarCitizenToolBox/app.git
synced 2024-12-23 05:23:44 +08:00
update Cpu Affinity
This commit is contained in:
parent
5ecfc82506
commit
faec463478
@ -201,4 +201,17 @@ foreach ($adapter in $adapterMemory) {
|
|||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
return totalSize;
|
return totalSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Future<int> getNumberOfLogicalProcessors() async {
|
||||||
|
final cpuNumberResult = await Process.run(powershellPath,
|
||||||
|
["(Get-WmiObject -Class Win32_Processor).NumberOfLogicalProcessors"]);
|
||||||
|
if (cpuNumberResult.exitCode != 0) return 0;
|
||||||
|
return int.tryParse(cpuNumberResult.stdout.toString().trim()) ?? 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<int?> getCpuAffinity(int eCoreCount) async {
|
||||||
|
final cpuNumber = await getNumberOfLogicalProcessors();
|
||||||
|
if (cpuNumber == 0) return null;
|
||||||
|
return (1 << cpuNumber) - (1 << eCoreCount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,8 @@ import 'package:flutter/foundation.dart';
|
|||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'dart:ui' as ui;
|
import 'dart:ui' as ui;
|
||||||
|
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
void dPrint(src) {
|
void dPrint(src) {
|
||||||
if (kDebugMode) {
|
if (kDebugMode) {
|
||||||
print(src);
|
print(src);
|
||||||
@ -58,6 +60,38 @@ Future<bool> showConfirmDialogs(
|
|||||||
return r == true;
|
return r == true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<String?> showInputDialogs(BuildContext context,
|
||||||
|
{required String title,
|
||||||
|
required String content,
|
||||||
|
BoxConstraints? constraints,
|
||||||
|
String? initialValue,
|
||||||
|
List<TextInputFormatter>? inputFormatters}) async {
|
||||||
|
String? userInput;
|
||||||
|
constraints ??=
|
||||||
|
BoxConstraints(maxWidth: MediaQuery.of(context).size.width * .38);
|
||||||
|
final ok = await showConfirmDialogs(
|
||||||
|
context,
|
||||||
|
title,
|
||||||
|
Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
if (content.isNotEmpty) Text(content),
|
||||||
|
const SizedBox(height: 6),
|
||||||
|
TextFormBox(
|
||||||
|
initialValue: initialValue,
|
||||||
|
onChanged: (str) {
|
||||||
|
userInput = str;
|
||||||
|
},
|
||||||
|
inputFormatters: inputFormatters,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
constraints: constraints);
|
||||||
|
if (ok == true) return userInput;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
Future showBaseDialog(BuildContext context,
|
Future showBaseDialog(BuildContext context,
|
||||||
{required String title,
|
{required String title,
|
||||||
required Widget content,
|
required Widget content,
|
||||||
|
@ -134,8 +134,7 @@ class HomeUIModel extends BaseUIModel {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
scInstallPaths = await SCLoggerHelper.getGameInstallPath(listData,
|
scInstallPaths = await SCLoggerHelper.getGameInstallPath(listData,
|
||||||
withVersion: ["LIVE", "PTU", "EPTU", "TECH-PREVIEW"],
|
withVersion: ["LIVE", "PTU", "EPTU"], checkExists: true);
|
||||||
checkExists: true);
|
|
||||||
if (scInstallPaths.isNotEmpty) {
|
if (scInstallPaths.isNotEmpty) {
|
||||||
scInstalledPath = scInstallPaths.first;
|
scInstalledPath = scInstallPaths.first;
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ class LoginDialog extends BaseUI<LoginDialogModel> {
|
|||||||
color: Colors.white.withOpacity(.6),
|
color: Colors.white.withOpacity(.6),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
] else if (model.loginStatus == 2) ...[
|
] else if (model.loginStatus == 2 || model.loginStatus == 3) ...[
|
||||||
Center(
|
Center(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
@ -76,7 +76,9 @@ class LoginDialog extends BaseUI<LoginDialogModel> {
|
|||||||
fontSize: 24, fontWeight: FontWeight.bold),
|
fontSize: 24, fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 32),
|
const SizedBox(height: 32),
|
||||||
const Text("正在为您启动游戏..."),
|
Text(model.loginStatus == 2
|
||||||
|
? "正在为您启动游戏..."
|
||||||
|
: "正在等待优化CPU参数..."),
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
const ProgressRing(),
|
const ProgressRing(),
|
||||||
],
|
],
|
||||||
|
@ -7,6 +7,7 @@ import 'package:hive/hive.dart';
|
|||||||
import 'package:jwt_decode/jwt_decode.dart';
|
import 'package:jwt_decode/jwt_decode.dart';
|
||||||
import 'package:local_auth/local_auth.dart';
|
import 'package:local_auth/local_auth.dart';
|
||||||
import 'package:starcitizen_doctor/base/ui_model.dart';
|
import 'package:starcitizen_doctor/base/ui_model.dart';
|
||||||
|
import 'package:starcitizen_doctor/common/helper/system_helper.dart';
|
||||||
import 'package:starcitizen_doctor/common/win32/credentials.dart';
|
import 'package:starcitizen_doctor/common/win32/credentials.dart';
|
||||||
import 'package:starcitizen_doctor/ui/home/home_ui_model.dart';
|
import 'package:starcitizen_doctor/ui/home/home_ui_model.dart';
|
||||||
import 'package:starcitizen_doctor/ui/home/webview/webview.dart';
|
import 'package:starcitizen_doctor/ui/home/webview/webview.dart';
|
||||||
@ -217,12 +218,21 @@ class LoginDialogModel extends BaseUIModel {
|
|||||||
await launchFile.writeAsString(json.encode(launchData));
|
await launchFile.writeAsString(json.encode(launchData));
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
await Future.delayed(const Duration(seconds: 1));
|
await Future.delayed(const Duration(seconds: 1));
|
||||||
|
|
||||||
|
await Future.delayed(const Duration(seconds: 3));
|
||||||
|
final confBox = await Hive.openBox("app_conf");
|
||||||
|
final inputGameLaunchECore = int.tryParse(
|
||||||
|
confBox.get("gameLaunch_eCore_count", defaultValue: "0")) ??
|
||||||
|
0;
|
||||||
|
final processorAffinity =
|
||||||
|
await SystemHelper.getCpuAffinity(inputGameLaunchECore);
|
||||||
|
|
||||||
|
// TODO 更新启动方式
|
||||||
|
|
||||||
homeUIModel.doLaunchGame(
|
homeUIModel.doLaunchGame(
|
||||||
'$installPath\\$executable',
|
'$installPath\\$executable',
|
||||||
["-no_login_dialog", ...launchOptions.toString().split(" ")],
|
["-no_login_dialog", ...launchOptions.toString().split(" ")],
|
||||||
installPath);
|
installPath);
|
||||||
await Future.delayed(const Duration(seconds: 3));
|
|
||||||
Navigator.pop(context!);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String getChannelID() {
|
String getChannelID() {
|
||||||
@ -232,8 +242,6 @@ class LoginDialogModel extends BaseUIModel {
|
|||||||
return "PTU";
|
return "PTU";
|
||||||
} else if (installPath.endsWith("\\EPTU")) {
|
} else if (installPath.endsWith("\\EPTU")) {
|
||||||
return "EPTU";
|
return "EPTU";
|
||||||
} else if (installPath.endsWith("\\TECH-PREVIEW")) {
|
|
||||||
return "TECH-PREVIEW";
|
|
||||||
}
|
}
|
||||||
return "LIVE";
|
return "LIVE";
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
import 'package:starcitizen_doctor/base/ui.dart';
|
import 'package:starcitizen_doctor/base/ui.dart';
|
||||||
import 'package:starcitizen_doctor/common/conf.dart';
|
import 'package:starcitizen_doctor/common/conf.dart';
|
||||||
import 'package:starcitizen_doctor/ui/settings/settings_ui_model.dart';
|
import 'package:starcitizen_doctor/ui/settings/settings_ui_model.dart';
|
||||||
@ -11,12 +12,18 @@ class SettingUI extends BaseUI<SettingUIModel> {
|
|||||||
margin: const EdgeInsets.all(16),
|
margin: const EdgeInsets.all(16),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
if (AppConf.isMSE)
|
if (AppConf.isMSE) ...[
|
||||||
makeSettingsItem(const Icon(FluentIcons.reset_device), "重置自动密码填充",
|
makeSettingsItem(const Icon(FluentIcons.reset_device), "重置自动密码填充",
|
||||||
subTitle:
|
subTitle:
|
||||||
"启用:${model.isEnableAutoLogin ? "已启用" : "已禁用"} 设备支持:${model.isDeviceSupportWinHello ? "支持" : "不支持"} 邮箱:${model.autoLoginEmail} 密码:${model.isEnableAutoLoginPwd ? "已加密保存" : "未保存"}",
|
"启用:${model.isEnableAutoLogin ? "已启用" : "已禁用"} 设备支持:${model.isDeviceSupportWinHello ? "支持" : "不支持"} 邮箱:${model.autoLoginEmail} 密码:${model.isEnableAutoLoginPwd ? "已加密保存" : "未保存"}",
|
||||||
onTap: model.onResetAutoLogin)
|
onTap: model.onResetAutoLogin),
|
||||||
else
|
const SizedBox(height: 12),
|
||||||
|
makeSettingsItem(const Icon(FontAwesomeIcons.microchip),
|
||||||
|
"启动游戏时忽略能效核心( 适用于Intel 12 ~ 14th处理器 )",
|
||||||
|
subTitle:
|
||||||
|
"已设置的核心数量:${model.inputGameLaunchECore} ( 设置需要忽略的处理器的能效心数量,盒子将在使用启动游戏功能时为您修改游戏所运行的CPU参数,当为 0 时不启用此功能 )",
|
||||||
|
onTap: model.setGameLaunchECore),
|
||||||
|
] else
|
||||||
const Text("暂无设置项"),
|
const Text("暂无设置项"),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
import 'package:local_auth/local_auth.dart';
|
import 'package:local_auth/local_auth.dart';
|
||||||
import 'package:starcitizen_doctor/base/ui_model.dart';
|
import 'package:starcitizen_doctor/base/ui_model.dart';
|
||||||
@ -10,6 +11,7 @@ class SettingUIModel extends BaseUIModel {
|
|||||||
String autoLoginEmail = "-";
|
String autoLoginEmail = "-";
|
||||||
bool isEnableAutoLogin = false;
|
bool isEnableAutoLogin = false;
|
||||||
bool isEnableAutoLoginPwd = false;
|
bool isEnableAutoLoginPwd = false;
|
||||||
|
String inputGameLaunchECore = "0";
|
||||||
|
|
||||||
@override
|
@override
|
||||||
loadData() async {
|
loadData() async {
|
||||||
@ -18,6 +20,7 @@ class SettingUIModel extends BaseUIModel {
|
|||||||
notifyListeners();
|
notifyListeners();
|
||||||
if (AppConf.isMSE) {
|
if (AppConf.isMSE) {
|
||||||
_updateAutoLoginAccount();
|
_updateAutoLoginAccount();
|
||||||
|
_updateGameLaunchECore();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,4 +44,25 @@ class SettingUIModel extends BaseUIModel {
|
|||||||
userBox.get("account_pwd_encrypted", defaultValue: "") != "";
|
userBox.get("account_pwd_encrypted", defaultValue: "") != "";
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> setGameLaunchECore() async {
|
||||||
|
final userBox = await Hive.openBox("app_conf");
|
||||||
|
final defaultInput =
|
||||||
|
userBox.get("gameLaunch_eCore_count", defaultValue: "0");
|
||||||
|
final input = await showInputDialogs(context!,
|
||||||
|
title: "请输入要忽略的 CPU 核心数",
|
||||||
|
content: "",
|
||||||
|
initialValue: defaultInput,
|
||||||
|
inputFormatters: [FilteringTextInputFormatter.digitsOnly]);
|
||||||
|
if (input == null) return;
|
||||||
|
userBox.put("gameLaunch_eCore_count", input);
|
||||||
|
reloadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future _updateGameLaunchECore() async {
|
||||||
|
final userBox = await Hive.openBox("app_conf");
|
||||||
|
inputGameLaunchECore =
|
||||||
|
userBox.get("gameLaunch_eCore_count", defaultValue: "0");
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -186,8 +186,7 @@ class ToolsUIModel extends BaseUIModel {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
scInstallPaths = await SCLoggerHelper.getGameInstallPath(listData,
|
scInstallPaths = await SCLoggerHelper.getGameInstallPath(listData,
|
||||||
checkExists: false,
|
checkExists: false, withVersion: ["LIVE", "PTU", "EPTU"]);
|
||||||
withVersion: ["LIVE", "PTU", "EPTU", "TECH-PREVIEW"]);
|
|
||||||
if (scInstallPaths.isNotEmpty) {
|
if (scInstallPaths.isNotEmpty) {
|
||||||
scInstalledPath = scInstallPaths.first;
|
scInstalledPath = scInstallPaths.first;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user