Load Atex based on the last loaded Avfx, testing?

This commit is contained in:
Ottermandias 2022-06-26 14:39:59 +02:00
parent 549f8ce4b4
commit 32cf729aa8
4 changed files with 42 additions and 38 deletions

View file

@ -1,10 +1,6 @@
using System;
using Dalamud.Game.ClientState.Objects.Types;
using Dalamud.Hooking;
using Dalamud.Logging;
using Dalamud.Utility.Signatures;
using FFXIVClientStructs.FFXIV.Client.Game.Character;
using FFXIVClientStructs.FFXIV.Client.Game.Object;
using Penumbra.Collections;
using GameObject = FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject;
@ -13,6 +9,7 @@ namespace Penumbra.Interop.Resolver;
public unsafe partial class PathResolver
{
private ModCollection? _animationLoadCollection;
private ModCollection? _lastAvfxCollection = null;
public delegate ulong LoadTimelineResourcesDelegate( IntPtr timeline );
@ -123,16 +120,4 @@ public unsafe partial class PathResolver
SomeOtherAvfxHook!.Original( unk );
_animationLoadCollection = last;
}
public delegate IntPtr SomeAtexDelegate( IntPtr a1, IntPtr a2, IntPtr a3, IntPtr a4, uint a5, IntPtr a6 );
[Signature( "E8 ?? ?? ?? ?? 84 C0 75 ?? 48 8B CE 41 B6" )]
public Hook< SomeAtexDelegate >? SomeAtexHook;
public IntPtr SomeAtexDetour( IntPtr a1, IntPtr a2, IntPtr a3, IntPtr a4, uint a5, IntPtr a6 )
{
var ret = SomeAtexHook!.Original( a1, a2, a3, a4, a5, a6 );
PluginLog.Information( $"{a1:X} {a2:X} {a3:X} {a4:X} {a5:X} {a6:X} {ret}" );
return ret;
}
}

View file

@ -99,7 +99,6 @@ public unsafe partial class PathResolver
LoadSomePapHook?.Enable();
SomeActionLoadHook?.Enable();
SomeOtherAvfxHook?.Enable();
SomeAtexHook?.Enable();
}
private void DisableDataHooks()
@ -115,7 +114,6 @@ public unsafe partial class PathResolver
LoadSomePapHook?.Disable();
SomeActionLoadHook?.Disable();
SomeOtherAvfxHook?.Disable();
SomeAtexHook?.Disable();
}
private void DisposeDataHooks()
@ -130,7 +128,6 @@ public unsafe partial class PathResolver
LoadSomePapHook?.Dispose();
SomeActionLoadHook?.Dispose();
SomeOtherAvfxHook?.Dispose();
SomeAtexHook?.Dispose();
}
// This map links DrawObjects directly to Actors (by ObjectTable index) and their collections.

View file

@ -44,7 +44,7 @@ public partial class PathResolver : IDisposable
|| PathCollections.TryRemove( gamePath.Path, out collection )
|| HandleAnimationFile( type, gamePath, out collection )
|| HandleDecalFile( type, gamePath, out collection );
if( !nonDefault || collection == null)
if( !nonDefault || collection == null )
{
collection = Penumbra.CollectionManager.Default;
}
@ -60,7 +60,7 @@ public partial class PathResolver : IDisposable
return true;
}
private bool HandleDecalFile( ResourceType type, Utf8GamePath gamePath, [NotNullWhen(true)] out ModCollection? collection )
private bool HandleDecalFile( ResourceType type, Utf8GamePath gamePath, [NotNullWhen( true )] out ModCollection? collection )
{
if( type == ResourceType.Tex
&& _lastCreatedCollection != null
@ -74,27 +74,43 @@ public partial class PathResolver : IDisposable
return false;
}
private bool HandleAnimationFile( ResourceType type, Utf8GamePath _, [NotNullWhen(true)] out ModCollection? collection )
private bool HandleAnimationFile( ResourceType type, Utf8GamePath _, [NotNullWhen( true )] out ModCollection? collection )
{
if( type == ResourceType.Atex )
if (_animationLoadCollection == null)
PluginLog.Information( $"ATEX {_} Default" );
else
{
PluginLog.Information( $"ATEX {_} {_animationLoadCollection?.Name}" );
}
if( _animationLoadCollection != null )
switch( type )
{
switch( type )
{
case ResourceType.Tmb:
case ResourceType.Pap:
case ResourceType.Avfx:
case ResourceType.Atex:
case ResourceType.Scd:
case ResourceType.Tmb:
case ResourceType.Pap:
case ResourceType.Scd:
if( _animationLoadCollection != null )
{
collection = _animationLoadCollection;
return true;
}
}
break;
case ResourceType.Avfx:
_lastAvfxCollection = _animationLoadCollection ?? Penumbra.CollectionManager.Default;
if( _animationLoadCollection != null )
{
collection = _animationLoadCollection;
return true;
}
break;
case ResourceType.Atex:
if( _lastAvfxCollection != null )
{
collection = _lastAvfxCollection;
return true;
}
if( _animationLoadCollection != null )
{
collection = _animationLoadCollection;
return true;
}
break;
}
collection = null;

View file

@ -504,6 +504,12 @@ public class Penumbra : IDisposable
CollectionManager.Default.Index );
sb.AppendFormat( "> **`Current Collection: `** {0}... ({1})\n", CollectionName( CollectionManager.Current ),
CollectionManager.Current.Index );
foreach( var type in CollectionTypeExtensions.Special )
{
var collection = CollectionManager.ByType( type );
if( collection != null )
sb.AppendFormat( "> **`{0,-29}`** {1}... ({2})\n", type.ToName(), CollectionName( collection ), collection.Index );
}
foreach( var (name, collection) in CollectionManager.Characters )
{
sb.AppendFormat( "> **`{2,-29}`** {0}... ({1})\n", CollectionName( collection ),