mirror of
https://github.com/xivdev/Penumbra.git
synced 2026-02-23 08:17:59 +01:00
Add mod setting API functions.
This commit is contained in:
parent
df1a75b58a
commit
c578bd3a49
5 changed files with 245 additions and 39 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue