feat: AdvancedLocalizationUI Error Message

This commit is contained in:
xkeyC 2024-05-05 21:50:18 +08:00
parent 0920696444
commit b965c6262f
11 changed files with 166 additions and 73 deletions

View File

@ -634,6 +634,12 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage(
"Localization has a new version!"),
"home_localization_new_version_installed": m34,
"home_localization_ptu_advanced_localization_tip_title":
MessageLookupByLibrary.simpleMessage(
"Recommended advanced localization"),
"home_localization_ptu_advanced_localization_tip_title_info":
MessageLookupByLibrary.simpleMessage(
"On PTU/EPTU and other test channels, the current localization text text may not be synchronized with the game, and the use of advanced localization can reduce garbled production."),
"home_localization_select_customize_file":
MessageLookupByLibrary.simpleMessage(
"Please select custom Localization file"),

View File

@ -571,6 +571,11 @@ class MessageLookup extends MessageLookupByLibrary {
"home_localization_new_version_available":
MessageLookupByLibrary.simpleMessage("汉化有新版本!"),
"home_localization_new_version_installed": m34,
"home_localization_ptu_advanced_localization_tip_title":
MessageLookupByLibrary.simpleMessage("推荐使用高级汉化"),
"home_localization_ptu_advanced_localization_tip_title_info":
MessageLookupByLibrary.simpleMessage(
"在 PTU/EPTU 等测试频道 ,当前汉化文本可能与游戏不同步,使用高级汉化可以减少乱码产生。"),
"home_localization_select_customize_file":
MessageLookupByLibrary.simpleMessage("请选择自定义汉化文件"),
"home_localization_select_customize_file_ini":

View File

@ -4783,6 +4783,26 @@ class S {
args: [],
);
}
/// `Recommended advanced localization`
String get home_localization_ptu_advanced_localization_tip_title {
return Intl.message(
'Recommended advanced localization',
name: 'home_localization_ptu_advanced_localization_tip_title',
desc: '',
args: [],
);
}
/// `On PTU/EPTU and other test channels, the current localization text text may not be synchronized with the game, and the use of advanced localization can reduce garbled production.`
String get home_localization_ptu_advanced_localization_tip_title_info {
return Intl.message(
'On PTU/EPTU and other test channels, the current localization text text may not be synchronized with the game, and the use of advanced localization can reduce garbled production.',
name: 'home_localization_ptu_advanced_localization_tip_title_info',
desc: '',
args: [],
);
}
}
class AppLocalizationDelegate extends LocalizationsDelegate<S> {

View File

@ -823,5 +823,7 @@
"tools_unp4k_msg_unknown_file_type": "Unknown file type\n{v0}",
"home_localization_select_customize_file_ini": "Please select INI file",
"home_localization_select_customize_file": "Please select custom Localization file",
"home_localization_action_select_customize_file": "Click to select INI file"
"home_localization_action_select_customize_file": "Click to select INI file",
"home_localization_ptu_advanced_localization_tip_title": "Recommended advanced localization",
"home_localization_ptu_advanced_localization_tip_title_info": "On PTU/EPTU and other test channels, the current localization text text may not be synchronized with the game, and the use of advanced localization can reduce garbled production."
}

View File

@ -789,5 +789,7 @@
"tools_unp4k_msg_unknown_file_type": "未知文件类型\n{v0}",
"home_localization_select_customize_file_ini": "请选择 ini 文件",
"home_localization_select_customize_file": "请选择自定义汉化文件",
"home_localization_action_select_customize_file": "点击选择 ini 文件"
"home_localization_action_select_customize_file": "点击选择 ini 文件",
"home_localization_ptu_advanced_localization_tip_title": "推荐使用高级汉化",
"home_localization_ptu_advanced_localization_tip_title_info": "在 PTU/EPTU 等测试频道 ,当前汉化文本可能与游戏不同步,使用高级汉化可以减少乱码产生。"
}

View File

@ -6,7 +6,7 @@ part of 'unp4kc.dart';
// RiverpodGenerator
// **************************************************************************
String _$unp4kCModelHash() => r'24f5043f687a5f652a0741b8e6f4a3855fca0101';
String _$unp4kCModelHash() => r'23b148d557f55aa6050f1b1e38a3465d22a09034';
/// See also [Unp4kCModel].
@ProviderFor(Unp4kCModel)

View File

@ -50,57 +50,68 @@ class AdvancedLocalizationUI extends HookConsumerWidget {
)
: Column(
children: [
Row(
children: [
const SizedBox(width: 12),
Expanded(
child: Row(
children: [
Text(
S.current.home_localization_advanced_msg_version(
state.apiLocalizationData?.versionName ?? "-"),
),
const SizedBox(width: 12),
Button(
onPressed: onSwitchFile,
child: const Padding(
padding: EdgeInsets.symmetric(
horizontal: 6, vertical: 3),
child: Icon(FluentIcons.switch_widget),
)),
if (state.customizeGlobalIni != null) ...[
if (state.errorMessage.isNotEmpty)
Padding(
padding: const EdgeInsets.all(32),
child: Center(
child: Text(state.errorMessage),
),
)
else ...[
Row(
children: [
const SizedBox(width: 12),
Expanded(
child: Row(
children: [
Text(
S.current.home_localization_advanced_msg_version(
state.apiLocalizationData?.versionName ??
"-"),
),
const SizedBox(width: 12),
Button(
onPressed: () {
model.setCustomizeGlobalIni(null);
},
onPressed: onSwitchFile,
child: const Padding(
padding: EdgeInsets.symmetric(
horizontal: 6, vertical: 3),
child: Icon(FluentIcons.delete),
child: Icon(FluentIcons.switch_widget),
)),
]
],
)),
Text(S.current.home_localization_advanced_title_msg(
state.serverGlobalIniLines, state.p4kGlobalIniLines)),
const SizedBox(width: 32),
Button(
child: Padding(
padding: const EdgeInsets.only(
left: 12, right: 12, top: 4, bottom: 4),
child: Text(S.current
.home_localization_advanced_action_install),
),
onPressed: () async {
await model.doInstall().unwrap(context: context);
}),
const SizedBox(width: 12),
],
),
Expanded(
child:
_makeBody(context, homeUIState, state, ref, model)),
if (state.customizeGlobalIni != null) ...[
const SizedBox(width: 12),
Button(
onPressed: () {
model.setCustomizeGlobalIni(null);
},
child: const Padding(
padding: EdgeInsets.symmetric(
horizontal: 6, vertical: 3),
child: Icon(FluentIcons.delete),
)),
]
],
)),
Text(S.current.home_localization_advanced_title_msg(
state.serverGlobalIniLines,
state.p4kGlobalIniLines)),
const SizedBox(width: 32),
Button(
child: Padding(
padding: const EdgeInsets.only(
left: 12, right: 12, top: 4, bottom: 4),
child: Text(S.current
.home_localization_advanced_action_install),
),
onPressed: () async {
await model.doInstall().unwrap(context: context);
}),
const SizedBox(width: 12),
],
),
Expanded(
child:
_makeBody(context, homeUIState, state, ref, model)),
]
],
));
}

View File

@ -29,6 +29,7 @@ class AdvancedLocalizationUIState with _$AdvancedLocalizationUIState {
ScLocalizationData? apiLocalizationData,
@Default(0) int p4kGlobalIniLines,
@Default(0) int serverGlobalIniLines,
@Default("") String errorMessage,
}) = _AdvancedLocalizationUIState;
}
@ -215,23 +216,29 @@ class AdvancedLocalizationUIModel extends _$AdvancedLocalizationUIModel {
}
Future<String> readEnglishInI(String gameDir) async {
var data = await Unp4kCModel.unp4kTools(
appGlobalState.applicationBinaryModuleDir!, [
"extract_memory",
"$gameDir\\Data.p4k",
"Data\\Localization\\english\\global.ini"
]);
// remove bom
if (data.length > 3 &&
data[0] == 0xEF &&
data[1] == 0xBB &&
data[2] == 0xBF) {
data = data.sublist(3);
try {
var data = await Unp4kCModel.unp4kTools(
appGlobalState.applicationBinaryModuleDir!, [
"extract_memory",
"$gameDir\\Data.p4k",
"Data\\Localization\\english\\global.ini"
]);
// remove bom
if (data.length > 3 &&
data[0] == 0xEF &&
data[1] == 0xBB &&
data[2] == 0xBF) {
data = data.sublist(3);
}
final iniData = String.fromCharCodes(data);
return iniData;
} catch (e) {
state = state.copyWith(
errorMessage: e.toString(),
);
// rethrow;
}
final iniData = String.fromCharCodes(data);
return iniData;
return "";
}
onChangeMod(AppAdvancedLocalizationClassKeysData item,

View File

@ -26,6 +26,7 @@ mixin _$AdvancedLocalizationUIState {
throw _privateConstructorUsedError;
int get p4kGlobalIniLines => throw _privateConstructorUsedError;
int get serverGlobalIniLines => throw _privateConstructorUsedError;
String get errorMessage => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$AdvancedLocalizationUIStateCopyWith<AdvancedLocalizationUIState>
@ -48,7 +49,8 @@ abstract class $AdvancedLocalizationUIStateCopyWith<$Res> {
String? customizeGlobalIni,
ScLocalizationData? apiLocalizationData,
int p4kGlobalIniLines,
int serverGlobalIniLines});
int serverGlobalIniLines,
String errorMessage});
}
/// @nodoc
@ -73,6 +75,7 @@ class _$AdvancedLocalizationUIStateCopyWithImpl<$Res,
Object? apiLocalizationData = freezed,
Object? p4kGlobalIniLines = null,
Object? serverGlobalIniLines = null,
Object? errorMessage = null,
}) {
return _then(_value.copyWith(
workingText: null == workingText
@ -107,6 +110,10 @@ class _$AdvancedLocalizationUIStateCopyWithImpl<$Res,
? _value.serverGlobalIniLines
: serverGlobalIniLines // ignore: cast_nullable_to_non_nullable
as int,
errorMessage: null == errorMessage
? _value.errorMessage
: errorMessage // ignore: cast_nullable_to_non_nullable
as String,
) as $Val);
}
}
@ -128,7 +135,8 @@ abstract class _$$AdvancedLocalizationUIStateImplCopyWith<$Res>
String? customizeGlobalIni,
ScLocalizationData? apiLocalizationData,
int p4kGlobalIniLines,
int serverGlobalIniLines});
int serverGlobalIniLines,
String errorMessage});
}
/// @nodoc
@ -152,6 +160,7 @@ class __$$AdvancedLocalizationUIStateImplCopyWithImpl<$Res>
Object? apiLocalizationData = freezed,
Object? p4kGlobalIniLines = null,
Object? serverGlobalIniLines = null,
Object? errorMessage = null,
}) {
return _then(_$AdvancedLocalizationUIStateImpl(
workingText: null == workingText
@ -186,6 +195,10 @@ class __$$AdvancedLocalizationUIStateImplCopyWithImpl<$Res>
? _value.serverGlobalIniLines
: serverGlobalIniLines // ignore: cast_nullable_to_non_nullable
as int,
errorMessage: null == errorMessage
? _value.errorMessage
: errorMessage // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
@ -203,7 +216,8 @@ class _$AdvancedLocalizationUIStateImpl
this.customizeGlobalIni,
this.apiLocalizationData,
this.p4kGlobalIniLines = 0,
this.serverGlobalIniLines = 0})
this.serverGlobalIniLines = 0,
this.errorMessage = ""})
: _classMap = classMap;
@override
@ -233,10 +247,13 @@ class _$AdvancedLocalizationUIStateImpl
@override
@JsonKey()
final int serverGlobalIniLines;
@override
@JsonKey()
final String errorMessage;
@override
String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) {
return 'AdvancedLocalizationUIState(workingText: $workingText, classMap: $classMap, p4kGlobalIni: $p4kGlobalIni, serverGlobalIni: $serverGlobalIni, customizeGlobalIni: $customizeGlobalIni, apiLocalizationData: $apiLocalizationData, p4kGlobalIniLines: $p4kGlobalIniLines, serverGlobalIniLines: $serverGlobalIniLines)';
return 'AdvancedLocalizationUIState(workingText: $workingText, classMap: $classMap, p4kGlobalIni: $p4kGlobalIni, serverGlobalIni: $serverGlobalIni, customizeGlobalIni: $customizeGlobalIni, apiLocalizationData: $apiLocalizationData, p4kGlobalIniLines: $p4kGlobalIniLines, serverGlobalIniLines: $serverGlobalIniLines, errorMessage: $errorMessage)';
}
@override
@ -251,7 +268,8 @@ class _$AdvancedLocalizationUIStateImpl
..add(DiagnosticsProperty('customizeGlobalIni', customizeGlobalIni))
..add(DiagnosticsProperty('apiLocalizationData', apiLocalizationData))
..add(DiagnosticsProperty('p4kGlobalIniLines', p4kGlobalIniLines))
..add(DiagnosticsProperty('serverGlobalIniLines', serverGlobalIniLines));
..add(DiagnosticsProperty('serverGlobalIniLines', serverGlobalIniLines))
..add(DiagnosticsProperty('errorMessage', errorMessage));
}
@override
@ -273,7 +291,9 @@ class _$AdvancedLocalizationUIStateImpl
(identical(other.p4kGlobalIniLines, p4kGlobalIniLines) ||
other.p4kGlobalIniLines == p4kGlobalIniLines) &&
(identical(other.serverGlobalIniLines, serverGlobalIniLines) ||
other.serverGlobalIniLines == serverGlobalIniLines));
other.serverGlobalIniLines == serverGlobalIniLines) &&
(identical(other.errorMessage, errorMessage) ||
other.errorMessage == errorMessage));
}
@override
@ -286,7 +306,8 @@ class _$AdvancedLocalizationUIStateImpl
customizeGlobalIni,
apiLocalizationData,
p4kGlobalIniLines,
serverGlobalIniLines);
serverGlobalIniLines,
errorMessage);
@JsonKey(ignore: true)
@override
@ -306,7 +327,8 @@ abstract class _AdvancedLocalizationUIState
final String? customizeGlobalIni,
final ScLocalizationData? apiLocalizationData,
final int p4kGlobalIniLines,
final int serverGlobalIniLines}) = _$AdvancedLocalizationUIStateImpl;
final int serverGlobalIniLines,
final String errorMessage}) = _$AdvancedLocalizationUIStateImpl;
@override
String get workingText;
@ -325,6 +347,8 @@ abstract class _AdvancedLocalizationUIState
@override
int get serverGlobalIniLines;
@override
String get errorMessage;
@override
@JsonKey(ignore: true)
_$$AdvancedLocalizationUIStateImplCopyWith<_$AdvancedLocalizationUIStateImpl>
get copyWith => throw _privateConstructorUsedError;

View File

@ -7,7 +7,7 @@ part of 'advanced_localization_ui_model.dart';
// **************************************************************************
String _$advancedLocalizationUIModelHash() =>
r'9acfe6624ebce488a8fd0ed13b84d8b4faab058c';
r'4e1fc9193a85a06ba11a249d6cc00d79306d2532';
/// See also [AdvancedLocalizationUIModel].
@ProviderFor(AdvancedLocalizationUIModel)

View File

@ -61,6 +61,22 @@ class LocalizationDialogUI extends HookConsumerWidget {
width: MediaQuery.of(context).size.width,
),
),
if (!(model.getScInstallPath() ?? "").contains("LIVE"))
Padding(
padding: const EdgeInsets.only(bottom: 12),
child: InfoBar(
title: Text(S.current
.home_localization_ptu_advanced_localization_tip_title),
content: Text(S.current
.home_localization_ptu_advanced_localization_tip_title_info),
severity: InfoBarSeverity.info,
style: InfoBarThemeData(decoration: (severity) {
return BoxDecoration(color: Colors.orange);
}, iconColor: (severity) {
return Colors.white;
}),
),
),
makeListContainer(
S.current.localization_info_translation_status,
[