mirror of
https://github.com/StarCitizenToolBox/app.git
synced 2026-01-14 12:10:28 +00:00
fix: 高级汉化,性能优化 页面故障
This commit is contained in:
parent
80f87a8337
commit
64d5e27a72
@ -28,9 +28,7 @@ class InputMethodDialogUI extends HookConsumerWidget {
|
|||||||
}, const []);
|
}, const []);
|
||||||
|
|
||||||
return ContentDialog(
|
return ContentDialog(
|
||||||
constraints: BoxConstraints(
|
constraints: BoxConstraints(maxWidth: MediaQuery.of(context).size.width * .8),
|
||||||
maxWidth: MediaQuery.of(context).size.width * .8,
|
|
||||||
),
|
|
||||||
title: makeTitle(context, state, model, destTextCtrl),
|
title: makeTitle(context, state, model, destTextCtrl),
|
||||||
content: state.keyMaps == null
|
content: state.keyMaps == null
|
||||||
? makeLoading(context)
|
? makeLoading(context)
|
||||||
@ -47,19 +45,17 @@ class InputMethodDialogUI extends HookConsumerWidget {
|
|||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(3),
|
padding: const EdgeInsets.all(3),
|
||||||
child: Text(
|
child: Text(
|
||||||
S.current.input_method_online_version_prompt,
|
S.current.input_method_online_version_prompt,
|
||||||
style: TextStyle(
|
style: TextStyle(color: Color(0xff4ca0e0), fontSize: 12),
|
||||||
color: Color(0xff4ca0e0),
|
|
||||||
fontSize: 12,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
onTap: () {
|
),
|
||||||
launchUrlString("https://ime.citizenwiki.cn/");
|
onTap: () {
|
||||||
}),
|
launchUrlString("https://ime.citizenwiki.cn/");
|
||||||
|
},
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
SizedBox(height: 12),
|
SizedBox(height: 12),
|
||||||
@ -67,14 +63,12 @@ class InputMethodDialogUI extends HookConsumerWidget {
|
|||||||
placeholder: S.current.input_method_input_placeholder,
|
placeholder: S.current.input_method_input_placeholder,
|
||||||
controller: srcTextCtrl,
|
controller: srcTextCtrl,
|
||||||
maxLines: 5,
|
maxLines: 5,
|
||||||
placeholderStyle:
|
placeholderStyle: TextStyle(color: Colors.white.withValues(alpha: .6)),
|
||||||
TextStyle(color: Colors.white.withValues(alpha: .6)),
|
|
||||||
style: TextStyle(fontSize: 16, color: Colors.white),
|
style: TextStyle(fontSize: 16, color: Colors.white),
|
||||||
onChanged: (str) async {
|
onChanged: (str) async {
|
||||||
final text = model.onTextChange("src", str);
|
final text = model.onTextChange("src", str);
|
||||||
destTextCtrl.text = text ?? "";
|
destTextCtrl.text = text ?? "";
|
||||||
if (text != null) {
|
if (text != null) {}
|
||||||
}
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
SizedBox(height: 16),
|
SizedBox(height: 16),
|
||||||
@ -85,10 +79,7 @@ class InputMethodDialogUI extends HookConsumerWidget {
|
|||||||
if (state.isAutoTranslateWorking)
|
if (state.isAutoTranslateWorking)
|
||||||
SizedBox(width: 24, height: 24, child: ProgressRing())
|
SizedBox(width: 24, height: 24, child: ProgressRing())
|
||||||
else
|
else
|
||||||
SizedBox(
|
SizedBox(width: 24, height: 24, child: Icon(FluentIcons.down)),
|
||||||
width: 24,
|
|
||||||
height: 24,
|
|
||||||
child: Icon(FluentIcons.down))
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -97,8 +88,7 @@ class InputMethodDialogUI extends HookConsumerWidget {
|
|||||||
placeholder: S.current.input_method_encoded_text_placeholder,
|
placeholder: S.current.input_method_encoded_text_placeholder,
|
||||||
controller: destTextCtrl,
|
controller: destTextCtrl,
|
||||||
maxLines: 5,
|
maxLines: 5,
|
||||||
placeholderStyle:
|
placeholderStyle: TextStyle(color: Colors.white.withValues(alpha: .6)),
|
||||||
TextStyle(color: Colors.white.withValues(alpha: .6)),
|
|
||||||
style: TextStyle(fontSize: 16, color: Colors.white),
|
style: TextStyle(fontSize: 16, color: Colors.white),
|
||||||
enabled: true,
|
enabled: true,
|
||||||
onChanged: (str) {
|
onChanged: (str) {
|
||||||
@ -119,24 +109,15 @@ class InputMethodDialogUI extends HookConsumerWidget {
|
|||||||
if (serverState.isServerStartup)
|
if (serverState.isServerStartup)
|
||||||
Button(
|
Button(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
showDialog(
|
showDialog(context: context, builder: (BuildContext context) => ServerQrDialogUI());
|
||||||
context: context,
|
|
||||||
builder: (BuildContext context) =>
|
|
||||||
ServerQrDialogUI(),
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(serverState.serverAddressText ?? "...", style: TextStyle(fontSize: 14)),
|
||||||
serverState.serverAddressText ?? "...",
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 14,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
SizedBox(width: 14),
|
SizedBox(width: 14),
|
||||||
ToggleSwitch(
|
ToggleSwitch(
|
||||||
checked: serverState.isServerStartup,
|
checked: serverState.isServerStartup,
|
||||||
onChanged: (b) =>
|
onChanged: (b) => _onSwitchServer(context, b, serverModel),
|
||||||
_onSwitchServer(context, b, serverModel)),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -148,12 +129,9 @@ class InputMethodDialogUI extends HookConsumerWidget {
|
|||||||
child: Text(
|
child: Text(
|
||||||
textAlign: TextAlign.end,
|
textAlign: TextAlign.end,
|
||||||
S.current.input_method_disclaimer,
|
S.current.input_method_disclaimer,
|
||||||
style: TextStyle(
|
style: TextStyle(fontSize: 13, color: Colors.white.withValues(alpha: .6)),
|
||||||
fontSize: 13,
|
|
||||||
color: Colors.white.withValues(alpha: .6),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -161,80 +139,59 @@ class InputMethodDialogUI extends HookConsumerWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget makeTitle(BuildContext context, InputMethodDialogUIState state,
|
Widget makeTitle(
|
||||||
InputMethodDialogUIModel model, TextEditingController destTextCtrl) {
|
BuildContext context,
|
||||||
|
InputMethodDialogUIState state,
|
||||||
|
InputMethodDialogUIModel model,
|
||||||
|
TextEditingController destTextCtrl,
|
||||||
|
) {
|
||||||
return Row(
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(
|
icon: const Icon(FluentIcons.back, size: 22),
|
||||||
FluentIcons.back,
|
onPressed: () {
|
||||||
size: 22,
|
context.pop();
|
||||||
),
|
},
|
||||||
onPressed: () {
|
),
|
||||||
context.pop();
|
|
||||||
}),
|
|
||||||
const SizedBox(width: 12),
|
const SizedBox(width: 12),
|
||||||
Text(S.current.input_method_experimental_input_method),
|
Text(S.current.input_method_experimental_input_method),
|
||||||
Spacer(),
|
Spacer(),
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(S.current.input_method_auto_copy, style: TextStyle(fontSize: 14)),
|
||||||
S.current.input_method_auto_copy,
|
|
||||||
style: TextStyle(fontSize: 14),
|
|
||||||
),
|
|
||||||
SizedBox(width: 12),
|
SizedBox(width: 12),
|
||||||
ToggleSwitch(
|
ToggleSwitch(checked: state.enableAutoCopy, onChanged: model.onSwitchAutoCopy),
|
||||||
checked: state.enableAutoCopy,
|
|
||||||
onChanged: model.onSwitchAutoCopy),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
SizedBox(width: 24),
|
SizedBox(width: 24),
|
||||||
FilledButton(
|
FilledButton(
|
||||||
child: Padding(
|
child: Padding(padding: const EdgeInsets.all(6), child: Icon(FluentIcons.copy)),
|
||||||
padding: const EdgeInsets.all(6),
|
|
||||||
child: Icon(FluentIcons.copy),
|
|
||||||
),
|
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (destTextCtrl.text.isNotEmpty) {
|
if (destTextCtrl.text.isNotEmpty) {
|
||||||
Clipboard.setData(ClipboardData(text: destTextCtrl.text));
|
Clipboard.setData(ClipboardData(text: destTextCtrl.text));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _onSwitchServer(
|
Future<void> _onSwitchServer(BuildContext context, bool value, InputMethodServer serverModel) async {
|
||||||
BuildContext context, bool value, InputMethodServer serverModel) async {
|
|
||||||
if (value) {
|
if (value) {
|
||||||
final userOK = await showConfirmDialogs(
|
final userOK = await showConfirmDialogs(
|
||||||
context,
|
context,
|
||||||
S.current.input_method_confirm_enable_remote_input,
|
S.current.input_method_confirm_enable_remote_input,
|
||||||
Text(S.current.input_method_enable_remote_input_instructions));
|
Text(S.current.input_method_enable_remote_input_instructions),
|
||||||
|
);
|
||||||
if (userOK) {
|
if (userOK) {
|
||||||
// ignore: use_build_context_synchronously
|
// ignore: use_build_context_synchronously
|
||||||
await serverModel.startServer().unwrap(context: context);
|
await serverModel.startServer().unwrap(context: context);
|
||||||
if (!context.mounted) return;
|
if (!context.mounted) return;
|
||||||
await showDialog(
|
await showDialog(context: context, builder: (BuildContext context) => ServerQrDialogUI());
|
||||||
context: context,
|
|
||||||
builder: (BuildContext context) => ServerQrDialogUI(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
await serverModel.stopServer().unwrap(context: context);
|
await serverModel.stopServer().unwrap(context: context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _onSwitchAutoTranslate(
|
|
||||||
BuildContext context, InputMethodDialogUIModel model, bool b) async {
|
|
||||||
if (b) {
|
|
||||||
final ok = await showConfirmDialogs(
|
|
||||||
context,
|
|
||||||
S.current.input_method_auto_translate_dialog_title,
|
|
||||||
Text(S.current.input_method_auto_translate_dialog_title_content));
|
|
||||||
if (ok != true) return;
|
|
||||||
}
|
|
||||||
model.toggleAutoTranslate(b);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,14 +43,14 @@ abstract class AdvancedLocalizationUIState with _$AdvancedLocalizationUIState {
|
|||||||
|
|
||||||
extension AdvancedLocalizationUIStateEx on AdvancedLocalizationUIState {
|
extension AdvancedLocalizationUIStateEx on AdvancedLocalizationUIState {
|
||||||
Map<AppAdvancedLocalizationClassKeysDataMode, String> get typeNames => {
|
Map<AppAdvancedLocalizationClassKeysDataMode, String> get typeNames => {
|
||||||
AppAdvancedLocalizationClassKeysDataMode.localization:
|
AppAdvancedLocalizationClassKeysDataMode.localization:
|
||||||
S.current.home_localization_advanced_action_mod_change_localization,
|
S.current.home_localization_advanced_action_mod_change_localization,
|
||||||
AppAdvancedLocalizationClassKeysDataMode.unLocalization:
|
AppAdvancedLocalizationClassKeysDataMode.unLocalization:
|
||||||
S.current.home_localization_advanced_action_mod_change_un_localization,
|
S.current.home_localization_advanced_action_mod_change_un_localization,
|
||||||
AppAdvancedLocalizationClassKeysDataMode.mixed: S.current.home_localization_advanced_action_mod_change_mixed,
|
AppAdvancedLocalizationClassKeysDataMode.mixed: S.current.home_localization_advanced_action_mod_change_mixed,
|
||||||
AppAdvancedLocalizationClassKeysDataMode.mixedNewline:
|
AppAdvancedLocalizationClassKeysDataMode.mixedNewline:
|
||||||
S.current.home_localization_advanced_action_mod_change_mixed_newline,
|
S.current.home_localization_advanced_action_mod_change_mixed_newline,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@riverpod
|
@riverpod
|
||||||
@ -64,6 +64,11 @@ class AdvancedLocalizationUIModel extends _$AdvancedLocalizationUIModel {
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool updateShouldNotify(previous, next) {
|
||||||
|
return !identical(previous, next);
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _init(LocalizationUIState localizationUIState, LocalizationUIModel localizationUIModel) async {
|
Future<void> _init(LocalizationUIState localizationUIState, LocalizationUIModel localizationUIModel) async {
|
||||||
final (p4kGlobalIni, serverGlobalIni) = await _readIni(localizationUIState, localizationUIModel);
|
final (p4kGlobalIni, serverGlobalIni) = await _readIni(localizationUIState, localizationUIModel);
|
||||||
final ald = await _readClassJson();
|
final ald = await _readClassJson();
|
||||||
@ -74,17 +79,18 @@ class AdvancedLocalizationUIModel extends _$AdvancedLocalizationUIModel {
|
|||||||
p4kGlobalIni,
|
p4kGlobalIni,
|
||||||
serverGlobalIni,
|
serverGlobalIni,
|
||||||
S.current.home_localization_advanced_json_text_un_localization,
|
S.current.home_localization_advanced_json_text_un_localization,
|
||||||
S.current.home_localization_advanced_json_text_others
|
S.current.home_localization_advanced_json_text_others,
|
||||||
));
|
));
|
||||||
final p4kGlobalIniLines = p4kGlobalIni.split("\n").length;
|
final p4kGlobalIniLines = p4kGlobalIni.split("\n").length;
|
||||||
final serverGlobalIniLines = serverGlobalIni.split("\n").length;
|
final serverGlobalIniLines = serverGlobalIni.split("\n").length;
|
||||||
state = state.copyWith(
|
state = state.copyWith(
|
||||||
workingText: "",
|
workingText: "",
|
||||||
p4kGlobalIni: p4kGlobalIni,
|
p4kGlobalIni: p4kGlobalIni,
|
||||||
serverGlobalIni: serverGlobalIni,
|
serverGlobalIni: serverGlobalIni,
|
||||||
p4kGlobalIniLines: p4kGlobalIniLines,
|
p4kGlobalIniLines: p4kGlobalIniLines,
|
||||||
serverGlobalIniLines: serverGlobalIniLines,
|
serverGlobalIniLines: serverGlobalIniLines,
|
||||||
classMap: m);
|
classMap: m,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCustomizeGlobalIni(String? data) async {
|
void setCustomizeGlobalIni(String? data) async {
|
||||||
@ -101,7 +107,8 @@ class AdvancedLocalizationUIModel extends _$AdvancedLocalizationUIModel {
|
|||||||
String serverGlobalIni,
|
String serverGlobalIni,
|
||||||
String unLocalizationClassName,
|
String unLocalizationClassName,
|
||||||
String othersClassName,
|
String othersClassName,
|
||||||
) v,
|
)
|
||||||
|
v,
|
||||||
) {
|
) {
|
||||||
final (
|
final (
|
||||||
AppAdvancedLocalizationData ald,
|
AppAdvancedLocalizationData ald,
|
||||||
@ -110,18 +117,11 @@ class AdvancedLocalizationUIModel extends _$AdvancedLocalizationUIModel {
|
|||||||
String unLocalizationClassName,
|
String unLocalizationClassName,
|
||||||
String othersClassName,
|
String othersClassName,
|
||||||
) = v;
|
) = v;
|
||||||
final unLocalization = AppAdvancedLocalizationClassKeysData(
|
final unLocalization =
|
||||||
id: "un_localization",
|
AppAdvancedLocalizationClassKeysData(id: "un_localization", className: unLocalizationClassName, keys: [])
|
||||||
className: unLocalizationClassName,
|
..mode = AppAdvancedLocalizationClassKeysDataMode.unLocalization
|
||||||
keys: [],
|
..lockMod = true;
|
||||||
)
|
final unClass = AppAdvancedLocalizationClassKeysData(id: "un_class", className: othersClassName, keys: []);
|
||||||
..mode = AppAdvancedLocalizationClassKeysDataMode.unLocalization
|
|
||||||
..lockMod = true;
|
|
||||||
final unClass = AppAdvancedLocalizationClassKeysData(
|
|
||||||
id: "un_class",
|
|
||||||
className: othersClassName,
|
|
||||||
keys: [],
|
|
||||||
);
|
|
||||||
final classMap = <String, AppAdvancedLocalizationClassKeysData>{
|
final classMap = <String, AppAdvancedLocalizationClassKeysData>{
|
||||||
for (final keys in ald.classKeys!) keys.id ?? "": keys,
|
for (final keys in ald.classKeys!) keys.id ?? "": keys,
|
||||||
};
|
};
|
||||||
@ -129,8 +129,9 @@ class AdvancedLocalizationUIModel extends _$AdvancedLocalizationUIModel {
|
|||||||
final p4kIniMap = readIniAsMap(p4kGlobalIni);
|
final p4kIniMap = readIniAsMap(p4kGlobalIni);
|
||||||
final serverIniMap = readIniAsMap(serverGlobalIni);
|
final serverIniMap = readIniAsMap(serverGlobalIni);
|
||||||
|
|
||||||
var regexList =
|
var regexList = classMap.values
|
||||||
classMap.values.expand((c) => c.keys!.map((k) => MapEntry(c, RegExp(k, caseSensitive: false)))).toList();
|
.expand((c) => c.keys!.map((k) => MapEntry(c, RegExp(k, caseSensitive: false))))
|
||||||
|
.toList();
|
||||||
|
|
||||||
iniKeysLoop:
|
iniKeysLoop:
|
||||||
for (var p4kIniKey in p4kIniMap.keys) {
|
for (var p4kIniKey in p4kIniMap.keys) {
|
||||||
@ -180,7 +181,9 @@ class AdvancedLocalizationUIModel extends _$AdvancedLocalizationUIModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<(String, String)> _readIni(
|
Future<(String, String)> _readIni(
|
||||||
LocalizationUIState localizationUIState, LocalizationUIModel localizationUIModel) async {
|
LocalizationUIState localizationUIState,
|
||||||
|
LocalizationUIModel localizationUIModel,
|
||||||
|
) async {
|
||||||
final homeUIState = ref.read(homeUIModelProvider);
|
final homeUIState = ref.read(homeUIModelProvider);
|
||||||
final gameDir = homeUIState.scInstalledPath;
|
final gameDir = homeUIState.scInstalledPath;
|
||||||
if (gameDir == null) return ("", "");
|
if (gameDir == null) return ("", "");
|
||||||
@ -190,15 +193,18 @@ class AdvancedLocalizationUIModel extends _$AdvancedLocalizationUIModel {
|
|||||||
state = state.copyWith(workingText: S.current.home_localization_advanced_msg_reading_server_localization_text);
|
state = state.copyWith(workingText: S.current.home_localization_advanced_msg_reading_server_localization_text);
|
||||||
|
|
||||||
if (state.customizeGlobalIni != null) {
|
if (state.customizeGlobalIni != null) {
|
||||||
final apiLocalizationData =
|
final apiLocalizationData = ScLocalizationData(
|
||||||
ScLocalizationData(versionName: S.current.localization_info_custom_files, info: "Customize");
|
versionName: S.current.localization_info_custom_files,
|
||||||
|
info: "Customize",
|
||||||
|
);
|
||||||
state = state.copyWith(apiLocalizationData: apiLocalizationData);
|
state = state.copyWith(apiLocalizationData: apiLocalizationData);
|
||||||
return (p4kGlobalIni, state.customizeGlobalIni!);
|
return (p4kGlobalIni, state.customizeGlobalIni!);
|
||||||
} else {
|
} else {
|
||||||
final apiLocalizationData = localizationUIState.apiLocalizationData?.values.firstOrNull;
|
final apiLocalizationData = localizationUIState.apiLocalizationData?.values.firstOrNull;
|
||||||
if (apiLocalizationData == null) return ("", "");
|
if (apiLocalizationData == null) return ("", "");
|
||||||
final file =
|
final file = File(
|
||||||
File("${localizationUIModel.getDownloadDir().absolute.path}\\${apiLocalizationData.versionName}.sclang");
|
"${localizationUIModel.getDownloadDir().absolute.path}\\${apiLocalizationData.versionName}.sclang",
|
||||||
|
);
|
||||||
if (!await file.exists()) {
|
if (!await file.exists()) {
|
||||||
await localizationUIModel.downloadLocalizationFile(file, apiLocalizationData);
|
await localizationUIModel.downloadLocalizationFile(file, apiLocalizationData);
|
||||||
}
|
}
|
||||||
@ -211,8 +217,11 @@ class AdvancedLocalizationUIModel extends _$AdvancedLocalizationUIModel {
|
|||||||
|
|
||||||
Future<String> readEnglishInI(String gameDir) async {
|
Future<String> readEnglishInI(String gameDir) async {
|
||||||
try {
|
try {
|
||||||
var data = await Unp4kCModel.unp4kTools(appGlobalState.applicationBinaryModuleDir!,
|
var data = await Unp4kCModel.unp4kTools(appGlobalState.applicationBinaryModuleDir!, [
|
||||||
["extract_memory", "$gameDir\\Data.p4k", "Data\\Localization\\english\\global.ini"]);
|
"extract_memory",
|
||||||
|
"$gameDir\\Data.p4k",
|
||||||
|
"Data\\Localization\\english\\global.ini",
|
||||||
|
]);
|
||||||
// remove bom
|
// remove bom
|
||||||
if (data.length > 3 && data[0] == 0xEF && data[1] == 0xBB && data[2] == 0xBF) {
|
if (data.length > 3 && data[0] == 0xEF && data[1] == 0xBB && data[2] == 0xBF) {
|
||||||
data = data.sublist(3);
|
data = data.sublist(3);
|
||||||
@ -224,15 +233,16 @@ class AdvancedLocalizationUIModel extends _$AdvancedLocalizationUIModel {
|
|||||||
if (Unp4kCModel.checkRunTimeError(errorMessage)) {
|
if (Unp4kCModel.checkRunTimeError(errorMessage)) {
|
||||||
AnalyticsApi.touch("advanced_localization_no_runtime");
|
AnalyticsApi.touch("advanced_localization_no_runtime");
|
||||||
}
|
}
|
||||||
state = state.copyWith(
|
state = state.copyWith(errorMessage: errorMessage);
|
||||||
errorMessage: errorMessage,
|
|
||||||
);
|
|
||||||
// rethrow;
|
// rethrow;
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> onChangeMod(AppAdvancedLocalizationClassKeysData item, AppAdvancedLocalizationClassKeysDataMode mode) async {
|
Future<void> onChangeMod(
|
||||||
|
AppAdvancedLocalizationClassKeysData item,
|
||||||
|
AppAdvancedLocalizationClassKeysDataMode mode,
|
||||||
|
) async {
|
||||||
if (item.lockMod) return;
|
if (item.lockMod) return;
|
||||||
item.mode = mode;
|
item.mode = mode;
|
||||||
item.isWorking = true;
|
item.isWorking = true;
|
||||||
@ -282,8 +292,13 @@ class AdvancedLocalizationUIModel extends _$AdvancedLocalizationUIModel {
|
|||||||
state = state.copyWith(workingText: S.current.home_localization_advanced_msg_gen_localization_install);
|
state = state.copyWith(workingText: S.current.home_localization_advanced_msg_gen_localization_install);
|
||||||
final localizationUIModel = ref.read(localizationUIModelProvider.notifier);
|
final localizationUIModel = ref.read(localizationUIModelProvider.notifier);
|
||||||
if (!context.mounted) return false;
|
if (!context.mounted) return false;
|
||||||
await localizationUIModel.installFormString(globalIni, state.apiLocalizationData?.versionName ?? "-",
|
await localizationUIModel.installFormString(
|
||||||
advanced: true, isEnableCommunityInputMethod: isEnableCommunityInputMethod, context: context);
|
globalIni,
|
||||||
|
state.apiLocalizationData?.versionName ?? "-",
|
||||||
|
advanced: true,
|
||||||
|
isEnableCommunityInputMethod: isEnableCommunityInputMethod,
|
||||||
|
context: context,
|
||||||
|
);
|
||||||
state = state.copyWith(workingText: "");
|
state = state.copyWith(workingText: "");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -291,73 +306,72 @@ class AdvancedLocalizationUIModel extends _$AdvancedLocalizationUIModel {
|
|||||||
// ignore: avoid_build_context_in_providers
|
// ignore: avoid_build_context_in_providers
|
||||||
Future<void> onInstall(BuildContext context) async {
|
Future<void> onInstall(BuildContext context) async {
|
||||||
var isEnableCommunityInputMethod = true;
|
var isEnableCommunityInputMethod = true;
|
||||||
final userOK =
|
final userOK = await showConfirmDialogs(
|
||||||
await showConfirmDialogs(context, S.current.input_method_confirm_install_advanced_localization, HookConsumer(
|
context,
|
||||||
builder: (BuildContext context, WidgetRef ref, Widget? child) {
|
S.current.input_method_confirm_install_advanced_localization,
|
||||||
final globalIni = useState<StringBuffer?>(null);
|
HookConsumer(
|
||||||
final enableCommunityInputMethod = useState(true);
|
builder: (BuildContext context, WidgetRef ref, Widget? child) {
|
||||||
final localizationState = ref.read(localizationUIModelProvider);
|
final globalIni = useState<StringBuffer?>(null);
|
||||||
useEffect(() {
|
final enableCommunityInputMethod = useState(true);
|
||||||
() async {
|
final localizationState = ref.read(localizationUIModelProvider);
|
||||||
final classMap = state.classMap!;
|
useEffect(() {
|
||||||
final g = StringBuffer();
|
() async {
|
||||||
for (var item in classMap.values) {
|
final classMap = state.classMap!;
|
||||||
for (var kv in item.valuesMap.entries) {
|
final g = StringBuffer();
|
||||||
g.write("${kv.key}=${kv.value}\n");
|
for (var item in classMap.values) {
|
||||||
await Future.delayed(Duration.zero);
|
for (var kv in item.valuesMap.entries) {
|
||||||
|
g.write("${kv.key}=${kv.value}\n");
|
||||||
|
await Future.delayed(Duration.zero);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
globalIni.value = g;
|
||||||
globalIni.value = g;
|
}();
|
||||||
}();
|
return null;
|
||||||
return null;
|
}, const []);
|
||||||
}, const []);
|
return Column(
|
||||||
return Column(
|
children: [
|
||||||
children: [
|
Expanded(
|
||||||
Expanded(
|
child: Container(
|
||||||
child: Container(
|
decoration: BoxDecoration(
|
||||||
decoration: BoxDecoration(
|
color: FluentTheme.of(context).cardColor,
|
||||||
color: FluentTheme.of(context).cardColor,
|
borderRadius: BorderRadius.circular(7),
|
||||||
borderRadius: BorderRadius.circular(7),
|
),
|
||||||
),
|
child: globalIni.value == null
|
||||||
child: globalIni.value == null
|
? makeLoading(context)
|
||||||
? makeLoading(context)
|
: CodeEditor(
|
||||||
: CodeEditor(
|
readOnly: true,
|
||||||
readOnly: true,
|
controller: CodeLineEditingController.fromText(globalIni.value!.toString()),
|
||||||
controller: CodeLineEditingController.fromText(globalIni.value!.toString()),
|
style: CodeEditorStyle(
|
||||||
style: CodeEditorStyle(
|
codeTheme: CodeHighlightTheme(
|
||||||
codeTheme: CodeHighlightTheme(
|
languages: {'ini': CodeHighlightThemeMode(mode: langIni)},
|
||||||
languages: {'ini': CodeHighlightThemeMode(mode: langIni)},
|
theme: vs2015Theme,
|
||||||
theme: vs2015Theme,
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(height: 16),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
S.current.input_method_install_community_input_method_support,
|
|
||||||
),
|
),
|
||||||
Spacer(),
|
),
|
||||||
ToggleSwitch(
|
SizedBox(height: 16),
|
||||||
checked: enableCommunityInputMethod.value,
|
Row(
|
||||||
onChanged: localizationState.communityInputMethodLanguageData == null
|
children: [
|
||||||
? null
|
Text(S.current.input_method_install_community_input_method_support),
|
||||||
: (v) {
|
Spacer(),
|
||||||
isEnableCommunityInputMethod = v;
|
ToggleSwitch(
|
||||||
enableCommunityInputMethod.value = v;
|
checked: enableCommunityInputMethod.value,
|
||||||
},
|
onChanged: localizationState.communityInputMethodLanguageData == null
|
||||||
)
|
? null
|
||||||
],
|
: (v) {
|
||||||
)
|
isEnableCommunityInputMethod = v;
|
||||||
],
|
enableCommunityInputMethod.value = v;
|
||||||
);
|
},
|
||||||
},
|
),
|
||||||
),
|
],
|
||||||
constraints: BoxConstraints(
|
),
|
||||||
maxWidth: MediaQuery.of(context).size.width * .8,
|
],
|
||||||
));
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
constraints: BoxConstraints(maxWidth: MediaQuery.of(context).size.width * .8),
|
||||||
|
);
|
||||||
if (userOK) {
|
if (userOK) {
|
||||||
if (!context.mounted) return;
|
if (!context.mounted) return;
|
||||||
await doInstall(context, isEnableCommunityInputMethod: isEnableCommunityInputMethod);
|
await doInstall(context, isEnableCommunityInputMethod: isEnableCommunityInputMethod);
|
||||||
|
|||||||
@ -47,6 +47,11 @@ class HomePerformanceUIModel extends _$HomePerformanceUIModel {
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool updateShouldNotify(previous, next) {
|
||||||
|
return !identical(previous, next);
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _init() async {
|
Future<void> _init() async {
|
||||||
customizeCtrl.clear();
|
customizeCtrl.clear();
|
||||||
_inAppKeys.clear();
|
_inAppKeys.clear();
|
||||||
@ -69,8 +74,7 @@ class HomePerformanceUIModel extends _$HomePerformanceUIModel {
|
|||||||
|
|
||||||
final box = await Hive.openBox("app_conf");
|
final box = await Hive.openBox("app_conf");
|
||||||
final v = box.get("close_graphics_performance_tip", defaultValue: -1);
|
final v = box.get("close_graphics_performance_tip", defaultValue: -1);
|
||||||
state = state.copyWith(
|
state = state.copyWith(showGraphicsPerformanceTip: v != _graphicsPerformanceTipVersion);
|
||||||
showGraphicsPerformanceTip: v != _graphicsPerformanceTipVersion);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _readConf() async {
|
Future<void> _readConf() async {
|
||||||
@ -89,16 +93,14 @@ class HomePerformanceUIModel extends _$HomePerformanceUIModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (kv.length == 2 && !_inAppKeys.contains(kv[0].trim())) {
|
if (kv.length == 2 && !_inAppKeys.contains(kv[0].trim())) {
|
||||||
customizeCtrl.text =
|
customizeCtrl.text = "${customizeCtrl.text}${kv[0].trim()}=${kv[1].trim()}\n";
|
||||||
"${customizeCtrl.text}${kv[0].trim()}=${kv[1].trim()}\n";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> closeTip() async {
|
Future<void> closeTip() async {
|
||||||
final box = await Hive.openBox("app_conf");
|
final box = await Hive.openBox("app_conf");
|
||||||
await box.put(
|
await box.put("close_graphics_performance_tip", _graphicsPerformanceTipVersion);
|
||||||
"close_graphics_performance_tip", _graphicsPerformanceTipVersion);
|
|
||||||
_init();
|
_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,13 +151,11 @@ class HomePerformanceUIModel extends _$HomePerformanceUIModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> clean(BuildContext context) async {
|
Future<void> clean(BuildContext context) async {
|
||||||
state = state.copyWith(
|
state = state.copyWith(workingString: S.current.performance_info_delete_config_file);
|
||||||
workingString: S.current.performance_info_delete_config_file);
|
|
||||||
if (await confFile.exists()) {
|
if (await confFile.exists()) {
|
||||||
await confFile.delete(recursive: true);
|
await confFile.delete(recursive: true);
|
||||||
}
|
}
|
||||||
state = state.copyWith(
|
state = state.copyWith(workingString: S.current.performance_action_clear_shaders);
|
||||||
workingString: S.current.performance_action_clear_shaders);
|
|
||||||
if (!context.mounted) return;
|
if (!context.mounted) return;
|
||||||
await cleanShaderCache(context);
|
await cleanShaderCache(context);
|
||||||
state = state.copyWith(workingString: S.current.performance_info_done);
|
state = state.copyWith(workingString: S.current.performance_info_done);
|
||||||
@ -166,8 +166,7 @@ class HomePerformanceUIModel extends _$HomePerformanceUIModel {
|
|||||||
|
|
||||||
Future<void> cleanShaderCache(BuildContext? context) async {
|
Future<void> cleanShaderCache(BuildContext? context) async {
|
||||||
final gameShaderCachePath = await SCLoggerHelper.getShaderCachePath();
|
final gameShaderCachePath = await SCLoggerHelper.getShaderCachePath();
|
||||||
final l =
|
final l = await Directory(gameShaderCachePath!).list(recursive: false).toList();
|
||||||
await Directory(gameShaderCachePath!).list(recursive: false).toList();
|
|
||||||
for (var value in l) {
|
for (var value in l) {
|
||||||
if (value is Directory) {
|
if (value is Directory) {
|
||||||
if (!value.absolute.path.contains("Crashes")) {
|
if (!value.absolute.path.contains("Crashes")) {
|
||||||
@ -184,8 +183,7 @@ class HomePerformanceUIModel extends _$HomePerformanceUIModel {
|
|||||||
Future<void> applyProfile(bool cleanShader) async {
|
Future<void> applyProfile(bool cleanShader) async {
|
||||||
if (state.performanceMap == null) return;
|
if (state.performanceMap == null) return;
|
||||||
AnalyticsApi.touch("performance_apply");
|
AnalyticsApi.touch("performance_apply");
|
||||||
state = state.copyWith(
|
state = state.copyWith(workingString: S.current.performance_info_generate_config_file);
|
||||||
workingString: S.current.performance_info_generate_config_file);
|
|
||||||
String conf = "";
|
String conf = "";
|
||||||
for (var v in state.performanceMap!.entries) {
|
for (var v in state.performanceMap!.entries) {
|
||||||
for (var c in v.value) {
|
for (var c in v.value) {
|
||||||
@ -204,16 +202,14 @@ class HomePerformanceUIModel extends _$HomePerformanceUIModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
state = state.copyWith(
|
state = state.copyWith(workingString: S.current.performance_info_write_out_config_file);
|
||||||
workingString: S.current.performance_info_write_out_config_file);
|
|
||||||
if (await confFile.exists()) {
|
if (await confFile.exists()) {
|
||||||
await confFile.delete();
|
await confFile.delete();
|
||||||
}
|
}
|
||||||
await confFile.create();
|
await confFile.create();
|
||||||
await confFile.writeAsString(conf);
|
await confFile.writeAsString(conf);
|
||||||
if (cleanShader) {
|
if (cleanShader) {
|
||||||
state = state.copyWith(
|
state = state.copyWith(workingString: S.current.performance_action_clear_shaders);
|
||||||
workingString: S.current.performance_action_clear_shaders);
|
|
||||||
await cleanShaderCache(null);
|
await cleanShaderCache(null);
|
||||||
}
|
}
|
||||||
state = state.copyWith(workingString: S.current.performance_info_done);
|
state = state.copyWith(workingString: S.current.performance_info_done);
|
||||||
|
|||||||
@ -1602,7 +1602,7 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.0"
|
version: "1.1.0"
|
||||||
xml:
|
xml:
|
||||||
dependency: transitive
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: xml
|
name: xml
|
||||||
sha256: "971043b3a0d3da28727e40ed3e0b5d18b742fa5a68665cca88e74b7876d5e025"
|
sha256: "971043b3a0d3da28727e40ed3e0b5d18b742fa5a68665cca88e74b7876d5e025"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user