Add IPC for Interface Collection.

This commit is contained in:
Ottermandias 2022-09-17 23:27:38 +02:00
parent 273111775c
commit 5538c5704d
6 changed files with 79 additions and 9 deletions

View file

@ -96,9 +96,13 @@ public interface IPenumbraApi : IPenumbraApiBase
// Queue redrawing of all currently available actors with the given RedrawType. // Queue redrawing of all currently available actors with the given RedrawType.
public void RedrawAll( RedrawType setting ); public void RedrawAll( RedrawType setting );
// Resolve a given gamePath via Penumbra using the Default and Forced collections. // Resolve a given gamePath via Penumbra using the Default collection.
// Returns the given gamePath if penumbra would not manipulate it. // Returns the given gamePath if penumbra would not manipulate it.
public string ResolvePath( string gamePath ); public string ResolveDefaultPath( string gamePath );
// Resolve a given gamePath via Penumbra using the Interface collection.
// Returns the given gamePath if penumbra would not manipulate it.
public string ResolveInterfacePath( string gamePath );
// Resolve a given gamePath via Penumbra using the character collection for the given name (if it exists) and the Forced collections. // Resolve a given gamePath via Penumbra using the character collection for the given name (if it exists) and the Forced collections.
// Returns the given gamePath if penumbra would not manipulate it. // Returns the given gamePath if penumbra would not manipulate it.
@ -133,6 +137,9 @@ public interface IPenumbraApi : IPenumbraApiBase
// Obtain the name of the default collection. // Obtain the name of the default collection.
public string GetDefaultCollection(); public string GetDefaultCollection();
// Obtain the name of the interface collection.
public string GetInterfaceCollection();
// Obtain the name of the collection associated with characterName and whether it is configured or inferred from default. // Obtain the name of the collection associated with characterName and whether it is configured or inferred from default.
public (string, bool) GetCharacterCollection( string characterName ); public (string, bool) GetCharacterCollection( string characterName );

View file

@ -311,6 +311,13 @@ public class IpcTester : IDisposable
.InvokeFunc( _currentResolvePath ) ); .InvokeFunc( _currentResolvePath ) );
} }
DrawIntro( PenumbraIpc.LabelProviderResolveInterface, "Interface Collection Resolve" );
if( _currentResolvePath.Length != 0 )
{
ImGui.TextUnformatted( _pi.GetIpcSubscriber< string, string >( PenumbraIpc.LabelProviderResolveInterface )
.InvokeFunc( _currentResolvePath ) );
}
DrawIntro( PenumbraIpc.LabelProviderResolveCharacter, "Character Collection Resolve" ); DrawIntro( PenumbraIpc.LabelProviderResolveCharacter, "Character Collection Resolve" );
if( _currentResolvePath.Length != 0 && _currentResolveCharacter.Length != 0 ) if( _currentResolvePath.Length != 0 && _currentResolveCharacter.Length != 0 )
{ {
@ -568,6 +575,8 @@ public class IpcTester : IDisposable
ImGui.TextUnformatted( _pi.GetIpcSubscriber< string >( PenumbraIpc.LabelProviderCurrentCollectionName ).InvokeFunc() ); ImGui.TextUnformatted( _pi.GetIpcSubscriber< string >( PenumbraIpc.LabelProviderCurrentCollectionName ).InvokeFunc() );
DrawIntro( PenumbraIpc.LabelProviderDefaultCollectionName, "Default Collection" ); DrawIntro( PenumbraIpc.LabelProviderDefaultCollectionName, "Default Collection" );
ImGui.TextUnformatted( _pi.GetIpcSubscriber< string >( PenumbraIpc.LabelProviderDefaultCollectionName ).InvokeFunc() ); ImGui.TextUnformatted( _pi.GetIpcSubscriber< string >( PenumbraIpc.LabelProviderDefaultCollectionName ).InvokeFunc() );
DrawIntro( PenumbraIpc.LabelProviderInterfaceCollectionName, "Interface Collection" );
ImGui.TextUnformatted( _pi.GetIpcSubscriber< string >( PenumbraIpc.LabelProviderInterfaceCollectionName ).InvokeFunc() );
DrawIntro( PenumbraIpc.LabelProviderCharacterCollectionName, "Character" ); DrawIntro( PenumbraIpc.LabelProviderCharacterCollectionName, "Character" );
ImGui.SetNextItemWidth( 200 * ImGuiHelpers.GlobalScale ); ImGui.SetNextItemWidth( 200 * ImGuiHelpers.GlobalScale );
ImGui.InputTextWithHint( "##characterCollectionName", "Character Name...", ref _characterCollectionName, 64 ); ImGui.InputTextWithHint( "##characterCollectionName", "Character Name...", ref _characterCollectionName, 64 );

View file

@ -21,7 +21,7 @@ namespace Penumbra.Api;
public class PenumbraApi : IDisposable, IPenumbraApi public class PenumbraApi : IDisposable, IPenumbraApi
{ {
public (int, int) ApiVersion public (int, int) ApiVersion
=> ( 4, 13 ); => ( 4, 14 );
private Penumbra? _penumbra; private Penumbra? _penumbra;
private Lumina.GameData? _lumina; private Lumina.GameData? _lumina;
@ -141,12 +141,18 @@ public class PenumbraApi : IDisposable, IPenumbraApi
_penumbra!.ObjectReloader.RedrawAll( setting ); _penumbra!.ObjectReloader.RedrawAll( setting );
} }
public string ResolvePath( string path ) public string ResolveDefaultPath( string path )
{ {
CheckInitialized(); CheckInitialized();
return ResolvePath( path, Penumbra.ModManager, Penumbra.CollectionManager.Default ); return ResolvePath( path, Penumbra.ModManager, Penumbra.CollectionManager.Default );
} }
public string ResolveInterfacePath( string path )
{
CheckInitialized();
return ResolvePath( path, Penumbra.ModManager, Penumbra.CollectionManager.Interface );
}
public string ResolvePlayerPath( string path ) public string ResolvePlayerPath( string path )
{ {
CheckInitialized(); CheckInitialized();
@ -185,7 +191,7 @@ 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 >( ResolveDefaultPath( 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 ) );
@ -233,6 +239,12 @@ public class PenumbraApi : IDisposable, IPenumbraApi
return Penumbra.CollectionManager.Default.Name; return Penumbra.CollectionManager.Default.Name;
} }
public string GetInterfaceCollection()
{
CheckInitialized();
return Penumbra.CollectionManager.Interface.Name;
}
public (string, bool) GetCharacterCollection( string characterName ) public (string, bool) GetCharacterCollection( string characterName )
{ {
CheckInitialized(); CheckInitialized();

View file

@ -274,6 +274,7 @@ public partial class PenumbraIpc
public partial class PenumbraIpc public partial class PenumbraIpc
{ {
public const string LabelProviderResolveDefault = "Penumbra.ResolveDefaultPath"; public const string LabelProviderResolveDefault = "Penumbra.ResolveDefaultPath";
public const string LabelProviderResolveInterface = "Penumbra.ResolveInterfacePath";
public const string LabelProviderResolveCharacter = "Penumbra.ResolveCharacterPath"; public const string LabelProviderResolveCharacter = "Penumbra.ResolveCharacterPath";
public const string LabelProviderResolvePlayer = "Penumbra.ResolvePlayerPath"; public const string LabelProviderResolvePlayer = "Penumbra.ResolvePlayerPath";
public const string LabelProviderGetDrawObjectInfo = "Penumbra.GetDrawObjectInfo"; public const string LabelProviderGetDrawObjectInfo = "Penumbra.GetDrawObjectInfo";
@ -285,6 +286,7 @@ public partial class PenumbraIpc
public const string LabelProviderGameObjectResourcePathResolved = "Penumbra.GameObjectResourcePathResolved"; public const string LabelProviderGameObjectResourcePathResolved = "Penumbra.GameObjectResourcePathResolved";
internal ICallGateProvider< string, string >? ProviderResolveDefault; internal ICallGateProvider< string, string >? ProviderResolveDefault;
internal ICallGateProvider< string, string >? ProviderResolveInterface;
internal ICallGateProvider< string, string, string >? ProviderResolveCharacter; internal ICallGateProvider< string, string, string >? ProviderResolveCharacter;
internal ICallGateProvider< string, string >? ProviderResolvePlayer; internal ICallGateProvider< string, string >? ProviderResolvePlayer;
internal ICallGateProvider< IntPtr, (IntPtr, string) >? ProviderGetDrawObjectInfo; internal ICallGateProvider< IntPtr, (IntPtr, string) >? ProviderGetDrawObjectInfo;
@ -300,13 +302,23 @@ public partial class PenumbraIpc
try try
{ {
ProviderResolveDefault = pi.GetIpcProvider< string, string >( LabelProviderResolveDefault ); ProviderResolveDefault = pi.GetIpcProvider< string, string >( LabelProviderResolveDefault );
ProviderResolveDefault.RegisterFunc( Api.ResolvePath ); ProviderResolveDefault.RegisterFunc( Api.ResolveDefaultPath );
} }
catch( Exception e ) catch( Exception e )
{ {
Penumbra.Log.Error( $"Error registering IPC provider for {LabelProviderResolveDefault}:\n{e}" ); Penumbra.Log.Error( $"Error registering IPC provider for {LabelProviderResolveDefault}:\n{e}" );
} }
try
{
ProviderResolveInterface = pi.GetIpcProvider< string, string >( LabelProviderResolveInterface );
ProviderResolveInterface.RegisterFunc( Api.ResolveInterfacePath );
}
catch( Exception e )
{
Penumbra.Log.Error( $"Error registering IPC provider for {LabelProviderResolveInterface}:\n{e}" );
}
try try
{ {
ProviderResolveCharacter = pi.GetIpcProvider< string, string, string >( LabelProviderResolveCharacter ); ProviderResolveCharacter = pi.GetIpcProvider< string, string, string >( LabelProviderResolveCharacter );
@ -411,6 +423,7 @@ public partial class PenumbraIpc
ProviderGetDrawObjectInfo?.UnregisterFunc(); ProviderGetDrawObjectInfo?.UnregisterFunc();
ProviderGetCutsceneParentIndex?.UnregisterFunc(); ProviderGetCutsceneParentIndex?.UnregisterFunc();
ProviderResolveDefault?.UnregisterFunc(); ProviderResolveDefault?.UnregisterFunc();
ProviderResolveInterface?.UnregisterFunc();
ProviderResolveCharacter?.UnregisterFunc(); ProviderResolveCharacter?.UnregisterFunc();
ProviderReverseResolvePath?.UnregisterFunc(); ProviderReverseResolvePath?.UnregisterFunc();
ProviderReverseResolvePathPlayer?.UnregisterFunc(); ProviderReverseResolvePathPlayer?.UnregisterFunc();
@ -499,6 +512,7 @@ public partial class PenumbraIpc
public const string LabelProviderGetCollections = "Penumbra.GetCollections"; public const string LabelProviderGetCollections = "Penumbra.GetCollections";
public const string LabelProviderCurrentCollectionName = "Penumbra.GetCurrentCollectionName"; public const string LabelProviderCurrentCollectionName = "Penumbra.GetCurrentCollectionName";
public const string LabelProviderDefaultCollectionName = "Penumbra.GetDefaultCollectionName"; public const string LabelProviderDefaultCollectionName = "Penumbra.GetDefaultCollectionName";
public const string LabelProviderInterfaceCollectionName = "Penumbra.GetInterfaceCollectionName";
public const string LabelProviderCharacterCollectionName = "Penumbra.GetCharacterCollectionName"; public const string LabelProviderCharacterCollectionName = "Penumbra.GetCharacterCollectionName";
public const string LabelProviderGetPlayerMetaManipulations = "Penumbra.GetPlayerMetaManipulations"; public const string LabelProviderGetPlayerMetaManipulations = "Penumbra.GetPlayerMetaManipulations";
public const string LabelProviderGetMetaManipulations = "Penumbra.GetMetaManipulations"; public const string LabelProviderGetMetaManipulations = "Penumbra.GetMetaManipulations";
@ -507,6 +521,7 @@ public partial class PenumbraIpc
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 >? ProviderInterfaceCollectionName;
internal ICallGateProvider< string, (string, bool) >? ProviderCharacterCollectionName; internal ICallGateProvider< string, (string, bool) >? ProviderCharacterCollectionName;
internal ICallGateProvider< string >? ProviderGetPlayerMetaManipulations; internal ICallGateProvider< string >? ProviderGetPlayerMetaManipulations;
internal ICallGateProvider< string, string >? ProviderGetMetaManipulations; internal ICallGateProvider< string, string >? ProviderGetMetaManipulations;
@ -553,6 +568,16 @@ public partial class PenumbraIpc
Penumbra.Log.Error( $"Error registering IPC provider for {LabelProviderDefaultCollectionName}:\n{e}" ); Penumbra.Log.Error( $"Error registering IPC provider for {LabelProviderDefaultCollectionName}:\n{e}" );
} }
try
{
ProviderInterfaceCollectionName = pi.GetIpcProvider<string>( LabelProviderInterfaceCollectionName );
ProviderInterfaceCollectionName.RegisterFunc( Api.GetInterfaceCollection );
}
catch( Exception e )
{
Penumbra.Log.Error( $"Error registering IPC provider for {LabelProviderInterfaceCollectionName}:\n{e}" );
}
try try
{ {
ProviderCharacterCollectionName = pi.GetIpcProvider< string, (string, bool) >( LabelProviderCharacterCollectionName ); ProviderCharacterCollectionName = pi.GetIpcProvider< string, (string, bool) >( LabelProviderCharacterCollectionName );
@ -590,6 +615,7 @@ public partial class PenumbraIpc
ProviderGetCollections?.UnregisterFunc(); ProviderGetCollections?.UnregisterFunc();
ProviderCurrentCollectionName?.UnregisterFunc(); ProviderCurrentCollectionName?.UnregisterFunc();
ProviderDefaultCollectionName?.UnregisterFunc(); ProviderDefaultCollectionName?.UnregisterFunc();
ProviderInterfaceCollectionName?.UnregisterFunc();
ProviderCharacterCollectionName?.UnregisterFunc(); ProviderCharacterCollectionName?.UnregisterFunc();
ProviderGetMetaManipulations?.UnregisterFunc(); ProviderGetMetaManipulations?.UnregisterFunc();
} }

View file

@ -18,6 +18,7 @@ public partial class ConfigWindow
Add5_7_0( ret ); Add5_7_0( ret );
Add5_7_1( ret ); Add5_7_1( ret );
Add5_8_0( ret );
return ret; return ret;
} }
@ -25,9 +26,21 @@ public partial class ConfigWindow
private static void Add5_8_0( Changelog log ) private static void Add5_8_0( Changelog log )
=> log.NextVersion( "Version 0.5.8.0" ) => log.NextVersion( "Version 0.5.8.0" )
.RegisterEntry( "Added choices what Change Logs are to be displayed. It is recommended to just keep showing all." ) .RegisterEntry( "Added choices what Change Logs are to be displayed. It is recommended to just keep showing all." )
.RegisterEntry( "Added an Interface Collection assignment." )
.RegisterEntry( "All your UI mods will have to be in the interface collection.", 1 )
.RegisterEntry( "Files that are categorized as UI files by the game will only check for redirections in this collection.", 1 )
.RegisterHighlight(
"Migration should have set your currently assigned Base Collection to the Interface Collection, please verify that.", 1 )
.RegisterEntry( "New API / IPC for the Interface Collection added.", 1 )
.RegisterHighlight( "API / IPC consumers should verify whether they need to change resolving to the new collection.", 1 )
.RegisterEntry(
"Added buttons for redrawing self or all as well as a tooltip to describe redraw options and a tutorial step for it." )
.RegisterEntry( "Collection Selectors now display None at the top if available." )
.RegisterEntry( "Fixed an issue with Actor 201 using Your Character collections in cutscenes." ) .RegisterEntry( "Fixed an issue with Actor 201 using Your Character collections in cutscenes." )
.RegisterEntry( "Fixed issues with and improved mod option editing." ) .RegisterEntry( "Fixed issues with and improved mod option editing." )
.RegisterEntry( "Backend optimizations." ); .RegisterEntry( "Backend optimizations." )
.RegisterEntry( "Changed metadata change system again.", 1 )
.RegisterEntry( "Improved logging efficiency.", 1 );
private static void Add5_7_1( Changelog log ) private static void Add5_7_1( Changelog log )
=> log.NextVersion( "Version 0.5.7.1" ) => log.NextVersion( "Version 0.5.7.1" )

View file

@ -100,7 +100,10 @@ public partial class ConfigWindow
using var combo = ImRaii.Combo( label, current?.Name ?? string.Empty ); using var combo = ImRaii.Combo( label, current?.Name ?? string.Empty );
if( combo ) if( combo )
{ {
foreach( var collection in Penumbra.CollectionManager.GetEnumeratorWithEmpty().Skip( withEmpty ? 0 : 1 ).OrderBy( c => c.Name ) ) var enumerator = Penumbra.CollectionManager.OrderBy( c => c.Name ).AsEnumerable();
if( withEmpty )
enumerator = enumerator.Prepend( ModCollection.Empty );
foreach( var collection in enumerator )
{ {
using var id = ImRaii.PushId( collection.Index ); using var id = ImRaii.PushId( collection.Index );
if( ImGui.Selectable( collection.Name, collection == current ) ) if( ImGui.Selectable( collection.Name, collection == current ) )