mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 10:17:22 +01:00
Some fixes with collection inheritance.
This commit is contained in:
parent
9508b8d9b3
commit
3e9f9289e5
4 changed files with 35 additions and 13 deletions
|
|
@ -115,7 +115,7 @@ public partial class ModCollection
|
|||
newCollection.Index = _collections.Count;
|
||||
_collections.Add( newCollection );
|
||||
newCollection.Save();
|
||||
PluginLog.Debug( "Added collection {Name:l}.", newCollection.Name );
|
||||
PluginLog.Debug( "Added collection {Name:l}.", newCollection.AnonymizedName );
|
||||
CollectionChanged.Invoke( CollectionType.Inactive, null, newCollection );
|
||||
SetCollection( newCollection.Index, CollectionType.Current );
|
||||
return true;
|
||||
|
|
@ -154,8 +154,17 @@ public partial class ModCollection
|
|||
}
|
||||
|
||||
var collection = _collections[ idx ];
|
||||
|
||||
// Clear own inheritances.
|
||||
foreach(var inheritance in collection.Inheritance)
|
||||
{
|
||||
collection.ClearSubscriptions( inheritance );
|
||||
}
|
||||
|
||||
collection.Delete();
|
||||
_collections.RemoveAt( idx );
|
||||
|
||||
// Clear external inheritances.
|
||||
foreach( var c in _collections )
|
||||
{
|
||||
var inheritedIdx = c._inheritance.IndexOf( collection );
|
||||
|
|
@ -170,7 +179,7 @@ public partial class ModCollection
|
|||
}
|
||||
}
|
||||
|
||||
PluginLog.Debug( "Removed collection {Name:l}.", collection.Name );
|
||||
PluginLog.Debug( "Removed collection {Name:l}.", collection.AnonymizedName );
|
||||
CollectionChanged.Invoke( CollectionType.Inactive, collection, null );
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ public partial class ModCollection
|
|||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
PluginLog.Error( $"Could not save collection {Name}:\n{e}" );
|
||||
PluginLog.Error( $"Could not save collection {AnonymizedName}:\n{e}" );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -90,11 +90,11 @@ public partial class ModCollection
|
|||
try
|
||||
{
|
||||
file.Delete();
|
||||
PluginLog.Information( "Deleted collection file {File:l} for {Name:l}.", file.FullName, Name );
|
||||
PluginLog.Information( "Deleted collection file for {Name:l}.", AnonymizedName );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
PluginLog.Error( $"Could not delete collection file {file.FullName} for {Name}:\n{e}" );
|
||||
PluginLog.Error( $"Could not delete collection file for {AnonymizedName}:\n{e}" );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -105,7 +105,7 @@ public partial class ModCollection
|
|||
inheritance = Array.Empty< string >();
|
||||
if( !file.Exists )
|
||||
{
|
||||
PluginLog.Error( $"Could not read collection because {file.FullName} does not exist." );
|
||||
PluginLog.Error( $"Could not read collection because file does not exist." );
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
@ -123,7 +123,7 @@ public partial class ModCollection
|
|||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
PluginLog.Error( $"Could not read collection information from {file.FullName}:\n{e}" );
|
||||
PluginLog.Error( $"Could not read collection information from file:\n{e}" );
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -88,13 +88,18 @@ public partial class ModCollection
|
|||
public void RemoveInheritance( int idx )
|
||||
{
|
||||
var inheritance = _inheritance[ idx ];
|
||||
inheritance.ModSettingChanged -= OnInheritedModSettingChange;
|
||||
inheritance.InheritanceChanged -= OnInheritedInheritanceChange;
|
||||
ClearSubscriptions( inheritance );
|
||||
_inheritance.RemoveAt( idx );
|
||||
InheritanceChanged.Invoke( false );
|
||||
PluginLog.Debug( "Removed {InheritedName:l} from {Name:l} inheritances.", inheritance.AnonymizedName, AnonymizedName );
|
||||
}
|
||||
|
||||
private void ClearSubscriptions( ModCollection other )
|
||||
{
|
||||
other.ModSettingChanged -= OnInheritedModSettingChange;
|
||||
other.InheritanceChanged -= OnInheritedInheritanceChange;
|
||||
}
|
||||
|
||||
// Order in the inheritance list is relevant.
|
||||
public void MoveInheritance( int from, int to )
|
||||
{
|
||||
|
|
@ -115,6 +120,13 @@ public partial class ModCollection
|
|||
ModSettingChanged.Invoke( type, modIdx, oldValue, groupIdx, true );
|
||||
return;
|
||||
default:
|
||||
if( modIdx < 0 || modIdx >= _settings.Count )
|
||||
{
|
||||
PluginLog.Warning(
|
||||
$"Collection state broken, Mod {modIdx} in inheritance does not exist. ({_settings.Count} mods exist)." );
|
||||
return;
|
||||
}
|
||||
|
||||
if( _settings[ modIdx ] == null )
|
||||
{
|
||||
ModSettingChanged.Invoke( type, modIdx, oldValue, groupIdx, true );
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using Penumbra.Collections;
|
|||
using Penumbra.Mods;
|
||||
using Penumbra.UI.Classes;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using Dalamud.Logging;
|
||||
|
||||
|
|
@ -43,13 +44,13 @@ public partial class ConfigWindow
|
|||
{
|
||||
PluginLog.Error( $"Exception thrown during ModPanel Render:\n{e}" );
|
||||
PluginLog.Error( $"{Penumbra.ModManager.Count} Mods\n"
|
||||
+ $"{Penumbra.CollectionManager.Current.Name} Current Collection\n"
|
||||
+ $"{Penumbra.CollectionManager.Current.AnonymizedName} Current Collection\n"
|
||||
+ $"{Penumbra.CollectionManager.Current.Settings.Count} Settings\n"
|
||||
+ $"{_selector.SortMode} Sort Mode\n"
|
||||
+ $"{_selector.SortMode.Name} Sort Mode\n"
|
||||
+ $"{_selector.SelectedLeaf?.Name ?? "NULL"} Selected Leaf\n"
|
||||
+ $"{_selector.Selected?.Name ?? "NULL"} Selected Mod\n"
|
||||
+ $"{string.Join( ", ", Penumbra.CollectionManager.Current.Inheritance )} Inheritances\n"
|
||||
+ $"{_selector.SelectedSettingCollection.Name} Collection\n" );
|
||||
+ $"{string.Join( ", ", Penumbra.CollectionManager.Current.Inheritance.Select(c => c.AnonymizedName) )} Inheritances\n"
|
||||
+ $"{_selector.SelectedSettingCollection.AnonymizedName} Collection\n" );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue