Force higher Penumbra API version and use better IPC for cutscene parents and game objects.

This commit is contained in:
Ottermandias 2025-04-09 15:11:04 +02:00
parent aad978f5f6
commit 7ed42005dd
2 changed files with 40 additions and 56 deletions

View file

@ -35,11 +35,7 @@ public readonly record struct ModSettings(Dictionary<string, List<string>> Setti
public class PenumbraService : IDisposable public class PenumbraService : IDisposable
{ {
public const int RequiredPenumbraBreakingVersion = 5; public const int RequiredPenumbraBreakingVersion = 5;
public const int RequiredPenumbraFeatureVersion = 3; public const int RequiredPenumbraFeatureVersion = 8;
public const int RequiredPenumbraFeatureVersionTemp = 4;
public const int RequiredPenumbraFeatureVersionTemp2 = 5;
public const int RequiredPenumbraFeatureVersionTemp3 = 6;
public const int RequiredPenumbraFeatureVersionTemp4 = 7;
private const int KeyFixed = -1610; private const int KeyFixed = -1610;
private const string NameFixed = "Glamourer (Automation)"; private const string NameFixed = "Glamourer (Automation)";
@ -57,8 +53,6 @@ public class PenumbraService : IDisposable
private global::Penumbra.Api.IpcSubscribers.GetCollectionsByIdentifier? _collectionByIdentifier; private global::Penumbra.Api.IpcSubscribers.GetCollectionsByIdentifier? _collectionByIdentifier;
private global::Penumbra.Api.IpcSubscribers.GetCollections? _collections; private global::Penumbra.Api.IpcSubscribers.GetCollections? _collections;
private global::Penumbra.Api.IpcSubscribers.RedrawObject? _redraw; private global::Penumbra.Api.IpcSubscribers.RedrawObject? _redraw;
private global::Penumbra.Api.IpcSubscribers.GetDrawObjectInfo? _drawObjectInfo;
private global::Penumbra.Api.IpcSubscribers.GetCutsceneParentIndex? _cutsceneParent;
private global::Penumbra.Api.IpcSubscribers.GetCollectionForObject? _objectCollection; private global::Penumbra.Api.IpcSubscribers.GetCollectionForObject? _objectCollection;
private global::Penumbra.Api.IpcSubscribers.GetModList? _getMods; private global::Penumbra.Api.IpcSubscribers.GetModList? _getMods;
private global::Penumbra.Api.IpcSubscribers.GetCollection? _currentCollection; private global::Penumbra.Api.IpcSubscribers.GetCollection? _currentCollection;
@ -82,6 +76,8 @@ public class PenumbraService : IDisposable
private global::Penumbra.Api.IpcSubscribers.GetChangedItems? _getChangedItems; private global::Penumbra.Api.IpcSubscribers.GetChangedItems? _getChangedItems;
private IReadOnlyList<(string ModDirectory, IReadOnlyDictionary<string, object?> ChangedItems)>? _changedItems; private IReadOnlyList<(string ModDirectory, IReadOnlyDictionary<string, object?> ChangedItems)>? _changedItems;
private Func<string, (string ModDirectory, string ModName)[]>? _checkCurrentChangedItems; private Func<string, (string ModDirectory, string ModName)[]>? _checkCurrentChangedItems;
private Func<int, int>? _checkCutsceneParent;
private Func<nint, nint>? _getGameObject;
private readonly IDisposable _initializedEvent; private readonly IDisposable _initializedEvent;
private readonly IDisposable _disposedEvent; private readonly IDisposable _disposedEvent;
@ -453,11 +449,11 @@ public class PenumbraService : IDisposable
/// <summary> Obtain the game object corresponding to a draw object. </summary> /// <summary> Obtain the game object corresponding to a draw object. </summary>
public Actor GameObjectFromDrawObject(Model drawObject) public Actor GameObjectFromDrawObject(Model drawObject)
=> Available ? _drawObjectInfo!.Invoke(drawObject.Address).Item1 : Actor.Null; => _getGameObject?.Invoke(drawObject.Address) ?? Actor.Null;
/// <summary> Obtain the parent of a cutscene actor if it is known. </summary> /// <summary> Obtain the parent of a cutscene actor if it is known. </summary>
public short CutsceneParent(ushort idx) public short CutsceneParent(ushort idx)
=> (short)(Available ? _cutsceneParent!.Invoke(idx) : -1); => (short)(_checkCutsceneParent?.Invoke(idx) ?? -1);
/// <summary> Try to redraw the given actor. </summary> /// <summary> Try to redraw the given actor. </summary>
public void RedrawObject(Actor actor, RedrawType settings) public void RedrawObject(Actor actor, RedrawType settings)
@ -522,8 +518,8 @@ public class PenumbraService : IDisposable
_collectionByIdentifier = new global::Penumbra.Api.IpcSubscribers.GetCollectionsByIdentifier(_pluginInterface); _collectionByIdentifier = new global::Penumbra.Api.IpcSubscribers.GetCollectionsByIdentifier(_pluginInterface);
_collections = new global::Penumbra.Api.IpcSubscribers.GetCollections(_pluginInterface); _collections = new global::Penumbra.Api.IpcSubscribers.GetCollections(_pluginInterface);
_redraw = new global::Penumbra.Api.IpcSubscribers.RedrawObject(_pluginInterface); _redraw = new global::Penumbra.Api.IpcSubscribers.RedrawObject(_pluginInterface);
_drawObjectInfo = new global::Penumbra.Api.IpcSubscribers.GetDrawObjectInfo(_pluginInterface); _checkCutsceneParent = new global::Penumbra.Api.IpcSubscribers.GetCutsceneParentIndexFunc(_pluginInterface).Invoke();
_cutsceneParent = new global::Penumbra.Api.IpcSubscribers.GetCutsceneParentIndex(_pluginInterface); _getGameObject = new global::Penumbra.Api.IpcSubscribers.GetGameObjectFromDrawObjectFunc(_pluginInterface).Invoke();
_objectCollection = new global::Penumbra.Api.IpcSubscribers.GetCollectionForObject(_pluginInterface); _objectCollection = new global::Penumbra.Api.IpcSubscribers.GetCollectionForObject(_pluginInterface);
_getMods = new global::Penumbra.Api.IpcSubscribers.GetModList(_pluginInterface); _getMods = new global::Penumbra.Api.IpcSubscribers.GetModList(_pluginInterface);
_currentCollection = new global::Penumbra.Api.IpcSubscribers.GetCollection(_pluginInterface); _currentCollection = new global::Penumbra.Api.IpcSubscribers.GetCollection(_pluginInterface);
@ -535,8 +531,6 @@ public class PenumbraService : IDisposable
_setModSettings = new global::Penumbra.Api.IpcSubscribers.TrySetModSettings(_pluginInterface); _setModSettings = new global::Penumbra.Api.IpcSubscribers.TrySetModSettings(_pluginInterface);
_openModPage = new global::Penumbra.Api.IpcSubscribers.OpenMainWindow(_pluginInterface); _openModPage = new global::Penumbra.Api.IpcSubscribers.OpenMainWindow(_pluginInterface);
_getChangedItems = new global::Penumbra.Api.IpcSubscribers.GetChangedItems(_pluginInterface); _getChangedItems = new global::Penumbra.Api.IpcSubscribers.GetChangedItems(_pluginInterface);
if (CurrentMinor >= RequiredPenumbraFeatureVersionTemp)
{
_setTemporaryModSettings = new global::Penumbra.Api.IpcSubscribers.SetTemporaryModSettings(_pluginInterface); _setTemporaryModSettings = new global::Penumbra.Api.IpcSubscribers.SetTemporaryModSettings(_pluginInterface);
_setTemporaryModSettingsPlayer = new global::Penumbra.Api.IpcSubscribers.SetTemporaryModSettingsPlayer(_pluginInterface); _setTemporaryModSettingsPlayer = new global::Penumbra.Api.IpcSubscribers.SetTemporaryModSettingsPlayer(_pluginInterface);
_removeTemporaryModSettings = new global::Penumbra.Api.IpcSubscribers.RemoveTemporaryModSettings(_pluginInterface); _removeTemporaryModSettings = new global::Penumbra.Api.IpcSubscribers.RemoveTemporaryModSettings(_pluginInterface);
@ -544,24 +538,14 @@ public class PenumbraService : IDisposable
_removeAllTemporaryModSettings = new global::Penumbra.Api.IpcSubscribers.RemoveAllTemporaryModSettings(_pluginInterface); _removeAllTemporaryModSettings = new global::Penumbra.Api.IpcSubscribers.RemoveAllTemporaryModSettings(_pluginInterface);
_removeAllTemporaryModSettingsPlayer = _removeAllTemporaryModSettingsPlayer =
new global::Penumbra.Api.IpcSubscribers.RemoveAllTemporaryModSettingsPlayer(_pluginInterface); new global::Penumbra.Api.IpcSubscribers.RemoveAllTemporaryModSettingsPlayer(_pluginInterface);
if (CurrentMinor >= RequiredPenumbraFeatureVersionTemp2)
{
_queryTemporaryModSettings = new global::Penumbra.Api.IpcSubscribers.QueryTemporaryModSettings(_pluginInterface); _queryTemporaryModSettings = new global::Penumbra.Api.IpcSubscribers.QueryTemporaryModSettings(_pluginInterface);
_queryTemporaryModSettingsPlayer = _queryTemporaryModSettingsPlayer =
new global::Penumbra.Api.IpcSubscribers.QueryTemporaryModSettingsPlayer(_pluginInterface); new global::Penumbra.Api.IpcSubscribers.QueryTemporaryModSettingsPlayer(_pluginInterface);
if (CurrentMinor >= RequiredPenumbraFeatureVersionTemp3)
{
_getCurrentSettingsWithTemp = new global::Penumbra.Api.IpcSubscribers.GetCurrentModSettingsWithTemp(_pluginInterface); _getCurrentSettingsWithTemp = new global::Penumbra.Api.IpcSubscribers.GetCurrentModSettingsWithTemp(_pluginInterface);
_getAllSettings = new global::Penumbra.Api.IpcSubscribers.GetAllModSettings(_pluginInterface); _getAllSettings = new global::Penumbra.Api.IpcSubscribers.GetAllModSettings(_pluginInterface);
if (CurrentMinor >= RequiredPenumbraFeatureVersionTemp4)
{
_changedItems = new global::Penumbra.Api.IpcSubscribers.GetChangedItemAdapterList(_pluginInterface).Invoke(); _changedItems = new global::Penumbra.Api.IpcSubscribers.GetChangedItemAdapterList(_pluginInterface).Invoke();
_checkCurrentChangedItems = _checkCurrentChangedItems =
new global::Penumbra.Api.IpcSubscribers.CheckCurrentChangedItemFunc(_pluginInterface).Invoke(); new global::Penumbra.Api.IpcSubscribers.CheckCurrentChangedItemFunc(_pluginInterface).Invoke();
}
}
}
}
Available = true; Available = true;
_penumbraReloaded.Invoke(); _penumbraReloaded.Invoke();
@ -587,8 +571,8 @@ public class PenumbraService : IDisposable
_collectionByIdentifier = null; _collectionByIdentifier = null;
_collections = null; _collections = null;
_redraw = null; _redraw = null;
_drawObjectInfo = null; _getGameObject = null;
_cutsceneParent = null; _checkCutsceneParent = null;
_objectCollection = null; _objectCollection = null;
_getMods = null; _getMods = null;
_currentCollection = null; _currentCollection = null;

@ -1 +1 @@
Subproject commit bd56d82816b8366e19dddfb2dc7fd7f167e264ee Subproject commit 47bd5424d04c667d0df1ac1dd1eeb3e50b476c2c