mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 18:27:24 +01:00
Add CheckCurrentChangedItemFunc,
This commit is contained in:
parent
0af9667789
commit
a9a556eb55
4 changed files with 24 additions and 4 deletions
|
|
@ -1 +1 @@
|
||||||
Subproject commit 7ae46f0d09f40b36a5b2d10382db46fbfb729117
|
Subproject commit 70f046830cc7cd35b3480b12b7efe94182477fbb
|
||||||
|
|
@ -2,6 +2,7 @@ using OtterGui.Services;
|
||||||
using Penumbra.Api.Enums;
|
using Penumbra.Api.Enums;
|
||||||
using Penumbra.Collections;
|
using Penumbra.Collections;
|
||||||
using Penumbra.Collections.Manager;
|
using Penumbra.Collections.Manager;
|
||||||
|
using Penumbra.Mods;
|
||||||
|
|
||||||
namespace Penumbra.Api.Api;
|
namespace Penumbra.Api.Api;
|
||||||
|
|
||||||
|
|
@ -23,11 +24,27 @@ public class CollectionApi(CollectionManager collections, ApiHelpers helpers) :
|
||||||
.Select(c => (c.Identity.Id, c.Identity.Name)));
|
.Select(c => (c.Identity.Id, c.Identity.Name)));
|
||||||
|
|
||||||
list.AddRange(collections.Storage
|
list.AddRange(collections.Storage
|
||||||
.Where(c => string.Equals(c.Identity.Name, identifier, StringComparison.OrdinalIgnoreCase) && !list.Contains((c.Identity.Id, c.Identity.Name)))
|
.Where(c => string.Equals(c.Identity.Name, identifier, StringComparison.OrdinalIgnoreCase)
|
||||||
|
&& !list.Contains((c.Identity.Id, c.Identity.Name)))
|
||||||
.Select(c => (c.Identity.Id, c.Identity.Name)));
|
.Select(c => (c.Identity.Id, c.Identity.Name)));
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Func<string, (string ModDirectory, string ModName)[]> CheckCurrentChangedItemFunc()
|
||||||
|
{
|
||||||
|
var weakRef = new WeakReference<CollectionManager>(collections);
|
||||||
|
return s =>
|
||||||
|
{
|
||||||
|
if (!weakRef.TryGetTarget(out var c))
|
||||||
|
throw new ObjectDisposedException("The underlying collection storage of this IPC container was disposed.");
|
||||||
|
|
||||||
|
if (!c.Active.Current.ChangedItems.TryGetValue(s, out var d))
|
||||||
|
return [];
|
||||||
|
|
||||||
|
return d.Item1.Select(m => (m is Mod mod ? mod.Identifier : string.Empty, m.Name.Text)).ToArray();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
public Dictionary<string, object?> GetChangedItemsForCollection(Guid collectionId)
|
public Dictionary<string, object?> GetChangedItemsForCollection(Guid collectionId)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
@ -74,7 +91,8 @@ public class CollectionApi(CollectionManager collections, ApiHelpers helpers) :
|
||||||
}
|
}
|
||||||
|
|
||||||
public Guid[] GetCollectionByName(string name)
|
public Guid[] GetCollectionByName(string name)
|
||||||
=> collections.Storage.Where(c => string.Equals(name, c.Identity.Name, StringComparison.OrdinalIgnoreCase)).Select(c => c.Identity.Id).ToArray();
|
=> collections.Storage.Where(c => string.Equals(name, c.Identity.Name, StringComparison.OrdinalIgnoreCase)).Select(c => c.Identity.Id)
|
||||||
|
.ToArray();
|
||||||
|
|
||||||
public (PenumbraApiEc, (Guid Id, string Name)? OldCollection) SetCollection(ApiCollectionType type, Guid? collectionId,
|
public (PenumbraApiEc, (Guid Id, string Name)? OldCollection) SetCollection(ApiCollectionType type, Guid? collectionId,
|
||||||
bool allowCreateNew, bool allowDelete)
|
bool allowCreateNew, bool allowDelete)
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ public sealed class IpcProviders : IDisposable, IApiService
|
||||||
IpcSubscribers.GetCollectionForObject.Provider(pi, api.Collection),
|
IpcSubscribers.GetCollectionForObject.Provider(pi, api.Collection),
|
||||||
IpcSubscribers.SetCollection.Provider(pi, api.Collection),
|
IpcSubscribers.SetCollection.Provider(pi, api.Collection),
|
||||||
IpcSubscribers.SetCollectionForObject.Provider(pi, api.Collection),
|
IpcSubscribers.SetCollectionForObject.Provider(pi, api.Collection),
|
||||||
|
IpcSubscribers.CheckCurrentChangedItemFunc.Provider(pi, api.Collection),
|
||||||
|
|
||||||
IpcSubscribers.ConvertTextureFile.Provider(pi, api.Editing),
|
IpcSubscribers.ConvertTextureFile.Provider(pi, api.Editing),
|
||||||
IpcSubscribers.ConvertTextureData.Provider(pi, api.Editing),
|
IpcSubscribers.ConvertTextureData.Provider(pi, api.Editing),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
using Penumbra.GameData.Data;
|
using Penumbra.GameData.Data;
|
||||||
|
using Penumbra.Mods.Manager;
|
||||||
|
|
||||||
namespace Penumbra.Mods.Manager;
|
namespace Penumbra.Api;
|
||||||
|
|
||||||
public sealed class ModChangedItemAdapter(WeakReference<ModStorage> storage)
|
public sealed class ModChangedItemAdapter(WeakReference<ModStorage> storage)
|
||||||
: IReadOnlyDictionary<string, IReadOnlyDictionary<string, object?>>,
|
: IReadOnlyDictionary<string, IReadOnlyDictionary<string, object?>>,
|
||||||
Loading…
Add table
Add a link
Reference in a new issue