mirror of
https://github.com/xivdev/Penumbra.git
synced 2026-01-03 06:13:45 +01:00
Add some methods and interface to view currently Changed Items.
This commit is contained in:
parent
982385ccbb
commit
0c0eeec158
9 changed files with 219 additions and 40 deletions
|
|
@ -1,3 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using Dalamud.Game.ClientState.Objects.Types;
|
||||
using Lumina.Data;
|
||||
using Penumbra.GameData.Enums;
|
||||
|
|
@ -43,5 +44,8 @@ namespace Penumbra.Api
|
|||
|
||||
// Try to load a given gamePath with the resolved path from Penumbra.
|
||||
public T? GetFile<T>( string gamePath, string characterName ) where T : FileResource;
|
||||
|
||||
// Gets a dictionary of effected items from a collection
|
||||
public IReadOnlyDictionary< string, object? > GetChangedItemsForCollection(string collectionName);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +1,13 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Dalamud.Game.ClientState.Objects.Types;
|
||||
using Dalamud.Logging;
|
||||
using Lumina.Data;
|
||||
using Lumina.Data.Parsing;
|
||||
using Lumina.Excel.GeneratedSheets;
|
||||
using Penumbra.GameData.Enums;
|
||||
using Penumbra.GameData.Util;
|
||||
using Penumbra.Mods;
|
||||
|
|
@ -131,5 +135,32 @@ namespace Penumbra.Api
|
|||
|
||||
public T? GetFile< T >( string gamePath, string characterName ) where T : FileResource
|
||||
=> GetFileIntern< T >( ResolvePath( gamePath, characterName ) );
|
||||
|
||||
public IReadOnlyDictionary< string, object? > GetChangedItemsForCollection( string collectionName )
|
||||
{
|
||||
CheckInitialized();
|
||||
try
|
||||
{
|
||||
var modManager = Service< ModManager >.Get();
|
||||
if( !modManager.Collections.Collections.TryGetValue( collectionName, out var collection ) )
|
||||
{
|
||||
collection = ModCollection.Empty;
|
||||
}
|
||||
|
||||
if( collection.Cache != null )
|
||||
{
|
||||
return collection.Cache.ChangedItems;
|
||||
}
|
||||
|
||||
PluginLog.Warning( $"Collection {collectionName} does not exist or is not loaded." );
|
||||
return new Dictionary< string, object? >();
|
||||
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
PluginLog.Error( $"Could not obtain Changed Items for {collectionName}:\n{e}" );
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Dalamud.Game.ClientState.Objects.Types;
|
||||
using Dalamud.Logging;
|
||||
using Dalamud.Plugin;
|
||||
|
|
@ -18,15 +19,17 @@ namespace Penumbra.Api
|
|||
|
||||
public const string LabelProviderChangedItemTooltip = "Penumbra.ChangedItemTooltip";
|
||||
public const string LabelProviderChangedItemClick = "Penumbra.ChangedItemClick";
|
||||
public const string LabelProviderGetChangedItems = "Penumbra.GetChangedItems";
|
||||
|
||||
internal ICallGateProvider< int >? ProviderApiVersion;
|
||||
internal ICallGateProvider< string, int, object >? ProviderRedrawName;
|
||||
internal ICallGateProvider< GameObject, int, object >? ProviderRedrawObject;
|
||||
internal ICallGateProvider< int, object >? ProviderRedrawAll;
|
||||
internal ICallGateProvider< string, string >? ProviderResolveDefault;
|
||||
internal ICallGateProvider< string, string, string >? ProviderResolveCharacter;
|
||||
internal ICallGateProvider< ChangedItemType, uint, object >? ProviderChangedItemTooltip;
|
||||
internal ICallGateProvider< MouseButton, ChangedItemType, uint, object >? ProviderChangedItemClick;
|
||||
internal ICallGateProvider< int >? ProviderApiVersion;
|
||||
internal ICallGateProvider< string, int, object >? ProviderRedrawName;
|
||||
internal ICallGateProvider< GameObject, int, object >? ProviderRedrawObject;
|
||||
internal ICallGateProvider< int, object >? ProviderRedrawAll;
|
||||
internal ICallGateProvider< string, string >? ProviderResolveDefault;
|
||||
internal ICallGateProvider< string, string, string >? ProviderResolveCharacter;
|
||||
internal ICallGateProvider< ChangedItemType, uint, object >? ProviderChangedItemTooltip;
|
||||
internal ICallGateProvider< MouseButton, ChangedItemType, uint, object >? ProviderChangedItemClick;
|
||||
internal ICallGateProvider< string, IReadOnlyDictionary< string, object? > >? ProviderGetChangedItems;
|
||||
|
||||
internal readonly IPenumbraApi Api;
|
||||
|
||||
|
|
@ -137,6 +140,16 @@ namespace Penumbra.Api
|
|||
{
|
||||
PluginLog.Error( $"Error registering IPC provider for {LabelProviderChangedItemClick}:\n{e}" );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
ProviderGetChangedItems = pi.GetIpcProvider< string, IReadOnlyDictionary< string, object? > >( LabelProviderGetChangedItems );
|
||||
ProviderGetChangedItems.RegisterFunc( api.GetChangedItemsForCollection );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
PluginLog.Error( $"Error registering IPC provider for {LabelProviderChangedItemClick}:\n{e}" );
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
|
@ -147,6 +160,7 @@ namespace Penumbra.Api
|
|||
ProviderRedrawAll?.UnregisterAction();
|
||||
ProviderResolveDefault?.UnregisterFunc();
|
||||
ProviderResolveCharacter?.UnregisterFunc();
|
||||
ProviderGetChangedItems?.UnregisterFunc();
|
||||
Api.ChangedItemClicked -= OnClick;
|
||||
Api.ChangedItemTooltip -= OnTooltip;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue