mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-13 20:24:17 +01:00
parent
1504af9f3d
commit
2103ae3053
3 changed files with 144 additions and 149 deletions
|
|
@ -57,7 +57,7 @@ public class PenumbraApi : IDisposable, IPenumbraApi
|
||||||
public IPluginConfiguration GetConfiguration()
|
public IPluginConfiguration GetConfiguration()
|
||||||
{
|
{
|
||||||
CheckInitialized();
|
CheckInitialized();
|
||||||
return JsonConvert.DeserializeObject< Configuration >( JsonConvert.SerializeObject( Penumbra.Config ) );
|
return JsonConvert.DeserializeObject<Configuration>( JsonConvert.SerializeObject( Penumbra.Config ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public event ChangedItemHover? ChangedItemTooltip;
|
public event ChangedItemHover? ChangedItemTooltip;
|
||||||
|
|
@ -138,23 +138,22 @@ public class PenumbraApi : IDisposable, IPenumbraApi
|
||||||
}
|
}
|
||||||
|
|
||||||
var gamePath = Utf8GamePath.FromString( path, out var p, true ) ? p : Utf8GamePath.Empty;
|
var gamePath = Utf8GamePath.FromString( path, out var p, true ) ? p : Utf8GamePath.Empty;
|
||||||
var ret = Penumbra.CollectionManager.Character( characterName ).ResolveReversePath( new FullPath( path ) ) ??
|
var ret = Penumbra.CollectionManager.Character( characterName ).ResolveReversePath( new FullPath( path ) ) ?? new List<Utf8GamePath>();
|
||||||
new List< Utf8GamePath >();
|
|
||||||
if( ret.Count == 0 ) ret.Add( gamePath );
|
if( ret.Count == 0 ) ret.Add( gamePath );
|
||||||
return ret.Select( r => r.ToString() ).ToArray();
|
return ret.Select( r => r.ToString() ).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
private T? GetFileIntern< T >( string resolvedPath ) where T : FileResource
|
private T? GetFileIntern<T>( string resolvedPath ) where T : FileResource
|
||||||
{
|
{
|
||||||
CheckInitialized();
|
CheckInitialized();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if( Path.IsPathRooted( resolvedPath ) )
|
if( Path.IsPathRooted( resolvedPath ) )
|
||||||
{
|
{
|
||||||
return _lumina?.GetFileFromDisk< T >( resolvedPath );
|
return _lumina?.GetFileFromDisk<T>( resolvedPath );
|
||||||
}
|
}
|
||||||
|
|
||||||
return Dalamud.GameData.GetFile< T >( resolvedPath );
|
return Dalamud.GameData.GetFile<T>( resolvedPath );
|
||||||
}
|
}
|
||||||
catch( Exception e )
|
catch( Exception e )
|
||||||
{
|
{
|
||||||
|
|
@ -163,13 +162,13 @@ public class PenumbraApi : IDisposable, IPenumbraApi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public T? GetFile< T >( string gamePath ) where T : FileResource
|
public T? GetFile<T>( string gamePath ) where T : FileResource
|
||||||
=> GetFileIntern< T >( ResolvePath( gamePath ) );
|
=> GetFileIntern<T>( ResolvePath( gamePath ) );
|
||||||
|
|
||||||
public T? GetFile< T >( string gamePath, string characterName ) where T : FileResource
|
public T? GetFile<T>( string gamePath, string characterName ) where T : FileResource
|
||||||
=> GetFileIntern< T >( ResolvePath( gamePath, characterName ) );
|
=> GetFileIntern<T>( ResolvePath( gamePath, characterName ) );
|
||||||
|
|
||||||
public IReadOnlyDictionary< string, object? > GetChangedItemsForCollection( string collectionName )
|
public IReadOnlyDictionary<string, object?> GetChangedItemsForCollection( string collectionName )
|
||||||
{
|
{
|
||||||
CheckInitialized();
|
CheckInitialized();
|
||||||
try
|
try
|
||||||
|
|
@ -185,7 +184,7 @@ public class PenumbraApi : IDisposable, IPenumbraApi
|
||||||
}
|
}
|
||||||
|
|
||||||
PluginLog.Warning( $"Collection {collectionName} does not exist or is not loaded." );
|
PluginLog.Warning( $"Collection {collectionName} does not exist or is not loaded." );
|
||||||
return new Dictionary< string, object? >();
|
return new Dictionary<string, object?>();
|
||||||
}
|
}
|
||||||
catch( Exception e )
|
catch( Exception e )
|
||||||
{
|
{
|
||||||
|
|
@ -194,7 +193,7 @@ public class PenumbraApi : IDisposable, IPenumbraApi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IList< string > GetCollections()
|
public IList<string> GetCollections()
|
||||||
{
|
{
|
||||||
CheckInitialized();
|
CheckInitialized();
|
||||||
return Penumbra.CollectionManager.Skip( 1 ).Select( c => c.Name ).ToArray();
|
return Penumbra.CollectionManager.Skip( 1 ).Select( c => c.Name ).ToArray();
|
||||||
|
|
@ -216,28 +215,27 @@ public class PenumbraApi : IDisposable, IPenumbraApi
|
||||||
{
|
{
|
||||||
CheckInitialized();
|
CheckInitialized();
|
||||||
return Penumbra.CollectionManager.Characters.TryGetValue( characterName, out var collection )
|
return Penumbra.CollectionManager.Characters.TryGetValue( characterName, out var collection )
|
||||||
? ( collection.Name, true )
|
? (collection.Name, true)
|
||||||
: ( Penumbra.CollectionManager.Default.Name, false );
|
: (Penumbra.CollectionManager.Default.Name, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public (IntPtr, string) GetDrawObjectInfo( IntPtr drawObject )
|
public (IntPtr, string) GetDrawObjectInfo( IntPtr drawObject )
|
||||||
{
|
{
|
||||||
CheckInitialized();
|
CheckInitialized();
|
||||||
var (obj, collection) = _penumbra!.PathResolver.IdentifyDrawObject( drawObject );
|
var (obj, collection) = _penumbra!.PathResolver.IdentifyDrawObject( drawObject );
|
||||||
return ( obj, collection.Name );
|
return (obj, collection.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IList< (string, string) > GetModList()
|
public IList<(string, string)> GetModList()
|
||||||
{
|
{
|
||||||
CheckInitialized();
|
CheckInitialized();
|
||||||
return Penumbra.ModManager.Select( m => ( m.ModPath.Name, m.Name.Text ) ).ToArray();
|
return Penumbra.ModManager.Select( m => (m.ModPath.Name, m.Name.Text) ).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dictionary< string, (string[], SelectType) >? GetAvailableModSettings( string modDirectory, string modName )
|
public Dictionary<string, (string[], SelectType)>? GetAvailableModSettings( string modDirectory, string modName )
|
||||||
=> throw new NotImplementedException();
|
=> throw new NotImplementedException();
|
||||||
|
|
||||||
public (PenumbraApiEc, (bool, int, Dictionary< string, string[] >, bool)?) GetCurrentModSettings( string collectionName,
|
public (PenumbraApiEc, (bool, int, Dictionary<string, string[]>, bool)?) GetCurrentModSettings( string collectionName, string modDirectory, string modName,
|
||||||
string modDirectory, string modName,
|
|
||||||
bool allowInheritance )
|
bool allowInheritance )
|
||||||
=> throw new NotImplementedException();
|
=> throw new NotImplementedException();
|
||||||
|
|
||||||
|
|
@ -253,8 +251,7 @@ public class PenumbraApi : IDisposable, IPenumbraApi
|
||||||
public PenumbraApiEc TrySetModSetting( string collectionName, string modDirectory, string modName, string optionGroupName, string option )
|
public PenumbraApiEc TrySetModSetting( string collectionName, string modDirectory, string modName, string optionGroupName, string option )
|
||||||
=> throw new NotImplementedException();
|
=> throw new NotImplementedException();
|
||||||
|
|
||||||
public PenumbraApiEc TrySetModSetting( string collectionName, string modDirectory, string modName, string optionGroupName,
|
public PenumbraApiEc TrySetModSetting( string collectionName, string modDirectory, string modName, string optionGroupName, string[] options )
|
||||||
string[] options )
|
|
||||||
=> throw new NotImplementedException();
|
=> throw new NotImplementedException();
|
||||||
|
|
||||||
public PenumbraApiEc CreateTemporaryCollection( string collectionName, string? character, bool forceOverwriteCharacter )
|
public PenumbraApiEc CreateTemporaryCollection( string collectionName, string? character, bool forceOverwriteCharacter )
|
||||||
|
|
|
||||||
|
|
@ -44,17 +44,17 @@ public partial class PenumbraIpc
|
||||||
public const string LabelProviderGetModDirectory = "Penumbra.GetModDirectory";
|
public const string LabelProviderGetModDirectory = "Penumbra.GetModDirectory";
|
||||||
public const string LabelProviderGetConfiguration = "Penumbra.GetConfiguration";
|
public const string LabelProviderGetConfiguration = "Penumbra.GetConfiguration";
|
||||||
|
|
||||||
internal ICallGateProvider< object? >? ProviderInitialized;
|
internal ICallGateProvider<object?>? ProviderInitialized;
|
||||||
internal ICallGateProvider< object? >? ProviderDisposed;
|
internal ICallGateProvider<object?>? ProviderDisposed;
|
||||||
internal ICallGateProvider< int >? ProviderApiVersion;
|
internal ICallGateProvider<int>? ProviderApiVersion;
|
||||||
internal ICallGateProvider< string >? ProviderGetModDirectory;
|
internal ICallGateProvider<string>? ProviderGetModDirectory;
|
||||||
internal ICallGateProvider< IPluginConfiguration >? ProviderGetConfiguration;
|
internal ICallGateProvider<IPluginConfiguration>? ProviderGetConfiguration;
|
||||||
|
|
||||||
private void InitializeGeneralProviders( DalamudPluginInterface pi )
|
private void InitializeGeneralProviders( DalamudPluginInterface pi )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ProviderInitialized = pi.GetIpcProvider< object? >( LabelProviderInitialized );
|
ProviderInitialized = pi.GetIpcProvider<object?>( LabelProviderInitialized );
|
||||||
}
|
}
|
||||||
catch( Exception e )
|
catch( Exception e )
|
||||||
{
|
{
|
||||||
|
|
@ -63,7 +63,7 @@ public partial class PenumbraIpc
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ProviderDisposed = pi.GetIpcProvider< object? >( LabelProviderDisposed );
|
ProviderDisposed = pi.GetIpcProvider<object?>( LabelProviderDisposed );
|
||||||
}
|
}
|
||||||
catch( Exception e )
|
catch( Exception e )
|
||||||
{
|
{
|
||||||
|
|
@ -72,7 +72,7 @@ public partial class PenumbraIpc
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ProviderApiVersion = pi.GetIpcProvider< int >( LabelProviderApiVersion );
|
ProviderApiVersion = pi.GetIpcProvider<int>( LabelProviderApiVersion );
|
||||||
ProviderApiVersion.RegisterFunc( () => Api.ApiVersion );
|
ProviderApiVersion.RegisterFunc( () => Api.ApiVersion );
|
||||||
}
|
}
|
||||||
catch( Exception e )
|
catch( Exception e )
|
||||||
|
|
@ -82,7 +82,7 @@ public partial class PenumbraIpc
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ProviderGetModDirectory = pi.GetIpcProvider< string >( LabelProviderGetModDirectory );
|
ProviderGetModDirectory = pi.GetIpcProvider<string>( LabelProviderGetModDirectory );
|
||||||
ProviderGetModDirectory.RegisterFunc( Api.GetModDirectory );
|
ProviderGetModDirectory.RegisterFunc( Api.GetModDirectory );
|
||||||
}
|
}
|
||||||
catch( Exception e )
|
catch( Exception e )
|
||||||
|
|
@ -92,7 +92,7 @@ public partial class PenumbraIpc
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ProviderGetConfiguration = pi.GetIpcProvider< IPluginConfiguration >( LabelProviderGetConfiguration );
|
ProviderGetConfiguration = pi.GetIpcProvider<IPluginConfiguration>( LabelProviderGetConfiguration );
|
||||||
ProviderGetConfiguration.RegisterFunc( Api.GetConfiguration );
|
ProviderGetConfiguration.RegisterFunc( Api.GetConfiguration );
|
||||||
}
|
}
|
||||||
catch( Exception e )
|
catch( Exception e )
|
||||||
|
|
@ -117,11 +117,11 @@ public partial class PenumbraIpc
|
||||||
public const string LabelProviderRedrawAll = "Penumbra.RedrawAll";
|
public const string LabelProviderRedrawAll = "Penumbra.RedrawAll";
|
||||||
public const string LabelProviderObjectIsRedrawn = "Penumbra.ObjectIsRedrawn";
|
public const string LabelProviderObjectIsRedrawn = "Penumbra.ObjectIsRedrawn";
|
||||||
|
|
||||||
internal ICallGateProvider< string, int, object >? ProviderRedrawName;
|
internal ICallGateProvider<string, int, object>? ProviderRedrawName;
|
||||||
internal ICallGateProvider< int, int, object >? ProviderRedrawIndex;
|
internal ICallGateProvider<int, int, object>? ProviderRedrawIndex;
|
||||||
internal ICallGateProvider< GameObject, int, object >? ProviderRedrawObject;
|
internal ICallGateProvider<GameObject, int, object>? ProviderRedrawObject;
|
||||||
internal ICallGateProvider< int, object >? ProviderRedrawAll;
|
internal ICallGateProvider<int, object>? ProviderRedrawAll;
|
||||||
internal ICallGateProvider< string, string >? ProviderObjectIsRedrawn;
|
internal ICallGateProvider<string, string> ProviderObjectIsRedrawn;
|
||||||
|
|
||||||
private static RedrawType CheckRedrawType( int value )
|
private static RedrawType CheckRedrawType( int value )
|
||||||
{
|
{
|
||||||
|
|
@ -138,7 +138,7 @@ public partial class PenumbraIpc
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ProviderRedrawName = pi.GetIpcProvider< string, int, object >( LabelProviderRedrawName );
|
ProviderRedrawName = pi.GetIpcProvider<string, int, object>( LabelProviderRedrawName );
|
||||||
ProviderRedrawName.RegisterAction( ( s, i ) => Api.RedrawObject( s, CheckRedrawType( i ) ) );
|
ProviderRedrawName.RegisterAction( ( s, i ) => Api.RedrawObject( s, CheckRedrawType( i ) ) );
|
||||||
}
|
}
|
||||||
catch( Exception e )
|
catch( Exception e )
|
||||||
|
|
@ -148,7 +148,7 @@ public partial class PenumbraIpc
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ProviderRedrawIndex = pi.GetIpcProvider< int, int, object >( LabelProviderRedrawIndex );
|
ProviderRedrawIndex = pi.GetIpcProvider<int, int, object>( LabelProviderRedrawIndex );
|
||||||
ProviderRedrawIndex.RegisterAction( ( idx, i ) => Api.RedrawObject( idx, CheckRedrawType( i ) ) );
|
ProviderRedrawIndex.RegisterAction( ( idx, i ) => Api.RedrawObject( idx, CheckRedrawType( i ) ) );
|
||||||
}
|
}
|
||||||
catch( Exception e )
|
catch( Exception e )
|
||||||
|
|
@ -158,7 +158,7 @@ public partial class PenumbraIpc
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ProviderRedrawObject = pi.GetIpcProvider< GameObject, int, object >( LabelProviderRedrawObject );
|
ProviderRedrawObject = pi.GetIpcProvider<GameObject, int, object>( LabelProviderRedrawObject );
|
||||||
ProviderRedrawObject.RegisterAction( ( o, i ) => Api.RedrawObject( o, CheckRedrawType( i ) ) );
|
ProviderRedrawObject.RegisterAction( ( o, i ) => Api.RedrawObject( o, CheckRedrawType( i ) ) );
|
||||||
}
|
}
|
||||||
catch( Exception e )
|
catch( Exception e )
|
||||||
|
|
@ -168,7 +168,7 @@ public partial class PenumbraIpc
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ProviderRedrawAll = pi.GetIpcProvider< int, object >( LabelProviderRedrawAll );
|
ProviderRedrawAll = pi.GetIpcProvider<int, object>( LabelProviderRedrawAll );
|
||||||
ProviderRedrawAll.RegisterAction( i => Api.RedrawAll( CheckRedrawType( i ) ) );
|
ProviderRedrawAll.RegisterAction( i => Api.RedrawAll( CheckRedrawType( i ) ) );
|
||||||
}
|
}
|
||||||
catch( Exception e )
|
catch( Exception e )
|
||||||
|
|
@ -178,7 +178,7 @@ public partial class PenumbraIpc
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ProviderObjectIsRedrawn = pi.GetIpcProvider< string, string >( LabelProviderObjectIsRedrawn );
|
ProviderObjectIsRedrawn = pi.GetIpcProvider<string, string>( LabelProviderObjectIsRedrawn );
|
||||||
Api.ObjectIsRedrawn += Api_ObjectIsRedrawn;
|
Api.ObjectIsRedrawn += Api_ObjectIsRedrawn;
|
||||||
}
|
}
|
||||||
catch( Exception e )
|
catch( Exception e )
|
||||||
|
|
@ -189,7 +189,7 @@ public partial class PenumbraIpc
|
||||||
|
|
||||||
private void Api_ObjectIsRedrawn( object? sender, EventArgs e )
|
private void Api_ObjectIsRedrawn( object? sender, EventArgs e )
|
||||||
{
|
{
|
||||||
ProviderObjectIsRedrawn?.SendMessage( ( ( GameObject? )sender )?.Name.ToString() ?? "" );
|
ProviderObjectIsRedrawn.SendMessage( ( ( GameObject? )sender )?.Name.ToString() ?? "" );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DisposeRedrawProviders()
|
private void DisposeRedrawProviders()
|
||||||
|
|
@ -209,16 +209,16 @@ public partial class PenumbraIpc
|
||||||
public const string LabelProviderGetDrawObjectInfo = "Penumbra.GetDrawObjectInfo";
|
public const string LabelProviderGetDrawObjectInfo = "Penumbra.GetDrawObjectInfo";
|
||||||
public const string LabelProviderReverseResolvePath = "Penumbra.ReverseResolvePath";
|
public const string LabelProviderReverseResolvePath = "Penumbra.ReverseResolvePath";
|
||||||
|
|
||||||
internal ICallGateProvider< string, string >? ProviderResolveDefault;
|
internal ICallGateProvider<string, string>? ProviderResolveDefault;
|
||||||
internal ICallGateProvider< string, string, string >? ProviderResolveCharacter;
|
internal ICallGateProvider<string, string, string>? ProviderResolveCharacter;
|
||||||
internal ICallGateProvider< IntPtr, (IntPtr, string) >? ProviderGetDrawObjectInfo;
|
internal ICallGateProvider<IntPtr, (IntPtr, string)>? ProviderGetDrawObjectInfo;
|
||||||
internal ICallGateProvider< string, string, string[] >? ProviderReverseResolvePath;
|
internal ICallGateProvider<string, string, string[]>? ProviderReverseResolvePath;
|
||||||
|
|
||||||
private void InitializeResolveProviders( DalamudPluginInterface pi )
|
private void InitializeResolveProviders( DalamudPluginInterface pi )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ProviderResolveDefault = pi.GetIpcProvider< string, string >( LabelProviderResolveDefault );
|
ProviderResolveDefault = pi.GetIpcProvider<string, string>( LabelProviderResolveDefault );
|
||||||
ProviderResolveDefault.RegisterFunc( Api.ResolvePath );
|
ProviderResolveDefault.RegisterFunc( Api.ResolvePath );
|
||||||
}
|
}
|
||||||
catch( Exception e )
|
catch( Exception e )
|
||||||
|
|
@ -228,7 +228,7 @@ public partial class PenumbraIpc
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ProviderResolveCharacter = pi.GetIpcProvider< string, string, string >( LabelProviderResolveCharacter );
|
ProviderResolveCharacter = pi.GetIpcProvider<string, string, string>( LabelProviderResolveCharacter );
|
||||||
ProviderResolveCharacter.RegisterFunc( Api.ResolvePath );
|
ProviderResolveCharacter.RegisterFunc( Api.ResolvePath );
|
||||||
}
|
}
|
||||||
catch( Exception e )
|
catch( Exception e )
|
||||||
|
|
@ -238,7 +238,7 @@ public partial class PenumbraIpc
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ProviderGetDrawObjectInfo = pi.GetIpcProvider< IntPtr, (IntPtr, string) >( LabelProviderGetDrawObjectInfo );
|
ProviderGetDrawObjectInfo = pi.GetIpcProvider<IntPtr, (IntPtr, string)>( LabelProviderGetDrawObjectInfo );
|
||||||
ProviderGetDrawObjectInfo.RegisterFunc( Api.GetDrawObjectInfo );
|
ProviderGetDrawObjectInfo.RegisterFunc( Api.GetDrawObjectInfo );
|
||||||
}
|
}
|
||||||
catch( Exception e )
|
catch( Exception e )
|
||||||
|
|
@ -248,7 +248,7 @@ public partial class PenumbraIpc
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ProviderReverseResolvePath = pi.GetIpcProvider< string, string, string[] >( LabelProviderReverseResolvePath );
|
ProviderReverseResolvePath = pi.GetIpcProvider<string, string, string[]>( LabelProviderReverseResolvePath );
|
||||||
ProviderReverseResolvePath.RegisterFunc( Api.ReverseResolvePath );
|
ProviderReverseResolvePath.RegisterFunc( Api.ReverseResolvePath );
|
||||||
}
|
}
|
||||||
catch( Exception e )
|
catch( Exception e )
|
||||||
|
|
@ -271,9 +271,9 @@ public partial class PenumbraIpc
|
||||||
public const string LabelProviderChangedItemClick = "Penumbra.ChangedItemClick";
|
public const string LabelProviderChangedItemClick = "Penumbra.ChangedItemClick";
|
||||||
public const string LabelProviderGetChangedItems = "Penumbra.GetChangedItems";
|
public const string LabelProviderGetChangedItems = "Penumbra.GetChangedItems";
|
||||||
|
|
||||||
internal ICallGateProvider< ChangedItemType, uint, object >? ProviderChangedItemTooltip;
|
internal ICallGateProvider<ChangedItemType, uint, object>? ProviderChangedItemTooltip;
|
||||||
internal ICallGateProvider< MouseButton, ChangedItemType, uint, object >? ProviderChangedItemClick;
|
internal ICallGateProvider<MouseButton, ChangedItemType, uint, object>? ProviderChangedItemClick;
|
||||||
internal ICallGateProvider< string, IReadOnlyDictionary< string, object? > >? ProviderGetChangedItems;
|
internal ICallGateProvider<string, IReadOnlyDictionary<string, object?>>? ProviderGetChangedItems;
|
||||||
|
|
||||||
private void OnClick( MouseButton click, object? item )
|
private void OnClick( MouseButton click, object? item )
|
||||||
{
|
{
|
||||||
|
|
@ -291,7 +291,7 @@ public partial class PenumbraIpc
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ProviderChangedItemTooltip = pi.GetIpcProvider< ChangedItemType, uint, object >( LabelProviderChangedItemTooltip );
|
ProviderChangedItemTooltip = pi.GetIpcProvider<ChangedItemType, uint, object>( LabelProviderChangedItemTooltip );
|
||||||
Api.ChangedItemTooltip += OnTooltip;
|
Api.ChangedItemTooltip += OnTooltip;
|
||||||
}
|
}
|
||||||
catch( Exception e )
|
catch( Exception e )
|
||||||
|
|
@ -301,7 +301,7 @@ public partial class PenumbraIpc
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ProviderChangedItemClick = pi.GetIpcProvider< MouseButton, ChangedItemType, uint, object >( LabelProviderChangedItemClick );
|
ProviderChangedItemClick = pi.GetIpcProvider<MouseButton, ChangedItemType, uint, object>( LabelProviderChangedItemClick );
|
||||||
Api.ChangedItemClicked += OnClick;
|
Api.ChangedItemClicked += OnClick;
|
||||||
}
|
}
|
||||||
catch( Exception e )
|
catch( Exception e )
|
||||||
|
|
@ -311,7 +311,7 @@ public partial class PenumbraIpc
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ProviderGetChangedItems = pi.GetIpcProvider< string, IReadOnlyDictionary< string, object? > >( LabelProviderGetChangedItems );
|
ProviderGetChangedItems = pi.GetIpcProvider<string, IReadOnlyDictionary<string, object?>>( LabelProviderGetChangedItems );
|
||||||
ProviderGetChangedItems.RegisterFunc( Api.GetChangedItemsForCollection );
|
ProviderGetChangedItems.RegisterFunc( Api.GetChangedItemsForCollection );
|
||||||
}
|
}
|
||||||
catch( Exception e )
|
catch( Exception e )
|
||||||
|
|
@ -336,17 +336,17 @@ public partial class PenumbraIpc
|
||||||
public const string LabelProviderDefaultCollectionName = "Penumbra.GetDefaultCollectionName";
|
public const string LabelProviderDefaultCollectionName = "Penumbra.GetDefaultCollectionName";
|
||||||
public const string LabelProviderCharacterCollectionName = "Penumbra.GetCharacterCollectionName";
|
public const string LabelProviderCharacterCollectionName = "Penumbra.GetCharacterCollectionName";
|
||||||
|
|
||||||
internal ICallGateProvider< IList< (string, string) > >? ProviderGetMods;
|
internal ICallGateProvider<IList<(string, string)>>? ProviderGetMods;
|
||||||
internal ICallGateProvider< IList< string > >? ProviderGetCollections;
|
internal ICallGateProvider<IList<string>>? ProviderGetCollections;
|
||||||
internal ICallGateProvider< string >? ProviderCurrentCollectionName;
|
internal ICallGateProvider<string>? ProviderCurrentCollectionName;
|
||||||
internal ICallGateProvider< string >? ProviderDefaultCollectionName;
|
internal ICallGateProvider<string>? ProviderDefaultCollectionName;
|
||||||
internal ICallGateProvider< string, (string, bool) >? ProviderCharacterCollectionName;
|
internal ICallGateProvider<string, (string, bool)>? ProviderCharacterCollectionName;
|
||||||
|
|
||||||
private void InitializeDataProviders( DalamudPluginInterface pi )
|
private void InitializeDataProviders( DalamudPluginInterface pi )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ProviderGetMods = pi.GetIpcProvider< IList< (string, string) > >( LabelProviderGetMods );
|
ProviderGetMods = pi.GetIpcProvider<IList<(string, string)>>( LabelProviderGetMods );
|
||||||
ProviderGetMods.RegisterFunc( Api.GetModList );
|
ProviderGetMods.RegisterFunc( Api.GetModList );
|
||||||
}
|
}
|
||||||
catch( Exception e )
|
catch( Exception e )
|
||||||
|
|
@ -356,7 +356,7 @@ public partial class PenumbraIpc
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ProviderGetCollections = pi.GetIpcProvider< IList< string > >( LabelProviderGetCollections );
|
ProviderGetCollections = pi.GetIpcProvider<IList<string>>( LabelProviderGetCollections );
|
||||||
ProviderGetCollections.RegisterFunc( Api.GetCollections );
|
ProviderGetCollections.RegisterFunc( Api.GetCollections );
|
||||||
}
|
}
|
||||||
catch( Exception e )
|
catch( Exception e )
|
||||||
|
|
@ -366,7 +366,7 @@ public partial class PenumbraIpc
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ProviderCurrentCollectionName = pi.GetIpcProvider< string >( LabelProviderCurrentCollectionName );
|
ProviderCurrentCollectionName = pi.GetIpcProvider<string>( LabelProviderCurrentCollectionName );
|
||||||
ProviderCurrentCollectionName.RegisterFunc( Api.GetCurrentCollection );
|
ProviderCurrentCollectionName.RegisterFunc( Api.GetCurrentCollection );
|
||||||
}
|
}
|
||||||
catch( Exception e )
|
catch( Exception e )
|
||||||
|
|
@ -376,7 +376,7 @@ public partial class PenumbraIpc
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ProviderDefaultCollectionName = pi.GetIpcProvider< string >( LabelProviderDefaultCollectionName );
|
ProviderDefaultCollectionName = pi.GetIpcProvider<string>( LabelProviderDefaultCollectionName );
|
||||||
ProviderDefaultCollectionName.RegisterFunc( Api.GetDefaultCollection );
|
ProviderDefaultCollectionName.RegisterFunc( Api.GetDefaultCollection );
|
||||||
}
|
}
|
||||||
catch( Exception e )
|
catch( Exception e )
|
||||||
|
|
@ -386,7 +386,7 @@ public partial class PenumbraIpc
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ProviderCharacterCollectionName = pi.GetIpcProvider< string, (string, bool) >( LabelProviderCharacterCollectionName );
|
ProviderCharacterCollectionName = pi.GetIpcProvider<string, (string, bool)>( LabelProviderCharacterCollectionName );
|
||||||
ProviderCharacterCollectionName.RegisterFunc( Api.GetCharacterCollection );
|
ProviderCharacterCollectionName.RegisterFunc( Api.GetCharacterCollection );
|
||||||
}
|
}
|
||||||
catch( Exception e )
|
catch( Exception e )
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,7 @@ using Penumbra.Util;
|
||||||
namespace Penumbra.Collections;
|
namespace Penumbra.Collections;
|
||||||
|
|
||||||
public record struct ModPath( Mod Mod, FullPath Path );
|
public record struct ModPath( Mod Mod, FullPath Path );
|
||||||
|
public record ModConflicts( Mod Mod2, List<object> Conflicts, bool HasPriority, bool Solved );
|
||||||
public record ModConflicts( Mod Mod2, List< object > Conflicts, bool HasPriority, bool Solved );
|
|
||||||
|
|
||||||
public partial class ModCollection
|
public partial class ModCollection
|
||||||
{
|
{
|
||||||
|
|
@ -22,16 +21,16 @@ public partial class ModCollection
|
||||||
private class Cache : IDisposable
|
private class Cache : IDisposable
|
||||||
{
|
{
|
||||||
private readonly ModCollection _collection;
|
private readonly ModCollection _collection;
|
||||||
private readonly SortedList< string, (SingleArray< Mod >, object?) > _changedItems = new();
|
private readonly SortedList<string, (SingleArray<Mod>, object?)> _changedItems = new();
|
||||||
public readonly Dictionary< Utf8GamePath, ModPath > ResolvedFiles = new();
|
public readonly Dictionary<Utf8GamePath, ModPath> ResolvedFiles = new();
|
||||||
public readonly MetaManager MetaManipulations;
|
public readonly MetaManager MetaManipulations;
|
||||||
private readonly Dictionary< Mod, SingleArray< ModConflicts > > _conflicts = new();
|
private readonly Dictionary<Mod, SingleArray<ModConflicts>> _conflicts = new();
|
||||||
|
|
||||||
public IEnumerable< SingleArray< ModConflicts > > AllConflicts
|
public IEnumerable<SingleArray<ModConflicts>> AllConflicts
|
||||||
=> _conflicts.Values;
|
=> _conflicts.Values;
|
||||||
|
|
||||||
public SingleArray< ModConflicts > Conflicts( Mod mod )
|
public SingleArray<ModConflicts> Conflicts( Mod mod )
|
||||||
=> _conflicts.TryGetValue( mod, out var c ) ? c : new SingleArray< ModConflicts >();
|
=> _conflicts.TryGetValue( mod, out var c ) ? c : new SingleArray<ModConflicts>();
|
||||||
|
|
||||||
// Count the number of changes of the effective file list.
|
// Count the number of changes of the effective file list.
|
||||||
// This is used for material and imc changes.
|
// This is used for material and imc changes.
|
||||||
|
|
@ -39,7 +38,7 @@ public partial class ModCollection
|
||||||
private int _changedItemsSaveCounter = -1;
|
private int _changedItemsSaveCounter = -1;
|
||||||
|
|
||||||
// Obtain currently changed items. Computes them if they haven't been computed before.
|
// Obtain currently changed items. Computes them if they haven't been computed before.
|
||||||
public IReadOnlyDictionary< string, (SingleArray< Mod >, object?) > ChangedItems
|
public IReadOnlyDictionary<string, (SingleArray<Mod>, object?)> ChangedItems
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
|
@ -80,7 +79,7 @@ public partial class ModCollection
|
||||||
return candidate.Path;
|
return candidate.Path;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List< Utf8GamePath > ReverseResolvePath( FullPath localFilePath )
|
public List<Utf8GamePath> ReverseResolvePath( FullPath localFilePath )
|
||||||
{
|
{
|
||||||
string strToSearchFor = localFilePath.FullName.Replace( '/', '\\' ).ToLower();
|
string strToSearchFor = localFilePath.FullName.Replace( '/', '\\' ).ToLower();
|
||||||
return ResolvedFiles.Where( f => f.Value.Path.FullName.ToLower() == strToSearchFor )
|
return ResolvedFiles.Where( f => f.Value.Path.FullName.ToLower() == strToSearchFor )
|
||||||
|
|
@ -92,38 +91,38 @@ public partial class ModCollection
|
||||||
switch( type )
|
switch( type )
|
||||||
{
|
{
|
||||||
case ModSettingChange.Inheritance:
|
case ModSettingChange.Inheritance:
|
||||||
ReloadMod( Penumbra.ModManager[ modIdx ], true );
|
ReloadMod( Penumbra.ModManager[modIdx], true );
|
||||||
break;
|
break;
|
||||||
case ModSettingChange.EnableState:
|
case ModSettingChange.EnableState:
|
||||||
if( oldValue == 0 )
|
if( oldValue == 0 )
|
||||||
{
|
{
|
||||||
AddMod( Penumbra.ModManager[ modIdx ], true );
|
AddMod( Penumbra.ModManager[modIdx], true );
|
||||||
}
|
}
|
||||||
else if( oldValue == 1 )
|
else if( oldValue == 1 )
|
||||||
{
|
{
|
||||||
RemoveMod( Penumbra.ModManager[ modIdx ], true );
|
RemoveMod( Penumbra.ModManager[modIdx], true );
|
||||||
}
|
}
|
||||||
else if( _collection[ modIdx ].Settings?.Enabled == true )
|
else if( _collection[modIdx].Settings?.Enabled == true )
|
||||||
{
|
{
|
||||||
ReloadMod( Penumbra.ModManager[ modIdx ], true );
|
ReloadMod( Penumbra.ModManager[modIdx], true );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RemoveMod( Penumbra.ModManager[ modIdx ], true );
|
RemoveMod( Penumbra.ModManager[modIdx], true );
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case ModSettingChange.Priority:
|
case ModSettingChange.Priority:
|
||||||
if( Conflicts( Penumbra.ModManager[ modIdx ] ).Count > 0 )
|
if( Conflicts( Penumbra.ModManager[modIdx] ).Count > 0 )
|
||||||
{
|
{
|
||||||
ReloadMod( Penumbra.ModManager[ modIdx ], true );
|
ReloadMod( Penumbra.ModManager[modIdx], true );
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case ModSettingChange.Setting:
|
case ModSettingChange.Setting:
|
||||||
if( _collection[ modIdx ].Settings?.Enabled == true )
|
if( _collection[modIdx].Settings?.Enabled == true )
|
||||||
{
|
{
|
||||||
ReloadMod( Penumbra.ModManager[ modIdx ], true );
|
ReloadMod( Penumbra.ModManager[modIdx], true );
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
@ -207,7 +206,7 @@ public partial class ModCollection
|
||||||
var newConflicts = Conflicts( conflict.Mod2 ).Remove( c => c.Mod2 == mod );
|
var newConflicts = Conflicts( conflict.Mod2 ).Remove( c => c.Mod2 == mod );
|
||||||
if( newConflicts.Count > 0 )
|
if( newConflicts.Count > 0 )
|
||||||
{
|
{
|
||||||
_conflicts[ conflict.Mod2 ] = newConflicts;
|
_conflicts[conflict.Mod2] = newConflicts;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -231,7 +230,7 @@ public partial class ModCollection
|
||||||
// Add all files and possibly manipulations of a given mod according to its settings in this collection.
|
// Add all files and possibly manipulations of a given mod according to its settings in this collection.
|
||||||
public void AddMod( Mod mod, bool addMetaChanges )
|
public void AddMod( Mod mod, bool addMetaChanges )
|
||||||
{
|
{
|
||||||
var settings = _collection[ mod.Index ].Settings;
|
var settings = _collection[mod.Index].Settings;
|
||||||
if( settings is not { Enabled: true } )
|
if( settings is not { Enabled: true } )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|
@ -244,11 +243,11 @@ public partial class ModCollection
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var config = settings.Settings[ groupIndex ];
|
var config = settings.Settings[groupIndex];
|
||||||
switch( group.Type )
|
switch( group.Type )
|
||||||
{
|
{
|
||||||
case SelectType.Single:
|
case SelectType.Single:
|
||||||
AddSubMod( group[ ( int )config ], mod );
|
AddSubMod( group[( int )config], mod );
|
||||||
break;
|
break;
|
||||||
case SelectType.Multi:
|
case SelectType.Multi:
|
||||||
{
|
{
|
||||||
|
|
@ -313,7 +312,7 @@ public partial class ModCollection
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var modPath = ResolvedFiles[ path ];
|
var modPath = ResolvedFiles[path];
|
||||||
// Lower prioritized option in the same mod.
|
// Lower prioritized option in the same mod.
|
||||||
if( mod == modPath.Mod )
|
if( mod == modPath.Mod )
|
||||||
{
|
{
|
||||||
|
|
@ -322,14 +321,14 @@ public partial class ModCollection
|
||||||
|
|
||||||
if( AddConflict( path, mod, modPath.Mod ) )
|
if( AddConflict( path, mod, modPath.Mod ) )
|
||||||
{
|
{
|
||||||
ResolvedFiles[ path ] = new ModPath( mod, file );
|
ResolvedFiles[path] = new ModPath( mod, file );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Remove all empty conflict sets for a given mod with the given conflicts.
|
// Remove all empty conflict sets for a given mod with the given conflicts.
|
||||||
// If transitive is true, also removes the corresponding version of the other mod.
|
// If transitive is true, also removes the corresponding version of the other mod.
|
||||||
private void RemoveEmptyConflicts( Mod mod, SingleArray< ModConflicts > oldConflicts, bool transitive )
|
private void RemoveEmptyConflicts( Mod mod, SingleArray<ModConflicts> oldConflicts, bool transitive )
|
||||||
{
|
{
|
||||||
var changedConflicts = oldConflicts.Remove( c =>
|
var changedConflicts = oldConflicts.Remove( c =>
|
||||||
{
|
{
|
||||||
|
|
@ -351,7 +350,7 @@ public partial class ModCollection
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_conflicts[ mod ] = changedConflicts;
|
_conflicts[mod] = changedConflicts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -360,8 +359,8 @@ public partial class ModCollection
|
||||||
// Returns if the added mod takes priority before the existing mod.
|
// Returns if the added mod takes priority before the existing mod.
|
||||||
private bool AddConflict( object data, Mod addedMod, Mod existingMod )
|
private bool AddConflict( object data, Mod addedMod, Mod existingMod )
|
||||||
{
|
{
|
||||||
var addedPriority = addedMod.Index >= 0 ? _collection[ addedMod.Index ].Settings!.Priority : int.MaxValue;
|
var addedPriority = addedMod.Index >= 0 ? _collection[addedMod.Index].Settings!.Priority : int.MaxValue;
|
||||||
var existingPriority = existingMod.Index >= 0 ? _collection[ existingMod.Index ].Settings!.Priority : int.MaxValue;
|
var existingPriority = existingMod.Index >= 0 ? _collection[existingMod.Index].Settings!.Priority : int.MaxValue;
|
||||||
|
|
||||||
if( existingPriority < addedPriority )
|
if( existingPriority < addedPriority )
|
||||||
{
|
{
|
||||||
|
|
@ -369,8 +368,7 @@ public partial class ModCollection
|
||||||
foreach( var conflict in tmpConflicts )
|
foreach( var conflict in tmpConflicts )
|
||||||
{
|
{
|
||||||
if( data is Utf8GamePath path && conflict.Conflicts.RemoveAll( p => p is Utf8GamePath x && x.Equals( path ) ) > 0
|
if( data is Utf8GamePath path && conflict.Conflicts.RemoveAll( p => p is Utf8GamePath x && x.Equals( path ) ) > 0
|
||||||
|| data is MetaManipulation meta &&
|
|| data is MetaManipulation meta && conflict.Conflicts.RemoveAll( m => m is MetaManipulation x && x.Equals( meta ) ) > 0 )
|
||||||
conflict.Conflicts.RemoveAll( m => m is MetaManipulation x && x.Equals( meta ) ) > 0 )
|
|
||||||
{
|
{
|
||||||
AddConflict( data, addedMod, conflict.Mod2 );
|
AddConflict( data, addedMod, conflict.Mod2 );
|
||||||
}
|
}
|
||||||
|
|
@ -389,10 +387,10 @@ public partial class ModCollection
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Add the same conflict list to both conflict directions.
|
// Add the same conflict list to both conflict directions.
|
||||||
var conflictList = new List< object > { data };
|
var conflictList = new List<object> { data };
|
||||||
_conflicts[ addedMod ] = addedConflicts.Append( new ModConflicts( existingMod, conflictList, existingPriority < addedPriority,
|
_conflicts[addedMod] = addedConflicts.Append( new ModConflicts( existingMod, conflictList, existingPriority < addedPriority,
|
||||||
existingPriority != addedPriority ) );
|
existingPriority != addedPriority ) );
|
||||||
_conflicts[ existingMod ] = existingConflicts.Append( new ModConflicts( addedMod, conflictList,
|
_conflicts[existingMod] = existingConflicts.Append( new ModConflicts( addedMod, conflictList,
|
||||||
existingPriority >= addedPriority,
|
existingPriority >= addedPriority,
|
||||||
existingPriority != addedPriority ) );
|
existingPriority != addedPriority ) );
|
||||||
}
|
}
|
||||||
|
|
@ -450,15 +448,15 @@ public partial class ModCollection
|
||||||
{
|
{
|
||||||
if( !_changedItems.TryGetValue( name, out var data ) )
|
if( !_changedItems.TryGetValue( name, out var data ) )
|
||||||
{
|
{
|
||||||
_changedItems.Add( name, ( new SingleArray< Mod >( modPath.Mod ), obj ) );
|
_changedItems.Add( name, (new SingleArray<Mod>( modPath.Mod ), obj) );
|
||||||
}
|
}
|
||||||
else if( !data.Item1.Contains( modPath.Mod ) )
|
else if( !data.Item1.Contains( modPath.Mod ) )
|
||||||
{
|
{
|
||||||
_changedItems[ name ] = ( data.Item1.Append( modPath.Mod ), obj is int x && data.Item2 is int y ? x + y : obj );
|
_changedItems[name] = (data.Item1.Append( modPath.Mod ), obj is int x && data.Item2 is int y ? x + y : obj);
|
||||||
}
|
}
|
||||||
else if( obj is int x && data.Item2 is int y )
|
else if( obj is int x && data.Item2 is int y )
|
||||||
{
|
{
|
||||||
_changedItems[ name ] = ( data.Item1, x + y );
|
_changedItems[name] = (data.Item1, x + y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue