Files
VRCX/Dotnet/OverlayWebSocket/OverlayManager.cs
Natsumi d2fd205476 Merge overlays, move overlay to separate process (#44)
* refactor: merge two overlay offScreenBrowser into one

* Electron support for shared overlay

* Separate overlay into its own process

* fix: invalid overlay texture size

* Handle duplicate processes

* Remove logging

---------

Co-authored-by: pa <maplenagisa@gmail.com>
Co-authored-by: rs189 <35667100+rs189@users.noreply.github.com>
2026-01-12 11:31:33 +13:00

53 lines
1.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using NLog;
namespace VRCX;
public class OverlayManager
{
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
private static Process _process;
public static void StartOverlay()
{
if (OverlayServer.IsConnected() ||
_process != null && !_process.HasExited)
{
logger.Error("Overlay server already started");
return;
}
StartOverlayProcess();
}
private static void StartOverlayProcess()
{
if (Environment.ProcessPath == null)
{
logger.Error("Cannot start Overlay process without a process path");
return;
}
var args = new List<string>();
args.Add(StartupArgs.VrcxLaunchArguments.Overlay);
if (Program.LaunchDebug)
args.Add(StartupArgs.VrcxLaunchArguments.IsDebugPrefix);
if (StartupArgs.LaunchArguments.ConfigDirectory != null)
args.Add($"{StartupArgs.VrcxLaunchArguments.ConfigDirectoryPrefix}={StartupArgs.LaunchArguments.ConfigDirectory}");
var startInfo = new ProcessStartInfo
{
FileName = Environment.ProcessPath,
Arguments = string.Join(' ', args),
UseShellExecute = false,
CreateNoWindow = true,
WorkingDirectory = Program.BaseDirectory
};
_process = Process.Start(startInfo);
logger.Info("Overlay process started");
}
}