Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Launch game with OpenVR flag if VR is required #124

Merged
merged 4 commits into from
Jun 29, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 22 additions & 9 deletions OWML.Launcher/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class App
private readonly OWPatcher _owPatcher;
private readonly VRPatcher _vrPatcher;

private const string VrArgument = " -vrmode openvr";

public App(IOwmlConfig owmlConfig, IModManifest owmlManifest, IModConsole writer, IModFinder modFinder,
OutputListener listener, PathFinder pathFinder, OWPatcher owPatcher, VRPatcher vrPatcher)
{
Expand Down Expand Up @@ -55,9 +57,10 @@ public void Run(string[] args)

ShowModList(mods);

PatchGame(mods);
var hasVrMod = HasVrMod(mods);
PatchGame(hasVrMod);

StartGame(args);
StartGame(args, hasVrMod);

if (hasPortArgument)
{
Expand Down Expand Up @@ -142,13 +145,18 @@ private void OnOutput(string s)
}
}

private void PatchGame(IList<IModData> mods)
private bool HasVrMod(IList<IModData> mods)
{
_owPatcher.PatchGame();

var vrMod = mods.FirstOrDefault(x => x.Config.RequireVR && x.Config.Enabled);
var enableVR = vrMod != null;
_writer.WriteLine(enableVR ? $"{vrMod.Manifest.UniqueName} requires VR." : "No mods require VR.");
var hasVrMod = vrMod != null;
_writer.WriteLine(hasVrMod ? $"{vrMod.Manifest.UniqueName} requires VR." : "No mods require VR.");
return hasVrMod;
}

private void PatchGame(bool enableVR)
{
_owPatcher.PatchGame();
_vrPatcher.PatchVR(enableVR);
try
{
_vrPatcher.PatchVR(enableVR);
Expand All @@ -159,12 +167,17 @@ private void PatchGame(IList<IModData> mods)
}
}

private void StartGame(string[] args)
private void StartGame(string[] args, bool enableVR)
{
_writer.WriteLine("Starting game...");
try
{
Process.Start($"{_owmlConfig.GamePath}/OuterWilds.exe", string.Join(" ", args));
var gameArgs = string.Join(" ", args);
if (enableVR)
{
gameArgs += VrArgument;
amazingalek marked this conversation as resolved.
Show resolved Hide resolved
}
Process.Start($"{_owmlConfig.GamePath}/OuterWilds.exe", gameArgs);
}
catch (Exception ex)
{
Expand Down