Make everything services.

This commit is contained in:
Ottermandias 2024-06-18 21:59:04 +02:00
parent cf1dcfcb7c
commit e05dbe9885
81 changed files with 220 additions and 317 deletions

View file

@ -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);

View file

@ -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;

View file

@ -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;
}

View file

@ -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;

View file

@ -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)]