2
2
using Penumbra . Api . Enums ;
3
3
using Penumbra . Collections ;
4
4
using Penumbra . Collections . Manager ;
5
+ using Penumbra . Mods ;
5
6
6
7
namespace Penumbra . Api . Api ;
7
8
@@ -23,11 +24,27 @@ public Dictionary<Guid, string> GetCollections()
23
24
. Select ( c => ( c . Identity . Id , c . Identity . Name ) ) ) ;
24
25
25
26
list . AddRange ( collections . Storage
26
- . Where ( c => string . Equals ( c . Identity . Name , identifier , StringComparison . OrdinalIgnoreCase ) && ! list . Contains ( ( c . Identity . Id , c . Identity . Name ) ) )
27
+ . Where ( c => string . Equals ( c . Identity . Name , identifier , StringComparison . OrdinalIgnoreCase )
28
+ && ! list . Contains ( ( c . Identity . Id , c . Identity . Name ) ) )
27
29
. Select ( c => ( c . Identity . Id , c . Identity . Name ) ) ) ;
28
30
return list ;
29
31
}
30
32
33
+ public Func < string , ( string ModDirectory , string ModName ) [ ] > CheckCurrentChangedItemFunc ( )
34
+ {
35
+ var weakRef = new WeakReference < CollectionManager > ( collections ) ;
36
+ return s =>
37
+ {
38
+ if ( ! weakRef . TryGetTarget ( out var c ) )
39
+ throw new ObjectDisposedException ( "The underlying collection storage of this IPC container was disposed." ) ;
40
+
41
+ if ( ! c . Active . Current . ChangedItems . TryGetValue ( s , out var d ) )
42
+ return [ ] ;
43
+
44
+ return d . Item1 . Select ( m => ( m is Mod mod ? mod . Identifier : string . Empty , m . Name . Text ) ) . ToArray ( ) ;
45
+ } ;
46
+ }
47
+
31
48
public Dictionary < string , object ? > GetChangedItemsForCollection ( Guid collectionId )
32
49
{
33
50
try
@@ -74,7 +91,8 @@ public Dictionary<Guid, string> GetCollections()
74
91
}
75
92
76
93
public Guid [ ] GetCollectionByName ( string name )
77
- => collections . Storage . Where ( c => string . Equals ( name , c . Identity . Name , StringComparison . OrdinalIgnoreCase ) ) . Select ( c => c . Identity . Id ) . ToArray ( ) ;
94
+ => collections . Storage . Where ( c => string . Equals ( name , c . Identity . Name , StringComparison . OrdinalIgnoreCase ) ) . Select ( c => c . Identity . Id )
95
+ . ToArray ( ) ;
78
96
79
97
public ( PenumbraApiEc , ( Guid Id , string Name ) ? OldCollection ) SetCollection ( ApiCollectionType type , Guid ? collectionId ,
80
98
bool allowCreateNew , bool allowDelete )
0 commit comments