Skip to content

Commit

Permalink
* owml quits when game quits (#60)
Browse files Browse the repository at this point in the history
* forwarding args to game
  • Loading branch information
amazingalek authored Jan 13, 2020
1 parent f4b0a2d commit 906607f
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 8 deletions.
7 changes: 7 additions & 0 deletions OWML.Common/Constants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace OWML.Common
{
public class Constants
{
public const string QuitKeyPhrase = "{RageAgainstTheDyingOfTheLight}";
}
}
1 change: 1 addition & 0 deletions OWML.Common/OWML.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Constants.cs" />
<Compile Include="Events.cs" />
<Compile Include="IHarmonyHelper.cs" />
<Compile Include="IModAssets.cs" />
Expand Down
14 changes: 9 additions & 5 deletions OWML.Launcher/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace OWML.Launcher
{
public class App
{
private const string Version = "0.3.25";
private const string Version = "0.3.26";

private readonly IOwmlConfig _owmlConfig;
private readonly IModConsole _writer;
Expand All @@ -36,7 +36,7 @@ public App(IOwmlConfig owmlConfig, IModConsole writer, IModFinder modFinder,
_update = update;
}

public void Run()
public void Run(string[] args)
{
_writer.WriteLine($"Started OWML version {Version}");
_writer.WriteLine("For detailed log, see Logs/OWML.Log.txt");
Expand All @@ -55,7 +55,7 @@ public void Run()

PatchGame(mods);

StartGame();
StartGame(args);

Console.ReadLine();
}
Expand Down Expand Up @@ -132,6 +132,10 @@ private void OnOutput(string s)
foreach (var line in lines)
{
_writer.WriteLine(line);
if (line == Constants.QuitKeyPhrase)
{
Environment.Exit(0);
}
}
}

Expand All @@ -145,12 +149,12 @@ private void PatchGame(IList<IModData> mods)
_vrPatcher.PatchVR(enableVR);
}

private void StartGame()
private void StartGame(string[] args)
{
_writer.WriteLine("Starting game...");
try
{
Process.Start($"{_owmlConfig.GamePath}/OuterWilds.exe");
Process.Start($"{_owmlConfig.GamePath}/OuterWilds.exe", string.Join(" ", args));
}
catch (Exception ex)
{
Expand Down
2 changes: 1 addition & 1 deletion OWML.Launcher/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ static void Main(string[] args)
var vrPatcher = new VRPatcher(owmlConfig, writer);
var update = new ModUpdate(writer);
var app = new App(owmlConfig, writer, modFinder, outputListener, pathFinder, owPatcher, vrPatcher, update);
app.Run();
app.Run(args);
}

private static IOwmlConfig GetOwmlConfig()
Expand Down
1 change: 1 addition & 0 deletions OWML.ModHelper/OWML.ModHelper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
<ItemGroup>
<Compile Include="ModBehaviour.cs" />
<Compile Include="ModConfig.cs" />
<Compile Include="OwmlBehaviour.cs" />
<Compile Include="OwmlConfig.cs" />
<Compile Include="ModConsole.cs" />
<Compile Include="ModHelper.cs" />
Expand Down
13 changes: 13 additions & 0 deletions OWML.ModHelper/OwmlBehaviour.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using OWML.Common;
using UnityEngine;

namespace OWML.ModHelper
{
public class OwmlBehaviour : MonoBehaviour
{
void OnApplicationQuit()
{
ModConsole.Instance.WriteLine(Constants.QuitKeyPhrase);
}
}
}
2 changes: 2 additions & 0 deletions OWML.ModLoader/ModLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public class ModLoader

public static void LoadMods()
{
var owmlGo = new GameObject();
owmlGo.AddComponent<OwmlBehaviour>();
var owmlConfig = GetOwmlConfig();
if (owmlConfig == null)
{
Expand Down
2 changes: 1 addition & 1 deletion OWML.SampleMods/OWML.EnableDebugMode/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"name": "EnableDebugMode",
"uniqueName": "Alek.EnableDebugMode",
"version": "0.2",
"owmlVersion": "0.3.25"
"owmlVersion": "0.3.26"
}
2 changes: 1 addition & 1 deletion OWML.SampleMods/OWML.LoadCustomAssets/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"name": "LoadCustomAssets",
"uniqueName": "Alek.LoadCustomAssets",
"version": "0.4",
"owmlVersion": "0.3.25"
"owmlVersion": "0.3.26"
}

0 comments on commit 906607f

Please sign in to comment.