mirror of
https://mirror.ghproxy.com/https://github.com/StarCitizenToolBox/app.git
synced 2024-12-23 06:33:43 +08:00
检查 USER.cfg
This commit is contained in:
parent
659feeb42e
commit
d7c70d7efc
@ -67,13 +67,19 @@ class LocalizationUI extends BaseUI<LocalizationUIModel> {
|
|||||||
onPressed: model.doDelIniFile(),
|
onPressed: model.doDelIniFile(),
|
||||||
child: const Padding(
|
child: const Padding(
|
||||||
padding: EdgeInsets.all(4),
|
padding: EdgeInsets.all(4),
|
||||||
child: Icon(FluentIcons.delete),
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Icon(FluentIcons.delete),
|
||||||
|
SizedBox(width: 6),
|
||||||
|
Text("删除"),
|
||||||
|
],
|
||||||
|
),
|
||||||
)),
|
)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
]),
|
]),
|
||||||
makeListContainer("最新版本", [
|
makeListContainer("社区汉化", [
|
||||||
if (model.apiLocalizationData == null)
|
if (model.apiLocalizationData == null)
|
||||||
makeLoading(context)
|
makeLoading(context)
|
||||||
else if (model.apiLocalizationData!.isEmpty)
|
else if (model.apiLocalizationData!.isEmpty)
|
||||||
@ -88,15 +94,38 @@ class LocalizationUI extends BaseUI<LocalizationUIModel> {
|
|||||||
for (final item in model.apiLocalizationData!.entries)
|
for (final item in model.apiLocalizationData!.entries)
|
||||||
makeRemoteList(context, model, item),
|
makeRemoteList(context, model, item),
|
||||||
]),
|
]),
|
||||||
makeListContainer("自定义", [
|
const SizedBox(height: 12),
|
||||||
|
IconButton(
|
||||||
|
icon: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Icon(model.enableCustomize
|
||||||
|
? FluentIcons.chevron_up
|
||||||
|
: FluentIcons.chevron_down),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
const Text("高级功能"),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
model.enableCustomize = !model.enableCustomize;
|
||||||
|
model.notifyListeners();
|
||||||
|
}),
|
||||||
|
AnimatedSize(
|
||||||
|
duration: const Duration(milliseconds: 130),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
model.enableCustomize
|
||||||
|
? makeListContainer("自定义文本", [
|
||||||
if (model.customizeList == null)
|
if (model.customizeList == null)
|
||||||
makeLoading(context)
|
makeLoading(context)
|
||||||
else if (model.customizeList!.isEmpty)
|
else if (model.customizeList!.isEmpty)
|
||||||
Center(
|
Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
"请将 任意名称.ini 文件放入 Customize_ini 文件夹,即可使用此工具快捷安装 / 切换。",
|
"暂无自定义文本",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 13, color: Colors.white.withOpacity(.8)),
|
fontSize: 13,
|
||||||
|
color: Colors.white.withOpacity(.8)),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
else ...[
|
else ...[
|
||||||
@ -117,7 +146,10 @@ class LocalizationUI extends BaseUI<LocalizationUIModel> {
|
|||||||
onPressed: model.doLocalInstall(file),
|
onPressed: model.doLocalInstall(file),
|
||||||
child: const Padding(
|
child: const Padding(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
left: 8, right: 8, top: 4, bottom: 4),
|
left: 8,
|
||||||
|
right: 8,
|
||||||
|
top: 4,
|
||||||
|
bottom: 4),
|
||||||
child: Text("安装"),
|
child: Text("安装"),
|
||||||
))
|
))
|
||||||
],
|
],
|
||||||
@ -128,9 +160,21 @@ class LocalizationUI extends BaseUI<LocalizationUIModel> {
|
|||||||
onPressed: () => model.openDir(),
|
onPressed: () => model.openDir(),
|
||||||
child: const Padding(
|
child: const Padding(
|
||||||
padding: EdgeInsets.all(4),
|
padding: EdgeInsets.all(4),
|
||||||
child: Icon(FluentIcons.folder_open),
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Icon(FluentIcons.folder_open),
|
||||||
|
SizedBox(width: 6),
|
||||||
|
Text("打开文件夹"),
|
||||||
|
],
|
||||||
|
),
|
||||||
)),
|
)),
|
||||||
]),
|
])
|
||||||
|
: SizedBox(
|
||||||
|
width: MediaQuery.of(context).size.width,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -190,9 +234,21 @@ class LocalizationUI extends BaseUI<LocalizationUIModel> {
|
|||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.only(
|
||||||
left: 8, right: 8, top: 4, bottom: 4),
|
left: 8, right: 8, top: 4, bottom: 4),
|
||||||
child: Text(isInstalled
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(right: 6),
|
||||||
|
child: Icon(isInstalled
|
||||||
|
? FluentIcons.check_mark
|
||||||
|
: (item.value.enable ?? false)
|
||||||
|
? FluentIcons.download
|
||||||
|
: FluentIcons.disable_updates),
|
||||||
|
),
|
||||||
|
Text(isInstalled
|
||||||
? "已安装"
|
? "已安装"
|
||||||
: ((item.value.enable ?? false) ? "安装" : "不可用")),
|
: ((item.value.enable ?? false) ? "安装" : "不可用")),
|
||||||
|
],
|
||||||
|
),
|
||||||
)),
|
)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -41,6 +41,8 @@ class LocalizationUIModel extends BaseUIModel {
|
|||||||
|
|
||||||
StreamSubscription? customizeDirListenSub;
|
StreamSubscription? customizeDirListenSub;
|
||||||
|
|
||||||
|
bool enableCustomize = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initModel() {
|
void initModel() {
|
||||||
selectedLanguage = languageSupport.entries.first.key;
|
selectedLanguage = languageSupport.entries.first.key;
|
||||||
@ -56,6 +58,7 @@ class LocalizationUIModel extends BaseUIModel {
|
|||||||
@override
|
@override
|
||||||
Future loadData() async {
|
Future loadData() async {
|
||||||
await _updateStatus();
|
await _updateStatus();
|
||||||
|
_checkUserCfg();
|
||||||
_scanCustomizeDir();
|
_scanCustomizeDir();
|
||||||
final l =
|
final l =
|
||||||
await handleError(() => Api.getScLocalizationData(selectedLanguage));
|
await handleError(() => Api.getScLocalizationData(selectedLanguage));
|
||||||
@ -263,6 +266,7 @@ class LocalizationUIModel extends BaseUIModel {
|
|||||||
"${scDataDir.absolute.path}\\Localization\\$selectedLanguage\\global.ini");
|
"${scDataDir.absolute.path}\\Localization\\$selectedLanguage\\global.ini");
|
||||||
return () async {
|
return () async {
|
||||||
if (await iniFile.exists()) await iniFile.delete();
|
if (await iniFile.exists()) await iniFile.delete();
|
||||||
|
await updateLangCfg(false);
|
||||||
await _updateStatus();
|
await _updateStatus();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -300,4 +304,33 @@ class LocalizationUIModel extends BaseUIModel {
|
|||||||
notifyListeners();
|
notifyListeners();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _checkUserCfg() async {
|
||||||
|
final userCfgFile = File("$scInstallPath\\USER.cfg");
|
||||||
|
if (await userCfgFile.exists()) {
|
||||||
|
final cfgString = await userCfgFile.readAsString();
|
||||||
|
if (cfgString.contains("g_language=") &&
|
||||||
|
!cfgString.contains("g_language=$selectedLanguage")) {
|
||||||
|
final ok = await showConfirmDialogs(
|
||||||
|
context!,
|
||||||
|
"是否移除不兼容的汉化参数",
|
||||||
|
const Text(
|
||||||
|
"USER.cfg 包含不兼容的汉化参数,这可能是以前的汉化文件的残留信息。\n\n这将可能导致汉化无效或乱码,点击确认为您一键移除(不会影响其他配置)。"),
|
||||||
|
constraints: BoxConstraints(
|
||||||
|
maxWidth: MediaQuery.of(context!).size.width * .35));
|
||||||
|
if (ok == true) {
|
||||||
|
var finalString = "";
|
||||||
|
for (var item in cfgString.split("\n")) {
|
||||||
|
if (!item.trim().startsWith("g_language=")) {
|
||||||
|
finalString = "$finalString$item\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await userCfgFile.delete();
|
||||||
|
await userCfgFile.create();
|
||||||
|
await userCfgFile.writeAsString(finalString, flush: true);
|
||||||
|
reloadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ dependencies:
|
|||||||
markdown_widget: ^2.2.0
|
markdown_widget: ^2.2.0
|
||||||
extended_image: ^8.1.1
|
extended_image: ^8.1.1
|
||||||
hyper_thread_downloader: ^1.0.5
|
hyper_thread_downloader: ^1.0.5
|
||||||
device_info_plus: ^10.0.0
|
device_info_plus: ^9.0.3
|
||||||
file_picker: ^5.5.0
|
file_picker: ^5.5.0
|
||||||
file_sizes: ^1.0.6
|
file_sizes: ^1.0.6
|
||||||
desktop_webview_window: ^0.2.3
|
desktop_webview_window: ^0.2.3
|
||||||
|
Loading…
Reference in New Issue
Block a user