mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 18:27:24 +01:00
Add IPC for Interface Collection.
This commit is contained in:
parent
273111775c
commit
5538c5704d
6 changed files with 79 additions and 9 deletions
|
|
@ -96,9 +96,13 @@ public interface IPenumbraApi : IPenumbraApiBase
|
|||
// Queue redrawing of all currently available actors with the given RedrawType.
|
||||
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.
|
||||
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.
|
||||
// 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.
|
||||
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.
|
||||
public (string, bool) GetCharacterCollection( string characterName );
|
||||
|
||||
|
|
|
|||
|
|
@ -311,6 +311,13 @@ public class IpcTester : IDisposable
|
|||
.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" );
|
||||
if( _currentResolvePath.Length != 0 && _currentResolveCharacter.Length != 0 )
|
||||
{
|
||||
|
|
@ -568,6 +575,8 @@ public class IpcTester : IDisposable
|
|||
ImGui.TextUnformatted( _pi.GetIpcSubscriber< string >( PenumbraIpc.LabelProviderCurrentCollectionName ).InvokeFunc() );
|
||||
DrawIntro( PenumbraIpc.LabelProviderDefaultCollectionName, "Default Collection" );
|
||||
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" );
|
||||
ImGui.SetNextItemWidth( 200 * ImGuiHelpers.GlobalScale );
|
||||
ImGui.InputTextWithHint( "##characterCollectionName", "Character Name...", ref _characterCollectionName, 64 );
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ namespace Penumbra.Api;
|
|||
public class PenumbraApi : IDisposable, IPenumbraApi
|
||||
{
|
||||
public (int, int) ApiVersion
|
||||
=> ( 4, 13 );
|
||||
=> ( 4, 14 );
|
||||
|
||||
private Penumbra? _penumbra;
|
||||
private Lumina.GameData? _lumina;
|
||||
|
|
@ -141,12 +141,18 @@ public class PenumbraApi : IDisposable, IPenumbraApi
|
|||
_penumbra!.ObjectReloader.RedrawAll( setting );
|
||||
}
|
||||
|
||||
public string ResolvePath( string path )
|
||||
public string ResolveDefaultPath( string path )
|
||||
{
|
||||
CheckInitialized();
|
||||
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 )
|
||||
{
|
||||
CheckInitialized();
|
||||
|
|
@ -185,7 +191,7 @@ public class PenumbraApi : IDisposable, IPenumbraApi
|
|||
}
|
||||
|
||||
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
|
||||
=> GetFileIntern< T >( ResolvePath( gamePath, characterName ) );
|
||||
|
|
@ -233,6 +239,12 @@ public class PenumbraApi : IDisposable, IPenumbraApi
|
|||
return Penumbra.CollectionManager.Default.Name;
|
||||
}
|
||||
|
||||
public string GetInterfaceCollection()
|
||||
{
|
||||
CheckInitialized();
|
||||
return Penumbra.CollectionManager.Interface.Name;
|
||||
}
|
||||
|
||||
public (string, bool) GetCharacterCollection( string characterName )
|
||||
{
|
||||
CheckInitialized();
|
||||
|
|
|
|||
|
|
@ -274,6 +274,7 @@ public partial class PenumbraIpc
|
|||
public partial class PenumbraIpc
|
||||
{
|
||||
public const string LabelProviderResolveDefault = "Penumbra.ResolveDefaultPath";
|
||||
public const string LabelProviderResolveInterface = "Penumbra.ResolveInterfacePath";
|
||||
public const string LabelProviderResolveCharacter = "Penumbra.ResolveCharacterPath";
|
||||
public const string LabelProviderResolvePlayer = "Penumbra.ResolvePlayerPath";
|
||||
public const string LabelProviderGetDrawObjectInfo = "Penumbra.GetDrawObjectInfo";
|
||||
|
|
@ -285,6 +286,7 @@ public partial class PenumbraIpc
|
|||
public const string LabelProviderGameObjectResourcePathResolved = "Penumbra.GameObjectResourcePathResolved";
|
||||
|
||||
internal ICallGateProvider< string, string >? ProviderResolveDefault;
|
||||
internal ICallGateProvider< string, string >? ProviderResolveInterface;
|
||||
internal ICallGateProvider< string, string, string >? ProviderResolveCharacter;
|
||||
internal ICallGateProvider< string, string >? ProviderResolvePlayer;
|
||||
internal ICallGateProvider< IntPtr, (IntPtr, string) >? ProviderGetDrawObjectInfo;
|
||||
|
|
@ -300,13 +302,23 @@ public partial class PenumbraIpc
|
|||
try
|
||||
{
|
||||
ProviderResolveDefault = pi.GetIpcProvider< string, string >( LabelProviderResolveDefault );
|
||||
ProviderResolveDefault.RegisterFunc( Api.ResolvePath );
|
||||
ProviderResolveDefault.RegisterFunc( Api.ResolveDefaultPath );
|
||||
}
|
||||
catch( Exception 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
|
||||
{
|
||||
ProviderResolveCharacter = pi.GetIpcProvider< string, string, string >( LabelProviderResolveCharacter );
|
||||
|
|
@ -411,6 +423,7 @@ public partial class PenumbraIpc
|
|||
ProviderGetDrawObjectInfo?.UnregisterFunc();
|
||||
ProviderGetCutsceneParentIndex?.UnregisterFunc();
|
||||
ProviderResolveDefault?.UnregisterFunc();
|
||||
ProviderResolveInterface?.UnregisterFunc();
|
||||
ProviderResolveCharacter?.UnregisterFunc();
|
||||
ProviderReverseResolvePath?.UnregisterFunc();
|
||||
ProviderReverseResolvePathPlayer?.UnregisterFunc();
|
||||
|
|
@ -499,6 +512,7 @@ public partial class PenumbraIpc
|
|||
public const string LabelProviderGetCollections = "Penumbra.GetCollections";
|
||||
public const string LabelProviderCurrentCollectionName = "Penumbra.GetCurrentCollectionName";
|
||||
public const string LabelProviderDefaultCollectionName = "Penumbra.GetDefaultCollectionName";
|
||||
public const string LabelProviderInterfaceCollectionName = "Penumbra.GetInterfaceCollectionName";
|
||||
public const string LabelProviderCharacterCollectionName = "Penumbra.GetCharacterCollectionName";
|
||||
public const string LabelProviderGetPlayerMetaManipulations = "Penumbra.GetPlayerMetaManipulations";
|
||||
public const string LabelProviderGetMetaManipulations = "Penumbra.GetMetaManipulations";
|
||||
|
|
@ -507,6 +521,7 @@ public partial class PenumbraIpc
|
|||
internal ICallGateProvider< IList< string > >? ProviderGetCollections;
|
||||
internal ICallGateProvider< string >? ProviderCurrentCollectionName;
|
||||
internal ICallGateProvider< string >? ProviderDefaultCollectionName;
|
||||
internal ICallGateProvider< string >? ProviderInterfaceCollectionName;
|
||||
internal ICallGateProvider< string, (string, bool) >? ProviderCharacterCollectionName;
|
||||
internal ICallGateProvider< string >? ProviderGetPlayerMetaManipulations;
|
||||
internal ICallGateProvider< string, string >? ProviderGetMetaManipulations;
|
||||
|
|
@ -553,6 +568,16 @@ public partial class PenumbraIpc
|
|||
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
|
||||
{
|
||||
ProviderCharacterCollectionName = pi.GetIpcProvider< string, (string, bool) >( LabelProviderCharacterCollectionName );
|
||||
|
|
@ -590,6 +615,7 @@ public partial class PenumbraIpc
|
|||
ProviderGetCollections?.UnregisterFunc();
|
||||
ProviderCurrentCollectionName?.UnregisterFunc();
|
||||
ProviderDefaultCollectionName?.UnregisterFunc();
|
||||
ProviderInterfaceCollectionName?.UnregisterFunc();
|
||||
ProviderCharacterCollectionName?.UnregisterFunc();
|
||||
ProviderGetMetaManipulations?.UnregisterFunc();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,16 +18,29 @@ public partial class ConfigWindow
|
|||
|
||||
Add5_7_0( ret );
|
||||
Add5_7_1( ret );
|
||||
Add5_8_0( ret );
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static void Add5_8_0( Changelog log )
|
||||
=> 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 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 )
|
||||
=> log.NextVersion( "Version 0.5.7.1" )
|
||||
|
|
|
|||
|
|
@ -100,7 +100,10 @@ public partial class ConfigWindow
|
|||
using var combo = ImRaii.Combo( label, current?.Name ?? string.Empty );
|
||||
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 );
|
||||
if( ImGui.Selectable( collection.Name, collection == current ) )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue