mirror of
https://github.com/wangdage12/Snap.Hutao.git
synced 2026-02-17 12:56:38 +08:00
支持注入时传命令行参数
This commit is contained in:
Binary file not shown.
@@ -139,6 +139,13 @@ internal sealed class GameFpsUnlockInterop : IGameIslandInterop, IDisposable
|
|||||||
category: "fps.unlocker",
|
category: "fps.unlocker",
|
||||||
level: Sentry.BreadcrumbLevel.Info);
|
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()
|
ProcessStartInfo startInfo = new()
|
||||||
{
|
{
|
||||||
FileName = unlockerPath,
|
FileName = unlockerPath,
|
||||||
@@ -148,11 +155,12 @@ internal sealed class GameFpsUnlockInterop : IGameIslandInterop, IDisposable
|
|||||||
RedirectStandardOutput = true,
|
RedirectStandardOutput = true,
|
||||||
RedirectStandardError = true,
|
RedirectStandardError = true,
|
||||||
WindowStyle = ProcessWindowStyle.Normal,
|
WindowStyle = ProcessWindowStyle.Normal,
|
||||||
|
Arguments = gameArguments,
|
||||||
};
|
};
|
||||||
|
|
||||||
unlockerProcess = new Process { StartInfo = startInfo };
|
unlockerProcess = new Process { StartInfo = startInfo };
|
||||||
|
|
||||||
|
|
||||||
unlockerProcess.Start();
|
unlockerProcess.Start();
|
||||||
|
|
||||||
|
|
||||||
@@ -170,7 +178,7 @@ internal sealed class GameFpsUnlockInterop : IGameIslandInterop, IDisposable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Task errorTask = Task.Run(async () =>
|
Task errorTask = Task.Run(async () =>
|
||||||
{
|
{
|
||||||
while (!unlockerProcess.StandardError.EndOfStream)
|
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)
|
private async ValueTask MonitorExistingUnlockerAsync(LaunchExecutionContext context, CancellationToken token)
|
||||||
{
|
{
|
||||||
// 恢复模式下,检查是否有解锁器进程在运行
|
// 恢复模式下,检查是否有解锁器进程在运行
|
||||||
|
|||||||
Reference in New Issue
Block a user