mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 18:27:24 +01:00
Fix display of conflicts in gui.
This commit is contained in:
parent
88224d4e27
commit
bcd20d7ccd
4 changed files with 30 additions and 32 deletions
|
|
@ -19,7 +19,7 @@ namespace Penumbra.Api
|
|||
public object? GetMods()
|
||||
{
|
||||
var modManager = Service< ModManager >.Get();
|
||||
return modManager.Collections.CurrentCollection.Cache?.AvailableMods.Select( x => new
|
||||
return modManager.Collections.CurrentCollection.Cache?.AvailableMods.Values.Select( x => new
|
||||
{
|
||||
x.Settings.Enabled,
|
||||
x.Settings.Priority,
|
||||
|
|
|
|||
|
|
@ -37,6 +37,11 @@ namespace Penumbra.Mods
|
|||
|
||||
public Mod.Mod GetMod( ModData mod )
|
||||
{
|
||||
if( Cache != null && Cache.AvailableMods.TryGetValue( mod.BasePath.Name, out var ret ))
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
if( Settings.TryGetValue( mod.BasePath.Name, out var settings ) )
|
||||
{
|
||||
return new Mod.Mod( settings, mod );
|
||||
|
|
@ -111,7 +116,7 @@ namespace Penumbra.Mods
|
|||
}
|
||||
|
||||
var changes = false;
|
||||
foreach( var mod in Cache.AvailableMods )
|
||||
foreach( var mod in Cache.AvailableMods.Values )
|
||||
{
|
||||
changes |= mod.FixSettings();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace Penumbra.Mods
|
|||
// It will only be setup if a collection gets activated in any way.
|
||||
public class ModCollectionCache
|
||||
{
|
||||
public readonly List<Mod.Mod> AvailableMods = new();
|
||||
public readonly Dictionary< string, Mod.Mod > AvailableMods = new();
|
||||
|
||||
public readonly Dictionary< GamePath, FileInfo > ResolvedFiles = new();
|
||||
public readonly Dictionary< GamePath, GamePath > SwappedFiles = new();
|
||||
|
|
@ -77,7 +77,7 @@ namespace Penumbra.Mods
|
|||
{
|
||||
MetaManipulations.Reset( false );
|
||||
|
||||
foreach( var mod in AvailableMods.Where( m => m.Settings.Enabled && m.Data.Resources.MetaManipulations.Count > 0 ) )
|
||||
foreach( var mod in AvailableMods.Values.Where( m => m.Settings.Enabled && m.Data.Resources.MetaManipulations.Count > 0 ) )
|
||||
{
|
||||
mod.Cache.ClearMetaConflicts();
|
||||
AddManipulations( mod );
|
||||
|
|
@ -92,7 +92,7 @@ namespace Penumbra.Mods
|
|||
SwappedFiles.Clear();
|
||||
|
||||
var registeredFiles = new Dictionary< GamePath, Mod.Mod >();
|
||||
foreach( var mod in AvailableMods.Where( m => m.Settings.Enabled ) )
|
||||
foreach( var mod in AvailableMods.Values.Where( m => m.Settings.Enabled ) )
|
||||
{
|
||||
mod.Cache.ClearFileConflicts();
|
||||
AddFiles( registeredFiles, mod );
|
||||
|
|
@ -102,28 +102,19 @@ namespace Penumbra.Mods
|
|||
|
||||
public void RemoveMod( DirectoryInfo basePath )
|
||||
{
|
||||
var hadMeta = false;
|
||||
var wasEnabled = false;
|
||||
AvailableMods.RemoveAll( m =>
|
||||
if( AvailableMods.TryGetValue( basePath.Name, out var mod ) )
|
||||
{
|
||||
if( m.Settings.Enabled )
|
||||
{
|
||||
wasEnabled = true;
|
||||
hadMeta |= m.Data.Resources.MetaManipulations.Count > 0;
|
||||
}
|
||||
|
||||
return m.Data.BasePath.Name == basePath.Name;
|
||||
} );
|
||||
|
||||
if( wasEnabled )
|
||||
AvailableMods.Remove( basePath.Name );
|
||||
if( mod.Settings.Enabled )
|
||||
{
|
||||
CalculateEffectiveFileList();
|
||||
if( hadMeta )
|
||||
if( mod.Data.Resources.MetaManipulations.Count > 0 )
|
||||
{
|
||||
UpdateMetaManipulations();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class PriorityComparer : IComparer< Mod.Mod >
|
||||
{
|
||||
|
|
@ -134,11 +125,12 @@ namespace Penumbra.Mods
|
|||
private static readonly PriorityComparer Comparer = new();
|
||||
|
||||
public void AddMod( ModSettings settings, ModData data )
|
||||
{
|
||||
if( !AvailableMods.TryGetValue( data.BasePath.Name, out var existingMod ) )
|
||||
{
|
||||
var newMod = new Mod.Mod( settings, data );
|
||||
var idx = AvailableMods.BinarySearch( newMod, Comparer );
|
||||
idx = idx < 0 ? ~idx : idx;
|
||||
AvailableMods.Insert( idx, newMod );
|
||||
AvailableMods[ data.BasePath.Name ] = newMod;
|
||||
|
||||
if( settings.Enabled )
|
||||
{
|
||||
CalculateEffectiveFileList();
|
||||
|
|
@ -148,6 +140,7 @@ namespace Penumbra.Mods
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public FileInfo? GetCandidateForGameFile( GamePath gameResourcePath )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -204,8 +204,8 @@ namespace Penumbra.UI
|
|||
if( ImGui.InputInt( "Priority", ref priority, 0 ) && priority != Mod!.Settings.Priority )
|
||||
{
|
||||
Mod.Settings.Priority = priority;
|
||||
_selector.Cache.ResetFilters();
|
||||
_base.SaveCurrentCollection( Mod.Data.Resources.MetaManipulations.Count > 0 );
|
||||
_selector.Cache.ResetFilters();
|
||||
}
|
||||
|
||||
if( ImGui.IsItemHovered() )
|
||||
|
|
@ -221,8 +221,8 @@ namespace Penumbra.UI
|
|||
if( ImGui.Checkbox( LabelModEnabled, ref enabled ) )
|
||||
{
|
||||
Mod.Settings.Enabled = enabled;
|
||||
_selector.Cache.ResetFilters();
|
||||
_base.SaveCurrentCollection( Mod.Data.Resources.MetaManipulations.Count > 0 );
|
||||
_selector.Cache.ResetFilters();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue