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",
|
||||
"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"
|
||||
|
||||
@ -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()
|
||||
{
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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>();
|
||||
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
|
||||
{
|
||||
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<IGameObjectHelper> 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");
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user