mirror of
https://github.com/StarCitizenToolBox/app.git
synced 2026-01-14 12:10:28 +00:00
feat: To avoid PTU information becoming outdated
This commit is contained in:
parent
cf3e67838d
commit
50c8d294f9
@ -1,7 +1,7 @@
|
|||||||
class ConstConf {
|
class ConstConf {
|
||||||
static const String appVersion = "3.0.0 Beta5";
|
static const String appVersion = "3.0.0 Beta6";
|
||||||
static const int appVersionCode = 75;
|
static const int appVersionCode = 76;
|
||||||
static const String appVersionDate = "2025-12-06";
|
static const String appVersionDate = "2025-12-13";
|
||||||
static const _gameChannels = ["LIVE", "4.0_PREVIEW", "PTU", "EPTU", "TECH-PREVIEW", "HOTFIX"];
|
static const _gameChannels = ["LIVE", "4.0_PREVIEW", "PTU", "EPTU", "TECH-PREVIEW", "HOTFIX"];
|
||||||
static const isMSE = String.fromEnvironment("MSE", defaultValue: "false") == "true";
|
static const isMSE = String.fromEnvironment("MSE", defaultValue: "false") == "true";
|
||||||
static const win32AppId = isMSE
|
static const win32AppId = isMSE
|
||||||
|
|||||||
@ -46,10 +46,7 @@ abstract class LocalizationUIState with _$LocalizationUIState {
|
|||||||
|
|
||||||
@riverpod
|
@riverpod
|
||||||
class LocalizationUIModel extends _$LocalizationUIModel {
|
class LocalizationUIModel extends _$LocalizationUIModel {
|
||||||
static const languageSupport = {
|
static const languageSupport = {"chinese_(simplified)": NoL10n.langZHS, "chinese_(traditional)": NoL10n.langZHT};
|
||||||
"chinese_(simplified)": NoL10n.langZHS,
|
|
||||||
"chinese_(traditional)": NoL10n.langZHT,
|
|
||||||
};
|
|
||||||
|
|
||||||
Directory get _downloadDir => Directory("${appGlobalState.applicationSupportDir}\\Localizations");
|
Directory get _downloadDir => Directory("${appGlobalState.applicationSupportDir}\\Localizations");
|
||||||
|
|
||||||
@ -120,12 +117,29 @@ class LocalizationUIModel extends _$LocalizationUIModel {
|
|||||||
if (_isDisposed) return;
|
if (_isDisposed) return;
|
||||||
if (lang == state.selectedLanguage) {
|
if (lang == state.selectedLanguage) {
|
||||||
final apiLocalizationData = <String, ScLocalizationData>{};
|
final apiLocalizationData = <String, ScLocalizationData>{};
|
||||||
for (var element in l) {
|
final isPTU = !_scInstallPath.contains("LIVE");
|
||||||
final isPTU = !_scInstallPath.contains("LIVE");
|
|
||||||
if (isPTU && element.gameChannel == "PTU") {
|
if (isPTU) {
|
||||||
apiLocalizationData[element.versionName ?? ""] = element;
|
for (var element in l) {
|
||||||
} else if (!isPTU && element.gameChannel == "PU") {
|
if (element.gameChannel == "PTU") {
|
||||||
apiLocalizationData[element.versionName ?? ""] = element;
|
var e = element;
|
||||||
|
// 获取 PU 相同 info 的数据
|
||||||
|
final puE = l.firstWhere((element) => element.info == e.info && element.gameChannel == "PU");
|
||||||
|
if (puE != null) {
|
||||||
|
// 检查是否比 PTU 新
|
||||||
|
if (puE.updateAt?.compareTo(e.updateAt ?? "") > 0) {
|
||||||
|
e = puE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
apiLocalizationData[element.versionName ?? ""] = e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// LIVE 频道:只展示 PU 数据
|
||||||
|
for (var element in l) {
|
||||||
|
if (element.gameChannel == "PU") {
|
||||||
|
apiLocalizationData[element.versionName ?? ""] = element;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_isDisposed) return;
|
if (_isDisposed) return;
|
||||||
@ -146,9 +160,12 @@ class LocalizationUIModel extends _$LocalizationUIModel {
|
|||||||
final cfgString = await userCfgFile.readAsString();
|
final cfgString = await userCfgFile.readAsString();
|
||||||
if (cfgString.contains("g_language") && !cfgString.contains("g_language=${state.selectedLanguage}")) {
|
if (cfgString.contains("g_language") && !cfgString.contains("g_language=${state.selectedLanguage}")) {
|
||||||
if (!context.mounted) return;
|
if (!context.mounted) return;
|
||||||
final ok = await showConfirmDialogs(context, S.current.localization_info_remove_incompatible_translation_params,
|
final ok = await showConfirmDialogs(
|
||||||
Text(S.current.localization_info_incompatible_translation_params_warning),
|
context,
|
||||||
constraints: BoxConstraints(maxWidth: MediaQuery.of(context).size.width * .35));
|
S.current.localization_info_remove_incompatible_translation_params,
|
||||||
|
Text(S.current.localization_info_incompatible_translation_params_warning),
|
||||||
|
constraints: BoxConstraints(maxWidth: MediaQuery.of(context).size.width * .35),
|
||||||
|
);
|
||||||
if (ok == true) {
|
if (ok == true) {
|
||||||
var finalString = "";
|
var finalString = "";
|
||||||
for (var item in cfgString.split("\n")) {
|
for (var item in cfgString.split("\n")) {
|
||||||
@ -264,8 +281,9 @@ class LocalizationUIModel extends _$LocalizationUIModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (communityInputMethodVersion != null) {
|
if (communityInputMethodVersion != null) {
|
||||||
globalIni
|
globalIni.write(
|
||||||
.write("_starcitizen_doctor_localization_community_input_method_version=$communityInputMethodVersion\n");
|
"_starcitizen_doctor_localization_community_input_method_version=$communityInputMethodVersion\n",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (communityInputMethodSupportData != null) {
|
if (communityInputMethodSupportData != null) {
|
||||||
for (var line in communityInputMethodSupportData.split("\n")) {
|
for (var line in communityInputMethodSupportData.split("\n")) {
|
||||||
@ -283,9 +301,12 @@ class LocalizationUIModel extends _$LocalizationUIModel {
|
|||||||
if ((context?.mounted ?? false) && isEnableVehicleSorting) {
|
if ((context?.mounted ?? false) && isEnableVehicleSorting) {
|
||||||
if (!context!.mounted) return;
|
if (!context!.mounted) return;
|
||||||
final iniStringDataVN = ValueNotifier(iniStringData);
|
final iniStringDataVN = ValueNotifier(iniStringData);
|
||||||
final ok = await showConfirmDialogs(context, S.current.tools_vehicle_sorting_title, VehicleSortingDialogUi(iniStringData: iniStringDataVN),constraints: BoxConstraints(
|
final ok = await showConfirmDialogs(
|
||||||
maxWidth: MediaQuery.of(context).size.width * .75,
|
context,
|
||||||
));
|
S.current.tools_vehicle_sorting_title,
|
||||||
|
VehicleSortingDialogUi(iniStringData: iniStringDataVN),
|
||||||
|
constraints: BoxConstraints(maxWidth: MediaQuery.of(context).size.width * .75),
|
||||||
|
);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
iniStringData = iniStringDataVN.value;
|
iniStringData = iniStringDataVN.value;
|
||||||
}
|
}
|
||||||
@ -354,8 +375,12 @@ class LocalizationUIModel extends _$LocalizationUIModel {
|
|||||||
return ("", "");
|
return ("", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
Future? doRemoteInstall(BuildContext context, ScLocalizationData value,
|
Future? doRemoteInstall(
|
||||||
{bool isEnableCommunityInputMethod = false, bool isEnableVehicleSorting = false}) async {
|
BuildContext context,
|
||||||
|
ScLocalizationData value, {
|
||||||
|
bool isEnableCommunityInputMethod = false,
|
||||||
|
bool isEnableVehicleSorting = false,
|
||||||
|
}) async {
|
||||||
AnalyticsApi.touch("install_localization");
|
AnalyticsApi.touch("install_localization");
|
||||||
|
|
||||||
final savePath = File("${_downloadDir.absolute.path}\\${value.versionName}.sclang");
|
final savePath = File("${_downloadDir.absolute.path}\\${value.versionName}.sclang");
|
||||||
@ -391,7 +416,8 @@ class LocalizationUIModel extends _$LocalizationUIModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<String> downloadOrGetCachedCommunityInputMethodSupportFile(
|
Future<String> downloadOrGetCachedCommunityInputMethodSupportFile(
|
||||||
InputMethodApiLanguageData communityInputMethodData) async {
|
InputMethodApiLanguageData communityInputMethodData,
|
||||||
|
) async {
|
||||||
final lang = state.selectedLanguage ?? "_";
|
final lang = state.selectedLanguage ?? "_";
|
||||||
final box = await Hive.openBox("community_input_method_data");
|
final box = await Hive.openBox("community_input_method_data");
|
||||||
final cachedVersion = box.get("${lang}_version");
|
final cachedVersion = box.get("${lang}_version");
|
||||||
@ -463,13 +489,16 @@ class LocalizationUIModel extends _$LocalizationUIModel {
|
|||||||
|
|
||||||
Future<void> _updateStatus() async {
|
Future<void> _updateStatus() async {
|
||||||
final iniPath = "${_scDataDir.absolute.path}\\Localization\\${state.selectedLanguage}\\global.ini";
|
final iniPath = "${_scDataDir.absolute.path}\\Localization\\${state.selectedLanguage}\\global.ini";
|
||||||
final patchStatus =
|
final patchStatus = MapEntry(
|
||||||
MapEntry(await _getLangCfgEnableLang(lang: state.selectedLanguage!), await _getInstalledIniVersion(iniPath));
|
await _getLangCfgEnableLang(lang: state.selectedLanguage!),
|
||||||
|
await _getInstalledIniVersion(iniPath),
|
||||||
|
);
|
||||||
final isInstalledAdvanced = await _checkAdvancedStatus(iniPath);
|
final isInstalledAdvanced = await _checkAdvancedStatus(iniPath);
|
||||||
final installedCommunityInputMethodSupportVersion = await getInstalledCommunityInputMethodSupportVersion(iniPath);
|
final installedCommunityInputMethodSupportVersion = await getInstalledCommunityInputMethodSupportVersion(iniPath);
|
||||||
|
|
||||||
dPrint(
|
dPrint(
|
||||||
"_updateStatus updateStatus: $patchStatus , isInstalledAdvanced: $isInstalledAdvanced ,installedCommunityInputMethodSupportVersion: $installedCommunityInputMethodSupportVersion");
|
"_updateStatus updateStatus: $patchStatus , isInstalledAdvanced: $isInstalledAdvanced ,installedCommunityInputMethodSupportVersion: $installedCommunityInputMethodSupportVersion",
|
||||||
|
);
|
||||||
if (_isDisposed) return;
|
if (_isDisposed) return;
|
||||||
state = state.copyWith(
|
state = state.copyWith(
|
||||||
patchStatus: patchStatus,
|
patchStatus: patchStatus,
|
||||||
@ -589,10 +618,11 @@ class LocalizationUIModel extends _$LocalizationUIModel {
|
|||||||
}
|
}
|
||||||
await installFormString(StringBuffer(localIniString), versioName, isEnableCommunityInputMethod: true);
|
await installFormString(StringBuffer(localIniString), versioName, isEnableCommunityInputMethod: true);
|
||||||
await win32.sendNotify(
|
await win32.sendNotify(
|
||||||
summary: S.current.input_method_support_updated,
|
summary: S.current.input_method_support_updated,
|
||||||
body: S.current.input_method_support_updated_to_version(cloudVersion),
|
body: S.current.input_method_support_updated_to_version(cloudVersion),
|
||||||
appName: S.current.home_title_app_name,
|
appName: S.current.home_title_app_name,
|
||||||
appId: ConstConf.win32AppId);
|
appId: ConstConf.win32AppId,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -601,7 +631,10 @@ class LocalizationUIModel extends _$LocalizationUIModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> onRemoteInsTall(
|
Future<void> onRemoteInsTall(
|
||||||
BuildContext context, MapEntry<String, ScLocalizationData> item, LocalizationUIState state) async {
|
BuildContext context,
|
||||||
|
MapEntry<String, ScLocalizationData> item,
|
||||||
|
LocalizationUIState state,
|
||||||
|
) async {
|
||||||
final appBox = Hive.box("app_conf");
|
final appBox = Hive.box("app_conf");
|
||||||
bool enableCommunityInputMethod = state.communityInputMethodLanguageData != null;
|
bool enableCommunityInputMethod = state.communityInputMethodLanguageData != null;
|
||||||
bool isEnableVehicleSorting = appBox.get("vehicle_sorting", defaultValue: false) ?? false;
|
bool isEnableVehicleSorting = appBox.get("vehicle_sorting", defaultValue: false) ?? false;
|
||||||
@ -652,9 +685,7 @@ class LocalizationUIModel extends _$LocalizationUIModel {
|
|||||||
SizedBox(height: 12),
|
SizedBox(height: 12),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(S.current.input_method_install_community_input_method_support),
|
||||||
S.current.input_method_install_community_input_method_support,
|
|
||||||
),
|
|
||||||
Spacer(),
|
Spacer(),
|
||||||
StatefulBuilder(
|
StatefulBuilder(
|
||||||
builder: (BuildContext context, void Function(void Function()) setState) {
|
builder: (BuildContext context, void Function(void Function()) setState) {
|
||||||
@ -668,15 +699,13 @@ class LocalizationUIModel extends _$LocalizationUIModel {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
)
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
SizedBox(height: 12),
|
SizedBox(height: 12),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(S.current.tools_vehicle_sorting_title),
|
||||||
S.current.tools_vehicle_sorting_title,
|
|
||||||
),
|
|
||||||
Spacer(),
|
Spacer(),
|
||||||
StatefulBuilder(
|
StatefulBuilder(
|
||||||
builder: (BuildContext context, void Function(void Function()) setState) {
|
builder: (BuildContext context, void Function(void Function()) setState) {
|
||||||
@ -689,7 +718,7 @@ class LocalizationUIModel extends _$LocalizationUIModel {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
)
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user