Skip to content

Commit

Permalink
Merge pull request #307 from amazingalek/dev
Browse files Browse the repository at this point in the history
master < dev
  • Loading branch information
amazingalek authored Aug 8, 2020
2 parents 46bf2ee + 672c04c commit 0b40a19
Show file tree
Hide file tree
Showing 25 changed files with 69 additions and 117 deletions.
4 changes: 3 additions & 1 deletion OWML.Common/Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public enum Events
BeforeEnable = 4,
AfterEnable = 5,
BeforeDisable = 6,
AfterDisable = 7
AfterDisable = 7,
BeforeDestroy = 8,
AfterDestroy = 9
}
}
1 change: 1 addition & 0 deletions OWML.Common/IModSocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
public interface IModSocket
{
void WriteToSocket(IModSocketMessage message);
void Close();
}
}
3 changes: 2 additions & 1 deletion OWML.Common/MessageType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public enum MessageType
Warning = 2,
Info = 3,
Success = 4,
Quit = 5
Quit = 5,
Fatal = 6
}
}
6 changes: 0 additions & 6 deletions OWML.GameFinder/OWML.GameFinder.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="PathFinder.cs" />
Expand Down
2 changes: 1 addition & 1 deletion OWML.Launcher/OWML.Manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"author": "Alek",
"name": "OWML",
"uniqueName": "Alek.OWML",
"version": "0.7.1",
"version": "0.7.2",
"description": "The mod loader and mod framework for Outer Wilds",
"minGameVersion": "1.0.7.0",
"maxGameVersion": "1.0.7.481"
Expand Down
9 changes: 7 additions & 2 deletions OWML.Launcher/SocketListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class SocketListener
private static int _port;
private static TcpListener _server;
private static IOwmlConfig _config;
private bool _hasReceivedFatalMessage;

public SocketListener(IOwmlConfig config)
{
Expand Down Expand Up @@ -76,7 +77,7 @@ private void ListenToSocket()

while ((i = stream.Read(bytes, 0, bytes.Length)) != 0)
{
ProcessMessage(bytes, i);
ProcessMessage(bytes, i);
}

ConsoleUtils.WriteByType(MessageType.Success, "Closing client!");
Expand Down Expand Up @@ -106,10 +107,14 @@ private void ProcessMessage(byte[] bytes, int count)
continue;
}

if (data.Type == MessageType.Quit)
if (data.Type == MessageType.Quit && !_hasReceivedFatalMessage)
{
Environment.Exit(0);
}
if (data.Type == MessageType.Fatal)
{
_hasReceivedFatalMessage = true;
}
ConsoleUtils.WriteByType(data.Type,
$"[{data.SenderName}.{data.SenderType}] : {data.Message}");
}
Expand Down
24 changes: 17 additions & 7 deletions OWML.Logging/ConsoleUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,26 @@ namespace OWML.Logging
{
public static class ConsoleUtils
{
private static Dictionary<MessageType, ConsoleColor> _messageTypeColors = new Dictionary<MessageType, ConsoleColor> {
{ MessageType.Error, ConsoleColor.Red },
{ MessageType.Warning, ConsoleColor.Yellow },
{ MessageType.Success, ConsoleColor.Green },
{ MessageType.Message, ConsoleColor.Gray },
{ MessageType.Info, ConsoleColor.Cyan },
{ MessageType.Fatal, ConsoleColor.Magenta }
};

public static void WriteByType(MessageType type, string line)
{
Console.ForegroundColor = new Dictionary<MessageType, ConsoleColor>
if (_messageTypeColors.ContainsKey(type))
{
Console.ForegroundColor = _messageTypeColors[type];
}
else
{
{ MessageType.Error, ConsoleColor.Red },
{ MessageType.Warning, ConsoleColor.Yellow },
{ MessageType.Success, ConsoleColor.Green },
{ MessageType.Message, ConsoleColor.Gray },
{ MessageType.Info, ConsoleColor.Cyan }
}[type];
Console.ForegroundColor = ConsoleColor.Gray;
}

Console.WriteLine(line);
Console.ForegroundColor = ConsoleColor.Gray;
}
Expand Down
5 changes: 5 additions & 0 deletions OWML.Logging/ModSocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,10 @@ public void WriteToSocket(IModSocketMessage message)
}
catch (SocketException) { }
}

public void Close()
{
_socket.Close();
}
}
}
11 changes: 11 additions & 0 deletions OWML.Logging/ModSocketOutput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@ private void WriteLine(MessageType type, string line, string senderType)
Message = line
};
_socket.WriteToSocket(message);

if (message.Type == MessageType.Fatal)
{
KillProcess();
}
}

private void KillProcess()
{
_socket.Close();
Process.GetCurrentProcess().Kill();
}

private string GetCallingType(StackTrace frame)
Expand Down
4 changes: 0 additions & 4 deletions OWML.Logging/OWML.Logging.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OW.Unity.Dlls.1.0.7\lib\net35\UnityEngine.dll</HintPath>
</Reference>
Expand Down
4 changes: 0 additions & 4 deletions OWML.ModHelper.Assets/OWML.ModHelper.Assets.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,6 @@
<Project>{3C00626F-B688-4F32-B493-5B7EC1C879A0}</Project>
<Name>OWML.Common</Name>
</ProjectReference>
<ProjectReference Include="..\OWML.ModHelper\OWML.ModHelper.csproj">
<Project>{CB57BAB8-D70E-4FCE-9BF1-328A924173A7}</Project>
<Name>OWML.ModHelper</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
Expand Down
7 changes: 7 additions & 0 deletions OWML.ModHelper.Events/ModEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ private void PatchEvent<T>(Common.Events ev)
_harmonyHelper.AddPostfix<T>("OnDisable", typeof(Patches), nameof(Patches.AfterDisable));
break;

case Common.Events.BeforeDestroy:
_harmonyHelper.AddPrefix<T>("OnDestroy", typeof(Patches), nameof(Patches.BeforeDestroy));
break;
case Common.Events.AfterDestroy:
_harmonyHelper.AddPostfix<T>("OnDestroy", typeof(Patches), nameof(Patches.AfterDestroy));
break;

default:
_console.WriteLine($"Error - Unrecognized event: {ev}", MessageType.Error);
throw new ArgumentOutOfRangeException(nameof(ev), ev, null);
Expand Down
3 changes: 3 additions & 0 deletions OWML.ModHelper.Events/Patches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ internal static class Patches
public static void BeforeDisable(MonoBehaviour __instance) => OnEvent?.Invoke(__instance, Common.Events.BeforeDisable);
public static void AfterDisable(MonoBehaviour __instance) => OnEvent?.Invoke(__instance, Common.Events.AfterDisable);

public static void BeforeDestroy(MonoBehaviour __instance) => OnEvent?.Invoke(__instance, Common.Events.BeforeDestroy);
public static void AfterDestroy(MonoBehaviour __instance) => OnEvent?.Invoke(__instance, Common.Events.AfterDestroy);

public static IEnumerable<CodeInstruction> EmptyMethod(IEnumerable<CodeInstruction> instructions)
{
return new List<CodeInstruction>();
Expand Down
9 changes: 0 additions & 9 deletions OWML.ModHelper.Input/OWML.ModHelper.Input.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,7 @@
<Reference Include="OW.Unity.Dlls, Version=1.0.7.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OW.Unity.Dlls.1.0.7\lib\net35\OW.Unity.Dlls.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OW.Unity.Dlls.1.0.7\lib\net35\UnityEngine.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -92,10 +87,6 @@
<Project>{b771615e-6b51-44f8-b862-d7543c12c0ff}</Project>
<Name>OWML.ModHelper.Events</Name>
</ProjectReference>
<ProjectReference Include="..\OWML.ModHelper\OWML.ModHelper.csproj">
<Project>{cb57bab8-d70e-4fce-9bf1-328a924173a7}</Project>
<Name>OWML.ModHelper</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
Expand Down
49 changes: 0 additions & 49 deletions OWML.ModHelper.Interaction/OWML.ModHelper.Interaction.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,45 +31,7 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OW.Unity.Dlls.1.0.7\lib\net35\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="OW.Unity.Dlls, Version=1.0.7.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OW.Unity.Dlls.1.0.7\lib\net35\OW.Unity.Dlls.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OW.Unity.Dlls.1.0.7\lib\net35\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.AudioModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OW.Unity.Dlls.1.0.7\lib\net35\UnityEngine.AudioModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OW.Unity.Dlls.1.0.7\lib\net35\UnityEngine.CoreModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.IMGUIModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OW.Unity.Dlls.1.0.7\lib\net35\UnityEngine.IMGUIModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.PhysicsModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OW.Unity.Dlls.1.0.7\lib\net35\UnityEngine.PhysicsModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.TextRenderingModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OW.Unity.Dlls.1.0.7\lib\net35\UnityEngine.TextRenderingModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OW.Unity.Dlls.1.0.7\lib\net35\UnityEngine.UI.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UIModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OW.Unity.Dlls.1.0.7\lib\net35\UnityEngine.UIModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UnityWebRequestWWWModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OW.Unity.Dlls.1.0.7\lib\net35\UnityEngine.UnityWebRequestWWWModule.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="InterfaceProxyBuilder.cs" />
Expand All @@ -82,17 +44,6 @@
<Project>{3C00626F-B688-4F32-B493-5B7EC1C879A0}</Project>
<Name>OWML.Common</Name>
</ProjectReference>
<ProjectReference Include="..\OWML.ModHelper.Events\OWML.ModHelper.Events.csproj">
<Project>{B771615E-6B51-44F8-B862-D7543C12C0FF}</Project>
<Name>OWML.ModHelper.Events</Name>
</ProjectReference>
<ProjectReference Include="..\OWML.ModHelper\OWML.ModHelper.csproj">
<Project>{cb57bab8-d70e-4fce-9bf1-328a924173a7}</Project>
<Name>OWML.ModHelper</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
4 changes: 0 additions & 4 deletions OWML.ModHelper.Interaction/packages.config

This file was deleted.

4 changes: 0 additions & 4 deletions OWML.ModHelper.Menus/OWML.ModHelper.Menus.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OW.Unity.Dlls.1.0.7\lib\net35\UnityEngine.dll</HintPath>
</Reference>
Expand Down
5 changes: 0 additions & 5 deletions OWML.ModHelper/OWML.ModHelper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Net" />
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OW.Unity.Dlls.1.0.7\lib\net35\UnityEngine.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -97,10 +96,6 @@
<Project>{6F14D39C-5747-4149-BE4D-365B43918A0A}</Project>
<Name>OWML.Logging</Name>
</ProjectReference>
<ProjectReference Include="..\OWML.ModHelper.Events\OWML.ModHelper.Events.csproj">
<Project>{B771615E-6B51-44F8-B862-D7543C12C0FF}</Project>
<Name>OWML.ModHelper.Events</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
4 changes: 1 addition & 3 deletions OWML.ModLoader/ModFinder.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Collections.Generic;
using System.IO;
using Newtonsoft.Json;
using OWML.Common;
using OWML.ModHelper;

Expand Down Expand Up @@ -28,8 +27,7 @@ public List<IModData> GetMods()
var mods = new List<IModData>();
foreach (var manifestFilename in manifestFilenames)
{
var json = File.ReadAllText(manifestFilename);
var manifest = JsonConvert.DeserializeObject<ModManifest>(json);
var manifest = JsonHelper.LoadJsonObject<ModManifest>(manifestFilename);
manifest.ModFolderPath = manifestFilename.Substring(0, manifestFilename.IndexOf(Constants.ModManifestFileName));
var modData = GetModData(manifest);
mods.Add(modData);
Expand Down
5 changes: 0 additions & 5 deletions OWML.Nuget/OWML.Nuget.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,7 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\OWML.ModHelper.Assets\NAudio-Unity\NAudio-Unity.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
Expand Down
6 changes: 0 additions & 6 deletions OWML.Patcher/OWML.Patcher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>dnpatch\dnpatch.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Json.Net.Unity3D.9.0.1\lib\net35\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
Expand All @@ -66,8 +63,5 @@
<Name>OWML.ModLoader</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
4 changes: 0 additions & 4 deletions OWML.Patcher/packages.config

This file was deleted.

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,7 +4,7 @@
"name": "EnableDebugMode",
"uniqueName": "Alek.EnableDebugMode",
"version": "0.2",
"owmlVersion": "0.7.1",
"owmlVersion": "0.7.2",
"description": "Enables the debug mode in Outer Wilds",
"requireVR": false
}
Loading

0 comments on commit 0b40a19

Please sign in to comment.