Add handling for the 1.0 Decal texture.

This commit is contained in:
Ottermandias 2022-09-19 18:52:49 +02:00
parent 57e66f9b66
commit ea023ebb5c
9 changed files with 147 additions and 17 deletions

View file

@ -26,6 +26,8 @@ public unsafe partial class CharacterUtility : IDisposable
public bool Ready { get; private set; }
public event Action LoadingFinished;
private IntPtr _defaultTransparentResource;
private IntPtr _defaultDecalResource;
// The relevant indices depend on which meta manipulations we allow for.
// The defines are set in the project configuration.
@ -76,6 +78,18 @@ public unsafe partial class CharacterUtility : IDisposable
}
}
if( _defaultTransparentResource == IntPtr.Zero )
{
_defaultTransparentResource = ( IntPtr )Address->TransparentTexResource;
anyMissing |= _defaultTransparentResource == IntPtr.Zero;
}
if( _defaultDecalResource == IntPtr.Zero )
{
_defaultDecalResource = ( IntPtr )Address->DecalTexResource;
anyMissing |= _defaultDecalResource == IntPtr.Zero;
}
if( !anyMissing )
{
Ready = true;
@ -86,15 +100,15 @@ public unsafe partial class CharacterUtility : IDisposable
public void SetResource( Structs.CharacterUtility.Index resourceIdx, IntPtr data, int length )
{
var idx = ReverseIndices[( int )resourceIdx];
var list = _lists[idx.Value];
var idx = ReverseIndices[ ( int )resourceIdx ];
var list = _lists[ idx.Value ];
list.SetResource( data, length );
}
public void ResetResource( Structs.CharacterUtility.Index resourceIdx )
{
var idx = ReverseIndices[( int )resourceIdx];
var list = _lists[idx.Value];
var idx = ReverseIndices[ ( int )resourceIdx ];
var list = _lists[ idx.Value ];
list.ResetResource();
}
@ -119,6 +133,9 @@ public unsafe partial class CharacterUtility : IDisposable
{
list.Dispose();
}
Address->TransparentTexResource = ( Structs.TextureResourceHandle* )_defaultTransparentResource;
Address->DecalTexResource = ( Structs.TextureResourceHandle* )_defaultDecalResource;
}
public void Dispose()