mirror of
https://github.com/xivdev/Penumbra.git
synced 2026-01-03 14:23:43 +01:00
Try to identify actors in banners correctly.
This commit is contained in:
parent
23919d8083
commit
6b558c5940
4 changed files with 83 additions and 72 deletions
|
|
@ -72,51 +72,73 @@ public sealed partial class IndividualCollections : IReadOnlyList< (string Displ
|
|||
return false;
|
||||
}
|
||||
case IdentifierType.Npc: return _individuals.TryGetValue( identifier, out collection );
|
||||
case IdentifierType.Special: return CheckWorlds( ConvertSpecialIdentifier( identifier ), out collection );
|
||||
case IdentifierType.Special: return CheckWorlds( ConvertSpecialIdentifier( identifier ).Item1, out collection );
|
||||
}
|
||||
|
||||
collection = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public ActorIdentifier ConvertSpecialIdentifier( ActorIdentifier identifier )
|
||||
public enum SpecialResult
|
||||
{
|
||||
PartyBanner,
|
||||
PvPBanner,
|
||||
Mahjong,
|
||||
CharacterScreen,
|
||||
FittingRoom,
|
||||
DyePreview,
|
||||
Portrait,
|
||||
Inspect,
|
||||
Card,
|
||||
Glamour,
|
||||
Invalid,
|
||||
}
|
||||
|
||||
public (ActorIdentifier, SpecialResult) ConvertSpecialIdentifier( ActorIdentifier identifier )
|
||||
{
|
||||
if( identifier.Type != IdentifierType.Special )
|
||||
{
|
||||
return identifier;
|
||||
return ( identifier, SpecialResult.Invalid );
|
||||
}
|
||||
|
||||
if( _actorManager.ResolvePartyBannerPlayer( identifier.Special, out var id )
|
||||
|| _actorManager.ResolvePvPBannerPlayer( identifier.Special, out id )
|
||||
|| _actorManager.ResolveMahjongPlayer( identifier.Special, out id ) )
|
||||
if( _actorManager.ResolvePartyBannerPlayer( identifier.Special, out var id ) )
|
||||
{
|
||||
return identifier;
|
||||
return ( id, SpecialResult.PartyBanner );
|
||||
}
|
||||
|
||||
if( _actorManager.ResolvePvPBannerPlayer( identifier.Special, out id ) )
|
||||
{
|
||||
return ( id, SpecialResult.PvPBanner );
|
||||
}
|
||||
|
||||
if( _actorManager.ResolveMahjongPlayer( identifier.Special, out id ) )
|
||||
{
|
||||
return ( id, SpecialResult.Mahjong );
|
||||
}
|
||||
|
||||
switch( identifier.Special )
|
||||
{
|
||||
case ScreenActor.CharacterScreen when Penumbra.Config.UseCharacterCollectionInMainWindow:
|
||||
case ScreenActor.FittingRoom when Penumbra.Config.UseCharacterCollectionInTryOn:
|
||||
case ScreenActor.DyePreview when Penumbra.Config.UseCharacterCollectionInTryOn:
|
||||
case ScreenActor.Portrait when Penumbra.Config.UseCharacterCollectionsInCards:
|
||||
return _actorManager.GetCurrentPlayer();
|
||||
case ScreenActor.CharacterScreen when Penumbra.Config.UseCharacterCollectionInMainWindow: return ( _actorManager.GetCurrentPlayer(), SpecialResult.CharacterScreen );
|
||||
case ScreenActor.FittingRoom when Penumbra.Config.UseCharacterCollectionInTryOn: return ( _actorManager.GetCurrentPlayer(), SpecialResult.FittingRoom );
|
||||
case ScreenActor.DyePreview when Penumbra.Config.UseCharacterCollectionInTryOn: return ( _actorManager.GetCurrentPlayer(), SpecialResult.DyePreview );
|
||||
case ScreenActor.Portrait when Penumbra.Config.UseCharacterCollectionsInCards: return ( _actorManager.GetCurrentPlayer(), SpecialResult.Portrait );
|
||||
case ScreenActor.ExamineScreen:
|
||||
{
|
||||
identifier = _actorManager.GetInspectPlayer();
|
||||
if( identifier.IsValid )
|
||||
{
|
||||
return Penumbra.Config.UseCharacterCollectionInInspect ? identifier : ActorIdentifier.Invalid;
|
||||
return ( Penumbra.Config.UseCharacterCollectionInInspect ? identifier : ActorIdentifier.Invalid, SpecialResult.Inspect );
|
||||
}
|
||||
|
||||
identifier = _actorManager.GetCardPlayer();
|
||||
if( identifier.IsValid )
|
||||
{
|
||||
return Penumbra.Config.UseCharacterCollectionInInspect ? identifier : ActorIdentifier.Invalid;
|
||||
return ( Penumbra.Config.UseCharacterCollectionInInspect ? identifier : ActorIdentifier.Invalid, SpecialResult.Card );
|
||||
}
|
||||
|
||||
return Penumbra.Config.UseCharacterCollectionInTryOn ? _actorManager.GetGlamourPlayer() : ActorIdentifier.Invalid;
|
||||
return ( Penumbra.Config.UseCharacterCollectionInTryOn ? _actorManager.GetGlamourPlayer() : ActorIdentifier.Invalid, SpecialResult.Glamour );
|
||||
}
|
||||
default: return identifier;
|
||||
default: return ( identifier, SpecialResult.Invalid );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ using Penumbra.GameData.Actors;
|
|||
using Penumbra.GameData.Enums;
|
||||
using Penumbra.Util;
|
||||
using Character = FFXIVClientStructs.FFXIV.Client.Game.Character.Character;
|
||||
using CustomizeData = Penumbra.GameData.Structs.CustomizeData;
|
||||
using GameObject = FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject;
|
||||
using ObjectKind = Dalamud.Game.ClientState.Objects.Enums.ObjectKind;
|
||||
|
||||
|
|
@ -18,48 +17,6 @@ namespace Penumbra.Interop.Resolver;
|
|||
|
||||
public unsafe partial class PathResolver
|
||||
{
|
||||
private static ResolveData IdentifyMahjong( GameObject* gameObject )
|
||||
{
|
||||
static bool SearchPlayer( Character* character, int idx, out ActorIdentifier id )
|
||||
{
|
||||
var other = ( Character* )Dalamud.Objects.GetObjectAddress( idx );
|
||||
if( other == null || !CustomizeData.Equals( ( CustomizeData* )character->CustomizeData, ( CustomizeData* )other->CustomizeData ) )
|
||||
{
|
||||
id = ActorIdentifier.Invalid;
|
||||
return false;
|
||||
}
|
||||
|
||||
id = Penumbra.Actors.FromObject( &other->GameObject, out _, false, true );
|
||||
return true;
|
||||
}
|
||||
|
||||
static ActorIdentifier SearchPlayers( Character* gameObject, int idx1, int idx2, int idx3 )
|
||||
=> SearchPlayer( gameObject, idx1, out var id ) || SearchPlayer( gameObject, idx2, out id ) || SearchPlayer( gameObject, idx3, out id )
|
||||
? id
|
||||
: ActorIdentifier.Invalid;
|
||||
|
||||
var identifier = gameObject->ObjectIndex switch
|
||||
{
|
||||
0 => Penumbra.Actors.GetCurrentPlayer(),
|
||||
2 => Penumbra.Actors.FromObject( gameObject, out _, false, true ),
|
||||
4 => Penumbra.Actors.FromObject( gameObject, out _, false, true ),
|
||||
6 => Penumbra.Actors.FromObject( gameObject, out _, false, true ),
|
||||
240 => Penumbra.Actors.GetCurrentPlayer(),
|
||||
241 => SearchPlayers( ( Character* )gameObject, 2, 4, 6 ),
|
||||
242 => SearchPlayers( ( Character* )gameObject, 4, 2, 6 ),
|
||||
243 => SearchPlayers( ( Character* )gameObject, 6, 2, 4 ),
|
||||
_ => ActorIdentifier.Invalid,
|
||||
};
|
||||
|
||||
var collection = ( identifier.IsValid ? CollectionByIdentifier( identifier ) : null )
|
||||
?? CheckYourself( identifier, gameObject )
|
||||
?? CollectionByAttributes( gameObject )
|
||||
?? Penumbra.CollectionManager.Default;
|
||||
|
||||
return IdentifiedCache.Set( collection, identifier, gameObject );
|
||||
}
|
||||
|
||||
|
||||
// Identify the correct collection for a GameObject by index and name.
|
||||
public static ResolveData IdentifyCollection( GameObject* gameObject, bool useCache )
|
||||
{
|
||||
|
|
@ -89,7 +46,7 @@ public unsafe partial class PathResolver
|
|||
}
|
||||
|
||||
// Aesthetician. The relevant actor is yourself, so use player collection when possible.
|
||||
if( Dalamud.GameGui.GetAddonByName( "ScreenLog", 1 ) == IntPtr.Zero )
|
||||
if( Dalamud.GameGui.GetAddonByName( "ScreenLog" ) == IntPtr.Zero )
|
||||
{
|
||||
var player = Penumbra.Actors.GetCurrentPlayer();
|
||||
var collection2 = ( player.IsValid ? CollectionByIdentifier( player ) : null )
|
||||
|
|
@ -102,12 +59,11 @@ public unsafe partial class PathResolver
|
|||
var identifier = Penumbra.Actors.FromObject( gameObject, out var owner, true, false );
|
||||
if( identifier.Type is IdentifierType.Special )
|
||||
{
|
||||
if( Penumbra.Config.UseNoModsInInspect && identifier.Special == ScreenActor.ExamineScreen )
|
||||
( identifier, var type ) = Penumbra.CollectionManager.Individuals.ConvertSpecialIdentifier( identifier );
|
||||
if( Penumbra.Config.UseNoModsInInspect && type == IndividualCollections.SpecialResult.Inspect )
|
||||
{
|
||||
return IdentifiedCache.Set( ModCollection.Empty, identifier, gameObject );
|
||||
}
|
||||
|
||||
identifier = Penumbra.CollectionManager.Individuals.ConvertSpecialIdentifier( identifier );
|
||||
}
|
||||
|
||||
var collection = CollectionByIdentifier( identifier )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue