using System.Diagnostics;
using System.IO;
namespace DorkNet.Launcher.Backend;
/// Launches the user's already-patched Rec Room install
/// directly via Recroom_Release.exe. Never goes through Steam —
/// DorkNet users may not own the game on Steam.
public static class RecRoomLauncher
{
/// The picked install path is the Recroom_Release_Data
/// folder; the executable lives at <parent>\Recroom_Release.exe.
/// Returns true if Process.Start succeeded.
/// passes Rec Room's +forcemode:screen arg so the game opens
/// in 2D desktop mode instead of trying to bind a headset.
public static bool TryLaunch(string recRoomDataPath, bool screenMode, out string error)
{
error = "";
if (string.IsNullOrEmpty(recRoomDataPath))
{
error = "No Rec Room install picked.";
return false;
}
var parent = Path.GetDirectoryName(recRoomDataPath.TrimEnd(Path.DirectorySeparatorChar));
if (string.IsNullOrEmpty(parent))
{
error = $"Couldn't resolve the parent directory of '{recRoomDataPath}'.";
return false;
}
var exe = Path.Combine(parent, "Recroom_Release.exe");
if (!File.Exists(exe))
{
error = $"Recroom_Release.exe not found at '{exe}'. " +
"Pick the *_Data folder that sits next to it.";
return false;
}
try
{
Process.Start(new ProcessStartInfo
{
FileName = exe,
WorkingDirectory = parent,
UseShellExecute = true,
Arguments = screenMode ? "+forcemode:screen" : "",
});
return true;
}
catch (Exception ex)
{
error = ex.Message;
return false;
}
}
}