mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 18:27:24 +01:00
Disable Meta Edits when mods are disabled.
This commit is contained in:
parent
361244385f
commit
d9dc37c994
4 changed files with 18 additions and 10 deletions
|
|
@ -45,6 +45,7 @@ public unsafe class MetaState : IDisposable
|
|||
[Signature(Sigs.HumanVTable, ScanType = ScanType.StaticAddress)]
|
||||
private readonly nint* _humanVTable = null!;
|
||||
|
||||
private readonly Configuration _config;
|
||||
private readonly CommunicatorService _communicator;
|
||||
private readonly PerformanceTracker _performance;
|
||||
private readonly CollectionResolver _collectionResolver;
|
||||
|
|
@ -56,7 +57,7 @@ public unsafe class MetaState : IDisposable
|
|||
private DisposableContainer _characterBaseCreateMetaChanges = DisposableContainer.Empty;
|
||||
|
||||
public MetaState(PerformanceTracker performance, CommunicatorService communicator, CollectionResolver collectionResolver,
|
||||
ResourceService resources, GameEventManager gameEventManager, CharacterUtility characterUtility)
|
||||
ResourceService resources, GameEventManager gameEventManager, CharacterUtility characterUtility, Configuration config)
|
||||
{
|
||||
_performance = performance;
|
||||
_communicator = communicator;
|
||||
|
|
@ -64,6 +65,7 @@ public unsafe class MetaState : IDisposable
|
|||
_resources = resources;
|
||||
_gameEventManager = gameEventManager;
|
||||
_characterUtility = characterUtility;
|
||||
_config = config;
|
||||
SignatureHelper.Initialise(this);
|
||||
_onModelLoadCompleteHook = Hook<OnModelLoadCompleteDelegate>.FromAddress(_humanVTable[58], OnModelLoadCompleteDetour);
|
||||
_getEqpIndirectHook.Enable();
|
||||
|
|
@ -127,7 +129,7 @@ public unsafe class MetaState : IDisposable
|
|||
_communicator.CreatingCharacterBase.Invoke(_lastCreatedCollection.AssociatedGameObject,
|
||||
_lastCreatedCollection.ModCollection.Name, (nint)(&modelCharaId), customize, equipData);
|
||||
|
||||
var decal = new DecalReverter(_characterUtility, _resources, _lastCreatedCollection.ModCollection, UsesDecal(modelCharaId, equipData));
|
||||
var decal = new DecalReverter(_config, _characterUtility, _resources, _lastCreatedCollection.ModCollection, UsesDecal(modelCharaId, equipData));
|
||||
var cmp = _lastCreatedCollection.ModCollection.TemporarilySetCmpFile(_characterUtility);
|
||||
_characterBaseCreateMetaChanges.Dispose(); // Should always be empty.
|
||||
_characterBaseCreateMetaChanges = new DisposableContainer(decal, cmp);
|
||||
|
|
@ -254,7 +256,7 @@ public unsafe class MetaState : IDisposable
|
|||
var resolveData = _collectionResolver.IdentifyCollection((DrawObject*)human, true);
|
||||
using var cmp = resolveData.ModCollection.TemporarilySetCmpFile(_characterUtility);
|
||||
using var decals =
|
||||
new DecalReverter(_characterUtility, _resources, resolveData.ModCollection, UsesDecal(0, data));
|
||||
new DecalReverter(_config, _characterUtility, _resources, resolveData.ModCollection, UsesDecal(0, data));
|
||||
var ret = _changeCustomize.Original(human, data, skipEquipment);
|
||||
_inChangeCustomize = false;
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -19,12 +19,15 @@ public sealed unsafe class DecalReverter : IDisposable
|
|||
private readonly Structs.TextureResourceHandle* _decal;
|
||||
private readonly Structs.TextureResourceHandle* _transparent;
|
||||
|
||||
public DecalReverter(CharacterUtility utility, ResourceService resources, ModCollection? collection, bool doDecal)
|
||||
public DecalReverter(Configuration config, CharacterUtility utility, ResourceService resources, ModCollection? collection, bool doDecal)
|
||||
{
|
||||
_utility = utility;
|
||||
var ptr = _utility.Address;
|
||||
_decal = null;
|
||||
_transparent = null;
|
||||
if (!config.EnableMods)
|
||||
return;
|
||||
|
||||
if (doDecal)
|
||||
{
|
||||
var decalPath = collection?.ResolvePath(DecalPath)?.InternalName ?? DecalPath.Path;
|
||||
|
|
|
|||
|
|
@ -106,6 +106,8 @@ public unsafe class MetaList : IDisposable
|
|||
|
||||
public sealed class MetaReverter : IDisposable
|
||||
{
|
||||
public static readonly MetaReverter Disabled = new(null!) { Disposed = true };
|
||||
|
||||
public readonly MetaList MetaList;
|
||||
public readonly nint Data;
|
||||
public readonly int Length;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ using Dalamud.Data;
|
|||
using Dalamud.Utility.Signatures;
|
||||
using FFXIVClientStructs.FFXIV.Client.System.Memory;
|
||||
using Penumbra.Collections;
|
||||
using Penumbra.Collections.Cache;
|
||||
using Penumbra.Collections.Manager;
|
||||
using Penumbra.GameData;
|
||||
using Penumbra.Import;
|
||||
|
|
@ -66,12 +65,12 @@ public unsafe class MetaFileManager
|
|||
{
|
||||
Penumbra.Log.Error($"Error writing TexToolsMeta:\n{e}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public void SetFile(MetaBaseFile? file, MetaIndex metaIndex)
|
||||
{
|
||||
if (file == null)
|
||||
if (file == null || !Config.EnableMods)
|
||||
CharacterUtility.ResetResource(metaIndex);
|
||||
else
|
||||
CharacterUtility.SetResource(metaIndex, (nint)file.Data, file.Length);
|
||||
|
|
@ -79,9 +78,11 @@ public unsafe class MetaFileManager
|
|||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public MetaList.MetaReverter TemporarilySetFile(MetaBaseFile? file, MetaIndex metaIndex)
|
||||
=> file == null
|
||||
? CharacterUtility.TemporarilyResetResource(metaIndex)
|
||||
: CharacterUtility.TemporarilySetResource(metaIndex, (nint)file.Data, file.Length);
|
||||
=> Config.EnableMods
|
||||
? file == null
|
||||
? CharacterUtility.TemporarilyResetResource(metaIndex)
|
||||
: CharacterUtility.TemporarilySetResource(metaIndex, (nint)file.Data, file.Length)
|
||||
: MetaList.MetaReverter.Disabled;
|
||||
|
||||
public void ApplyDefaultFiles(ModCollection collection)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue