mirror of
https://github.com/xivdev/Penumbra.git
synced 2026-02-23 16:27:47 +01:00
Use improved filesystem.
This commit is contained in:
parent
4981b0348f
commit
1f4ec984b3
3 changed files with 5 additions and 15 deletions
|
|
@ -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