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()
|
public object? GetMods()
|
||||||
{
|
{
|
||||||
var modManager = Service< ModManager >.Get();
|
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.Enabled,
|
||||||
x.Settings.Priority,
|
x.Settings.Priority,
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,11 @@ namespace Penumbra.Mods
|
||||||
|
|
||||||
public Mod.Mod GetMod( ModData mod )
|
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 ) )
|
if( Settings.TryGetValue( mod.BasePath.Name, out var settings ) )
|
||||||
{
|
{
|
||||||
return new Mod.Mod( settings, mod );
|
return new Mod.Mod( settings, mod );
|
||||||
|
|
@ -111,7 +116,7 @@ namespace Penumbra.Mods
|
||||||
}
|
}
|
||||||
|
|
||||||
var changes = false;
|
var changes = false;
|
||||||
foreach( var mod in Cache.AvailableMods )
|
foreach( var mod in Cache.AvailableMods.Values )
|
||||||
{
|
{
|
||||||
changes |= mod.FixSettings();
|
changes |= mod.FixSettings();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ namespace Penumbra.Mods
|
||||||
// It will only be setup if a collection gets activated in any way.
|
// It will only be setup if a collection gets activated in any way.
|
||||||
public class ModCollectionCache
|
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, FileInfo > ResolvedFiles = new();
|
||||||
public readonly Dictionary< GamePath, GamePath > SwappedFiles = new();
|
public readonly Dictionary< GamePath, GamePath > SwappedFiles = new();
|
||||||
|
|
@ -77,7 +77,7 @@ namespace Penumbra.Mods
|
||||||
{
|
{
|
||||||
MetaManipulations.Reset( false );
|
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();
|
mod.Cache.ClearMetaConflicts();
|
||||||
AddManipulations( mod );
|
AddManipulations( mod );
|
||||||
|
|
@ -92,7 +92,7 @@ namespace Penumbra.Mods
|
||||||
SwappedFiles.Clear();
|
SwappedFiles.Clear();
|
||||||
|
|
||||||
var registeredFiles = new Dictionary< GamePath, Mod.Mod >();
|
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();
|
mod.Cache.ClearFileConflicts();
|
||||||
AddFiles( registeredFiles, mod );
|
AddFiles( registeredFiles, mod );
|
||||||
|
|
@ -102,25 +102,16 @@ namespace Penumbra.Mods
|
||||||
|
|
||||||
public void RemoveMod( DirectoryInfo basePath )
|
public void RemoveMod( DirectoryInfo basePath )
|
||||||
{
|
{
|
||||||
var hadMeta = false;
|
if( AvailableMods.TryGetValue( basePath.Name, out var mod ) )
|
||||||
var wasEnabled = false;
|
|
||||||
AvailableMods.RemoveAll( m =>
|
|
||||||
{
|
{
|
||||||
if( m.Settings.Enabled )
|
AvailableMods.Remove( basePath.Name );
|
||||||
|
if( mod.Settings.Enabled )
|
||||||
{
|
{
|
||||||
wasEnabled = true;
|
CalculateEffectiveFileList();
|
||||||
hadMeta |= m.Data.Resources.MetaManipulations.Count > 0;
|
if( mod.Data.Resources.MetaManipulations.Count > 0 )
|
||||||
}
|
{
|
||||||
|
UpdateMetaManipulations();
|
||||||
return m.Data.BasePath.Name == basePath.Name;
|
}
|
||||||
} );
|
|
||||||
|
|
||||||
if( wasEnabled )
|
|
||||||
{
|
|
||||||
CalculateEffectiveFileList();
|
|
||||||
if( hadMeta )
|
|
||||||
{
|
|
||||||
UpdateMetaManipulations();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -135,16 +126,18 @@ namespace Penumbra.Mods
|
||||||
|
|
||||||
public void AddMod( ModSettings settings, ModData data )
|
public void AddMod( ModSettings settings, ModData data )
|
||||||
{
|
{
|
||||||
var newMod = new Mod.Mod( settings, data );
|
if( !AvailableMods.TryGetValue( data.BasePath.Name, out var existingMod ) )
|
||||||
var idx = AvailableMods.BinarySearch( newMod, Comparer );
|
|
||||||
idx = idx < 0 ? ~idx : idx;
|
|
||||||
AvailableMods.Insert( idx, newMod );
|
|
||||||
if( settings.Enabled )
|
|
||||||
{
|
{
|
||||||
CalculateEffectiveFileList();
|
var newMod = new Mod.Mod( settings, data );
|
||||||
if( data.Resources.MetaManipulations.Count > 0 )
|
AvailableMods[ data.BasePath.Name ] = newMod;
|
||||||
|
|
||||||
|
if( settings.Enabled )
|
||||||
{
|
{
|
||||||
UpdateMetaManipulations();
|
CalculateEffectiveFileList();
|
||||||
|
if( data.Resources.MetaManipulations.Count > 0 )
|
||||||
|
{
|
||||||
|
UpdateMetaManipulations();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -204,8 +204,8 @@ namespace Penumbra.UI
|
||||||
if( ImGui.InputInt( "Priority", ref priority, 0 ) && priority != Mod!.Settings.Priority )
|
if( ImGui.InputInt( "Priority", ref priority, 0 ) && priority != Mod!.Settings.Priority )
|
||||||
{
|
{
|
||||||
Mod.Settings.Priority = priority;
|
Mod.Settings.Priority = priority;
|
||||||
_selector.Cache.ResetFilters();
|
|
||||||
_base.SaveCurrentCollection( Mod.Data.Resources.MetaManipulations.Count > 0 );
|
_base.SaveCurrentCollection( Mod.Data.Resources.MetaManipulations.Count > 0 );
|
||||||
|
_selector.Cache.ResetFilters();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ImGui.IsItemHovered() )
|
if( ImGui.IsItemHovered() )
|
||||||
|
|
@ -221,8 +221,8 @@ namespace Penumbra.UI
|
||||||
if( ImGui.Checkbox( LabelModEnabled, ref enabled ) )
|
if( ImGui.Checkbox( LabelModEnabled, ref enabled ) )
|
||||||
{
|
{
|
||||||
Mod.Settings.Enabled = enabled;
|
Mod.Settings.Enabled = enabled;
|
||||||
_selector.Cache.ResetFilters();
|
|
||||||
_base.SaveCurrentCollection( Mod.Data.Resources.MetaManipulations.Count > 0 );
|
_base.SaveCurrentCollection( Mod.Data.Resources.MetaManipulations.Count > 0 );
|
||||||
|
_selector.Cache.ResetFilters();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue