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( MessageLookupByLibrary.simpleMessage(
"Localization has a new version!"), "Localization has a new version!"),
"home_localization_new_version_installed": m34, "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": "home_localization_select_customize_file":
MessageLookupByLibrary.simpleMessage( MessageLookupByLibrary.simpleMessage(
"Please select custom Localization file"), "Please select custom Localization file"),

View File

@ -571,6 +571,11 @@ class MessageLookup extends MessageLookupByLibrary {
"home_localization_new_version_available": "home_localization_new_version_available":
MessageLookupByLibrary.simpleMessage("汉化有新版本!"), MessageLookupByLibrary.simpleMessage("汉化有新版本!"),
"home_localization_new_version_installed": m34, "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": "home_localization_select_customize_file":
MessageLookupByLibrary.simpleMessage("请选择自定义汉化文件"), MessageLookupByLibrary.simpleMessage("请选择自定义汉化文件"),
"home_localization_select_customize_file_ini": "home_localization_select_customize_file_ini":

View File

@ -4783,6 +4783,26 @@ class S {
args: [], 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> { class AppLocalizationDelegate extends LocalizationsDelegate<S> {

View File

@ -823,5 +823,7 @@
"tools_unp4k_msg_unknown_file_type": "Unknown file type\n{v0}", "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_ini": "Please select INI file",
"home_localization_select_customize_file": "Please select custom Localization 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}", "tools_unp4k_msg_unknown_file_type": "未知文件类型\n{v0}",
"home_localization_select_customize_file_ini": "请选择 ini 文件", "home_localization_select_customize_file_ini": "请选择 ini 文件",
"home_localization_select_customize_file": "请选择自定义汉化文件", "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 // RiverpodGenerator
// ************************************************************************** // **************************************************************************
String _$unp4kCModelHash() => r'24f5043f687a5f652a0741b8e6f4a3855fca0101'; String _$unp4kCModelHash() => r'23b148d557f55aa6050f1b1e38a3465d22a09034';
/// See also [Unp4kCModel]. /// See also [Unp4kCModel].
@ProviderFor(Unp4kCModel) @ProviderFor(Unp4kCModel)

View File

@ -50,6 +50,14 @@ class AdvancedLocalizationUI extends HookConsumerWidget {
) )
: Column( : Column(
children: [ children: [
if (state.errorMessage.isNotEmpty)
Padding(
padding: const EdgeInsets.all(32),
child: Center(
child: Text(state.errorMessage),
),
)
else ...[
Row( Row(
children: [ children: [
const SizedBox(width: 12), const SizedBox(width: 12),
@ -58,7 +66,8 @@ class AdvancedLocalizationUI extends HookConsumerWidget {
children: [ children: [
Text( Text(
S.current.home_localization_advanced_msg_version( S.current.home_localization_advanced_msg_version(
state.apiLocalizationData?.versionName ?? "-"), state.apiLocalizationData?.versionName ??
"-"),
), ),
const SizedBox(width: 12), const SizedBox(width: 12),
Button( Button(
@ -83,7 +92,8 @@ class AdvancedLocalizationUI extends HookConsumerWidget {
], ],
)), )),
Text(S.current.home_localization_advanced_title_msg( Text(S.current.home_localization_advanced_title_msg(
state.serverGlobalIniLines, state.p4kGlobalIniLines)), state.serverGlobalIniLines,
state.p4kGlobalIniLines)),
const SizedBox(width: 32), const SizedBox(width: 32),
Button( Button(
child: Padding( child: Padding(
@ -101,6 +111,7 @@ class AdvancedLocalizationUI extends HookConsumerWidget {
Expanded( Expanded(
child: child:
_makeBody(context, homeUIState, state, ref, model)), _makeBody(context, homeUIState, state, ref, model)),
]
], ],
)); ));
} }

View File

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

View File

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

View File

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

View File

@ -61,6 +61,22 @@ class LocalizationDialogUI extends HookConsumerWidget {
width: MediaQuery.of(context).size.width, 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( makeListContainer(
S.current.localization_info_translation_status, S.current.localization_info_translation_status,
[ [