mirror of
https://github.com/ow-mods/owml.git
synced 2025-12-11 20:15:48 +01:00
Popup fix (#334)
* fixed popup bug * tests for Steam game finder * improved error messages when loading mods
This commit is contained in:
parent
fec3221651
commit
fee8f13116
@ -2,7 +2,7 @@
|
|||||||
"author": "Alek",
|
"author": "Alek",
|
||||||
"name": "OWML",
|
"name": "OWML",
|
||||||
"uniqueName": "Alek.OWML",
|
"uniqueName": "Alek.OWML",
|
||||||
"version": "1.1.6",
|
"version": "1.1.7",
|
||||||
"description": "The mod loader and mod framework for Outer Wilds",
|
"description": "The mod loader and mod framework for Outer Wilds",
|
||||||
"minGameVersion": "1.0.7.0",
|
"minGameVersion": "1.0.7.0",
|
||||||
"maxGameVersion": "1.0.7.481"
|
"maxGameVersion": "1.0.7.481"
|
||||||
|
|||||||
@ -13,11 +13,11 @@ namespace OWML.ModHelper.Menus
|
|||||||
|
|
||||||
private PopupInputMenu _inputMenu;
|
private PopupInputMenu _inputMenu;
|
||||||
|
|
||||||
public ModInputMenu(IModConsole console)
|
public ModInputMenu(IModConsole console)
|
||||||
: base(console)
|
: base(console)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Initialize(PopupInputMenu menu)
|
public void Initialize(PopupInputMenu menu)
|
||||||
{
|
{
|
||||||
if (Menu != null)
|
if (Menu != null)
|
||||||
@ -69,15 +69,11 @@ namespace OWML.ModHelper.Menus
|
|||||||
_inputMenu = null;
|
_inputMenu = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool OnValidateNumber()
|
private bool OnValidateNumber() =>
|
||||||
{
|
float.TryParse(_inputMenu.GetInputText(), out _);
|
||||||
return float.TryParse(_inputMenu.GetInputText(), out _);
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool OnValidateCharNumber(char c)
|
private bool OnValidateCharNumber(char c) =>
|
||||||
{
|
"0123456789.".Contains("" + c);
|
||||||
return "0123456789.".Contains("" + c);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnPopupConfirm()
|
protected override void OnPopupConfirm()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -51,7 +51,8 @@ namespace OWML.ModHelper.Menus
|
|||||||
public IModMessagePopup CreateMessagePopup(string message, bool addCancel = false, string okMessage = "OK", string cancelMessage = "Cancel")
|
public IModMessagePopup CreateMessagePopup(string message, bool addCancel = false, string okMessage = "OK", string cancelMessage = "Cancel")
|
||||||
{
|
{
|
||||||
var newPopup = _messagePopup.Copy();
|
var newPopup = _messagePopup.Copy();
|
||||||
newPopup.ShowMessage(message, addCancel, okMessage, cancelMessage);
|
_events.Unity.FireOnNextUpdate(() =>
|
||||||
|
newPopup.ShowMessage(message, addCancel, okMessage, cancelMessage));
|
||||||
newPopup.OnCancel += () => OnPopupClose(newPopup);
|
newPopup.OnCancel += () => OnPopupClose(newPopup);
|
||||||
newPopup.OnConfirm += () => OnPopupClose(newPopup);
|
newPopup.OnConfirm += () => OnPopupClose(newPopup);
|
||||||
return newPopup;
|
return newPopup;
|
||||||
@ -60,7 +61,8 @@ namespace OWML.ModHelper.Menus
|
|||||||
public IModInputMenu CreateInputPopup(InputType inputType, string value)
|
public IModInputMenu CreateInputPopup(InputType inputType, string value)
|
||||||
{
|
{
|
||||||
var newPopup = _inputPopup.Copy();
|
var newPopup = _inputPopup.Copy();
|
||||||
newPopup.Open(inputType, value);
|
_events.Unity.FireOnNextUpdate(() =>
|
||||||
|
newPopup.Open(inputType, value));
|
||||||
newPopup.OnCancel += () => OnPopupClose(newPopup);
|
newPopup.OnCancel += () => OnPopupClose(newPopup);
|
||||||
newPopup.OnConfirm += _ => OnPopupClose(newPopup);
|
newPopup.OnConfirm += _ => OnPopupClose(newPopup);
|
||||||
return newPopup;
|
return newPopup;
|
||||||
@ -70,7 +72,8 @@ namespace OWML.ModHelper.Menus
|
|||||||
IModInputCombinationMenu combinationMenu = null, IModInputCombinationElement element = null)
|
IModInputCombinationMenu combinationMenu = null, IModInputCombinationElement element = null)
|
||||||
{
|
{
|
||||||
var newPopup = _combinationPopup.Copy();
|
var newPopup = _combinationPopup.Copy();
|
||||||
newPopup.Open(value, comboName, combinationMenu, element);
|
_events.Unity.FireOnNextUpdate(() =>
|
||||||
|
newPopup.Open(value, comboName, combinationMenu, element));
|
||||||
newPopup.OnCancel += () => OnPopupClose(newPopup);
|
newPopup.OnCancel += () => OnPopupClose(newPopup);
|
||||||
newPopup.OnConfirm += _ => OnPopupClose(newPopup);
|
newPopup.OnConfirm += _ => OnPopupClose(newPopup);
|
||||||
return newPopup;
|
return newPopup;
|
||||||
|
|||||||
@ -129,9 +129,16 @@ namespace OWML.ModLoader
|
|||||||
{
|
{
|
||||||
return assembly.GetTypes().FirstOrDefault(x => x.IsSubclassOf(typeof(ModBehaviour)));
|
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)
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using OWML.Common;
|
using OWML.Common;
|
||||||
|
using OWML.Common.Menus;
|
||||||
using OWML.ModHelper;
|
using OWML.ModHelper;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
@ -44,6 +45,22 @@ namespace OWML.LoadCustomAssets
|
|||||||
var modMenu = ModHelper.Menus.ModsMenu.GetModMenu(this);
|
var modMenu = ModHelper.Menus.ModsMenu.GetModMenu(this);
|
||||||
|
|
||||||
TestLogging();
|
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)
|
public override void Configure(IModConfig config)
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using System.IO;
|
using System;
|
||||||
|
using System.IO;
|
||||||
using OWML.Common;
|
using OWML.Common;
|
||||||
using OWML.Tests.Setup;
|
using OWML.Tests.Setup;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
@ -20,7 +21,7 @@ namespace OWML.GameFinder.Tests
|
|||||||
|
|
||||||
var gamePath = pathFinder.FindGamePath();
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using System.IO;
|
using System;
|
||||||
|
using System.IO;
|
||||||
using OWML.Common;
|
using OWML.Common;
|
||||||
using OWML.Tests.Setup;
|
using OWML.Tests.Setup;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
@ -20,7 +21,7 @@ namespace OWML.GameFinder.Tests
|
|||||||
|
|
||||||
var gamePath = pathFinder.FindGamePath();
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
27
tests/OWML.GameFinder.Tests/SteamGameFinderTests.cs
Normal file
27
tests/OWML.GameFinder.Tests/SteamGameFinderTests.cs
Normal file
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -26,7 +26,7 @@ namespace OWML.Launcher.Tests
|
|||||||
var app = container.Resolve<App>();
|
var app = container.Resolve<App>();
|
||||||
app.Run();
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,10 @@ namespace OWML.Tests.Setup
|
|||||||
{
|
{
|
||||||
public class OWMLTests
|
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 OwmlSolutionPath => GetSolutionPath();
|
||||||
|
|
||||||
protected string OwmlReleasePath => $"{OwmlSolutionPath}/src/OWML.Launcher/bin/Debug/net48/";
|
protected string OwmlReleasePath => $"{OwmlSolutionPath}/src/OWML.Launcher/bin/Debug/net48/";
|
||||||
@ -22,9 +26,7 @@ namespace OWML.Tests.Setup
|
|||||||
protected Mock<IGameObjectHelper> GOHelper { get; } = new();
|
protected Mock<IGameObjectHelper> GOHelper { get; } = new();
|
||||||
|
|
||||||
protected IOwmlConfig Config { get; } = new OwmlConfig();
|
protected IOwmlConfig Config { get; } = new OwmlConfig();
|
||||||
|
|
||||||
private const string GamePath = "C:/Program Files/Epic Games/OuterWilds";
|
|
||||||
|
|
||||||
private readonly ITestOutputHelper _outputHelper;
|
private readonly ITestOutputHelper _outputHelper;
|
||||||
|
|
||||||
public OWMLTests(ITestOutputHelper outputHelper)
|
public OWMLTests(ITestOutputHelper outputHelper)
|
||||||
@ -32,10 +34,10 @@ namespace OWML.Tests.Setup
|
|||||||
_outputHelper = outputHelper;
|
_outputHelper = outputHelper;
|
||||||
|
|
||||||
Config.OWMLPath = OwmlReleasePath;
|
Config.OWMLPath = OwmlReleasePath;
|
||||||
Config.GamePath = GamePath;
|
Config.GamePath = SteamGamePath;
|
||||||
|
|
||||||
AppHelper.Setup(s => s.DataPath)
|
AppHelper.Setup(s => s.DataPath)
|
||||||
.Returns(() => $"{GamePath}/OuterWilds_Data");
|
.Returns(() => $"{SteamGamePath}/OuterWilds_Data");
|
||||||
AppHelper.Setup(s => s.Version)
|
AppHelper.Setup(s => s.Version)
|
||||||
.Returns(() => "1.3.3.7");
|
.Returns(() => "1.3.3.7");
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user