mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-29 20:03:44 +01:00
Add CopyModSetting API.
This commit is contained in:
parent
f63903e3e6
commit
dc493268f8
6 changed files with 98 additions and 5 deletions
|
|
@ -1084,6 +1084,13 @@ public class IpcTester : IDisposable
|
|||
_lastSettingsError = Ipc.TrySetModPriority.Subscriber( _pi ).Invoke( _settingsCollection, _settingsModDirectory, _settingsModName, _settingsPriority );
|
||||
}
|
||||
|
||||
DrawIntro( Ipc.CopyModSettings.Label, "Copy Mod Settings" );
|
||||
if( ImGui.Button( "Copy Settings" ) )
|
||||
{
|
||||
_lastSettingsError = Ipc.CopyModSettings.Subscriber( _pi ).Invoke( _settingsCollection, _settingsModDirectory, _settingsModName );
|
||||
}
|
||||
ImGuiUtil.HoverTooltip( "Copy settings from Mod Directory Name to Mod Name (as directory) in collection." );
|
||||
|
||||
DrawIntro( Ipc.TrySetModSetting.Label, "Set Setting(s)" );
|
||||
if( _availableSettings == null )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -618,6 +618,31 @@ public class PenumbraApi : IDisposable, IPenumbraApi
|
|||
}
|
||||
|
||||
|
||||
public PenumbraApiEc CopyModSettings( string? collectionName, string modDirectoryFrom, string modDirectoryTo )
|
||||
{
|
||||
CheckInitialized();
|
||||
|
||||
var sourceModIdx = Penumbra.ModManager.FirstOrDefault( m => string.Equals( m.ModPath.Name, modDirectoryFrom, StringComparison.OrdinalIgnoreCase ) )?.Index ?? -1;
|
||||
var targetModIdx = Penumbra.ModManager.FirstOrDefault( m => string.Equals( m.ModPath.Name, modDirectoryTo, StringComparison.OrdinalIgnoreCase ) )?.Index ?? -1;
|
||||
if( string.IsNullOrEmpty( collectionName ) )
|
||||
{
|
||||
foreach( var collection in Penumbra.CollectionManager )
|
||||
{
|
||||
collection.CopyModSettings( sourceModIdx, modDirectoryFrom, targetModIdx, modDirectoryTo );
|
||||
}
|
||||
}
|
||||
else if( Penumbra.CollectionManager.ByName( collectionName, out var collection ) )
|
||||
{
|
||||
collection.CopyModSettings( sourceModIdx, modDirectoryFrom, targetModIdx, modDirectoryTo );
|
||||
}
|
||||
else
|
||||
{
|
||||
return PenumbraApiEc.CollectionMissing;
|
||||
}
|
||||
|
||||
return PenumbraApiEc.Success;
|
||||
}
|
||||
|
||||
public (PenumbraApiEc, string) CreateTemporaryCollection( string tag, string character, bool forceOverwriteCharacter )
|
||||
{
|
||||
CheckInitialized();
|
||||
|
|
|
|||
|
|
@ -91,6 +91,7 @@ public class PenumbraIpcProviders : IDisposable
|
|||
internal readonly FuncProvider< string, string, string, string, string, PenumbraApiEc > TrySetModSetting;
|
||||
internal readonly FuncProvider< string, string, string, string, IReadOnlyList< string >, PenumbraApiEc > TrySetModSettings;
|
||||
internal readonly EventProvider< ModSettingChange, string, string, bool > ModSettingChanged;
|
||||
internal readonly FuncProvider< string, string, string, PenumbraApiEc > CopyModSettings;
|
||||
|
||||
// Temporary
|
||||
internal readonly FuncProvider< string, string, bool, (PenumbraApiEc, string) > CreateTemporaryCollection;
|
||||
|
|
@ -188,9 +189,10 @@ public class PenumbraIpcProviders : IDisposable
|
|||
TrySetModPriority = Ipc.TrySetModPriority.Provider( pi, Api.TrySetModPriority );
|
||||
TrySetModSetting = Ipc.TrySetModSetting.Provider( pi, Api.TrySetModSetting );
|
||||
TrySetModSettings = Ipc.TrySetModSettings.Provider( pi, Api.TrySetModSettings );
|
||||
ModSettingChanged = Ipc.ModSettingChanged.Provider( pi,
|
||||
ModSettingChanged = Ipc.ModSettingChanged.Provider( pi,
|
||||
() => Api.ModSettingChanged += ModSettingChangedEvent,
|
||||
() => Api.ModSettingChanged -= ModSettingChangedEvent );
|
||||
CopyModSettings = Ipc.CopyModSettings.Provider( pi, Api.CopyModSettings );
|
||||
|
||||
// Temporary
|
||||
CreateTemporaryCollection = Ipc.CreateTemporaryCollection.Provider( pi, Api.CreateTemporaryCollection );
|
||||
|
|
@ -287,6 +289,7 @@ public class PenumbraIpcProviders : IDisposable
|
|||
TrySetModSetting.Dispose();
|
||||
TrySetModSettings.Dispose();
|
||||
ModSettingChanged.Dispose();
|
||||
CopyModSettings.Dispose();
|
||||
|
||||
// Temporary
|
||||
CreateTemporaryCollection.Dispose();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue