Skip to content

Commit

Permalink
Merge pull request #295 from amazingalek/dev
Browse files Browse the repository at this point in the history
master < dev
  • Loading branch information
Raicuparta authored Aug 3, 2020
2 parents 3633202 + 7ce00e8 commit ab4d43a
Show file tree
Hide file tree
Showing 96 changed files with 1,230 additions and 662 deletions.
1 change: 1 addition & 0 deletions OWML.Common/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
public class Constants
{
public const string OwmlTitle = "OWML";
public const string ConsolePortArgument = "consolePort";
public const string OwmlConfigFileName = "OWML.Config.json";
public const string OwmlDefaultConfigFileName = "OWML.DefaultConfig.json";
Expand Down
3 changes: 3 additions & 0 deletions OWML.Common/IModAsset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ namespace OWML.Common
{
public interface IModAsset<T>
{
event Action<T> Loaded;

[Obsolete("Use Loaded instead.")]
Action<T> OnLoaded { get; set; }
}
}
5 changes: 1 addition & 4 deletions OWML.Common/IModConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@ namespace OWML.Common
public interface IModConfig
{
bool Enabled { get; set; }
[Obsolete("Use ModManifest.RequireVR instead")]
bool RequireVR { get; set; }
Dictionary<string, object> Settings { get; set; }

T GetSettingsValue<T>(string key);
void SetSettingsValue(string key, object value);

[Obsolete("Use GetSettingsValue instead")]
T GetSetting<T>(string key);
IModConfig Copy();
}
}
2 changes: 2 additions & 0 deletions OWML.Common/IModData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ public interface IModData
IModConfig DefaultConfig { get; }
bool Enabled { get; }
bool RequireVR { get; }
bool RequireReload { get; }

void UpdateSnapshot();
void ResetConfigToDefaults();
bool FixConfigs();
}
Expand Down
7 changes: 4 additions & 3 deletions OWML.Common/IModEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ public interface IModEvents
{
IModPlayerEvents Player { get; }
IModSceneEvents Scenes { get; }
IModUnityEvents Unity { get; }

event Action<MonoBehaviour, Events> Event;

[Obsolete("Use Event instead.")]
Action<MonoBehaviour, Events> OnEvent { get; set; }

void Subscribe<T>(Events ev) where T : MonoBehaviour;

[Obsolete("Use Subscribe instead")]
void AddEvent<T>(Events ev) where T : MonoBehaviour;
}
}
2 changes: 2 additions & 0 deletions OWML.Common/IModManifest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@ public interface IModManifest
string[] Dependencies { get; }
bool PriorityLoad { get; }
bool RequireVR { get; }
string MinGameVersion { get; }
string MaxGameVersion { get; }
}
}
7 changes: 7 additions & 0 deletions OWML.Common/IModSocket.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace OWML.Common
{
public interface IModSocket
{
void WriteToSocket(IModSocketMessage message);
}
}
10 changes: 10 additions & 0 deletions OWML.Common/IModSocketMessage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace OWML.Common
{
public interface IModSocketMessage
{
string SenderName { get; }
string SenderType { get; }
MessageType Type { get; }
string Message { get; }
}
}
14 changes: 14 additions & 0 deletions OWML.Common/IModUnityEvents.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;

namespace OWML.Common
{
public interface IModUnityEvents
{
event Action OnUpdate;
event Action OnFixedUpdate;
event Action OnLateUpdate;

void FireOnNextUpdate(Action action);
void FireInNUpdates(Action action, int n);
}
}
4 changes: 0 additions & 4 deletions OWML.Common/Menus/IModInputCombinationElementMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,5 @@ public interface IModInputCombinationElementMenu : IModMenu
{
event Action<string> OnConfirm;
event Action OnCancel;

void Initialize(PopupInputMenu menu);
void Open(string value, string comboName, IModInputCombinationMenu combinationMenu = null,
IModInputCombinationElement element = null);
}
}
2 changes: 0 additions & 2 deletions OWML.Common/Menus/IModInputMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,5 @@ public interface IModInputMenu : IModMenu
{
event Action<string> OnConfirm;
event Action OnCancel;
void Initialize(PopupInputMenu inputMenu);
void Open(InputType inputType, string value);
}
}
8 changes: 2 additions & 6 deletions OWML.Common/Menus/IModMenu.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using UnityEngine.UI;

namespace OWML.Common.Menus
{
Expand All @@ -20,7 +19,9 @@ public interface IModMenu
IModButton GetTitleButton(string title);
IModPromptButton GetPromptButton(string title);

[Obsolete("Use AddButton(IModButtonBase) instead.")]
IModButton AddButton(IModButton button);
[Obsolete("Use AddButton(IModButtonBase, int) instead.")]
IModButton AddButton(IModButton button, int index);
IModButtonBase AddButton(IModButtonBase button);
IModButtonBase AddButton(IModButtonBase button, int index);
Expand Down Expand Up @@ -60,10 +61,5 @@ public interface IModMenu

void SelectFirst();
void UpdateNavigation();

[Obsolete("Use Buttons instead")]
List<Button> GetButtons();
[Obsolete("Use button.Duplicate instead")]
Button AddButton(string title, int index);
}
}
4 changes: 1 addition & 3 deletions OWML.Common/Menus/IModMenus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ public interface IModMenus
IModMainMenu MainMenu { get; }
IModPauseMenu PauseMenu { get; }
IModsMenu ModsMenu { get; }
IModConfigMenuBase OwmlMenu { get; }
IModInputMenu InputMenu { get; }
IModInputCombinationElementMenu InputCombinationElementMenu { get; }
IModInputCombinationMenu InputCombinationMenu { get; }
IModPopupManager PopupManager { get; }
}
}
10 changes: 10 additions & 0 deletions OWML.Common/Menus/IModMessagePopup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;

namespace OWML.Common.Menus
{
public interface IModMessagePopup : IModMenu
{
event Action OnConfirm;
event Action OnCancel;
}
}
13 changes: 13 additions & 0 deletions OWML.Common/Menus/IModPopupManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using UnityEngine;

namespace OWML.Common.Menus
{
public interface IModPopupManager
{
void Initialize(GameObject popupCanvas);
IModMessagePopup CreateMessagePopup(string message, bool addCancel = false, string okMessage = "OK", string cancelMessage = "Cancel");
IModInputMenu CreateInputPopup(InputType inputType, string value);
IModInputCombinationElementMenu CreateCombinationInput(string value, string comboName,
IModInputCombinationMenu combinationMenu = null, IModInputCombinationElement element = null);
}
}
8 changes: 5 additions & 3 deletions OWML.Common/Menus/IModPopupMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ namespace OWML.Common.Menus
{
public interface IModPopupMenu : IModMenu
{
event Action OnOpened;
event Action OnClosed;

[Obsolete("Use OnOpened instead.")]
Action OnOpen { get; set; }
[Obsolete("Use OnClosed instead.")]
Action OnClose { get; set; }

bool IsOpen { get; }
Expand All @@ -19,8 +24,5 @@ public interface IModPopupMenu : IModMenu
IModPopupMenu Copy(string title);
void Initialize(Menu menu);
void Initialize(Menu menu, LayoutGroup layoutGroup);

[Obsolete("Use Copy instead")]
IModPopupMenu CreateCopy(string name);
}
}
5 changes: 5 additions & 0 deletions OWML.Common/OWML.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,14 @@
<Compile Include="IModInteraction.cs" />
<Compile Include="IModPlayerEvents.cs" />
<Compile Include="IModSceneEvents.cs" />
<Compile Include="IModSocket.cs" />
<Compile Include="IModUnityEvents.cs" />
<Compile Include="IModSocketMessage.cs" />
<Compile Include="Menus\IModPopupManager.cs" />
<Compile Include="Menus\IModSeparator.cs" />
<Compile Include="Menus\IModInputBase.cs" />
<Compile Include="Menus\IModFieldInput.cs" />
<Compile Include="Menus\IModMessagePopup.cs" />
<Compile Include="Menus\IModMenuWithSelectables.cs" />
<Compile Include="Menus\IModLayoutManager.cs" />
<Compile Include="Menus\IModInputCombinationElementMenu.cs" />
Expand Down
40 changes: 39 additions & 1 deletion OWML.Launcher/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public void Run(string[] args)

LocateGamePath();

CheckGameVersion();

CopyGameFiles();

CreateLogsDirectory();
Expand Down Expand Up @@ -70,6 +72,42 @@ private void LocateGamePath()
}
}

private void CheckGameVersion()
{
var versionReader = new GameVersionReader(new BinaryPatcher(_owmlConfig, _writer));
var gameVersionString = versionReader.GetGameVersion();
_writer.WriteLine($"Game version: {gameVersionString}", MessageType.Info);
var isValidFormat = Version.TryParse(gameVersionString, out var gameVersion);
var minVersion = new Version(_owmlManifest.MinGameVersion);
var maxVersion = new Version(_owmlManifest.MaxGameVersion);
if (!isValidFormat)
{
_writer.WriteLine("Warning - non-standard game version formatting found", MessageType.Warning);
}
if (!isValidFormat || gameVersion > maxVersion)
{
PotentiallyUnsupported();
return;
}
if (gameVersion < minVersion)
{
_writer.WriteLine("Unsupported game version found", MessageType.Error);
AnyKeyExitConsole();
}
}

private void AnyKeyExitConsole()
{
_writer.WriteLine("Press any key to exit...", MessageType.Info);
Console.ReadKey();
ExitConsole();
}

private void PotentiallyUnsupported()
{
_writer.WriteLine("Potentially unsupported game version found, continue at your own risk", MessageType.Warning);
}

private void CopyGameFiles()
{
var filesToCopy = new[] { "UnityEngine.CoreModule.dll", "Assembly-CSharp.dll" };
Expand Down Expand Up @@ -112,7 +150,7 @@ private bool IsMadeForSameOwmlMajorVersion(IModManifest manifest)

private bool HasVrMod(List<IModData> mods)
{
var vrMod = mods.FirstOrDefault(x => x.RequireVR && x.Config.Enabled);
var vrMod = mods.FirstOrDefault(x => x.RequireVR && x.Enabled);
var hasVrMod = vrMod != null;
_writer.WriteLine(hasVrMod ? $"{vrMod.Manifest.UniqueName} requires VR." : "No mods require VR.");
return hasVrMod;
Expand Down
4 changes: 4 additions & 0 deletions OWML.Launcher/OWML.Launcher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@
<Project>{a3d507f5-22a2-4a18-b529-868fe8d59cf3}</Project>
<Name>OWML.GameFinder</Name>
</ProjectReference>
<ProjectReference Include="..\OWML.Logging\OWML.Logging.csproj">
<Project>{6F14D39C-5747-4149-BE4D-365B43918A0A}</Project>
<Name>OWML.Logging</Name>
</ProjectReference>
<ProjectReference Include="..\OWML.ModHelper\OWML.ModHelper.csproj">
<Project>{CB57BAB8-D70E-4FCE-9BF1-328A924173A7}</Project>
<Name>OWML.ModHelper</Name>
Expand Down
6 changes: 4 additions & 2 deletions OWML.Launcher/OWML.Manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"author": "Alek",
"name": "OWML",
"uniqueName": "Alek.OWML",
"version": "0.6.1",
"description": "The mod loader and mod framework for Outer Wilds"
"version": "0.7.0",
"description": "The mod loader and mod framework for Outer Wilds",
"minGameVersion": "1.0.7.0",
"maxGameVersion": "1.0.7.481"
}
19 changes: 14 additions & 5 deletions OWML.Launcher/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using OWML.Common;
using OWML.GameFinder;
using OWML.Logging;
using OWML.ModHelper;
using OWML.ModLoader;
using OWML.Patcher;
Expand All @@ -12,11 +13,11 @@ public class Program
static void Main(string[] args)
{
var owmlConfig = GetOwmlConfig() ?? CreateOwmlConfig();
SaveConsolePort(owmlConfig);
var hasConsolePort = CommandLineArguments.HasArgument(Constants.ConsolePortArgument);
SaveConsolePort(owmlConfig, hasConsolePort);
SaveOwmlPath(owmlConfig);
var owmlManifest = GetOwmlManifest();
var writer = OutputFactory.CreateOutput(owmlConfig, null, owmlManifest,
CommandLineArguments.HasArgument(Constants.ConsolePortArgument));
var writer = CreateWriter(owmlConfig, owmlManifest, hasConsolePort);
var modFinder = new ModFinder(owmlConfig, writer);
var pathFinder = new PathFinder(owmlConfig, writer);
var owPatcher = new OWPatcher(owmlConfig, writer);
Expand All @@ -26,9 +27,9 @@ static void Main(string[] args)
app.Run(args);
}

private static void SaveConsolePort(IOwmlConfig owmlConfig)
private static void SaveConsolePort(IOwmlConfig owmlConfig, bool hasConsolePort)
{
if (CommandLineArguments.HasArgument(Constants.ConsolePortArgument))
if (hasConsolePort)
{
var argument = CommandLineArguments.GetArgument(Constants.ConsolePortArgument);
if (!int.TryParse(argument, out var port))
Expand All @@ -37,6 +38,7 @@ private static void SaveConsolePort(IOwmlConfig owmlConfig)
return;
}
owmlConfig.SocketPort = port;
JsonHelper.SaveJsonObject(Constants.OwmlConfigFileName, owmlConfig);
}
else
{
Expand Down Expand Up @@ -67,5 +69,12 @@ private static IModManifest GetOwmlManifest()
return JsonHelper.LoadJsonObject<ModManifest>(Constants.OwmlManifestFileName);
}

private static IModConsole CreateWriter(IOwmlConfig owmlConfig, IModManifest owmlManifest, bool hasConsolePort)
{
return hasConsolePort
? new ModSocketOutput(owmlConfig, null, owmlManifest, new ModSocket(owmlConfig.SocketPort))
: (IModConsole)new OutputWriter();
}

}
}
5 changes: 3 additions & 2 deletions OWML.Launcher/SocketListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using OWML.Logging;

namespace OWML.Launcher
{
Expand Down Expand Up @@ -93,10 +94,10 @@ private void ProcessMessage(byte[] bytes, int count)
{
continue;
}
SocketMessage data;
ModSocketMessage data;
try
{
data = JsonConvert.DeserializeObject<SocketMessage>(json);
data = JsonConvert.DeserializeObject<ModSocketMessage>(json);
}
catch (Exception ex)
{
Expand Down
Loading

0 comments on commit ab4d43a

Please sign in to comment.