mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-15 05:04:15 +01:00
feat: add InherentDependencyAttribute, mark PM inherently dependent on IM
This commit is contained in:
parent
4a228f4e3b
commit
f40ea4310c
5 changed files with 34 additions and 4 deletions
|
|
@ -4,7 +4,7 @@
|
|||
<TargetFramework>net7.0-windows</TargetFramework>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<Platforms>x64;AnyCPU</Platforms>
|
||||
<LangVersion>10.0</LangVersion>
|
||||
<LangVersion>11.0</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Label="Feature">
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ using Lumina.Excel.GeneratedSheets;
|
|||
using Newtonsoft.Json;
|
||||
using PInvoke;
|
||||
using Serilog;
|
||||
|
||||
using Condition = Dalamud.Game.ClientState.Conditions.Condition;
|
||||
|
||||
namespace Dalamud.Interface.Internal.Windows;
|
||||
|
|
@ -1728,11 +1729,11 @@ internal class DataWindow : Window
|
|||
|
||||
foreach (var color in colorSheet)
|
||||
{
|
||||
this.DrawUIColor(color);
|
||||
this.DrawUiColor(color);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawUIColor(UIColor color)
|
||||
private void DrawUiColor(UIColor color)
|
||||
{
|
||||
ImGui.Text($"[{color.RowId:D3}] ");
|
||||
ImGui.SameLine();
|
||||
|
|
@ -1750,7 +1751,7 @@ internal class DataWindow : Window
|
|||
var r = (byte)(color >> 24);
|
||||
var g = (byte)(color >> 16);
|
||||
var b = (byte)(color >> 8);
|
||||
var a = (byte)(color);
|
||||
var a = (byte)color;
|
||||
|
||||
return new Vector4(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f);
|
||||
}
|
||||
|
|
|
|||
20
Dalamud/IoC/Internal/InherentDependencyAttribute.cs
Normal file
20
Dalamud/IoC/Internal/InherentDependencyAttribute.cs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
using System;
|
||||
|
||||
namespace Dalamud.IoC.Internal;
|
||||
|
||||
/// <summary>
|
||||
/// Mark a class as being dependent on a service, without actually injecting it.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The service to be dependent upon.</typeparam>
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
internal class InherentDependencyAttribute<T> : InherentDependencyAttribute where T : IServiceType
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper class used for matching. Use the generic version.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
internal class InherentDependencyAttribute : Attribute
|
||||
{
|
||||
}
|
||||
|
|
@ -20,6 +20,7 @@ using Dalamud.Game.Text;
|
|||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using Dalamud.Game.Text.SeStringHandling.Payloads;
|
||||
using Dalamud.Interface.Internal;
|
||||
using Dalamud.IoC.Internal;
|
||||
using Dalamud.Logging.Internal;
|
||||
using Dalamud.Plugin.Internal.Exceptions;
|
||||
using Dalamud.Plugin.Internal.Types;
|
||||
|
|
@ -33,6 +34,9 @@ namespace Dalamud.Plugin.Internal;
|
|||
/// Class responsible for loading and unloading plugins.
|
||||
/// </summary>
|
||||
[ServiceManager.EarlyLoadedService]
|
||||
#pragma warning disable SA1015
|
||||
[InherentDependency<InterfaceManager.InterfaceManagerWithScene>]
|
||||
#pragma warning restore SA1015
|
||||
internal partial class PluginManager : IDisposable, IServiceType
|
||||
{
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -128,6 +128,11 @@ internal static class Service<T> where T : IServiceType
|
|||
.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
|
||||
.Select(x => x.FieldType)
|
||||
.Where(x => x.GetCustomAttribute<ServiceManager.ServiceDependency>(true) != null));
|
||||
res.AddRange(typeof(T)
|
||||
.GetCustomAttributes()
|
||||
.OfType<InherentDependencyAttribute>()
|
||||
.Select(x => x.GetType().GetGenericArguments().First()));
|
||||
|
||||
return res
|
||||
.Distinct()
|
||||
.Select(x => typeof(Service<>).MakeGenericType(x))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue