diff --git a/OtterGui b/OtterGui index 17a3ee57..78528f93 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit 17a3ee5711ca30eb7f5b393dfb8136f0bce49b2b +Subproject commit 78528f93ac253db0061d9a8244cfa0cee5c2f873 diff --git a/Penumbra/Api/Api/ModsApi.cs b/Penumbra/Api/Api/ModsApi.cs index ace98f83..78c62953 100644 --- a/Penumbra/Api/Api/ModsApi.cs +++ b/Penumbra/Api/Api/ModsApi.cs @@ -112,7 +112,7 @@ public class ModsApi : IPenumbraApiMods, IApiService, IDisposable public (PenumbraApiEc, string, bool, bool) GetModPath(string modDirectory, string modName) { if (!_modManager.TryGetMod(modDirectory, modName, out var mod) - || !_modFileSystem.FindLeaf(mod, out var leaf)) + || !_modFileSystem.TryGetValue(mod, out var leaf)) return (PenumbraApiEc.ModMissing, string.Empty, false, false); var fullPath = leaf.FullName(); @@ -127,7 +127,7 @@ public class ModsApi : IPenumbraApiMods, IApiService, IDisposable return PenumbraApiEc.InvalidArgument; if (!_modManager.TryGetMod(modDirectory, modName, out var mod) - || !_modFileSystem.FindLeaf(mod, out var leaf)) + || !_modFileSystem.TryGetValue(mod, out var leaf)) return PenumbraApiEc.ModMissing; try diff --git a/Penumbra/Mods/Manager/ModFileSystem.cs b/Penumbra/Mods/Manager/ModFileSystem.cs index 693db944..a5c46972 100644 --- a/Penumbra/Mods/Manager/ModFileSystem.cs +++ b/Penumbra/Mods/Manager/ModFileSystem.cs @@ -80,7 +80,7 @@ public sealed class ModFileSystem : FileSystem, IDisposable, ISavable, ISer // Update sort order when defaulted mod names change. private void OnModDataChange(ModDataChangeType type, Mod mod, string? oldName) { - if (!type.HasFlag(ModDataChangeType.Name) || oldName == null || !FindLeaf(mod, out var leaf)) + if (!type.HasFlag(ModDataChangeType.Name) || oldName == null || !TryGetValue(mod, out var leaf)) return; var old = oldName.FixName(); @@ -111,7 +111,7 @@ public sealed class ModFileSystem : FileSystem, IDisposable, ISavable, ISer CreateDuplicateLeaf(parent, mod.Name.Text, mod); break; case ModPathChangeType.Deleted: - if (FindLeaf(mod, out var leaf)) + if (TryGetValue(mod, out var leaf)) Delete(leaf); break; @@ -124,16 +124,6 @@ public sealed class ModFileSystem : FileSystem, IDisposable, ISavable, ISer } } - // Search the entire filesystem for the leaf corresponding to a mod. - public bool FindLeaf(Mod mod, [NotNullWhen(true)] out Leaf? leaf) - { - leaf = Root.GetAllDescendants(ISortMode.Lexicographical) - .OfType() - .FirstOrDefault(l => l.Value == mod); - return leaf != null; - } - - // Used for saving and loading. private static string ModToIdentifier(Mod mod) => mod.ModPath.Name;