feat: Disable game launch tools when not in zh_CN

fix: https://github.com/StarCitizenToolBox/app/issues/82
This commit is contained in:
xkeyC 2025-05-04 10:07:07 +08:00
parent 033e2824a4
commit 85bc6e487b

View File

@ -54,9 +54,7 @@ class HomeUI extends HookConsumerWidget {
child: Text(S.current.doctor_action_view_details), child: Text(S.current.doctor_action_view_details),
onPressed: () => _showPlacard(context, homeState), onPressed: () => _showPlacard(context, homeState),
), ),
onClose: homeState.appPlacardData?.alwaysShow == true onClose: homeState.appPlacardData?.alwaysShow == true ? null : () => model.closePlacard(),
? null
: () => model.closePlacard(),
), ),
const SizedBox(height: 6), const SizedBox(height: 6),
], ],
@ -87,8 +85,7 @@ class HomeUI extends HookConsumerWidget {
); );
} }
List<Widget> makeIndex(BuildContext context, HomeUIModel model, List<Widget> makeIndex(BuildContext context, HomeUIModel model, HomeUIModelState homeState, WidgetRef ref) {
HomeUIModelState homeState, WidgetRef ref) {
double width = 280; double width = 280;
return [ return [
Stack( Stack(
@ -154,35 +151,28 @@ class HomeUI extends HookConsumerWidget {
onChanged: model.onChangeInstallPath, onChanged: model.onChangeInstallPath,
), ),
), ),
if (S.current.app_language_code == "zh_CN") ...[
const SizedBox(width: 12),
Button(
onPressed: homeState.webLocalizationVersionsData == null ? null : () => model.launchRSI(context),
style: homeState.isCurGameRunning
? null
: ButtonStyle(
backgroundColor: WidgetStateProperty.resolveWith(_getRunButtonColor),
),
child: Padding(
padding: const EdgeInsets.all(6),
child: Icon(
homeState.isCurGameRunning ? FluentIcons.stop_solid : FluentIcons.play_solid,
color: homeState.isCurGameRunning ? Colors.red.withValues(alpha: .8) : Colors.white,
),
)),
],
const SizedBox(width: 12), const SizedBox(width: 12),
Button( Button(
onPressed: homeState.webLocalizationVersionsData == null onPressed: () => _checkAndGoInputMethod(context, homeState, model, ref),
? null
: () => model.launchRSI(context),
style: homeState.isCurGameRunning
? null
: ButtonStyle(
backgroundColor:
WidgetStateProperty.resolveWith(_getRunButtonColor),
),
child: Padding(
padding: const EdgeInsets.all(6),
child: Icon(
homeState.isCurGameRunning
? FluentIcons.stop_solid
: FluentIcons.play_solid,
color: homeState.isCurGameRunning
? Colors.red.withValues(alpha: .8)
: Colors.white,
),
)),
const SizedBox(width: 12),
Button(
onPressed: () =>
_checkAndGoInputMethod(context, homeState, model, ref),
style: ButtonStyle( style: ButtonStyle(
backgroundColor: backgroundColor: WidgetStateProperty.resolveWith((_) => Colors.blue),
WidgetStateProperty.resolveWith((_) => Colors.blue),
), ),
child: Padding( child: Padding(
padding: const EdgeInsets.all(6), padding: const EdgeInsets.all(6),
@ -206,8 +196,7 @@ class HomeUI extends HookConsumerWidget {
]; ];
} }
Widget makeLeftColumn(BuildContext context, HomeUIModel model, double width, Widget makeLeftColumn(BuildContext context, HomeUIModel model, double width, HomeUIModelState homeState) {
HomeUIModelState homeState) {
return Stack( return Stack(
children: [ children: [
Column( Column(
@ -228,13 +217,10 @@ class HomeUI extends HookConsumerWidget {
colorFilter: makeSvgColor(Colors.white), colorFilter: makeSvgColor(Colors.white),
height: 18, height: 18,
), ),
name: S.current name: S.current.home_action_star_citizen_website_localization,
.home_action_star_citizen_website_localization, webTitle: S.current.home_action_star_citizen_website_localization,
webTitle: S.current
.home_action_star_citizen_website_localization,
webURL: "https://robertsspaceindustries.com", webURL: "https://robertsspaceindustries.com",
info: S.current info: S.current.home_action_info_roberts_space_industries_origin,
.home_action_info_roberts_space_industries_origin,
useLocalization: true, useLocalization: true,
width: width, width: width,
touchKey: "webLocalization_rsi"), touchKey: "webLocalization_rsi"),
@ -252,8 +238,7 @@ class HomeUI extends HookConsumerWidget {
name: S.current.home_action_uex_localization, name: S.current.home_action_uex_localization,
webTitle: S.current.home_action_uex_localization, webTitle: S.current.home_action_uex_localization,
webURL: "https://uexcorp.space/", webURL: "https://uexcorp.space/",
info: S.current info: S.current.home_action_info_mining_refining_trade_calculator,
.home_action_info_mining_refining_trade_calculator,
useLocalization: true, useLocalization: true,
width: width, width: width,
touchKey: "webLocalization_uex"), touchKey: "webLocalization_uex"),
@ -269,11 +254,9 @@ class HomeUI extends HookConsumerWidget {
], ],
), ),
name: S.current.home_action_dps_calculator_localization, name: S.current.home_action_dps_calculator_localization,
webTitle: webTitle: S.current.home_action_dps_calculator_localization,
S.current.home_action_dps_calculator_localization,
webURL: "https://www.erkul.games/live/calculator", webURL: "https://www.erkul.games/live/calculator",
info: S.current info: S.current.home_action_info_ship_upgrade_damage_value_query,
.home_action_info_ship_upgrade_damage_value_query,
useLocalization: true, useLocalization: true,
width: width, width: width,
touchKey: "webLocalization_dps"), touchKey: "webLocalization_dps"),
@ -283,8 +266,7 @@ class HomeUI extends HookConsumerWidget {
Row( Row(
children: [ children: [
Button( Button(
child: child: const FaIcon(FontAwesomeIcons.chrome, size: 18),
const FaIcon(FontAwesomeIcons.chrome, size: 18),
onPressed: () { onPressed: () {
launchUrlString( launchUrlString(
"https://chrome.google.com/webstore/detail/gocnjckojmledijgmadmacoikibcggja?authuser=0&hl=zh-CN"); "https://chrome.google.com/webstore/detail/gocnjckojmledijgmadmacoikibcggja?authuser=0&hl=zh-CN");
@ -300,21 +282,17 @@ class HomeUI extends HookConsumerWidget {
), ),
const SizedBox(width: 12), const SizedBox(width: 12),
Button( Button(
child: const FaIcon(FontAwesomeIcons.firefoxBrowser, child: const FaIcon(FontAwesomeIcons.firefoxBrowser, size: 18),
size: 18),
onPressed: () { onPressed: () {
launchUrlString( launchUrlString("https://addons.mozilla.org/zh-CN/firefox/"
"https://addons.mozilla.org/zh-CN/firefox/"
"addon/%E6%98%9F%E9%99%85%E5%85%AC%E6%B0%91%E7%9B%92%E5%AD%90%E6%B5%8F%E8%A7%88%E5%99%A8%E6%8B%93%E5%B1%95/"); "addon/%E6%98%9F%E9%99%85%E5%85%AC%E6%B0%91%E7%9B%92%E5%AD%90%E6%B5%8F%E8%A7%88%E5%99%A8%E6%8B%93%E5%B1%95/");
}, },
), ),
const SizedBox(width: 12), const SizedBox(width: 12),
Button( Button(
child: child: const FaIcon(FontAwesomeIcons.github, size: 18),
const FaIcon(FontAwesomeIcons.github, size: 18),
onPressed: () { onPressed: () {
launchUrlString( launchUrlString("https://github.com/StarCitizenToolBox/StarCitizenBoxBrowserEx");
"https://github.com/StarCitizenToolBox/StarCitizenBoxBrowserEx");
}, },
), ),
], ],
@ -330,9 +308,8 @@ class HomeUI extends HookConsumerWidget {
if (homeState.webLocalizationVersionsData == null) if (homeState.webLocalizationVersionsData == null)
Positioned.fill( Positioned.fill(
child: Container( child: Container(
decoration: BoxDecoration( decoration:
color: Colors.black.withValues(alpha: .3), BoxDecoration(color: Colors.black.withValues(alpha: .3), borderRadius: BorderRadius.circular(12)),
borderRadius: BorderRadius.circular(12)),
child: const Center( child: const Center(
child: ProgressRing(), child: ProgressRing(),
), ),
@ -341,16 +318,13 @@ class HomeUI extends HookConsumerWidget {
); );
} }
Widget makeNewsCard( Widget makeNewsCard(BuildContext context, HomeUIModel model, HomeUIModelState homeState) {
BuildContext context, HomeUIModel model, HomeUIModelState homeState) {
return ScrollConfiguration( return ScrollConfiguration(
behavior: ScrollConfiguration.of(context).copyWith(scrollbars: false), behavior: ScrollConfiguration.of(context).copyWith(scrollbars: false),
child: Container( child: Container(
width: 316, width: 316,
height: 386, height: 386,
decoration: BoxDecoration( decoration: BoxDecoration(color: Colors.white.withValues(alpha: .1), borderRadius: BorderRadius.circular(12)),
color: Colors.white.withValues(alpha: .1),
borderRadius: BorderRadius.circular(12)),
child: SingleChildScrollView( child: SingleChildScrollView(
child: Column( child: Column(
children: [ children: [
@ -365,13 +339,11 @@ class HomeUI extends HookConsumerWidget {
), ),
child: homeState.rssVideoItems == null child: homeState.rssVideoItems == null
? Container( ? Container(
decoration: BoxDecoration( decoration: BoxDecoration(color: Colors.white.withValues(alpha: .1)),
color: Colors.white.withValues(alpha: .1)),
child: makeLoading(context), child: makeLoading(context),
) )
: Swiper( : Swiper(
itemCount: getMinNumber( itemCount: getMinNumber([homeState.rssVideoItems?.length ?? 0, 6]),
[homeState.rssVideoItems?.length ?? 0, 6]),
itemBuilder: (context, index) { itemBuilder: (context, index) {
final item = homeState.rssVideoItems![index]; final item = homeState.rssVideoItems![index];
return GestureDetector( return GestureDetector(
@ -408,8 +380,7 @@ class HomeUI extends HookConsumerWidget {
} }
}, },
child: Padding( child: Padding(
padding: const EdgeInsets.only( padding: const EdgeInsets.only(left: 12, right: 12, top: 4, bottom: 4),
left: 12, right: 12, top: 4, bottom: 4),
child: Row( child: Row(
children: [ children: [
getRssIcon(item.link ?? ""), getRssIcon(item.link ?? ""),
@ -459,24 +430,14 @@ class HomeUI extends HookConsumerWidget {
return const FaIcon(FontAwesomeIcons.rss, size: 14); return const FaIcon(FontAwesomeIcons.rss, size: 14);
} }
Widget makeIndexActionLists(BuildContext context, HomeUIModel model, Widget makeIndexActionLists(BuildContext context, HomeUIModel model, HomeUIModelState homeState, WidgetRef ref) {
HomeUIModelState homeState, WidgetRef ref) {
final items = [ final items = [
_HomeItemData( _HomeItemData("game_doctor", S.current.home_action_one_click_diagnosis,
"game_doctor", S.current.home_action_info_one_click_diagnosis_star_citizen, FluentIcons.auto_deploy_settings),
S.current.home_action_one_click_diagnosis, _HomeItemData("localization", S.current.home_action_localization_management,
S.current.home_action_info_one_click_diagnosis_star_citizen, S.current.home_action_info_quick_install_localization_resources, FluentIcons.locale_language),
FluentIcons.auto_deploy_settings), _HomeItemData("performance", S.current.home_action_performance_optimization,
_HomeItemData( S.current.home_action_info_engine_config_optimization, FluentIcons.process_meta_task),
"localization",
S.current.home_action_localization_management,
S.current.home_action_info_quick_install_localization_resources,
FluentIcons.locale_language),
_HomeItemData(
"performance",
S.current.home_action_performance_optimization,
S.current.home_action_info_engine_config_optimization,
FluentIcons.process_meta_task),
]; ];
return Padding( return Padding(
padding: const EdgeInsets.all(24), padding: const EdgeInsets.all(24),
@ -497,9 +458,7 @@ class HomeUI extends HookConsumerWidget {
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
color: states.isHovered color: states.isHovered
? FluentTheme.of(context) ? FluentTheme.of(context).cardColor.withValues(alpha: .1)
.cardColor
.withValues(alpha: .1)
: FluentTheme.of(context).cardColor, : FluentTheme.of(context).cardColor,
), ),
child: Padding( child: Padding(
@ -508,8 +467,7 @@ class HomeUI extends HookConsumerWidget {
children: [ children: [
Container( Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white.withValues(alpha: .2), color: Colors.white.withValues(alpha: .2), borderRadius: BorderRadius.circular(1000)),
borderRadius: BorderRadius.circular(1000)),
child: Padding( child: Padding(
padding: const EdgeInsets.all(12), padding: const EdgeInsets.all(12),
child: Icon( child: Icon(
@ -531,22 +489,15 @@ class HomeUI extends HookConsumerWidget {
const SizedBox(height: 4), const SizedBox(height: 4),
Text( Text(
item.infoString, item.infoString,
style: TextStyle( style: TextStyle(fontSize: 14, color: Colors.white.withValues(alpha: .6)),
fontSize: 14,
color: Colors.white.withValues(alpha: .6)),
), ),
], ],
)), )),
if (item.key == "localization" && if (item.key == "localization" && homeState.localizationUpdateInfo != null)
homeState.localizationUpdateInfo != null)
Container( Container(
padding: const EdgeInsets.only( padding: const EdgeInsets.only(top: 3, bottom: 3, left: 8, right: 8),
top: 3, bottom: 3, left: 8, right: 8), decoration: BoxDecoration(color: Colors.red, borderRadius: BorderRadius.circular(12)),
decoration: BoxDecoration( child: Text(homeState.localizationUpdateInfo?.key ?? " "),
color: Colors.red,
borderRadius: BorderRadius.circular(12)),
child: Text(
homeState.localizationUpdateInfo?.key ?? " "),
), ),
const SizedBox(width: 12), const SizedBox(width: 12),
const Icon( const Icon(
@ -610,9 +561,7 @@ class HomeUI extends HookConsumerWidget {
child: Text( child: Text(
info, info,
maxLines: 1, maxLines: 1,
style: TextStyle( style: TextStyle(fontSize: 12, color: Colors.white.withValues(alpha: .6)),
fontSize: 12,
color: Colors.white.withValues(alpha: .6)),
), ),
) )
], ],
@ -632,12 +581,10 @@ class HomeUI extends HookConsumerWidget {
); );
} }
Widget makeGameStatusCard(BuildContext context, HomeUIModel model, Widget makeGameStatusCard(BuildContext context, HomeUIModel model, double width, HomeUIModelState homeState) {
double width, HomeUIModelState homeState) {
final statusCnName = { final statusCnName = {
"Platform": S.current.home_action_rsi_status_platform, "Platform": S.current.home_action_rsi_status_platform,
"Persistent Universe": "Persistent Universe": S.current.home_action_rsi_status_persistent_universe,
S.current.home_action_rsi_status_persistent_universe,
"Electronic Access": S.current.home_action_rsi_status_electronic_access, "Electronic Access": S.current.home_action_rsi_status_electronic_access,
"Arena Commander": S.current.home_action_rsi_status_arena_commander "Arena Commander": S.current.home_action_rsi_status_arena_commander
}; };
@ -648,9 +595,7 @@ class HomeUI extends HookConsumerWidget {
child: GestureDetector( child: GestureDetector(
onTap: () { onTap: () {
model.goWebView( model.goWebView(
context, context, S.current.home_action_rsi_status_rsi_server_status, "https://status.robertsspaceindustries.com/",
S.current.home_action_rsi_status_rsi_server_status,
"https://status.robertsspaceindustries.com/",
useLocalization: true); useLocalization: true);
}, },
child: Container( child: Container(
@ -676,9 +621,7 @@ class HomeUI extends HookConsumerWidget {
child: Center( child: Center(
child: Icon( child: Icon(
FontAwesomeIcons.solidCircle, FontAwesomeIcons.solidCircle,
color: model.isRSIServerStatusOK(item) color: model.isRSIServerStatusOK(item) ? Colors.green : Colors.red,
? Colors.green
: Colors.red,
size: 12, size: 12,
), ),
), ),
@ -704,8 +647,7 @@ class HomeUI extends HookConsumerWidget {
); );
} }
Widget makeActivityBanner(BuildContext context, HomeUIModel model, Widget makeActivityBanner(BuildContext context, HomeUIModel model, double width, HomeUIModelState homeState) {
double width, HomeUIModelState homeState) {
return Tilt( return Tilt(
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
shadowConfig: const ShadowConfig(disable: true), shadowConfig: const ShadowConfig(disable: true),
@ -715,8 +657,7 @@ class HomeUI extends HookConsumerWidget {
width: width + 24, width: width + 24,
decoration: BoxDecoration(color: FluentTheme.of(context).cardColor), decoration: BoxDecoration(color: FluentTheme.of(context).cardColor),
child: Padding( child: Padding(
padding: padding: const EdgeInsets.only(left: 12, right: 12, top: 8, bottom: 8),
const EdgeInsets.only(left: 12, right: 12, top: 8, bottom: 8),
child: (homeState.countdownFestivalListData == null) child: (homeState.countdownFestivalListData == null)
? SizedBox( ? SizedBox(
width: width, width: width,
@ -729,13 +670,11 @@ class HomeUI extends HookConsumerWidget {
width: width, width: width,
height: 62, height: 62,
child: Swiper( child: Swiper(
itemCount: getMinNumber( itemCount: getMinNumber([homeState.countdownFestivalListData!.length, 6]),
[homeState.countdownFestivalListData!.length, 6]),
autoplay: true, autoplay: true,
autoplayDelay: 5000, autoplayDelay: 5000,
itemBuilder: (context, index) { itemBuilder: (context, index) {
final item = final item = homeState.countdownFestivalListData![index];
homeState.countdownFestivalListData![index];
return Row( return Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [ children: [
@ -758,9 +697,7 @@ class HomeUI extends HookConsumerWidget {
), ),
const SizedBox(height: 3), const SizedBox(height: 3),
CountdownTimeText( CountdownTimeText(
targetTime: targetTime: DateTime.fromMillisecondsSinceEpoch(item.time ?? 0),
DateTime.fromMillisecondsSinceEpoch(
item.time ?? 0),
), ),
], ],
), ),
@ -790,8 +727,7 @@ class HomeUI extends HookConsumerWidget {
context: context, context: context,
builder: (context) { builder: (context) {
return HomeMdContentDialogUI( return HomeMdContentDialogUI(
title: homeState.appPlacardData?.title ?? title: homeState.appPlacardData?.title ?? S.current.home_announcement_details,
S.current.home_announcement_details,
url: homeState.appPlacardData?.link, url: homeState.appPlacardData?.link,
); );
}); });
@ -800,14 +736,11 @@ class HomeUI extends HookConsumerWidget {
} }
_onTapFestival(BuildContext context) { _onTapFestival(BuildContext context) {
showDialog( showDialog(context: context, builder: (context) => const HomeCountdownDialogUI());
context: context, builder: (context) => const HomeCountdownDialogUI());
} }
Future<void> _onMenuTap(BuildContext context, String key, Future<void> _onMenuTap(BuildContext context, String key, HomeUIModelState homeState, WidgetRef ref) async {
HomeUIModelState homeState, WidgetRef ref) async { String gameInstallReqInfo = S.current.home_action_info_valid_install_location_required;
String gameInstallReqInfo =
S.current.home_action_info_valid_install_location_required;
switch (key) { switch (key) {
case "localization": case "localization":
if (homeState.scInstalledPath == "not_install") { if (homeState.scInstalledPath == "not_install") {
@ -858,25 +791,22 @@ class HomeUI extends HookConsumerWidget {
} }
} }
void _checkAndGoInputMethod(BuildContext context, HomeUIModelState homeState, void _checkAndGoInputMethod(
HomeUIModel model, WidgetRef ref) async { BuildContext context, HomeUIModelState homeState, HomeUIModel model, WidgetRef ref) async {
final localizationState = ref.read(localizationUIModelProvider); final localizationState = ref.read(localizationUIModelProvider);
if (localizationState.communityInputMethodLanguageData == null) { if (localizationState.communityInputMethodLanguageData == null) {
showToast(context, S.current.input_method_feature_maintenance); showToast(context, S.current.input_method_feature_maintenance);
return; return;
} }
if (localizationState.installedCommunityInputMethodSupportVersion == null) { if (localizationState.installedCommunityInputMethodSupportVersion == null) {
final userOK = await showConfirmDialogs( final userOK = await showConfirmDialogs(context, S.current.input_method_community_input_method_not_installed,
context,
S.current.input_method_community_input_method_not_installed,
Text(S.current.input_method_install_community_input_method_prompt)); Text(S.current.input_method_install_community_input_method_prompt));
if (userOK) { if (userOK) {
if (!context.mounted) return; if (!context.mounted) return;
() async { () async {
await _onMenuTap(context, 'localization', homeState, ref); await _onMenuTap(context, 'localization', homeState, ref);
final localizationState = ref.read(localizationUIModelProvider); final localizationState = ref.read(localizationUIModelProvider);
if (localizationState.installedCommunityInputMethodSupportVersion != if (localizationState.installedCommunityInputMethodSupportVersion != null) {
null) {
await Future.delayed(Duration(milliseconds: 300)); await Future.delayed(Duration(milliseconds: 300));
if (!context.mounted) return; if (!context.mounted) return;
await _goInputMethod(context, model); await _goInputMethod(context, model);
@ -885,8 +815,7 @@ class HomeUI extends HookConsumerWidget {
}(); }();
await Future.delayed(Duration(milliseconds: 300)); await Future.delayed(Duration(milliseconds: 300));
final localizationModel = final localizationModel = ref.read(localizationUIModelProvider.notifier);
ref.read(localizationUIModelProvider.notifier);
if (!context.mounted) return; if (!context.mounted) return;
localizationModel.checkReinstall(context); localizationModel.checkReinstall(context);
} }