mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 10:17:22 +01:00
Use improved filesystem.
This commit is contained in:
parent
4981b0348f
commit
1f4ec984b3
3 changed files with 5 additions and 15 deletions
2
OtterGui
2
OtterGui
|
|
@ -1 +1 @@
|
|||
Subproject commit 17a3ee5711ca30eb7f5b393dfb8136f0bce49b2b
|
||||
Subproject commit 78528f93ac253db0061d9a8244cfa0cee5c2f873
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ public sealed class ModFileSystem : FileSystem<Mod>, 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<Mod>, 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<Mod>, 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<Mod>.Lexicographical)
|
||||
.OfType<Leaf>()
|
||||
.FirstOrDefault(l => l.Value == mod);
|
||||
return leaf != null;
|
||||
}
|
||||
|
||||
|
||||
// Used for saving and loading.
|
||||
private static string ModToIdentifier(Mod mod)
|
||||
=> mod.ModPath.Name;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue