diff --git a/src/OWML.Launcher/OWML.Manifest.json b/src/OWML.Launcher/OWML.Manifest.json index 0b652dda..aced3206 100644 --- a/src/OWML.Launcher/OWML.Manifest.json +++ b/src/OWML.Launcher/OWML.Manifest.json @@ -2,7 +2,7 @@ "author": "Alek", "name": "OWML", "uniqueName": "Alek.OWML", - "version": "1.1.6", + "version": "1.1.7", "description": "The mod loader and mod framework for Outer Wilds", "minGameVersion": "1.0.7.0", "maxGameVersion": "1.0.7.481" diff --git a/src/OWML.ModHelper.Menus/ModInputMenu.cs b/src/OWML.ModHelper.Menus/ModInputMenu.cs index d3917d2b..0599a22c 100644 --- a/src/OWML.ModHelper.Menus/ModInputMenu.cs +++ b/src/OWML.ModHelper.Menus/ModInputMenu.cs @@ -13,11 +13,11 @@ namespace OWML.ModHelper.Menus private PopupInputMenu _inputMenu; - public ModInputMenu(IModConsole console) + public ModInputMenu(IModConsole console) : base(console) { } - + public void Initialize(PopupInputMenu menu) { if (Menu != null) @@ -69,15 +69,11 @@ namespace OWML.ModHelper.Menus _inputMenu = null; } - private bool OnValidateNumber() - { - return float.TryParse(_inputMenu.GetInputText(), out _); - } + private bool OnValidateNumber() => + float.TryParse(_inputMenu.GetInputText(), out _); - private bool OnValidateCharNumber(char c) - { - return "0123456789.".Contains("" + c); - } + private bool OnValidateCharNumber(char c) => + "0123456789.".Contains("" + c); protected override void OnPopupConfirm() { diff --git a/src/OWML.ModHelper.Menus/ModPopupManager.cs b/src/OWML.ModHelper.Menus/ModPopupManager.cs index da7ba1e8..19b6e5dd 100644 --- a/src/OWML.ModHelper.Menus/ModPopupManager.cs +++ b/src/OWML.ModHelper.Menus/ModPopupManager.cs @@ -51,7 +51,8 @@ namespace OWML.ModHelper.Menus public IModMessagePopup CreateMessagePopup(string message, bool addCancel = false, string okMessage = "OK", string cancelMessage = "Cancel") { var newPopup = _messagePopup.Copy(); - newPopup.ShowMessage(message, addCancel, okMessage, cancelMessage); + _events.Unity.FireOnNextUpdate(() => + newPopup.ShowMessage(message, addCancel, okMessage, cancelMessage)); newPopup.OnCancel += () => OnPopupClose(newPopup); newPopup.OnConfirm += () => OnPopupClose(newPopup); return newPopup; @@ -60,7 +61,8 @@ namespace OWML.ModHelper.Menus public IModInputMenu CreateInputPopup(InputType inputType, string value) { var newPopup = _inputPopup.Copy(); - newPopup.Open(inputType, value); + _events.Unity.FireOnNextUpdate(() => + newPopup.Open(inputType, value)); newPopup.OnCancel += () => OnPopupClose(newPopup); newPopup.OnConfirm += _ => OnPopupClose(newPopup); return newPopup; @@ -70,7 +72,8 @@ namespace OWML.ModHelper.Menus IModInputCombinationMenu combinationMenu = null, IModInputCombinationElement element = null) { var newPopup = _combinationPopup.Copy(); - newPopup.Open(value, comboName, combinationMenu, element); + _events.Unity.FireOnNextUpdate(() => + newPopup.Open(value, comboName, combinationMenu, element)); newPopup.OnCancel += () => OnPopupClose(newPopup); newPopup.OnConfirm += _ => OnPopupClose(newPopup); return newPopup; diff --git a/src/OWML.ModLoader/Owo.cs b/src/OWML.ModLoader/Owo.cs index 6737e9a5..f0e2f07d 100644 --- a/src/OWML.ModLoader/Owo.cs +++ b/src/OWML.ModLoader/Owo.cs @@ -129,9 +129,16 @@ namespace OWML.ModLoader { return assembly.GetTypes().FirstOrDefault(x => x.IsSubclassOf(typeof(ModBehaviour))); } + catch (ReflectionTypeLoadException ex) + { + _console.WriteLine($"ReflectionTypeLoadException while trying to load {nameof(ModBehaviour)} of mod {modData.Manifest.UniqueName}: {ex.Message}\n" + + "Top 5 LoaderExceptions:\n" + + $"* {string.Join("\n* ", ex.LoaderExceptions.Take(5).ToList().Select(e => e.Message).ToArray())}", MessageType.Error); + return null; + } catch (Exception ex) { - _console.WriteLine($"Error while trying to get {typeof(ModBehaviour)}: {ex.Message}", MessageType.Error); + _console.WriteLine($"Exception while trying to get {nameof(ModBehaviour)} of mod {modData.Manifest.UniqueName}: {ex.Message}", MessageType.Error); return null; } } diff --git a/src/SampleMods/OWML.LoadCustomAssets/LoadCustomAssets.cs b/src/SampleMods/OWML.LoadCustomAssets/LoadCustomAssets.cs index 668e19dc..d381099d 100644 --- a/src/SampleMods/OWML.LoadCustomAssets/LoadCustomAssets.cs +++ b/src/SampleMods/OWML.LoadCustomAssets/LoadCustomAssets.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using OWML.Common; +using OWML.Common.Menus; using OWML.ModHelper; using UnityEngine; @@ -44,6 +45,22 @@ namespace OWML.LoadCustomAssets var modMenu = ModHelper.Menus.ModsMenu.GetModMenu(this); TestLogging(); + + TestPopup(); + } + + private void TestPopup() + { + ModHelper.Menus.PauseMenu.OnInit += () => + { + var popupButton = ModHelper.Menus.PauseMenu.ResumeButton.Duplicate("POPUP TEST"); + popupButton.OnClick += () => + { + ModHelper.Console.WriteLine("making popup, hopefully"); + var popup = ModHelper.Menus.PopupManager.CreateInputPopup(InputType.Text, "Event Name"); + popup.OnConfirm += s => ModHelper.Console.WriteLine("clicked confirm"); + }; + }; } public override void Configure(IModConfig config) diff --git a/tests/OWML.GameFinder.Tests/EpicGameFinderTests.cs b/tests/OWML.GameFinder.Tests/EpicGameFinderTests.cs index 6fd32c54..99759449 100644 --- a/tests/OWML.GameFinder.Tests/EpicGameFinderTests.cs +++ b/tests/OWML.GameFinder.Tests/EpicGameFinderTests.cs @@ -1,4 +1,5 @@ -using System.IO; +using System; +using System.IO; using OWML.Common; using OWML.Tests.Setup; using Xunit; @@ -20,7 +21,7 @@ namespace OWML.GameFinder.Tests var gamePath = pathFinder.FindGamePath(); - Assert.Equal(new DirectoryInfo(Config.GamePath).FullName, new DirectoryInfo(gamePath).FullName); + Assert.Equal(new DirectoryInfo(EpicGamePath).FullName, new DirectoryInfo(gamePath).FullName, StringComparer.InvariantCultureIgnoreCase); } } } diff --git a/tests/OWML.GameFinder.Tests/GameFinderTests.cs b/tests/OWML.GameFinder.Tests/GameFinderTests.cs index 116792c3..7a9d07b0 100644 --- a/tests/OWML.GameFinder.Tests/GameFinderTests.cs +++ b/tests/OWML.GameFinder.Tests/GameFinderTests.cs @@ -1,4 +1,5 @@ -using System.IO; +using System; +using System.IO; using OWML.Common; using OWML.Tests.Setup; using Xunit; @@ -20,7 +21,7 @@ namespace OWML.GameFinder.Tests var gamePath = pathFinder.FindGamePath(); - Assert.Equal(new DirectoryInfo(Config.GamePath).FullName, new DirectoryInfo(gamePath).FullName); + Assert.Equal(new DirectoryInfo(SteamGamePath).FullName, new DirectoryInfo(gamePath).FullName, StringComparer.InvariantCultureIgnoreCase); } } } diff --git a/tests/OWML.GameFinder.Tests/SteamGameFinderTests.cs b/tests/OWML.GameFinder.Tests/SteamGameFinderTests.cs new file mode 100644 index 00000000..11c80390 --- /dev/null +++ b/tests/OWML.GameFinder.Tests/SteamGameFinderTests.cs @@ -0,0 +1,27 @@ +using System; +using System.IO; +using OWML.Common; +using OWML.Tests.Setup; +using Xunit; +using Xunit.Abstractions; + +namespace OWML.GameFinder.Tests +{ + public class SteamGameFinderTests : OWMLTests + { + public SteamGameFinderTests(ITestOutputHelper outputHelper) + : base(outputHelper) + { + } + + [Fact] + public void SteamGameFinder_FindGamePath() + { + var pathFinder = new SteamGameFinder(new OwmlConfig(), Console.Object); + + var gamePath = pathFinder.FindGamePath(); + + Assert.Equal(new DirectoryInfo(SteamGamePath).FullName, new DirectoryInfo(gamePath).FullName, StringComparer.InvariantCultureIgnoreCase); + } + } +} diff --git a/tests/OWML.Launcher.Tests/LauncherTests.cs b/tests/OWML.Launcher.Tests/LauncherTests.cs index 76b894b4..86966fbf 100644 --- a/tests/OWML.Launcher.Tests/LauncherTests.cs +++ b/tests/OWML.Launcher.Tests/LauncherTests.cs @@ -26,7 +26,7 @@ namespace OWML.Launcher.Tests var app = container.Resolve(); app.Run(); - processHelper.Verify(s => s.Start(Config.ExePath, new string[] { }), Times.Once); + processHelper.Verify(s => s.Start($"{SteamGamePath}/OuterWilds.exe", new string[] { }), Times.Once); } } } diff --git a/tests/OWML.Tests.Setup/OWMLTests.cs b/tests/OWML.Tests.Setup/OWMLTests.cs index d54eebbe..1ab4fdd1 100644 --- a/tests/OWML.Tests.Setup/OWMLTests.cs +++ b/tests/OWML.Tests.Setup/OWMLTests.cs @@ -9,6 +9,10 @@ namespace OWML.Tests.Setup { public class OWMLTests { + protected string EpicGamePath => "C:/Program Files/Epic Games/OuterWilds"; + + protected string SteamGamePath => "C:/Program Files (x86)/Steam/steamapps/common/Outer Wilds"; + protected string OwmlSolutionPath => GetSolutionPath(); protected string OwmlReleasePath => $"{OwmlSolutionPath}/src/OWML.Launcher/bin/Debug/net48/"; @@ -22,9 +26,7 @@ namespace OWML.Tests.Setup protected Mock GOHelper { get; } = new(); protected IOwmlConfig Config { get; } = new OwmlConfig(); - - private const string GamePath = "C:/Program Files/Epic Games/OuterWilds"; - + private readonly ITestOutputHelper _outputHelper; public OWMLTests(ITestOutputHelper outputHelper) @@ -32,10 +34,10 @@ namespace OWML.Tests.Setup _outputHelper = outputHelper; Config.OWMLPath = OwmlReleasePath; - Config.GamePath = GamePath; + Config.GamePath = SteamGamePath; AppHelper.Setup(s => s.DataPath) - .Returns(() => $"{GamePath}/OuterWilds_Data"); + .Returns(() => $"{SteamGamePath}/OuterWilds_Data"); AppHelper.Setup(s => s.Version) .Returns(() => "1.3.3.7");