Skip to content

Commit

Permalink
Better Service dependency handling (#1535)
Browse files Browse the repository at this point in the history
  • Loading branch information
Soreepeong committed Nov 28, 2023
1 parent fcebd15 commit b66be84
Show file tree
Hide file tree
Showing 25 changed files with 415 additions and 197 deletions.
2 changes: 1 addition & 1 deletion Dalamud/Configuration/Internal/DalamudConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace Dalamud.Configuration.Internal;
/// Class containing Dalamud settings.
/// </summary>
[Serializable]
[ServiceManager.Service]
[ServiceManager.ProvidedService]
#pragma warning disable SA1015
[InherentDependency<ReliableFileStorage>] // We must still have this when unloading
#pragma warning restore SA1015
Expand Down
2 changes: 1 addition & 1 deletion Dalamud/Dalamud.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace Dalamud;
/// <summary>
/// The main Dalamud class containing all subsystems.
/// </summary>
[ServiceManager.Service]
[ServiceManager.ProvidedService]
internal sealed class Dalamud : IServiceType
{
#region Internals
Expand Down
2 changes: 1 addition & 1 deletion Dalamud/Game/Addon/Events/AddonEventManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace Dalamud.Game.Addon.Events;
/// Service provider for addon event management.
/// </summary>
[InterfaceVersion("1.0")]
[ServiceManager.EarlyLoadedService]
[ServiceManager.BlockingEarlyLoadedService]
internal unsafe class AddonEventManager : IDisposable, IServiceType
{
/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Dalamud/Game/Addon/Lifecycle/AddonLifecycle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace Dalamud.Game.Addon.Lifecycle;
/// This class provides events for in-game addon lifecycles.
/// </summary>
[InterfaceVersion("1.0")]
[ServiceManager.EarlyLoadedService]
[ServiceManager.BlockingEarlyLoadedService]
internal unsafe class AddonLifecycle : IDisposable, IServiceType
{
private static readonly ModuleLog Log = new("AddonLifecycle");
Expand Down
2 changes: 1 addition & 1 deletion Dalamud/Game/Config/GameConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Dalamud.Game.Config;
/// This class represents the game's configuration.
/// </summary>
[InterfaceVersion("1.0")]
[ServiceManager.EarlyLoadedService]
[ServiceManager.BlockingEarlyLoadedService]
internal sealed class GameConfig : IServiceType, IGameConfig, IDisposable
{
private readonly GameConfigAddressResolver address = new();
Expand Down
2 changes: 1 addition & 1 deletion Dalamud/Game/DutyState/DutyState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Dalamud.Game.DutyState;
/// This class represents the state of the currently occupied duty.
/// </summary>
[InterfaceVersion("1.0")]
[ServiceManager.EarlyLoadedService]
[ServiceManager.BlockingEarlyLoadedService]
internal unsafe class DutyState : IDisposable, IServiceType, IDutyState
{
private readonly DutyStateAddressResolver address;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;
Expand All @@ -22,14 +21,14 @@ internal class UniversalisMarketBoardUploader : IMarketBoardUploader

private const string ApiKey = "GGD6RdSfGyRiHM5WDnAo0Nj9Nv7aC5NDhMj3BebT";

private readonly HttpClient httpClient = Service<HappyHttpClient>.Get().SharedHttpClient;
private readonly HttpClient httpClient;

/// <summary>
/// Initializes a new instance of the <see cref="UniversalisMarketBoardUploader"/> class.
/// </summary>
public UniversalisMarketBoardUploader()
{
}
/// <param name="happyHttpClient">An instance of <see cref="HappyHttpClient"/>.</param>
public UniversalisMarketBoardUploader(HappyHttpClient happyHttpClient) =>
this.httpClient = happyHttpClient.SharedHttpClient;

/// <inheritdoc/>
public async Task Upload(MarketBoardItemRequest request)
Expand Down
10 changes: 7 additions & 3 deletions Dalamud/Game/Network/Internal/NetworkHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Dalamud.Game.Network.Internal.MarketBoardUploaders.Universalis;
using Dalamud.Game.Network.Structures;
using Dalamud.Hooking;
using Dalamud.Networking.Http;
using Dalamud.Utility;
using FFXIVClientStructs.FFXIV.Client.UI.Info;
using Lumina.Excel.GeneratedSheets;
Expand All @@ -23,7 +24,7 @@ namespace Dalamud.Game.Network.Internal;
/// <summary>
/// This class handles network notifications and uploading market board data.
/// </summary>
[ServiceManager.EarlyLoadedService]
[ServiceManager.BlockingEarlyLoadedService]
internal unsafe class NetworkHandlers : IDisposable, IServiceType
{
private readonly IMarketBoardUploader uploader;
Expand Down Expand Up @@ -55,9 +56,12 @@ internal unsafe class NetworkHandlers : IDisposable, IServiceType
private bool disposing;

[ServiceManager.ServiceConstructor]
private NetworkHandlers(GameNetwork gameNetwork, TargetSigScanner sigScanner)
private NetworkHandlers(
GameNetwork gameNetwork,
TargetSigScanner sigScanner,
HappyHttpClient happyHttpClient)
{
this.uploader = new UniversalisMarketBoardUploader();
this.uploader = new UniversalisMarketBoardUploader(happyHttpClient);

this.addressResolver = new NetworkHandlersAddressResolver();
this.addressResolver.Setup(sigScanner);
Expand Down
2 changes: 1 addition & 1 deletion Dalamud/Game/TargetSigScanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Dalamud.Game;
/// </summary>
[PluginInterface]
[InterfaceVersion("1.0")]
[ServiceManager.Service]
[ServiceManager.ProvidedService]
#pragma warning disable SA1015
[ResolveVia<ISigScanner>]
#pragma warning restore SA1015
Expand Down
2 changes: 1 addition & 1 deletion Dalamud/Interface/DragDrop/DragDropManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Dalamud.Interface.DragDrop;
/// and can be used to create ImGui drag and drop sources and targets for those external events.
/// </summary>
[PluginInterface]
[ServiceManager.EarlyLoadedService]
[ServiceManager.BlockingEarlyLoadedService]
#pragma warning disable SA1015
[ResolveVia<IDragDropManager>]
#pragma warning restore SA1015
Expand Down
2 changes: 1 addition & 1 deletion Dalamud/Interface/GameFonts/GameFontManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace Dalamud.Interface.GameFonts;
/// <summary>
/// Loads game font for use in ImGui.
/// </summary>
[ServiceManager.EarlyLoadedService]
[ServiceManager.BlockingEarlyLoadedService]
internal class GameFontManager : IServiceType
{
private static readonly string?[] FontNames =
Expand Down
Loading

0 comments on commit b66be84

Please sign in to comment.