mirror of
https://github.com/xivdev/Penumbra.git
synced 2026-02-23 16:27:47 +01:00
Make everything services.
This commit is contained in:
parent
cf1dcfcb7c
commit
e05dbe9885
81 changed files with 220 additions and 317 deletions
|
|
@ -1,6 +1,5 @@
|
|||
using Dalamud.Plugin.Services;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game.Character;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game.Object;
|
||||
using OtterGui.Services;
|
||||
using Penumbra.GameData.Enums;
|
||||
using Penumbra.GameData.Interop;
|
||||
|
|
@ -9,7 +8,7 @@ using Penumbra.String;
|
|||
|
||||
namespace Penumbra.Interop.PathResolving;
|
||||
|
||||
public sealed class CutsceneService : IService, IDisposable
|
||||
public sealed class CutsceneService : IRequiredService, IDisposable
|
||||
{
|
||||
public const int CutsceneStartIdx = (int)ScreenActor.CutsceneStart;
|
||||
public const int CutsceneEndIdx = (int)ScreenActor.CutsceneEnd;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using Dalamud.Plugin.Services;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game.Character;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game.Object;
|
||||
using OtterGui.Services;
|
||||
using Penumbra.Collections;
|
||||
using Penumbra.Collections.Manager;
|
||||
using Penumbra.Communication;
|
||||
|
|
@ -10,7 +11,8 @@ using Penumbra.Services;
|
|||
|
||||
namespace Penumbra.Interop.PathResolving;
|
||||
|
||||
public unsafe class IdentifiedCollectionCache : IDisposable, IEnumerable<(nint Address, ActorIdentifier Identifier, ModCollection Collection)>
|
||||
public unsafe class IdentifiedCollectionCache : IDisposable, IEnumerable<(nint Address, ActorIdentifier Identifier, ModCollection Collection)>,
|
||||
IService
|
||||
{
|
||||
private readonly CommunicatorService _communicator;
|
||||
private readonly CharacterDestructor _characterDestructor;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using FFXIVClientStructs.FFXIV.Client.Graphics.Scene;
|
||||
using OtterGui.Classes;
|
||||
using OtterGui.Services;
|
||||
using Penumbra.Collections;
|
||||
using Penumbra.Api.Enums;
|
||||
using Penumbra.GameData.Structs;
|
||||
|
|
@ -34,7 +35,7 @@ namespace Penumbra.Interop.PathResolving;
|
|||
// ChangeCustomize and RspSetupCharacter, which is hooked here, as well as Character.CalculateHeight.
|
||||
|
||||
// GMP Entries seem to be only used by "48 8B ?? 53 55 57 48 83 ?? ?? 48 8B", which is SetupVisor.
|
||||
public sealed unsafe class MetaState : IDisposable
|
||||
public sealed unsafe class MetaState : IDisposable, IService
|
||||
{
|
||||
private readonly Configuration _config;
|
||||
private readonly CommunicatorService _communicator;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using FFXIVClientStructs.FFXIV.Client.System.Resource;
|
||||
using OtterGui.Services;
|
||||
using Penumbra.Api.Enums;
|
||||
using Penumbra.Collections;
|
||||
using Penumbra.Collections.Manager;
|
||||
|
|
@ -9,7 +10,7 @@ using Penumbra.Util;
|
|||
|
||||
namespace Penumbra.Interop.PathResolving;
|
||||
|
||||
public class PathResolver : IDisposable
|
||||
public class PathResolver : IDisposable, IService
|
||||
{
|
||||
private readonly PerformanceTracker _performance;
|
||||
private readonly Configuration _config;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
using OtterGui.Services;
|
||||
using Penumbra.Collections;
|
||||
using Penumbra.Interop.Services;
|
||||
using Penumbra.String;
|
||||
|
|
@ -5,7 +6,7 @@ using Penumbra.String;
|
|||
namespace Penumbra.Interop.PathResolving;
|
||||
|
||||
public sealed class PathState(CollectionResolver collectionResolver, MetaState metaState, CharacterUtility characterUtility)
|
||||
: IDisposable
|
||||
: IDisposable, IService
|
||||
{
|
||||
public readonly CollectionResolver CollectionResolver = collectionResolver;
|
||||
public readonly MetaState MetaState = metaState;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
using OtterGui.Services;
|
||||
using Penumbra.Api.Enums;
|
||||
using Penumbra.Collections;
|
||||
using Penumbra.Interop.Hooks.Resources;
|
||||
using Penumbra.Interop.ResourceLoading;
|
||||
using Penumbra.Interop.Structs;
|
||||
using Penumbra.String;
|
||||
using Penumbra.String.Classes;
|
||||
|
||||
namespace Penumbra.Interop.PathResolving;
|
||||
|
|
@ -13,7 +13,7 @@ namespace Penumbra.Interop.PathResolving;
|
|||
/// Those are loaded synchronously.
|
||||
/// Thus, we need to ensure the correct files are loaded when a material is loaded.
|
||||
/// </summary>
|
||||
public sealed unsafe class SubfileHelper : IDisposable, IReadOnlyCollection<KeyValuePair<nint, ResolveData>>
|
||||
public sealed unsafe class SubfileHelper : IDisposable, IReadOnlyCollection<KeyValuePair<nint, ResolveData>>, IService
|
||||
{
|
||||
private readonly GameState _gameState;
|
||||
private readonly ResourceLoader _loader;
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
using Dalamud.Hooking;
|
||||
using Dalamud.Plugin.Services;
|
||||
using Dalamud.Utility.Signatures;
|
||||
using OtterGui.Services;
|
||||
using Penumbra.GameData;
|
||||
using Penumbra.Interop.Structs;
|
||||
using Penumbra.Util;
|
||||
|
||||
namespace Penumbra.Interop.ResourceLoading;
|
||||
|
||||
public unsafe class FileReadService : IDisposable
|
||||
public unsafe class FileReadService : IDisposable, IRequiredService
|
||||
{
|
||||
public FileReadService(PerformanceTracker performance, ResourceManagerService resourceManager, IGameInteropProvider interop)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using FFXIVClientStructs.FFXIV.Client.System.Resource;
|
||||
using OtterGui.Services;
|
||||
using Penumbra.Api.Enums;
|
||||
using Penumbra.Collections;
|
||||
using Penumbra.Interop.PathResolving;
|
||||
|
|
@ -10,7 +11,7 @@ using FileMode = Penumbra.Interop.Structs.FileMode;
|
|||
|
||||
namespace Penumbra.Interop.ResourceLoading;
|
||||
|
||||
public unsafe class ResourceLoader : IDisposable
|
||||
public unsafe class ResourceLoader : IDisposable, IService
|
||||
{
|
||||
private readonly ResourceService _resources;
|
||||
private readonly FileReadService _fileReadService;
|
||||
|
|
@ -212,7 +213,7 @@ public unsafe class ResourceLoader : IDisposable
|
|||
/// <summary>
|
||||
/// Catch weird errors with invalid decrements of the reference count.
|
||||
/// </summary>
|
||||
private void DecRefProtection(ResourceHandle* handle, ref byte? returnValue)
|
||||
private static void DecRefProtection(ResourceHandle* handle, ref byte? returnValue)
|
||||
{
|
||||
if (handle->RefCount != 0)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -4,12 +4,13 @@ using FFXIVClientStructs.FFXIV.Client.System.Resource;
|
|||
using FFXIVClientStructs.FFXIV.Client.System.Resource.Handle;
|
||||
using FFXIVClientStructs.Interop;
|
||||
using FFXIVClientStructs.STD;
|
||||
using OtterGui.Services;
|
||||
using Penumbra.Api.Enums;
|
||||
using Penumbra.GameData;
|
||||
|
||||
namespace Penumbra.Interop.ResourceLoading;
|
||||
|
||||
public unsafe class ResourceManagerService
|
||||
public unsafe class ResourceManagerService : IRequiredService
|
||||
{
|
||||
public ResourceManagerService(IGameInteropProvider interop)
|
||||
=> interop.InitializeFromAttributes(this);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ using Dalamud.Hooking;
|
|||
using Dalamud.Plugin.Services;
|
||||
using Dalamud.Utility.Signatures;
|
||||
using FFXIVClientStructs.FFXIV.Client.System.Resource;
|
||||
using OtterGui.Services;
|
||||
using Penumbra.Api.Enums;
|
||||
using Penumbra.GameData;
|
||||
using Penumbra.Interop.SafeHandles;
|
||||
|
|
@ -13,7 +14,7 @@ using CSResourceHandle = FFXIVClientStructs.FFXIV.Client.System.Resource.Handle.
|
|||
|
||||
namespace Penumbra.Interop.ResourceLoading;
|
||||
|
||||
public unsafe class ResourceService : IDisposable
|
||||
public unsafe class ResourceService : IDisposable, IRequiredService
|
||||
{
|
||||
private readonly PerformanceTracker _performance;
|
||||
private readonly ResourceManagerService _resourceManager;
|
||||
|
|
|
|||
|
|
@ -2,13 +2,14 @@ using Dalamud.Hooking;
|
|||
using Dalamud.Plugin.Services;
|
||||
using Dalamud.Utility.Signatures;
|
||||
using FFXIVClientStructs.FFXIV.Client.System.Resource.Handle;
|
||||
using OtterGui.Services;
|
||||
using Penumbra.Api.Enums;
|
||||
using Penumbra.GameData;
|
||||
using Penumbra.String.Classes;
|
||||
|
||||
namespace Penumbra.Interop.ResourceLoading;
|
||||
|
||||
public unsafe class TexMdlService : IDisposable
|
||||
public unsafe class TexMdlService : IDisposable, IRequiredService
|
||||
{
|
||||
/// <summary> Custom ulong flag to signal our files as opposed to SE files. </summary>
|
||||
public static readonly IntPtr CustomFileFlag = new(0xDEADBEEF);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using Dalamud.Plugin.Services;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game.Object;
|
||||
using OtterGui.Services;
|
||||
using Penumbra.Api.Enums;
|
||||
using Penumbra.GameData.Actors;
|
||||
using Penumbra.GameData.Data;
|
||||
|
|
@ -17,7 +18,7 @@ public class ResourceTreeFactory(
|
|||
ObjectIdentification identifier,
|
||||
Configuration config,
|
||||
ActorManager actors,
|
||||
PathState pathState)
|
||||
PathState pathState) : IService
|
||||
{
|
||||
private TreeBuildCache CreateTreeBuildCache()
|
||||
=> new(objects, gameData, actors);
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
using Dalamud.Plugin.Services;
|
||||
using Dalamud.Utility.Signatures;
|
||||
using OtterGui.Services;
|
||||
using Penumbra.GameData;
|
||||
using Penumbra.Interop.Structs;
|
||||
|
||||
namespace Penumbra.Interop.Services;
|
||||
|
||||
public unsafe class CharacterUtility : IDisposable
|
||||
public unsafe class CharacterUtility : IDisposable, IRequiredService
|
||||
{
|
||||
public record struct InternalIndex(int Value);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using Dalamud.Plugin.Services;
|
||||
using FFXIVClientStructs.FFXIV.Client.System.Framework;
|
||||
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||
using OtterGui.Services;
|
||||
using Penumbra.GameData;
|
||||
|
||||
namespace Penumbra.Interop.Services;
|
||||
|
|
@ -9,7 +10,7 @@ namespace Penumbra.Interop.Services;
|
|||
/// Handle font reloading via game functions.
|
||||
/// May cause a interface flicker while reloading.
|
||||
/// </summary>
|
||||
public unsafe class FontReloader
|
||||
public unsafe class FontReloader : IService
|
||||
{
|
||||
public bool Valid
|
||||
=> _reloadFontsFunc != null;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
using Dalamud.Plugin.Services;
|
||||
using FFXIVClientStructs.FFXIV.Client.Graphics.Render;
|
||||
using FFXIVClientStructs.FFXIV.Client.System.Resource.Handle;
|
||||
using OtterGui.Services;
|
||||
|
||||
namespace Penumbra.Interop.Services;
|
||||
|
||||
public unsafe class ModelRenderer : IDisposable
|
||||
public unsafe class ModelRenderer : IDisposable, IRequiredService
|
||||
{
|
||||
public bool Ready { get; private set; }
|
||||
|
||||
|
|
@ -37,14 +38,14 @@ public unsafe class ModelRenderer : IDisposable
|
|||
|
||||
if (DefaultCharacterGlassShaderPackage == null)
|
||||
{
|
||||
DefaultCharacterGlassShaderPackage = *CharacterGlassShaderPackage;
|
||||
anyMissing |= DefaultCharacterGlassShaderPackage == null;
|
||||
DefaultCharacterGlassShaderPackage = *CharacterGlassShaderPackage;
|
||||
anyMissing |= DefaultCharacterGlassShaderPackage == null;
|
||||
}
|
||||
|
||||
if (anyMissing)
|
||||
return;
|
||||
|
||||
Ready = true;
|
||||
Ready = true;
|
||||
_framework.Update -= LoadDefaultResources;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ using Dalamud.Game.ClientState.Objects.Types;
|
|||
using Dalamud.Plugin.Services;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game.Housing;
|
||||
using FFXIVClientStructs.Interop;
|
||||
using OtterGui.Services;
|
||||
using Penumbra.Api;
|
||||
using Penumbra.Api.Enums;
|
||||
using Penumbra.Communication;
|
||||
|
|
@ -20,7 +21,7 @@ using Character = FFXIVClientStructs.FFXIV.Client.Game.Character.Character;
|
|||
|
||||
namespace Penumbra.Interop.Services;
|
||||
|
||||
public unsafe partial class RedrawService
|
||||
public unsafe partial class RedrawService : IService
|
||||
{
|
||||
public const int GPosePlayerIdx = 201;
|
||||
public const int GPoseSlots = 42;
|
||||
|
|
@ -171,7 +172,8 @@ public sealed unsafe partial class RedrawService : IDisposable
|
|||
if (gPose)
|
||||
DisableDraw(actor!);
|
||||
|
||||
if (actor is PlayerCharacter && _objects.GetDalamudObject(tableIndex + 1) is { ObjectKind: ObjectKind.MountType or ObjectKind.Ornament } mountOrOrnament)
|
||||
if (actor is PlayerCharacter
|
||||
&& _objects.GetDalamudObject(tableIndex + 1) is { ObjectKind: ObjectKind.MountType or ObjectKind.Ornament } mountOrOrnament)
|
||||
{
|
||||
*ActorDrawState(mountOrOrnament) |= DrawState.Invisibility;
|
||||
if (gPose)
|
||||
|
|
@ -190,7 +192,8 @@ public sealed unsafe partial class RedrawService : IDisposable
|
|||
if (gPose)
|
||||
EnableDraw(actor!);
|
||||
|
||||
if (actor is PlayerCharacter && _objects.GetDalamudObject(tableIndex + 1) is { ObjectKind: ObjectKind.MountType or ObjectKind.Ornament } mountOrOrnament)
|
||||
if (actor is PlayerCharacter
|
||||
&& _objects.GetDalamudObject(tableIndex + 1) is { ObjectKind: ObjectKind.MountType or ObjectKind.Ornament } mountOrOrnament)
|
||||
{
|
||||
*ActorDrawState(mountOrOrnament) &= ~DrawState.Invisibility;
|
||||
if (gPose)
|
||||
|
|
@ -380,7 +383,7 @@ public sealed unsafe partial class RedrawService : IDisposable
|
|||
if (!ret && lowerName.Length > 1 && lowerName[0] == '#' && ushort.TryParse(lowerName[1..], out var objectIndex))
|
||||
{
|
||||
ret = true;
|
||||
actor = _objects.GetDalamudObject((int) objectIndex);
|
||||
actor = _objects.GetDalamudObject((int)objectIndex);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
using Dalamud.Plugin.Services;
|
||||
using Dalamud.Plugin.Services;
|
||||
using Dalamud.Utility.Signatures;
|
||||
using OtterGui.Services;
|
||||
using Penumbra.GameData;
|
||||
|
||||
namespace Penumbra.Interop.Services;
|
||||
|
||||
public unsafe class ResidentResourceManager
|
||||
public unsafe class ResidentResourceManager : IService
|
||||
{
|
||||
// A static pointer to the resident resource manager address.
|
||||
[Signature(Sigs.ResidentResourceManager, ScanType = ScanType.StaticAddress)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue