Fix best match fullpath returning broken FullPath instead of nullopt.

This commit is contained in:
Ottermandias 2024-05-28 00:11:31 +02:00
parent fe266dca31
commit f11cefcec1
2 changed files with 15 additions and 6 deletions

View file

@ -4,6 +4,7 @@ using Newtonsoft.Json.Linq;
using OtterGui;
using OtterGui.Classes;
using Penumbra.Api.Enums;
using Penumbra.GameData;
using Penumbra.GameData.Data;
using Penumbra.Meta.Manipulations;
using Penumbra.Mods.Settings;
@ -40,9 +41,13 @@ public sealed class MultiModGroup(Mod mod) : IModGroup, ITexToolsGroup
=> OptionData.Count > 0;
public FullPath? FindBestMatch(Utf8GamePath gamePath)
=> OptionData.OrderByDescending(o => o.Priority)
.SelectWhere(o => (o.Files.TryGetValue(gamePath, out var file) || o.FileSwaps.TryGetValue(gamePath, out file), file))
.FirstOrDefault();
{
foreach (var path in OptionData.OrderByDescending(o => o.Priority)
.SelectWhere(o => (o.Files.TryGetValue(gamePath, out var file) || o.FileSwaps.TryGetValue(gamePath, out file), file)))
return path;
return null;
}
public IModOption? AddOption(string name, string description = "")
{

View file

@ -30,9 +30,13 @@ public sealed class SingleModGroup(Mod mod) : IModGroup, ITexToolsGroup
public readonly List<SingleSubMod> OptionData = [];
public FullPath? FindBestMatch(Utf8GamePath gamePath)
=> OptionData
.SelectWhere(m => (m.Files.TryGetValue(gamePath, out var file) || m.FileSwaps.TryGetValue(gamePath, out file), file))
.FirstOrDefault();
{
foreach (var path in OptionData
.SelectWhere(m => (m.Files.TryGetValue(gamePath, out var file) || m.FileSwaps.TryGetValue(gamePath, out file), file)))
return path;
return null;
}
public IModOption AddOption(string name, string description = "")
{