diff --git a/bin/unlockfps.exe b/bin/unlockfps.exe index 122be81..a6e443f 100644 Binary files a/bin/unlockfps.exe and b/bin/unlockfps.exe differ diff --git a/src/Snap.Hutao/Snap.Hutao/Service/Game/Island/GameFpsUnlockInterop.cs b/src/Snap.Hutao/Snap.Hutao/Service/Game/Island/GameFpsUnlockInterop.cs index ff87617..7b87cbe 100644 --- a/src/Snap.Hutao/Snap.Hutao/Service/Game/Island/GameFpsUnlockInterop.cs +++ b/src/Snap.Hutao/Snap.Hutao/Service/Game/Island/GameFpsUnlockInterop.cs @@ -139,6 +139,13 @@ internal sealed class GameFpsUnlockInterop : IGameIslandInterop, IDisposable category: "fps.unlocker", level: Sentry.BreadcrumbLevel.Info); + // 构建游戏启动参数,传递给 unlockfps.exe + string gameArguments = BuildGameArguments(context); + SentrySdk.AddBreadcrumb( + $"Game arguments for unlocker: {gameArguments}", + category: "fps.unlocker", + level: Sentry.BreadcrumbLevel.Info); + ProcessStartInfo startInfo = new() { FileName = unlockerPath, @@ -148,11 +155,12 @@ internal sealed class GameFpsUnlockInterop : IGameIslandInterop, IDisposable RedirectStandardOutput = true, RedirectStandardError = true, WindowStyle = ProcessWindowStyle.Normal, + Arguments = gameArguments, }; unlockerProcess = new Process { StartInfo = startInfo }; - + unlockerProcess.Start(); @@ -170,7 +178,7 @@ internal sealed class GameFpsUnlockInterop : IGameIslandInterop, IDisposable } } }); - + Task errorTask = Task.Run(async () => { while (!unlockerProcess.StandardError.EndOfStream) @@ -197,6 +205,53 @@ internal sealed class GameFpsUnlockInterop : IGameIslandInterop, IDisposable } } + private string BuildGameArguments(BeforeLaunchExecutionContext context) + { + LaunchOptions launchOptions = context.LaunchOptions; + + if (!launchOptions.AreCommandLineArgumentsEnabled.Value) + { + return string.Empty; + } + + StringBuilder arguments = new(); + + // 构建与 GameProcessFactory.CreateForDefault 相同的命令行参数 + if (launchOptions.IsBorderless.Value) + { + arguments.Append(" -popupwindow"); + } + + if (launchOptions.IsExclusive.Value) + { + arguments.Append(" -window-mode exclusive"); + } + + arguments.Append($" -screen-fullscreen {(launchOptions.IsFullScreen.Value ? "1" : "0")}"); + + if (launchOptions.IsScreenWidthEnabled.Value) + { + arguments.Append($" -screen-width {launchOptions.ScreenWidth.Value}"); + } + + if (launchOptions.IsScreenHeightEnabled.Value) + { + arguments.Append($" -screen-height {launchOptions.ScreenHeight.Value}"); + } + + if (launchOptions.IsMonitorEnabled.Value) + { + arguments.Append($" -monitor {launchOptions.Monitor.Value?.Value ?? 1}"); + } + + if (launchOptions.IsPlatformTypeEnabled.Value) + { + arguments.Append($" -platform_type {launchOptions.PlatformType.Value:G}"); + } + + return arguments.ToString(); + } + private async ValueTask MonitorExistingUnlockerAsync(LaunchExecutionContext context, CancellationToken token) { // 恢复模式下,检查是否有解锁器进程在运行