chore: make all services with interfaces internal

This commit is contained in:
goat 2023-09-17 21:09:00 +02:00
parent ab9b7e1602
commit 5809cf5d7c
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B
40 changed files with 67 additions and 86 deletions

View file

@ -26,7 +26,7 @@ namespace Dalamud.Data;
#pragma warning disable SA1015
[ResolveVia<IDataManager>]
#pragma warning restore SA1015
public sealed class DataManager : IDisposable, IServiceType, IDataManager
internal sealed class DataManager : IDisposable, IServiceType, IDataManager
{
private readonly Thread luminaResourceThread;
private readonly CancellationTokenSource luminaCancellationTokenSource;

View file

@ -10,7 +10,7 @@ namespace Dalamud.Game;
/// <summary>
/// Base memory address resolver.
/// </summary>
public abstract class BaseAddressResolver
internal abstract class BaseAddressResolver
{
/// <summary>
/// Gets a list of memory addresses that were found, to list in /xldata.

View file

@ -18,7 +18,7 @@ namespace Dalamud.Game.ClientState.Aetherytes;
#pragma warning disable SA1015
[ResolveVia<IAetheryteList>]
#pragma warning restore SA1015
public sealed unsafe partial class AetheryteList : IServiceType, IAetheryteList
internal sealed unsafe partial class AetheryteList : IServiceType, IAetheryteList
{
[ServiceManager.ServiceDependency]
private readonly ClientState clientState = Service<ClientState>.Get();
@ -78,7 +78,7 @@ public sealed unsafe partial class AetheryteList : IServiceType, IAetheryteList
/// <summary>
/// This collection represents the list of available Aetherytes in the Teleport window.
/// </summary>
public sealed partial class AetheryteList
internal sealed partial class AetheryteList
{
/// <inheritdoc/>
public int Count => this.Length;

View file

@ -20,7 +20,7 @@ namespace Dalamud.Game.ClientState.Buddy;
#pragma warning disable SA1015
[ResolveVia<IBuddyList>]
#pragma warning restore SA1015
public sealed partial class BuddyList : IServiceType, IBuddyList
internal sealed partial class BuddyList : IServiceType, IBuddyList
{
private const uint InvalidObjectID = 0xE0000000;
@ -147,7 +147,7 @@ public sealed partial class BuddyList : IServiceType, IBuddyList
/// <summary>
/// This collection represents the buddies present in your squadron or trust party.
/// </summary>
public sealed partial class BuddyList
internal sealed partial class BuddyList
{
/// <inheritdoc/>
int IReadOnlyCollection<BuddyMember>.Count => this.Length;

View file

@ -1,4 +1,3 @@
using System;
using System.Runtime.InteropServices;
using Dalamud.Data;
@ -25,7 +24,7 @@ namespace Dalamud.Game.ClientState;
#pragma warning disable SA1015
[ResolveVia<IClientState>]
#pragma warning restore SA1015
public sealed class ClientState : IDisposable, IServiceType, IClientState
internal sealed class ClientState : IDisposable, IServiceType, IClientState
{
private readonly GameLifecycle lifecycle;
private readonly ClientStateAddressResolver address;
@ -141,7 +140,7 @@ public sealed class ClientState : IDisposable, IServiceType, IClientState
this.CfPop?.InvokeSafely(this, e);
}
private void FrameworkOnOnUpdateEvent(Framework framework1)
private void FrameworkOnOnUpdateEvent(IFramework framework1)
{
var condition = Service<Conditions.Condition>.GetNullable();
var gameGui = Service<GameGui>.GetNullable();

View file

@ -5,7 +5,7 @@ namespace Dalamud.Game.ClientState;
/// <summary>
/// Client state memory address resolver.
/// </summary>
public sealed class ClientStateAddressResolver : BaseAddressResolver
internal sealed class ClientStateAddressResolver : BaseAddressResolver
{
// Static offsets

View file

@ -1,5 +1,3 @@
using System;
using Dalamud.IoC;
using Dalamud.IoC.Internal;
using Dalamud.Plugin.Services;
@ -92,7 +90,7 @@ internal sealed partial class Condition : IServiceType, ICondition
framework.Update += this.FrameworkUpdate;
}
private void FrameworkUpdate(Framework framework)
private void FrameworkUpdate(IFramework framework)
{
for (var i = 0; i < MaxConditionEntries; i++)
{

View file

@ -18,7 +18,7 @@ namespace Dalamud.Game.ClientState.Fates;
#pragma warning disable SA1015
[ResolveVia<IFateTable>]
#pragma warning restore SA1015
public sealed partial class FateTable : IServiceType, IFateTable
internal sealed partial class FateTable : IServiceType, IFateTable
{
private readonly ClientStateAddressResolver address;
@ -110,7 +110,7 @@ public sealed partial class FateTable : IServiceType, IFateTable
/// <summary>
/// This collection represents the currently available Fate events.
/// </summary>
public sealed partial class FateTable
internal sealed partial class FateTable
{
/// <inheritdoc/>
int IReadOnlyCollection<Fate>.Count => this.Length;

View file

@ -21,7 +21,7 @@ namespace Dalamud.Game.ClientState.GamePad;
#pragma warning disable SA1015
[ResolveVia<IGamepadState>]
#pragma warning restore SA1015
public unsafe class GamepadState : IDisposable, IServiceType, IGamepadState
internal unsafe class GamepadState : IDisposable, IServiceType, IGamepadState
{
private readonly Hook<ControllerPoll>? gamepadPoll;

View file

@ -19,7 +19,7 @@ namespace Dalamud.Game.ClientState.JobGauge;
#pragma warning disable SA1015
[ResolveVia<IJobGauges>]
#pragma warning restore SA1015
public class JobGauges : IServiceType, IJobGauges
internal class JobGauges : IServiceType, IJobGauges
{
private Dictionary<Type, JobGaugeBase> cache = new();

View file

@ -28,7 +28,7 @@ namespace Dalamud.Game.ClientState.Keys;
#pragma warning disable SA1015
[ResolveVia<IKeyState>]
#pragma warning restore SA1015
public class KeyState : IServiceType, IKeyState
internal class KeyState : IServiceType, IKeyState
{
// The array is accessed in a way that this limit doesn't appear to exist
// but there is other state data past this point, and keys beyond here aren't

View file

@ -21,7 +21,7 @@ namespace Dalamud.Game.ClientState.Objects;
#pragma warning disable SA1015
[ResolveVia<IObjectTable>]
#pragma warning restore SA1015
public sealed partial class ObjectTable : IServiceType, IObjectTable
internal sealed partial class ObjectTable : IServiceType, IObjectTable
{
private const int ObjectTableLength = 596;
@ -109,7 +109,7 @@ public sealed partial class ObjectTable : IServiceType, IObjectTable
/// <summary>
/// This collection represents the currently spawned FFXIV game objects.
/// </summary>
public sealed partial class ObjectTable
internal sealed partial class ObjectTable
{
/// <inheritdoc/>
int IReadOnlyCollection<GameObject>.Count => this.Length;

View file

@ -16,7 +16,7 @@ namespace Dalamud.Game.ClientState.Objects;
#pragma warning disable SA1015
[ResolveVia<ITargetManager>]
#pragma warning restore SA1015
public sealed unsafe class TargetManager : IServiceType, ITargetManager
internal sealed unsafe class TargetManager : IServiceType, ITargetManager
{
[ServiceManager.ServiceDependency]
private readonly ClientState clientState = Service<ClientState>.Get();

View file

@ -19,7 +19,7 @@ namespace Dalamud.Game.ClientState.Party;
#pragma warning disable SA1015
[ResolveVia<IPartyList>]
#pragma warning restore SA1015
public sealed unsafe partial class PartyList : IServiceType, IPartyList
internal sealed unsafe partial class PartyList : IServiceType, IPartyList
{
private const int GroupLength = 8;
private const int AllianceLength = 20;
@ -130,7 +130,7 @@ public sealed unsafe partial class PartyList : IServiceType, IPartyList
/// <summary>
/// This collection represents the party members present in your party or alliance.
/// </summary>
public sealed partial class PartyList
internal sealed partial class PartyList
{
/// <inheritdoc/>
int IReadOnlyCollection<PartyMember>.Count => this.Length;

View file

@ -23,7 +23,7 @@ namespace Dalamud.Game.Command;
#pragma warning disable SA1015
[ResolveVia<ICommandManager>]
#pragma warning restore SA1015
public sealed class CommandManager : IServiceType, IDisposable, ICommandManager
internal sealed class CommandManager : IServiceType, IDisposable, ICommandManager
{
private readonly ConcurrentDictionary<string, CommandInfo> commandMap = new();
private readonly Regex commandRegexEn = new(@"^The command (?<command>.+) does not exist\.$", RegexOptions.Compiled);

View file

@ -17,7 +17,7 @@ namespace Dalamud.Game.Config;
#pragma warning disable SA1015
[ResolveVia<IGameConfig>]
#pragma warning restore SA1015
public sealed class GameConfig : IServiceType, IGameConfig, IDisposable
internal sealed class GameConfig : IServiceType, IGameConfig, IDisposable
{
private readonly GameConfigAddressResolver address = new();
private Hook<ConfigChangeDelegate>? configChangeHook;

View file

@ -3,7 +3,7 @@
/// <summary>
/// Game config system address resolver.
/// </summary>
public sealed class GameConfigAddressResolver : BaseAddressResolver
internal sealed class GameConfigAddressResolver : BaseAddressResolver
{
/// <summary>
/// Gets the address of the method called when any config option is changed.

View file

@ -135,7 +135,7 @@ internal unsafe class DutyState : IDisposable, IServiceType, IDutyState
/// Joining a duty in progress, or disconnecting and reconnecting will cause the player to miss the event.
/// </summary>
/// <param name="framework1">Framework reference.</param>
private void FrameworkOnUpdateEvent(Framework framework1)
private void FrameworkOnUpdateEvent(IFramework framework1)
{
// If the duty hasn't been started, and has not been completed yet this territory
if (!this.IsDutyStarted && !this.CompletedThisTerritory)

View file

@ -3,7 +3,7 @@ namespace Dalamud.Game.DutyState;
/// <summary>
/// Duty state memory address resolver.
/// </summary>
public class DutyStateAddressResolver : BaseAddressResolver
internal class DutyStateAddressResolver : BaseAddressResolver
{
/// <summary>
/// Gets the address of the method which is called when the client receives a content director update.

View file

@ -27,7 +27,7 @@ namespace Dalamud.Game;
#pragma warning disable SA1015
[ResolveVia<IFramework>]
#pragma warning restore SA1015
public sealed class Framework : IDisposable, IServiceType, IFramework
internal sealed class Framework : IDisposable, IServiceType, IFramework
{
private static readonly Stopwatch StatsStopwatch = new();
@ -39,6 +39,8 @@ public sealed class Framework : IDisposable, IServiceType, IFramework
private readonly Hook<OnUpdateDetour> updateHook;
private readonly Hook<OnRealDestroyDelegate> destroyHook;
private readonly FrameworkAddressResolver addressResolver;
[ServiceManager.ServiceDependency]
private readonly DalamudConfiguration configuration = Service<DalamudConfiguration>.Get();
@ -54,11 +56,11 @@ public sealed class Framework : IDisposable, IServiceType, IFramework
this.lifecycle = lifecycle;
this.hitchDetector = new HitchDetector("FrameworkUpdate", this.configuration.FrameworkUpdateHitch);
this.Address = new FrameworkAddressResolver();
this.Address.Setup(sigScanner);
this.addressResolver = new FrameworkAddressResolver();
this.addressResolver.Setup(sigScanner);
this.updateHook = Hook<OnUpdateDetour>.FromAddress(this.Address.TickAddress, this.HandleFrameworkUpdate);
this.destroyHook = Hook<OnRealDestroyDelegate>.FromAddress(this.Address.DestroyAddress, this.HandleFrameworkDestroy);
this.updateHook = Hook<OnUpdateDetour>.FromAddress(this.addressResolver.TickAddress, this.HandleFrameworkUpdate);
this.destroyHook = Hook<OnRealDestroyDelegate>.FromAddress(this.addressResolver.DestroyAddress, this.HandleFrameworkDestroy);
}
/// <summary>
@ -92,9 +94,6 @@ public sealed class Framework : IDisposable, IServiceType, IFramework
/// </summary>
public static Dictionary<string, List<double>> StatsHistory { get; } = new();
/// <inheritdoc/>
public FrameworkAddressResolver Address { get; }
/// <inheritdoc/>
public DateTime LastUpdate { get; private set; } = DateTime.MinValue;

View file

@ -5,7 +5,7 @@ namespace Dalamud.Game;
/// <summary>
/// The address resolver for the <see cref="Framework"/> class.
/// </summary>
public sealed class FrameworkAddressResolver : BaseAddressResolver
internal sealed class FrameworkAddressResolver : BaseAddressResolver
{
/// <summary>
/// Gets the address for the function that is called once the Framework is destroyed.

View file

@ -15,7 +15,7 @@ namespace Dalamud.Game;
#pragma warning disable SA1015
[ResolveVia<IGameLifecycle>]
#pragma warning restore SA1015
public class GameLifecycle : IServiceType, IGameLifecycle
internal class GameLifecycle : IServiceType, IGameLifecycle
{
private readonly CancellationTokenSource dalamudUnloadCts = new();
private readonly CancellationTokenSource gameShutdownCts = new();

View file

@ -1,11 +1,9 @@
using System;
namespace Dalamud.Game.Gui;
/// <summary>
/// The address resolver for the <see cref="ChatGui"/> class.
/// </summary>
public sealed class ChatGuiAddressResolver : BaseAddressResolver
internal sealed class ChatGuiAddressResolver : BaseAddressResolver
{
/// <summary>
/// Gets the address of the native PrintMessage method.

View file

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using Dalamud.Configuration.Internal;
@ -22,7 +21,7 @@ namespace Dalamud.Game.Gui.Dtr;
#pragma warning disable SA1015
[ResolveVia<IDtrBar>]
#pragma warning restore SA1015
public sealed unsafe class DtrBar : IDisposable, IServiceType, IDtrBar
internal sealed unsafe class DtrBar : IDisposable, IServiceType, IDtrBar
{
private const uint BaseNodeId = 1000;
@ -133,7 +132,7 @@ public sealed unsafe class DtrBar : IDisposable, IServiceType, IDtrBar
private AtkUnitBase* GetDtr() => (AtkUnitBase*)this.gameGui.GetAddonByName("_DTR").ToPointer();
private void Update(Framework unused)
private void Update(IFramework unused)
{
this.HandleRemovedNodes();

View file

@ -1,11 +1,9 @@
using System;
namespace Dalamud.Game.Gui.FlyText;
/// <summary>
/// An address resolver for the <see cref="FlyTextGui"/> class.
/// </summary>
public class FlyTextGuiAddressResolver : BaseAddressResolver
internal class FlyTextGuiAddressResolver : BaseAddressResolver
{
/// <summary>
/// Gets the address of the native AddFlyText method, which occurs

View file

@ -1,11 +1,9 @@
using System;
namespace Dalamud.Game.Gui.PartyFinder;
/// <summary>
/// The address resolver for the <see cref="PartyFinderGui"/> class.
/// </summary>
public class PartyFinderAddressResolver : BaseAddressResolver
internal class PartyFinderAddressResolver : BaseAddressResolver
{
/// <summary>
/// Gets the address of the native ReceiveListing method.

View file

@ -1,4 +1,4 @@
using Dalamud.Data;
using Dalamud.Plugin.Services;
using Lumina.Excel.GeneratedSheets;
namespace Dalamud.Game.Gui.PartyFinder.Types;
@ -14,7 +14,7 @@ public static class JobFlagsExtensions
/// <param name="job">A JobFlags enum member.</param>
/// <param name="data">A DataManager to get the ClassJob from.</param>
/// <returns>A ClassJob if found or null if not.</returns>
public static ClassJob ClassJob(this JobFlags job, DataManager data)
public static ClassJob? ClassJob(this JobFlags job, IDataManager data)
{
var jobs = data.GetExcelSheet<ClassJob>();
@ -52,6 +52,6 @@ public static class JobFlagsExtensions
_ => null,
};
return row == null ? null : jobs.GetRow((uint)row);
return row == null ? null : jobs?.GetRow((uint)row);
}
}

View file

@ -1,11 +1,9 @@
using System;
namespace Dalamud.Game.Gui.Toast;
/// <summary>
/// An address resolver for the <see cref="ToastGui"/> class.
/// </summary>
public class ToastGuiAddressResolver : BaseAddressResolver
internal class ToastGuiAddressResolver : BaseAddressResolver
{
/// <summary>
/// Gets the address of the native ShowNormalToast method.

View file

@ -1,4 +1,3 @@
using System;
using System.Diagnostics;
using System.Linq;
@ -10,7 +9,7 @@ namespace Dalamud.Game.Internal.DXGI;
/// The address resolver for native D3D11 methods to facilitate displaying the Dalamud UI.
/// </summary>
[Obsolete("This has been deprecated in favor of the VTable resolver.")]
public sealed class SwapChainSigResolver : BaseAddressResolver, ISwapChainAddressResolver
internal sealed class SwapChainSigResolver : BaseAddressResolver, ISwapChainAddressResolver
{
/// <inheritdoc/>
public IntPtr Present { get; set; }

View file

@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.InteropServices;
@ -15,7 +14,7 @@ namespace Dalamud.Game.Internal.DXGI;
/// <remarks>
/// If the normal signature based method of resolution fails, this is the backup.
/// </remarks>
public class SwapChainVtableResolver : BaseAddressResolver, ISwapChainAddressResolver
internal class SwapChainVtableResolver : BaseAddressResolver, ISwapChainAddressResolver
{
/// <inheritdoc/>
public IntPtr Present { get; set; }

View file

@ -17,7 +17,7 @@ namespace Dalamud.Game.Libc;
#pragma warning disable SA1015
[ResolveVia<ILibcFunction>]
#pragma warning restore SA1015
public sealed class LibcFunction : IServiceType, ILibcFunction
internal sealed class LibcFunction : IServiceType, ILibcFunction
{
private readonly LibcFunctionAddressResolver address;
private readonly StdStringFromCStringDelegate stdStringCtorCString;

View file

@ -5,7 +5,7 @@ namespace Dalamud.Game.Libc;
/// <summary>
/// The address resolver for the <see cref="LibcFunction"/> class.
/// </summary>
public sealed class LibcFunctionAddressResolver : BaseAddressResolver
internal sealed class LibcFunctionAddressResolver : BaseAddressResolver
{
private delegate IntPtr StringFromCString();

View file

@ -1,11 +1,9 @@
using System;
namespace Dalamud.Game.Network;
/// <summary>
/// The address resolver for the <see cref="GameNetwork"/> class.
/// </summary>
public sealed class GameNetworkAddressResolver : BaseAddressResolver
internal sealed class GameNetworkAddressResolver : BaseAddressResolver
{
/// <summary>
/// Gets the address of the ProcessZonePacketDown method.

View file

@ -25,7 +25,7 @@ namespace Dalamud.Game;
#pragma warning disable SA1015
[ResolveVia<ISigScanner>]
#pragma warning restore SA1015
public class SigScanner : IDisposable, IServiceType, ISigScanner
internal class SigScanner : IDisposable, IServiceType, ISigScanner
{
private readonly FileInfo? cacheFile;

View file

@ -5,6 +5,7 @@ using System.IO;
using Dalamud.Data;
using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Plugin.Services;
using Newtonsoft.Json;
using Serilog;
@ -27,12 +28,6 @@ public abstract partial class Payload
// To force-invalidate it, Dirty can be set to true
private byte[] encodedData;
/// <summary>
/// Gets the Lumina instance to use for any necessary data lookups.
/// </summary>
[JsonIgnore]
public DataManager DataResolver => Service<DataManager>.Get();
/// <summary>
/// Gets the type of this payload.
/// </summary>
@ -43,6 +38,13 @@ public abstract partial class Payload
/// </summary>
public bool Dirty { get; protected set; } = true;
/// <summary>
/// Gets the Lumina instance to use for any necessary data lookups.
/// </summary>
[JsonIgnore]
// TODO: We should refactor this. It should not be possible to get IDataManager through here.
protected IDataManager DataResolver => Service<DataManager>.Get();
/// <summary>
/// Decodes a binary representation of a payload into its corresponding nice object payload.
/// </summary>

View file

@ -442,7 +442,7 @@ internal class TextureManager : IDisposable, IServiceType, ITextureSubstitutionP
}
}
private void FrameworkOnUpdate(Framework fw)
private void FrameworkOnUpdate(IFramework fw)
{
lock (this.activeTextures)
{

View file

@ -11,6 +11,7 @@ using Dalamud.Interface.Animation.EasingFunctions;
using Dalamud.Interface.Utility;
using Dalamud.Interface.Utility.Raii;
using Dalamud.Interface.Windowing;
using Dalamud.Plugin.Services;
using ImGuiNET;
using ImGuiScene;
@ -358,7 +359,7 @@ internal class TitleScreenMenuWindow : Window, IDisposable
return isHover;
}
private void FrameworkOnUpdate(Framework framework)
private void FrameworkOnUpdate(IFramework framework)
{
var clientState = Service<ClientState>.Get();
this.IsOpen = !clientState.IsLoggedIn;

View file

@ -1,4 +1,3 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
@ -6,6 +5,7 @@ using System.Reflection;
using System.Threading.Tasks;
using Dalamud.Game;
using Dalamud.Plugin.Services;
namespace Dalamud.Logging.Internal;
@ -141,7 +141,7 @@ internal class TaskTracker : IDisposable, IServiceType
return true;
}
private void FrameworkOnUpdate(Framework framework)
private void FrameworkOnUpdate(IFramework framework)
{
UpdateData();
}

View file

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
@ -7,6 +6,7 @@ using CheapLoc;
using Dalamud.Game;
using Dalamud.Game.Command;
using Dalamud.Game.Gui;
using Dalamud.Plugin.Services;
using Dalamud.Utility;
using Serilog;
@ -78,7 +78,7 @@ internal class ProfileCommandHandler : IServiceType, IDisposable
this.framework.Update += this.FrameworkOnUpdate;
}
private void FrameworkOnUpdate(Framework framework1)
private void FrameworkOnUpdate(IFramework framework1)
{
if (this.profileManager.IsBusy)
return;

View file

@ -15,18 +15,13 @@ public interface IFramework
/// A delegate type used with the <see cref="Update"/> event.
/// </summary>
/// <param name="framework">The Framework instance.</param>
public delegate void OnUpdateDelegate(Framework framework);
public delegate void OnUpdateDelegate(IFramework framework);
/// <summary>
/// Event that gets fired every time the game framework updates.
/// </summary>
public event OnUpdateDelegate Update;
/// <summary>
/// Gets a raw pointer to the instance of Client::Framework.
/// </summary>
public FrameworkAddressResolver Address { get; }
/// <summary>
/// Gets the last time that the Framework Update event was triggered.
/// </summary>