mirror of
https://ghfast.top/https://github.com/StarCitizenToolBox/app.git
synced 2025-06-28 06:44:45 +08:00
feat: RSILauncherEnhance
This commit is contained in:
@ -6,7 +6,7 @@ part of 'home_ui_model.dart';
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$homeUIModelHash() => r'8308b6e327b7eeda64c39bcd73e9f2d9e6470437';
|
||||
String _$homeUIModelHash() => r'85d3242abb4264a814768a2d5ce108df46df38d9';
|
||||
|
||||
/// See also [HomeUIModel].
|
||||
@ProviderFor(HomeUIModel)
|
||||
|
383
lib/ui/tools/dialogs/rsi_launcher_enhance_dialog_ui.dart
Normal file
383
lib/ui/tools/dialogs/rsi_launcher_enhance_dialog_ui.dart
Normal file
@ -0,0 +1,383 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:archive/archive_io.dart';
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:starcitizen_doctor/app.dart';
|
||||
import 'package:starcitizen_doctor/common/conf/url_conf.dart';
|
||||
import 'package:starcitizen_doctor/common/helper/system_helper.dart';
|
||||
import 'package:starcitizen_doctor/common/io/rs_http.dart';
|
||||
import 'package:starcitizen_doctor/common/rust/api/asar_api.dart' as asar_api;
|
||||
import 'package:starcitizen_doctor/common/utils/log.dart';
|
||||
import 'package:starcitizen_doctor/generated/no_l10n_strings.dart';
|
||||
import 'package:starcitizen_doctor/widgets/widgets.dart';
|
||||
|
||||
part 'rsi_launcher_enhance_dialog_ui.freezed.dart';
|
||||
|
||||
@freezed
|
||||
class RSILauncherStateData with _$RSILauncherStateData {
|
||||
const factory RSILauncherStateData({
|
||||
required String version,
|
||||
required asar_api.RsiLauncherAsarData data,
|
||||
required String serverData,
|
||||
@Default(false) bool isPatchInstalled,
|
||||
String? enabledLocalization,
|
||||
bool? enableDownloaderBoost,
|
||||
}) = _RSILauncherStateData;
|
||||
}
|
||||
|
||||
class RsiLauncherEnhanceDialogUI extends HookConsumerWidget {
|
||||
const RsiLauncherEnhanceDialogUI({super.key});
|
||||
|
||||
static const supportLocalizationMap = {
|
||||
"en": NoL10n.langEn,
|
||||
"zh_CN": NoL10n.langZHS,
|
||||
};
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final workingText = useState("");
|
||||
|
||||
final assarState = useState<RSILauncherStateData?>(null);
|
||||
|
||||
Future<void> readState() async {
|
||||
workingText.value = "读取启动器信息...";
|
||||
assarState.value = await _readState(context).unwrap(context: context);
|
||||
if (assarState.value == null) {
|
||||
workingText.value = "";
|
||||
return;
|
||||
}
|
||||
workingText.value = "正在从网络获取增强数据...";
|
||||
if (!context.mounted) return;
|
||||
await _loadEnhanceData(context, ref, assarState)
|
||||
.unwrap(context: context)
|
||||
.unwrap(context: context);
|
||||
workingText.value = "";
|
||||
}
|
||||
|
||||
void doInstall() async {
|
||||
workingText.value = "生成补丁 ...";
|
||||
final newScript =
|
||||
await _genNewScript(assarState).unwrap(context: context);
|
||||
workingText.value = "安装补丁,这需要一点时间,取决于您的计算机性能 ...";
|
||||
if (!context.mounted) return;
|
||||
await assarState.value?.data
|
||||
.writeMainJs(content: utf8.encode(newScript))
|
||||
.unwrap(context: context);
|
||||
await readState();
|
||||
}
|
||||
|
||||
useEffect(() {
|
||||
readState();
|
||||
return null;
|
||||
}, const []);
|
||||
|
||||
return ContentDialog(
|
||||
constraints:
|
||||
BoxConstraints(maxWidth: MediaQuery.of(context).size.width * .48),
|
||||
title: Row(children: [
|
||||
IconButton(
|
||||
icon: const Icon(
|
||||
FluentIcons.back,
|
||||
size: 22,
|
||||
),
|
||||
onPressed:
|
||||
workingText.value.isEmpty ? Navigator.of(context).pop : null),
|
||||
const SizedBox(width: 12),
|
||||
const Text("RSI 启动器增强"),
|
||||
]),
|
||||
content: AnimatedSize(
|
||||
duration: const Duration(milliseconds: 130),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (workingText.value.isNotEmpty) ...[
|
||||
Center(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
const Row(),
|
||||
const SizedBox(height: 12),
|
||||
const ProgressRing(),
|
||||
const SizedBox(height: 12),
|
||||
Text(workingText.value),
|
||||
const SizedBox(height: 12),
|
||||
],
|
||||
),
|
||||
),
|
||||
] else ...[
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
"启动器内部版本信息:${assarState.value?.version}",
|
||||
style: TextStyle(
|
||||
color: Colors.white.withOpacity(.6),
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"补丁状态:${(assarState.value?.isPatchInstalled ?? false) ? "已安装" : "未安装"}",
|
||||
style: TextStyle(
|
||||
color: Colors.white.withOpacity(.6),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
if (assarState.value?.serverData.isEmpty ?? true) ...[
|
||||
const Text("获取增强数据失败,可能是网络问题或当前版本不支持"),
|
||||
] else ...[
|
||||
const SizedBox(height: 24),
|
||||
if (assarState.value?.enabledLocalization != null)
|
||||
Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
margin: const EdgeInsets.only(bottom: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: FluentTheme.of(context).cardColor,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text("RSI 启动器本地化"),
|
||||
const SizedBox(height: 3),
|
||||
Text(
|
||||
"为 RSI 启动器增加多语言支持。",
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: Colors.white.withOpacity(.6),
|
||||
),
|
||||
),
|
||||
],
|
||||
)),
|
||||
ComboBox(
|
||||
items: [
|
||||
for (final key in supportLocalizationMap.keys)
|
||||
ComboBoxItem(
|
||||
value: key,
|
||||
child: Text(supportLocalizationMap[key]!))
|
||||
],
|
||||
value: assarState.value?.enabledLocalization,
|
||||
onChanged: (v) {
|
||||
assarState.value = assarState.value!
|
||||
.copyWith(enabledLocalization: v);
|
||||
},
|
||||
),
|
||||
],
|
||||
)),
|
||||
const SizedBox(height: 3),
|
||||
if (assarState.value?.enableDownloaderBoost != null)
|
||||
Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
margin: const EdgeInsets.only(bottom: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: FluentTheme.of(context).cardColor,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Row(children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text("RSI 启动器下载增强"),
|
||||
const SizedBox(height: 3),
|
||||
Text(
|
||||
"下载游戏时可使用更多线程以提升下载速度,启用后请在启动器设置修改线程数。",
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: Colors.white.withOpacity(.6),
|
||||
),
|
||||
),
|
||||
],
|
||||
)),
|
||||
ToggleSwitch(
|
||||
onChanged: (value) {
|
||||
assarState.value = assarState.value
|
||||
?.copyWith(enableDownloaderBoost: value);
|
||||
},
|
||||
checked:
|
||||
assarState.value?.enableDownloaderBoost ?? false,
|
||||
)
|
||||
])),
|
||||
const SizedBox(height: 12),
|
||||
Center(
|
||||
child: FilledButton(
|
||||
onPressed: doInstall,
|
||||
child: const Padding(
|
||||
padding:
|
||||
EdgeInsets.symmetric(vertical: 4, horizontal: 6),
|
||||
child: Text("安装增强补丁"),
|
||||
))),
|
||||
],
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
"* 如需卸载增强补丁,请覆盖安装 RSI 启动器。",
|
||||
style: TextStyle(
|
||||
color: Colors.white.withOpacity(.6), fontSize: 13),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<RSILauncherStateData?> _readState(BuildContext context) async {
|
||||
final lPath = await SystemHelper.getRSILauncherPath(skipEXE: true);
|
||||
if (lPath.isEmpty) {
|
||||
if (!context.mounted) return null;
|
||||
showToast(context, "未找到 RSI 启动器");
|
||||
return null;
|
||||
}
|
||||
dPrint("[RsiLauncherEnhanceDialogUI] rsiLauncherPath ==== $lPath");
|
||||
final dataPath = "${lPath}resources\\app.asar";
|
||||
dPrint("[RsiLauncherEnhanceDialogUI] rsiLauncherDataPath ==== $dataPath");
|
||||
try {
|
||||
final data = await asar_api.getRsiLauncherAsarData(asarPath: dataPath);
|
||||
dPrint(
|
||||
"[RsiLauncherEnhanceDialogUI] rsiLauncherPath main.js path == ${data.mainJsPath}");
|
||||
final version =
|
||||
RegExp(r"main\.(\w+)\.js").firstMatch(data.mainJsPath)?.group(1);
|
||||
if (version == null) {
|
||||
if (!context.mounted) return null;
|
||||
showToast(context, "读取启动器信息失败!");
|
||||
return null;
|
||||
}
|
||||
dPrint(
|
||||
"[RsiLauncherEnhanceDialogUI] rsiLauncherPath main.js version == $version");
|
||||
|
||||
final mainJsString = String.fromCharCodes(data.mainJsContent);
|
||||
|
||||
final (enabledLocalization, enableDownloaderBoost) =
|
||||
_readScriptState(mainJsString);
|
||||
|
||||
return RSILauncherStateData(
|
||||
version: version,
|
||||
data: data,
|
||||
serverData: "",
|
||||
isPatchInstalled: mainJsString.contains("SC_TOOLBOX"),
|
||||
enabledLocalization: enabledLocalization,
|
||||
enableDownloaderBoost: enableDownloaderBoost,
|
||||
);
|
||||
} catch (e) {
|
||||
if (!context.mounted) return null;
|
||||
showToast(context, "读取启动器信息失败:$e");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Future<String> _loadEnhanceData(BuildContext context, WidgetRef ref,
|
||||
ValueNotifier<RSILauncherStateData?> assarState) async {
|
||||
final globalModel = ref.read(appGlobalModelProvider);
|
||||
final enhancePath =
|
||||
"${globalModel.applicationSupportDir}/launcher_enhance_data";
|
||||
final enhanceFile =
|
||||
File("$enhancePath/${assarState.value?.version}.tar.gz");
|
||||
if (!await enhanceFile.exists()) {
|
||||
final downloadUrl =
|
||||
"${URLConf.gitApiRSILauncherEnhanceUrl}/archive/${assarState.value?.version}.tar.gz";
|
||||
final r = await RSHttp.get(downloadUrl).unwrap();
|
||||
if (r.statusCode != 200 || r.data == null) {
|
||||
return "";
|
||||
}
|
||||
await enhanceFile.create(recursive: true);
|
||||
await enhanceFile.writeAsBytes(r.data!, flush: true);
|
||||
}
|
||||
final severMainJS =
|
||||
await compute(_readArchive, (enhanceFile.path, "main.js"));
|
||||
final serverMainJSString = severMainJS.toString();
|
||||
final scriptState = _readScriptState(serverMainJSString);
|
||||
if (assarState.value?.enabledLocalization == null) {
|
||||
assarState.value =
|
||||
assarState.value?.copyWith(enabledLocalization: scriptState.$1);
|
||||
dPrint(
|
||||
"[RsiLauncherEnhanceDialogUI] _loadEnhanceData enabledLocalization == ${scriptState.$1}");
|
||||
}
|
||||
if (assarState.value?.enableDownloaderBoost == null) {
|
||||
assarState.value =
|
||||
assarState.value?.copyWith(enableDownloaderBoost: scriptState.$2);
|
||||
dPrint(
|
||||
"[RsiLauncherEnhanceDialogUI] _loadEnhanceData enableDownloaderBoost == ${scriptState.$2}");
|
||||
}
|
||||
assarState.value =
|
||||
assarState.value?.copyWith(serverData: serverMainJSString);
|
||||
return serverMainJSString;
|
||||
}
|
||||
|
||||
static StringBuffer _readArchive((String savePath, String fileName) data) {
|
||||
final inputStream = InputFileStream(data.$1);
|
||||
final archive =
|
||||
TarDecoder().decodeBytes(GZipDecoder().decodeBuffer(inputStream));
|
||||
StringBuffer dataBuffer = StringBuffer("");
|
||||
for (var element in archive.files) {
|
||||
if (element.name.endsWith(data.$2)) {
|
||||
for (var value
|
||||
in (element.rawContent?.readString() ?? "").split("\n")) {
|
||||
final tv = value;
|
||||
if (tv.isNotEmpty) dataBuffer.writeln(tv);
|
||||
}
|
||||
}
|
||||
}
|
||||
archive.clear();
|
||||
return dataBuffer;
|
||||
}
|
||||
|
||||
// ignore: constant_identifier_names
|
||||
static const SC_TOOLBOX_ENABLED_LOCALIZATION_SCRIPT_START =
|
||||
"const SC_TOOLBOX_ENABLED_LOCALIZATION = ";
|
||||
|
||||
// ignore: constant_identifier_names
|
||||
static const SC_TOOLBOX_ENABLE_DOWNLOADER_BOOST_SCRIPT_START =
|
||||
"const SC_TOOLBOX_ENABLE_DOWNLOADER_BOOST = ";
|
||||
|
||||
(String?, bool?) _readScriptState(String mainJsString) {
|
||||
String? enabledLocalization;
|
||||
bool? enableDownloaderBoost;
|
||||
for (final line in mainJsString.split("\n")) {
|
||||
final lineTrim = line.trim();
|
||||
if (lineTrim.startsWith(SC_TOOLBOX_ENABLED_LOCALIZATION_SCRIPT_START)) {
|
||||
enabledLocalization = lineTrim
|
||||
.substring(SC_TOOLBOX_ENABLED_LOCALIZATION_SCRIPT_START.length)
|
||||
.replaceAll("\"", "")
|
||||
.replaceAll(";", "");
|
||||
} else if (lineTrim
|
||||
.startsWith(SC_TOOLBOX_ENABLE_DOWNLOADER_BOOST_SCRIPT_START)) {
|
||||
enableDownloaderBoost = lineTrim
|
||||
.substring(
|
||||
SC_TOOLBOX_ENABLE_DOWNLOADER_BOOST_SCRIPT_START.length)
|
||||
.toLowerCase() ==
|
||||
"true;";
|
||||
}
|
||||
}
|
||||
return (enabledLocalization, enableDownloaderBoost);
|
||||
}
|
||||
|
||||
Future<String> _genNewScript(
|
||||
ValueNotifier<RSILauncherStateData?> assarState) async {
|
||||
final serverScriptLines = assarState.value!.serverData.split("\n");
|
||||
final StringBuffer scriptBuffer = StringBuffer("");
|
||||
for (final line in serverScriptLines) {
|
||||
final lineTrim = line.trim();
|
||||
if (lineTrim.startsWith(SC_TOOLBOX_ENABLED_LOCALIZATION_SCRIPT_START)) {
|
||||
scriptBuffer.writeln(
|
||||
"$SC_TOOLBOX_ENABLED_LOCALIZATION_SCRIPT_START\"${assarState.value!.enabledLocalization}\";");
|
||||
} else if (lineTrim
|
||||
.startsWith(SC_TOOLBOX_ENABLE_DOWNLOADER_BOOST_SCRIPT_START)) {
|
||||
scriptBuffer.writeln(
|
||||
"$SC_TOOLBOX_ENABLE_DOWNLOADER_BOOST_SCRIPT_START${assarState.value!.enableDownloaderBoost};");
|
||||
} else {
|
||||
scriptBuffer.writeln(line);
|
||||
}
|
||||
}
|
||||
return scriptBuffer.toString();
|
||||
}
|
||||
}
|
245
lib/ui/tools/dialogs/rsi_launcher_enhance_dialog_ui.freezed.dart
Normal file
245
lib/ui/tools/dialogs/rsi_launcher_enhance_dialog_ui.freezed.dart
Normal file
@ -0,0 +1,245 @@
|
||||
// coverage:ignore-file
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'rsi_launcher_enhance_dialog_ui.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
final _privateConstructorUsedError = UnsupportedError(
|
||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
|
||||
|
||||
/// @nodoc
|
||||
mixin _$RSILauncherStateData {
|
||||
String get version => throw _privateConstructorUsedError;
|
||||
asar_api.RsiLauncherAsarData get data => throw _privateConstructorUsedError;
|
||||
String get serverData => throw _privateConstructorUsedError;
|
||||
bool get isPatchInstalled => throw _privateConstructorUsedError;
|
||||
String? get enabledLocalization => throw _privateConstructorUsedError;
|
||||
bool? get enableDownloaderBoost => throw _privateConstructorUsedError;
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
$RSILauncherStateDataCopyWith<RSILauncherStateData> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $RSILauncherStateDataCopyWith<$Res> {
|
||||
factory $RSILauncherStateDataCopyWith(RSILauncherStateData value,
|
||||
$Res Function(RSILauncherStateData) then) =
|
||||
_$RSILauncherStateDataCopyWithImpl<$Res, RSILauncherStateData>;
|
||||
@useResult
|
||||
$Res call(
|
||||
{String version,
|
||||
asar_api.RsiLauncherAsarData data,
|
||||
String serverData,
|
||||
bool isPatchInstalled,
|
||||
String? enabledLocalization,
|
||||
bool? enableDownloaderBoost});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$RSILauncherStateDataCopyWithImpl<$Res,
|
||||
$Val extends RSILauncherStateData>
|
||||
implements $RSILauncherStateDataCopyWith<$Res> {
|
||||
_$RSILauncherStateDataCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? version = null,
|
||||
Object? data = null,
|
||||
Object? serverData = null,
|
||||
Object? isPatchInstalled = null,
|
||||
Object? enabledLocalization = freezed,
|
||||
Object? enableDownloaderBoost = freezed,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
version: null == version
|
||||
? _value.version
|
||||
: version // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
data: null == data
|
||||
? _value.data
|
||||
: data // ignore: cast_nullable_to_non_nullable
|
||||
as asar_api.RsiLauncherAsarData,
|
||||
serverData: null == serverData
|
||||
? _value.serverData
|
||||
: serverData // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
isPatchInstalled: null == isPatchInstalled
|
||||
? _value.isPatchInstalled
|
||||
: isPatchInstalled // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
enabledLocalization: freezed == enabledLocalization
|
||||
? _value.enabledLocalization
|
||||
: enabledLocalization // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
enableDownloaderBoost: freezed == enableDownloaderBoost
|
||||
? _value.enableDownloaderBoost
|
||||
: enableDownloaderBoost // ignore: cast_nullable_to_non_nullable
|
||||
as bool?,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$RSILauncherStateDataImplCopyWith<$Res>
|
||||
implements $RSILauncherStateDataCopyWith<$Res> {
|
||||
factory _$$RSILauncherStateDataImplCopyWith(_$RSILauncherStateDataImpl value,
|
||||
$Res Function(_$RSILauncherStateDataImpl) then) =
|
||||
__$$RSILauncherStateDataImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call(
|
||||
{String version,
|
||||
asar_api.RsiLauncherAsarData data,
|
||||
String serverData,
|
||||
bool isPatchInstalled,
|
||||
String? enabledLocalization,
|
||||
bool? enableDownloaderBoost});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$RSILauncherStateDataImplCopyWithImpl<$Res>
|
||||
extends _$RSILauncherStateDataCopyWithImpl<$Res, _$RSILauncherStateDataImpl>
|
||||
implements _$$RSILauncherStateDataImplCopyWith<$Res> {
|
||||
__$$RSILauncherStateDataImplCopyWithImpl(_$RSILauncherStateDataImpl _value,
|
||||
$Res Function(_$RSILauncherStateDataImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? version = null,
|
||||
Object? data = null,
|
||||
Object? serverData = null,
|
||||
Object? isPatchInstalled = null,
|
||||
Object? enabledLocalization = freezed,
|
||||
Object? enableDownloaderBoost = freezed,
|
||||
}) {
|
||||
return _then(_$RSILauncherStateDataImpl(
|
||||
version: null == version
|
||||
? _value.version
|
||||
: version // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
data: null == data
|
||||
? _value.data
|
||||
: data // ignore: cast_nullable_to_non_nullable
|
||||
as asar_api.RsiLauncherAsarData,
|
||||
serverData: null == serverData
|
||||
? _value.serverData
|
||||
: serverData // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
isPatchInstalled: null == isPatchInstalled
|
||||
? _value.isPatchInstalled
|
||||
: isPatchInstalled // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
enabledLocalization: freezed == enabledLocalization
|
||||
? _value.enabledLocalization
|
||||
: enabledLocalization // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
enableDownloaderBoost: freezed == enableDownloaderBoost
|
||||
? _value.enableDownloaderBoost
|
||||
: enableDownloaderBoost // ignore: cast_nullable_to_non_nullable
|
||||
as bool?,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$RSILauncherStateDataImpl implements _RSILauncherStateData {
|
||||
const _$RSILauncherStateDataImpl(
|
||||
{required this.version,
|
||||
required this.data,
|
||||
required this.serverData,
|
||||
this.isPatchInstalled = false,
|
||||
this.enabledLocalization,
|
||||
this.enableDownloaderBoost});
|
||||
|
||||
@override
|
||||
final String version;
|
||||
@override
|
||||
final asar_api.RsiLauncherAsarData data;
|
||||
@override
|
||||
final String serverData;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool isPatchInstalled;
|
||||
@override
|
||||
final String? enabledLocalization;
|
||||
@override
|
||||
final bool? enableDownloaderBoost;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'RSILauncherStateData(version: $version, data: $data, serverData: $serverData, isPatchInstalled: $isPatchInstalled, enabledLocalization: $enabledLocalization, enableDownloaderBoost: $enableDownloaderBoost)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$RSILauncherStateDataImpl &&
|
||||
(identical(other.version, version) || other.version == version) &&
|
||||
(identical(other.data, data) || other.data == data) &&
|
||||
(identical(other.serverData, serverData) ||
|
||||
other.serverData == serverData) &&
|
||||
(identical(other.isPatchInstalled, isPatchInstalled) ||
|
||||
other.isPatchInstalled == isPatchInstalled) &&
|
||||
(identical(other.enabledLocalization, enabledLocalization) ||
|
||||
other.enabledLocalization == enabledLocalization) &&
|
||||
(identical(other.enableDownloaderBoost, enableDownloaderBoost) ||
|
||||
other.enableDownloaderBoost == enableDownloaderBoost));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, version, data, serverData,
|
||||
isPatchInstalled, enabledLocalization, enableDownloaderBoost);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$RSILauncherStateDataImplCopyWith<_$RSILauncherStateDataImpl>
|
||||
get copyWith =>
|
||||
__$$RSILauncherStateDataImplCopyWithImpl<_$RSILauncherStateDataImpl>(
|
||||
this, _$identity);
|
||||
}
|
||||
|
||||
abstract class _RSILauncherStateData implements RSILauncherStateData {
|
||||
const factory _RSILauncherStateData(
|
||||
{required final String version,
|
||||
required final asar_api.RsiLauncherAsarData data,
|
||||
required final String serverData,
|
||||
final bool isPatchInstalled,
|
||||
final String? enabledLocalization,
|
||||
final bool? enableDownloaderBoost}) = _$RSILauncherStateDataImpl;
|
||||
|
||||
@override
|
||||
String get version;
|
||||
@override
|
||||
asar_api.RsiLauncherAsarData get data;
|
||||
@override
|
||||
String get serverData;
|
||||
@override
|
||||
bool get isPatchInstalled;
|
||||
@override
|
||||
String? get enabledLocalization;
|
||||
@override
|
||||
bool? get enableDownloaderBoost;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
_$$RSILauncherStateDataImplCopyWith<_$RSILauncherStateDataImpl>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
@ -23,6 +23,7 @@ import 'package:url_launcher/url_launcher_string.dart';
|
||||
import 'package:xml/xml.dart';
|
||||
|
||||
import 'dialogs/hosts_booster_dialog_ui.dart';
|
||||
import 'dialogs/rsi_launcher_enhance_dialog_ui.dart';
|
||||
|
||||
part 'tools_ui_model.g.dart';
|
||||
|
||||
@ -90,6 +91,13 @@ class ToolsUIModel extends _$ToolsUIModel {
|
||||
const Icon(FluentIcons.virtual_network, size: 24),
|
||||
onTap: () => _doHostsBooster(context),
|
||||
),
|
||||
ToolsItemData(
|
||||
"rsilauncher_enhance_mod",
|
||||
"RSI 启动器增强",
|
||||
"启动器汉化,下载线程增强",
|
||||
const Icon(FluentIcons.c_plus_plus, size: 24),
|
||||
onTap: () => _rsiEnhance(context),
|
||||
),
|
||||
ToolsItemData(
|
||||
"reinstall_eac",
|
||||
S.current.tools_action_reinstall_easyanticheat,
|
||||
@ -584,4 +592,10 @@ class ToolsUIModel extends _$ToolsUIModel {
|
||||
_unp4kc(BuildContext context) async {
|
||||
context.push("/tools/unp4kc");
|
||||
}
|
||||
|
||||
_rsiEnhance(BuildContext context) async {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) => const RsiLauncherEnhanceDialogUI());
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ part of 'tools_ui_model.dart';
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$toolsUIModelHash() => r'5753016dc2cbcf3fafd2fa561d5b91a3295ca04b';
|
||||
String _$toolsUIModelHash() => r'6cf170210fa7a7c2c63bde9d0920c64a20a81263';
|
||||
|
||||
/// See also [ToolsUIModel].
|
||||
@ProviderFor(ToolsUIModel)
|
||||
|
Reference in New Issue
Block a user