Add mod setting API functions.

This commit is contained in:
Ottermandias 2022-06-18 15:18:35 +02:00
parent df1a75b58a
commit c578bd3a49
5 changed files with 245 additions and 39 deletions

View file

@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
namespace Penumbra.Mods;
@ -37,5 +38,28 @@ public sealed partial class Mod
ModOptionChanged += OnModOptionChange;
ModPathChanged += OnModPathChange;
}
// Try to obtain a mod by its directory name (unique identifier, preferred),
// or the first mod of the given name if no directory fits.
public bool TryGetMod( string modDirectory, string modName, [NotNullWhen( true )] out Mod? mod )
{
mod = null;
foreach( var m in _mods )
{
if( m.ModPath.Name == modDirectory )
{
mod = m;
return true;
}
if( m.Name == modName )
{
mod ??= m;
}
}
return mod != null;
}
}
}