mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 18:27:24 +01:00
Some cleanup.
This commit is contained in:
parent
363b220613
commit
b79fbc7653
2 changed files with 20 additions and 24 deletions
|
|
@ -95,10 +95,10 @@ public class ItemSwapContainer
|
||||||
public void LoadMod(Mod? mod, ModSettings? settings)
|
public void LoadMod(Mod? mod, ModSettings? settings)
|
||||||
{
|
{
|
||||||
Clear();
|
Clear();
|
||||||
if (mod == null)
|
if (mod == null || mod.Index < 0)
|
||||||
{
|
{
|
||||||
_modRedirections = new Dictionary<Utf8GamePath, FullPath>();
|
_modRedirections = [];
|
||||||
_modManipulations = new HashSet<MetaManipulation>();
|
_modManipulations = [];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ namespace Penumbra.Mods.Subclasses;
|
||||||
public class ModSettings
|
public class ModSettings
|
||||||
{
|
{
|
||||||
public static readonly ModSettings Empty = new();
|
public static readonly ModSettings Empty = new();
|
||||||
public List< uint > Settings { get; private init; } = new();
|
public List< uint > Settings { get; private init; } = [];
|
||||||
public int Priority { get; set; }
|
public int Priority { get; set; }
|
||||||
public bool Enabled { get; set; }
|
public bool Enabled { get; set; }
|
||||||
|
|
||||||
|
|
@ -21,7 +21,7 @@ public class ModSettings
|
||||||
{
|
{
|
||||||
Enabled = Enabled,
|
Enabled = Enabled,
|
||||||
Priority = Priority,
|
Priority = Priority,
|
||||||
Settings = Settings.ToList(),
|
Settings = [.. Settings],
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create default settings for a given mod.
|
// Create default settings for a given mod.
|
||||||
|
|
@ -36,31 +36,14 @@ public class ModSettings
|
||||||
// Return everything required to resolve things for a single mod with given settings (which can be null, in which case the default is used.
|
// Return everything required to resolve things for a single mod with given settings (which can be null, in which case the default is used.
|
||||||
public static (Dictionary< Utf8GamePath, FullPath >, HashSet< MetaManipulation >) GetResolveData( Mod mod, ModSettings? settings )
|
public static (Dictionary< Utf8GamePath, FullPath >, HashSet< MetaManipulation >) GetResolveData( Mod mod, ModSettings? settings )
|
||||||
{
|
{
|
||||||
if( settings == null )
|
if (settings == null)
|
||||||
{
|
settings = DefaultSettings(mod);
|
||||||
settings = DefaultSettings( mod );
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
settings.AddMissingSettings( mod );
|
settings.AddMissingSettings( mod );
|
||||||
}
|
|
||||||
|
|
||||||
var dict = new Dictionary< Utf8GamePath, FullPath >();
|
var dict = new Dictionary< Utf8GamePath, FullPath >();
|
||||||
var set = new HashSet< MetaManipulation >();
|
var set = new HashSet< MetaManipulation >();
|
||||||
|
|
||||||
void AddOption( ISubMod option )
|
|
||||||
{
|
|
||||||
foreach( var (path, file) in option.Files.Concat( option.FileSwaps ) )
|
|
||||||
{
|
|
||||||
dict.TryAdd( path, file );
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach( var manip in option.Manipulations )
|
|
||||||
{
|
|
||||||
set.Add( manip );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach( var (group, index) in mod.Groups.WithIndex().OrderByDescending( g => g.Value.Priority ) )
|
foreach( var (group, index) in mod.Groups.WithIndex().OrderByDescending( g => g.Value.Priority ) )
|
||||||
{
|
{
|
||||||
if( group.Type is GroupType.Single )
|
if( group.Type is GroupType.Single )
|
||||||
|
|
@ -81,6 +64,19 @@ public class ModSettings
|
||||||
|
|
||||||
AddOption( mod.Default );
|
AddOption( mod.Default );
|
||||||
return ( dict, set );
|
return ( dict, set );
|
||||||
|
|
||||||
|
void AddOption( ISubMod option )
|
||||||
|
{
|
||||||
|
foreach( var (path, file) in option.Files.Concat( option.FileSwaps ) )
|
||||||
|
{
|
||||||
|
dict.TryAdd( path, file );
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach( var manip in option.Manipulations )
|
||||||
|
{
|
||||||
|
set.Add( manip );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Automatically react to changes in a mods available options.
|
// Automatically react to changes in a mods available options.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue