Extract Strings to separate submodule.

This commit is contained in:
Ottermandias 2022-10-29 15:53:45 +02:00
parent bc901f3ff6
commit 35baba18bf
75 changed files with 751 additions and 1657 deletions

View file

@ -2,8 +2,8 @@ using System;
using Dalamud.Hooking;
using Dalamud.Utility.Signatures;
using Penumbra.Collections;
using Penumbra.GameData.ByteString;
using Penumbra.GameData.Enums;
using Penumbra.String.Classes;
using GameObject = FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject;
namespace Penumbra.Interop.Resolver;

View file

@ -8,8 +8,8 @@ using FFXIVClientStructs.FFXIV.Client.Game.Object;
using Penumbra.Api;
using FFXIVClientStructs.FFXIV.Client.Graphics.Scene;
using OtterGui.Classes;
using Penumbra.GameData.ByteString;
using Penumbra.GameData.Enums;
using Penumbra.String.Classes;
namespace Penumbra.Interop.Resolver;
@ -57,7 +57,7 @@ public unsafe partial class PathResolver
{
if( type == ResourceType.Tex
&& LastCreatedCollection.Valid
&& gamePath.Path.Substring( "chara/common/texture/".Length ).StartsWith( 'd', 'e', 'c', 'a', 'l' ) )
&& gamePath.Path.Substring( "chara/common/texture/".Length ).StartsWith( "decal"u8 ) )
{
resolveData = LastCreatedCollection;
return true;

View file

@ -7,8 +7,8 @@ using FFXIVClientStructs.FFXIV.Client.UI.Agent;
using FFXIVClientStructs.FFXIV.Component.GUI;
using Lumina.Excel.GeneratedSheets;
using Penumbra.Collections;
using Penumbra.GameData.ByteString;
using Penumbra.GameData.Enums;
using Penumbra.String;
using CustomizeData = Penumbra.GameData.Structs.CustomizeData;
using ObjectKind = Dalamud.Game.ClientState.Objects.Enums.ObjectKind;
@ -66,7 +66,7 @@ public unsafe partial class PathResolver
}
var block = data + 0x7A;
return new Utf8String( block ).ToString();
return new ByteString( block ).ToString();
}
// Obtain the name of the player character if the glamour plate edit window is open.
@ -130,7 +130,7 @@ public unsafe partial class PathResolver
if( owner != null )
{
return new Utf8String( owner->Name ).ToString();
return new ByteString( owner->Name ).ToString();
}
return null;
@ -169,7 +169,7 @@ public unsafe partial class PathResolver
if( Penumbra.Config.PreferNamedCollectionsOverOwners )
{
// Early return if we prefer the actors own name over its owner.
actorName = new Utf8String( gameObject->Name ).ToString();
actorName = new ByteString( gameObject->Name ).ToString();
if( actorName.Length > 0
&& CollectionByActorName( actorName, out var actorCollection ) )
{
@ -189,7 +189,7 @@ public unsafe partial class PathResolver
>= CutsceneCharacters.CutsceneStartIdx and < CutsceneCharacters.CutsceneEndIdx => GetCutsceneName( gameObject ),
_ => null,
}
?? GetOwnerName( gameObject ) ?? actorName ?? new Utf8String( gameObject->Name ).ToString();
?? GetOwnerName( gameObject ) ?? actorName ?? new ByteString( gameObject->Name ).ToString();
// First check temporary character collections, then the own configuration, then special collections.
var collection = CollectionByActorName( actualName, out var c )

View file

@ -4,9 +4,10 @@ using Dalamud.Hooking;
using Dalamud.Utility.Signatures;
using FFXIVClientStructs.FFXIV.Client.System.Resource;
using Penumbra.Collections;
using Penumbra.GameData.ByteString;
using Penumbra.GameData.Enums;
using Penumbra.Interop.Structs;
using Penumbra.String;
using Penumbra.String.Classes;
namespace Penumbra.Interop.Resolver;
@ -78,7 +79,7 @@ public unsafe partial class PathResolver
// We need to set the correct collection for the actual material path that is loaded
// before actually loading the file.
public bool MtrlLoadHandler( Utf8String split, Utf8String path, ResourceManager* resourceManager,
public bool MtrlLoadHandler( ByteString split, ByteString path, ResourceManager* resourceManager,
SeFileDescriptor* fileDescriptor, int priority, bool isSync, out byte ret )
{
ret = 0;
@ -149,7 +150,7 @@ public unsafe partial class PathResolver
}
var mtrl = ( MtrlResource* )mtrlResourceHandle;
var mtrlPath = Utf8String.FromSpanUnsafe( mtrl->Handle.FileNameSpan(), true, null, true );
var mtrlPath = ByteString.FromSpanUnsafe( mtrl->Handle.FileNameSpan(), true, null, true );
_mtrlData = _paths.TryGetValue( mtrlPath, out var c ) ? c : ResolveData.Invalid;
}
}

View file

@ -4,7 +4,7 @@ using System.Collections.Generic;
using System.Runtime.CompilerServices;
using Dalamud.Utility.Signatures;
using Penumbra.Collections;
using Penumbra.GameData.ByteString;
using Penumbra.String;
namespace Penumbra.Interop.Resolver;
@ -31,7 +31,7 @@ public unsafe partial class PathResolver
private readonly ResolverHooks _monster;
// This map links files to their corresponding collection, if it is non-default.
private readonly ConcurrentDictionary< Utf8String, ResolveData > _pathCollections = new();
private readonly ConcurrentDictionary< ByteString, ResolveData > _pathCollections = new();
public PathState( PathResolver parent )
{
@ -69,13 +69,13 @@ public unsafe partial class PathResolver
public int Count
=> _pathCollections.Count;
public IEnumerable< KeyValuePair< Utf8String, ResolveData > > Paths
public IEnumerable< KeyValuePair< ByteString, ResolveData > > Paths
=> _pathCollections;
public bool TryGetValue( Utf8String path, out ResolveData collection )
public bool TryGetValue( ByteString path, out ResolveData collection )
=> _pathCollections.TryGetValue( path, out collection );
public bool Consume( Utf8String path, out ResolveData collection )
public bool Consume( ByteString path, out ResolveData collection )
=> _pathCollections.TryRemove( path, out collection );
// Just add or remove the resolved path.
@ -87,13 +87,13 @@ public unsafe partial class PathResolver
return path;
}
var gamePath = new Utf8String( ( byte* )path );
var gamePath = new ByteString( ( byte* )path );
SetCollection( gameObject, gamePath, collection );
return path;
}
// Special handling for paths so that we do not store non-owned temporary strings in the dictionary.
public void SetCollection( IntPtr gameObject, Utf8String path, ModCollection collection )
public void SetCollection( IntPtr gameObject, ByteString path, ModCollection collection )
{
if( _pathCollections.ContainsKey( path ) || path.IsOwned )
{

View file

@ -5,9 +5,10 @@ using FFXIVClientStructs.FFXIV.Client.Game.Object;
using FFXIVClientStructs.FFXIV.Client.Graphics.Scene;
using FFXIVClientStructs.FFXIV.Client.System.Resource;
using Penumbra.Collections;
using Penumbra.GameData.ByteString;
using Penumbra.GameData.Enums;
using Penumbra.Interop.Loader;
using Penumbra.String;
using Penumbra.String.Classes;
namespace Penumbra.Interop.Resolver;
@ -151,7 +152,7 @@ public partial class PathResolver : IDisposable
return resolveData;
}
internal IEnumerable< KeyValuePair< Utf8String, ResolveData > > PathCollections
internal IEnumerable< KeyValuePair< ByteString, ResolveData > > PathCollections
=> _paths.Paths;
internal IEnumerable< KeyValuePair< IntPtr, (ResolveData, int) > > DrawObjectMap