diff --git a/src/Snap.Hutao/Snap.Hutao/Model/Entity/SettingEntry.Constant.cs b/src/Snap.Hutao/Snap.Hutao/Model/Entity/SettingEntry.Constant.cs
index 6d06195e..f22ffdf9 100644
--- a/src/Snap.Hutao/Snap.Hutao/Model/Entity/SettingEntry.Constant.cs
+++ b/src/Snap.Hutao/Snap.Hutao/Model/Entity/SettingEntry.Constant.cs
@@ -42,6 +42,7 @@ internal sealed partial class SettingEntry
public const string LaunchIsUseCloudThirdPartyMobile = "Launch.IsUseCloudThirdPartyMobile";
public const string LaunchIsWindowsHDREnabled = "Launch.IsWindowsHDREnabled";
public const string LaunchUseStarwardPlayTimeStatistics = "Launch.UseStarwardPlayTimeStatistics";
+ public const string LaunchUseBetterGenshinImpactAutomation = "Launch.UseBetterGenshinImpactAutomation";
public const string LaunchSetDiscordActivityWhenPlaying = "Launch.SetDiscordActivityWhenPlaying";
[Obsolete("不再支持多开")]
@@ -49,4 +50,4 @@ internal sealed partial class SettingEntry
[Obsolete("不再使用 PowerShell")]
public const string PowerShellPath = "PowerShellPath";
-}
+}
\ No newline at end of file
diff --git a/src/Snap.Hutao/Snap.Hutao/Resource/Localization/SH.resx b/src/Snap.Hutao/Snap.Hutao/Resource/Localization/SH.resx
index 8e91eb72..edd66c79 100644
--- a/src/Snap.Hutao/Snap.Hutao/Resource/Localization/SH.resx
+++ b/src/Snap.Hutao/Snap.Hutao/Resource/Localization/SH.resx
@@ -2192,6 +2192,12 @@
启动参数
+
+ 在游戏启动后尝试启动并使用 Better GI 进行自动化任务
+
+
+ Better GI
+
常规
diff --git a/src/Snap.Hutao/Snap.Hutao/Service/Game/LaunchOptions.cs b/src/Snap.Hutao/Snap.Hutao/Service/Game/LaunchOptions.cs
index 322e93a2..11ede9a5 100644
--- a/src/Snap.Hutao/Snap.Hutao/Service/Game/LaunchOptions.cs
+++ b/src/Snap.Hutao/Snap.Hutao/Service/Game/LaunchOptions.cs
@@ -45,6 +45,7 @@ internal sealed class LaunchOptions : DbStoreOptions
private bool? isWindowsHDREnabled;
private AspectRatio? selectedAspectRatio;
private bool? useStarwardPlayTimeStatistics;
+ private bool? useBetterGenshinImpactAutomation;
private bool? setDiscordActivityWhenPlaying;
public LaunchOptions(IServiceProvider serviceProvider)
@@ -232,6 +233,12 @@ internal sealed class LaunchOptions : DbStoreOptions
set => SetOption(ref useStarwardPlayTimeStatistics, SettingEntry.LaunchUseStarwardPlayTimeStatistics, value);
}
+ public bool UseBetterGenshinImpactAutomation
+ {
+ get => GetOption(ref useBetterGenshinImpactAutomation, SettingEntry.LaunchUseBetterGenshinImpactAutomation, false);
+ set => SetOption(ref useBetterGenshinImpactAutomation, SettingEntry.LaunchUseBetterGenshinImpactAutomation, value);
+ }
+
public bool SetDiscordActivityWhenPlaying
{
get => GetOption(ref setDiscordActivityWhenPlaying, SettingEntry.LaunchSetDiscordActivityWhenPlaying, true);
diff --git a/src/Snap.Hutao/Snap.Hutao/Service/Game/Launching/Handler/LaunchExecutionBetterGenshinImpactAutomationHandlder.cs b/src/Snap.Hutao/Snap.Hutao/Service/Game/Launching/Handler/LaunchExecutionBetterGenshinImpactAutomationHandlder.cs
new file mode 100644
index 00000000..ef544e6c
--- /dev/null
+++ b/src/Snap.Hutao/Snap.Hutao/Service/Game/Launching/Handler/LaunchExecutionBetterGenshinImpactAutomationHandlder.cs
@@ -0,0 +1,30 @@
+// Copyright (c) DGP Studio. All rights reserved.
+// Licensed under the MIT license.
+
+using Windows.System;
+
+namespace Snap.Hutao.Service.Game.Launching.Handler;
+
+internal sealed class LaunchExecutionBetterGenshinImpactAutomationHandlder : ILaunchExecutionDelegateHandler
+{
+ public async ValueTask OnExecutionAsync(LaunchExecutionContext context, LaunchExecutionDelegate next)
+ {
+ if (context.Options.UseBetterGenshinImpactAutomation)
+ {
+ context.Logger.LogInformation("Using BetterGI to automate gameplay");
+ await LaunchBetterGenshinImpactAsync(context).ConfigureAwait(false);
+ }
+
+ await next().ConfigureAwait(false);
+ }
+
+ private static async ValueTask LaunchBetterGenshinImpactAsync(LaunchExecutionContext context)
+ {
+ Uri betterGenshinImpactUri = "bettergi://start".ToUri();
+ if (await Launcher.QueryUriSupportAsync(betterGenshinImpactUri, LaunchQuerySupportType.Uri) is LaunchQuerySupportStatus.Available)
+ {
+ context.Logger.LogInformation("Launching BetterGI");
+ await Launcher.LaunchUriAsync(betterGenshinImpactUri);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Snap.Hutao/Snap.Hutao/Service/Game/Launching/Handler/LaunchExecutionUnlockFpsHandler.cs b/src/Snap.Hutao/Snap.Hutao/Service/Game/Launching/Handler/LaunchExecutionUnlockFpsHandler.cs
index dc007240..632a6c64 100644
--- a/src/Snap.Hutao/Snap.Hutao/Service/Game/Launching/Handler/LaunchExecutionUnlockFpsHandler.cs
+++ b/src/Snap.Hutao/Snap.Hutao/Service/Game/Launching/Handler/LaunchExecutionUnlockFpsHandler.cs
@@ -34,6 +34,7 @@ internal sealed class LaunchExecutionUnlockFpsHandler : ILaunchExecutionDelegate
// The Unlocker can't unlock the process
context.Process.Kill();
+ return;
}
}
diff --git a/src/Snap.Hutao/Snap.Hutao/Service/Game/Launching/LaunchExecutionInvoker.cs b/src/Snap.Hutao/Snap.Hutao/Service/Game/Launching/LaunchExecutionInvoker.cs
index 780c0e10..7f1e3364 100644
--- a/src/Snap.Hutao/Snap.Hutao/Service/Game/Launching/LaunchExecutionInvoker.cs
+++ b/src/Snap.Hutao/Snap.Hutao/Service/Game/Launching/LaunchExecutionInvoker.cs
@@ -24,8 +24,9 @@ internal sealed class LaunchExecutionInvoker
handlers.Enqueue(new LaunchExecutionGameProcessInitializationHandler());
handlers.Enqueue(new LaunchExecutionSetDiscordActivityHandler());
handlers.Enqueue(new LaunchExecutionGameProcessStartHandler());
- handlers.Enqueue(new LaunchExecutionStarwardPlayTimeStatisticsHandler());
handlers.Enqueue(new LaunchExecutionUnlockFpsHandler());
+ handlers.Enqueue(new LaunchExecutionStarwardPlayTimeStatisticsHandler());
+ handlers.Enqueue(new LaunchExecutionBetterGenshinImpactAutomationHandlder());
handlers.Enqueue(new LaunchExecutionGameProcessExitHandler());
}
@@ -40,9 +41,9 @@ internal sealed class LaunchExecutionInvoker
if (handlers.TryDequeue(out ILaunchExecutionDelegateHandler? handler))
{
string typeName = TypeNameHelper.GetTypeDisplayName(handler, false);
- context.Logger.LogInformation("Handler[{Handler}] begin execution", typeName);
+ context.Logger.LogInformation("Handler [{Handler}] begin execution", typeName);
await handler.OnExecutionAsync(context, () => InvokeHandlerAsync(context)).ConfigureAwait(false);
- context.Logger.LogInformation("Handler[{Handler}] end execution", typeName);
+ context.Logger.LogInformation("Handler [{Handler}] end execution", typeName);
}
return context;
diff --git a/src/Snap.Hutao/Snap.Hutao/View/Page/LaunchGamePage.xaml b/src/Snap.Hutao/Snap.Hutao/View/Page/LaunchGamePage.xaml
index 1d5c95d1..d6d941cd 100644
--- a/src/Snap.Hutao/Snap.Hutao/View/Page/LaunchGamePage.xaml
+++ b/src/Snap.Hutao/Snap.Hutao/View/Page/LaunchGamePage.xaml
@@ -346,6 +346,12 @@
HeaderIcon="{shcm:FontIcon Glyph=}">
+
+
+