Skip to content

Commit

Permalink
feat: unp4kTools extract_memory
Browse files Browse the repository at this point in the history
  • Loading branch information
xkeyC committed Apr 27, 2024
1 parent 9bdccc3 commit a7e1d8d
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 32 deletions.
Binary file modified assets/binary/unp4kc.zip
Binary file not shown.
19 changes: 19 additions & 0 deletions lib/provider/unp4kc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -223,4 +223,23 @@ class Unp4kCModel extends _$Unp4kCModel {
rsPid: _rsPid!, data: "$mode<:,:>$filePath<:,:>$outputPath\n");
}
}

static Future<Uint8List> unp4kTools(
String applicationBinaryModuleDir, List<String> args) async {
await BinaryModuleConf.extractModule(
["unp4kc"], applicationBinaryModuleDir);
final execDir = "$applicationBinaryModuleDir\\unp4kc";
final exec = "$execDir\\unp4kc.exe";
final r = await Process.run(exec, args);
if (r.exitCode != 0) {
throw Exception(
"error: ${r.exitCode} , info= ${r.stdout} , err= ${r.stderr}");
}
final eventJson = await compute(json.decode, r.stdout.toString());
if (eventJson["action"] == "data: Uint8List") {
final data = eventJson["data"];
return Uint8List.fromList((data as List).cast<int>());
}
throw Exception("error: data error");
}
}
2 changes: 1 addition & 1 deletion lib/provider/unp4kc.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/ui/home/dialogs/home_game_login_dialog_ui_model.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/ui/home/home_ui_model.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions lib/ui/home/localization/localization_ui_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import 'package:starcitizen_doctor/common/utils/log.dart';
import 'package:starcitizen_doctor/common/utils/provider.dart';
import 'package:starcitizen_doctor/data/sc_localization_data.dart';
import 'package:starcitizen_doctor/generated/no_l10n_strings.dart';
import 'package:starcitizen_doctor/provider/unp4kc.dart';
import 'package:starcitizen_doctor/ui/home/home_ui_model.dart';
import 'package:starcitizen_doctor/widgets/widgets.dart';
import 'package:url_launcher/url_launcher_string.dart';
Expand Down Expand Up @@ -88,6 +89,17 @@ class LocalizationUIModel extends _$LocalizationUIModel {
await _loadData();
}

readEnglishInI() async {
final data = await Unp4kCModel.unp4kTools(
appGlobalState.applicationBinaryModuleDir!, [
"extract_memory",
"$_scInstallPath\\Data.p4k",
"Data\\Localization\\english\\global.ini"
]);
final iniData = String.fromCharCodes(data);
dPrint("read english ini => ${iniData.length}");
}

final Map<String, Map<String, ScLocalizationData>>
_allVersionLocalizationData = {};

Expand Down
2 changes: 1 addition & 1 deletion lib/ui/home/localization/localization_ui_model.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 5 additions & 27 deletions lib/ui/settings/settings_ui_model.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ final _privateConstructorUsedError = UnsupportedError(

/// @nodoc
mixin _$SettingsUIState {
dynamic get isDeviceSupportWinHello => throw _privateConstructorUsedError;
bool get isEnableToolSiteMirrors => throw _privateConstructorUsedError;
String get inputGameLaunchECore => throw _privateConstructorUsedError;
String? get customLauncherPath => throw _privateConstructorUsedError;
Expand All @@ -35,8 +34,7 @@ abstract class $SettingsUIStateCopyWith<$Res> {
_$SettingsUIStateCopyWithImpl<$Res, SettingsUIState>;
@useResult
$Res call(
{dynamic isDeviceSupportWinHello,
bool isEnableToolSiteMirrors,
{bool isEnableToolSiteMirrors,
String inputGameLaunchECore,
String? customLauncherPath,
String? customGamePath,
Expand All @@ -56,18 +54,13 @@ class _$SettingsUIStateCopyWithImpl<$Res, $Val extends SettingsUIState>
@pragma('vm:prefer-inline')
@override
$Res call({
Object? isDeviceSupportWinHello = freezed,
Object? isEnableToolSiteMirrors = null,
Object? inputGameLaunchECore = null,
Object? customLauncherPath = freezed,
Object? customGamePath = freezed,
Object? locationCacheSize = null,
}) {
return _then(_value.copyWith(
isDeviceSupportWinHello: freezed == isDeviceSupportWinHello
? _value.isDeviceSupportWinHello
: isDeviceSupportWinHello // ignore: cast_nullable_to_non_nullable
as dynamic,
isEnableToolSiteMirrors: null == isEnableToolSiteMirrors
? _value.isEnableToolSiteMirrors
: isEnableToolSiteMirrors // ignore: cast_nullable_to_non_nullable
Expand Down Expand Up @@ -101,8 +94,7 @@ abstract class _$$SettingsUIStateImplCopyWith<$Res>
@override
@useResult
$Res call(
{dynamic isDeviceSupportWinHello,
bool isEnableToolSiteMirrors,
{bool isEnableToolSiteMirrors,
String inputGameLaunchECore,
String? customLauncherPath,
String? customGamePath,
Expand All @@ -120,17 +112,13 @@ class __$$SettingsUIStateImplCopyWithImpl<$Res>
@pragma('vm:prefer-inline')
@override
$Res call({
Object? isDeviceSupportWinHello = freezed,
Object? isEnableToolSiteMirrors = null,
Object? inputGameLaunchECore = null,
Object? customLauncherPath = freezed,
Object? customGamePath = freezed,
Object? locationCacheSize = null,
}) {
return _then(_$SettingsUIStateImpl(
isDeviceSupportWinHello: freezed == isDeviceSupportWinHello
? _value.isDeviceSupportWinHello!
: isDeviceSupportWinHello,
isEnableToolSiteMirrors: null == isEnableToolSiteMirrors
? _value.isEnableToolSiteMirrors
: isEnableToolSiteMirrors // ignore: cast_nullable_to_non_nullable
Expand Down Expand Up @@ -159,16 +147,12 @@ class __$$SettingsUIStateImplCopyWithImpl<$Res>
class _$SettingsUIStateImpl implements _SettingsUIState {
_$SettingsUIStateImpl(
{this.isDeviceSupportWinHello = false,
this.isEnableToolSiteMirrors = false,
{this.isEnableToolSiteMirrors = false,
this.inputGameLaunchECore = "0",
this.customLauncherPath,
this.customGamePath,
this.locationCacheSize = 0});

@override
@JsonKey()
final dynamic isDeviceSupportWinHello;
@override
@JsonKey()
final bool isEnableToolSiteMirrors;
Expand All @@ -185,16 +169,14 @@ class _$SettingsUIStateImpl implements _SettingsUIState {

@override
String toString() {
return 'SettingsUIState(isDeviceSupportWinHello: $isDeviceSupportWinHello, isEnableToolSiteMirrors: $isEnableToolSiteMirrors, inputGameLaunchECore: $inputGameLaunchECore, customLauncherPath: $customLauncherPath, customGamePath: $customGamePath, locationCacheSize: $locationCacheSize)';
return 'SettingsUIState(isEnableToolSiteMirrors: $isEnableToolSiteMirrors, inputGameLaunchECore: $inputGameLaunchECore, customLauncherPath: $customLauncherPath, customGamePath: $customGamePath, locationCacheSize: $locationCacheSize)';
}

@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$SettingsUIStateImpl &&
const DeepCollectionEquality().equals(
other.isDeviceSupportWinHello, isDeviceSupportWinHello) &&
(identical(
other.isEnableToolSiteMirrors, isEnableToolSiteMirrors) ||
other.isEnableToolSiteMirrors == isEnableToolSiteMirrors) &&
Expand All @@ -211,7 +193,6 @@ class _$SettingsUIStateImpl implements _SettingsUIState {
@override
int get hashCode => Object.hash(
runtimeType,
const DeepCollectionEquality().hash(isDeviceSupportWinHello),
isEnableToolSiteMirrors,
inputGameLaunchECore,
customLauncherPath,
Expand All @@ -228,15 +209,12 @@ class _$SettingsUIStateImpl implements _SettingsUIState {

abstract class _SettingsUIState implements SettingsUIState {
factory _SettingsUIState(
{final dynamic isDeviceSupportWinHello,
final bool isEnableToolSiteMirrors,
{final bool isEnableToolSiteMirrors,
final String inputGameLaunchECore,
final String? customLauncherPath,
final String? customGamePath,
final int locationCacheSize}) = _$SettingsUIStateImpl;

@override
dynamic get isDeviceSupportWinHello;
@override
bool get isEnableToolSiteMirrors;
@override
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/settings/settings_ui_model.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a7e1d8d

Please sign in to comment.