mirror of
https://ghfast.top/https://github.com/StarCitizenToolBox/app.git
synced 2025-06-28 11:24:46 +08:00
新增自定义安装位置
新增根据现有安装位置推测其他版本位置
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:hive/hive.dart';
|
||||
|
||||
import '../utils/base_utils.dart';
|
||||
|
||||
class SCLoggerHelper {
|
||||
@ -48,33 +50,59 @@ class SCLoggerHelper {
|
||||
List<String> withVersion = const ["LIVE"]}) async {
|
||||
List<String> scInstallPaths = [];
|
||||
|
||||
for (var v in withVersion) {
|
||||
for (var i = listData.length - 1; i > 0; i--) {
|
||||
final m = listData[i];
|
||||
final info = m["[browser][info] "];
|
||||
if (info is String) {
|
||||
String installPath = "";
|
||||
if (info.contains("Installing Star Citizen $v")) {
|
||||
installPath = "${info.split(" at ")[1]}\\$v";
|
||||
}
|
||||
if (info.contains("Launching Star Citizen $v from")) {
|
||||
installPath = info
|
||||
.replaceAll("Launching Star Citizen $v from (", "")
|
||||
.replaceAll(")", "");
|
||||
}
|
||||
if (installPath.isNotEmpty && !scInstallPaths.contains(installPath)) {
|
||||
if (!checkExists) {
|
||||
dPrint("find installPath == $installPath");
|
||||
scInstallPaths.add(installPath);
|
||||
} else if (await File("$installPath/Bin64/StarCitizen.exe")
|
||||
.exists() &&
|
||||
await File("$installPath/Data.p4k").exists()) {
|
||||
dPrint("find installPath == $installPath");
|
||||
scInstallPaths.add(installPath);
|
||||
checkAndAddPath(String path, bool checkExists) async {
|
||||
if (path.isNotEmpty && !scInstallPaths.contains(path)) {
|
||||
if (!checkExists) {
|
||||
dPrint("find installPath == $path");
|
||||
scInstallPaths.add(path);
|
||||
} else if (await File("$path/Bin64/StarCitizen.exe").exists() &&
|
||||
await File("$path/Data.p4k").exists()) {
|
||||
dPrint("find installPath == $path");
|
||||
scInstallPaths.add(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final confBox = await Hive.openBox("app_conf");
|
||||
final path = confBox.get("custom_game_path");
|
||||
if (path != null && path != "") {
|
||||
for (var v in withVersion) {
|
||||
await checkAndAddPath("$path\\$v", checkExists);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
for (var v in withVersion) {
|
||||
for (var i = listData.length - 1; i > 0; i--) {
|
||||
final m = listData[i];
|
||||
final info = m["[browser][info] "];
|
||||
if (info is String) {
|
||||
String installPath = "";
|
||||
if (info.contains("Installing Star Citizen $v")) {
|
||||
installPath = "${info.split(" at ")[1]}\\$v";
|
||||
}
|
||||
if (info.contains("Launching Star Citizen $v from")) {
|
||||
installPath = info
|
||||
.replaceAll("Launching Star Citizen $v from (", "")
|
||||
.replaceAll(")", "");
|
||||
}
|
||||
await checkAndAddPath(installPath, checkExists);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
dPrint(e);
|
||||
if (scInstallPaths.isEmpty) rethrow;
|
||||
}
|
||||
|
||||
if (scInstallPaths.isNotEmpty) {
|
||||
// 动态检测更多位置
|
||||
for (var fileName in List.from(scInstallPaths)) {
|
||||
for (var v in withVersion) {
|
||||
await checkAndAddPath(
|
||||
fileName.toString().replaceAll("\\$v", ""), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return scInstallPaths;
|
||||
|
@ -1,5 +1,6 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:starcitizen_doctor/common/utils/base_utils.dart';
|
||||
|
||||
class SystemHelper {
|
||||
@ -79,6 +80,14 @@ class SystemHelper {
|
||||
|
||||
/// 获取 RSI 启动器 目录
|
||||
static Future<String> getRSILauncherPath() async {
|
||||
final confBox = await Hive.openBox("app_conf");
|
||||
final path = confBox.get("custom_launcher_path");
|
||||
if (path != null && path != "") {
|
||||
if (await File(path).exists()) {
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, String> envVars = Platform.environment;
|
||||
final programDataPath = envVars["programdata"];
|
||||
final rsiFilePath =
|
||||
|
Reference in New Issue
Block a user