mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-01-02 05:43:40 +01:00
fix: Mark remaining as obsolete
This commit is contained in:
parent
77a15a533d
commit
a1cc4fa91b
3 changed files with 57 additions and 18 deletions
|
|
@ -14,6 +14,11 @@ namespace Dalamud.Test.Compliance;
|
||||||
|
|
||||||
public class PublicApiTests
|
public class PublicApiTests
|
||||||
{
|
{
|
||||||
|
private static List<Type> IgnoredTypes { get; } =
|
||||||
|
[
|
||||||
|
typeof(Utility.CStringExtensions),
|
||||||
|
];
|
||||||
|
|
||||||
private static List<Assembly> PermittedAssemblies { get; } =
|
private static List<Assembly> PermittedAssemblies { get; } =
|
||||||
[
|
[
|
||||||
typeof(object).Assembly,
|
typeof(object).Assembly,
|
||||||
|
|
@ -38,7 +43,7 @@ public class PublicApiTests
|
||||||
[Fact]
|
[Fact]
|
||||||
public void NoRestrictedTypes()
|
public void NoRestrictedTypes()
|
||||||
{
|
{
|
||||||
foreach (var type in typeof(Dalamud).Assembly.GetTypes().Where(t => t.IsPublic))
|
foreach (var type in typeof(Dalamud).Assembly.GetTypes().Where(t => t.IsPublic).Except(IgnoredTypes))
|
||||||
{
|
{
|
||||||
if (type.GetCustomAttribute<ObsoleteAttribute>() != null) continue;
|
if (type.GetCustomAttribute<ObsoleteAttribute>() != null) continue;
|
||||||
|
|
||||||
|
|
@ -48,14 +53,14 @@ public class PublicApiTests
|
||||||
|
|
||||||
if (!this.IsPermittedType(m.ReturnType))
|
if (!this.IsPermittedType(m.ReturnType))
|
||||||
{
|
{
|
||||||
Assert.Fail($"Method {type.FullName}.{m.Name} returns invalid type: {m.ReturnType.FullName}");
|
Assert.Fail($"Method {type.FullName}.{m.Name} returns unapproved type: {m.ReturnType.FullName}");
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var param in m.GetParameters())
|
foreach (var param in m.GetParameters())
|
||||||
{
|
{
|
||||||
if (!this.IsPermittedType(param.ParameterType))
|
if (!this.IsPermittedType(param.ParameterType))
|
||||||
{
|
{
|
||||||
Assert.Fail($"Method {type.FullName}.{m.Name} uses invalid type: {param.ParameterType.FullName}");
|
Assert.Fail($"Method {type.FullName}.{m.Name} uses unapproved type: {param.ParameterType.FullName}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -68,7 +73,7 @@ public class PublicApiTests
|
||||||
if (!this.IsPermittedType(p.PropertyType))
|
if (!this.IsPermittedType(p.PropertyType))
|
||||||
{
|
{
|
||||||
Assert.Fail(
|
Assert.Fail(
|
||||||
$"Property {type.FullName}.{p.Name} is invalid type: {p.PropertyType.FullName}");
|
$"Property {type.FullName}.{p.Name} is unapproved type: {p.PropertyType.FullName}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -79,7 +84,7 @@ public class PublicApiTests
|
||||||
if (!this.IsPermittedType(f.FieldType))
|
if (!this.IsPermittedType(f.FieldType))
|
||||||
{
|
{
|
||||||
Assert.Fail(
|
Assert.Fail(
|
||||||
$"Field {type.FullName}.{f.Name} is invalid type: {f.FieldType.FullName}");
|
$"Field {type.FullName}.{f.Name} is unapproved type: {f.FieldType.FullName}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,37 +72,38 @@ public unsafe class SMNGauge : JobGaugeBase<SummonerGauge>
|
||||||
/// Use the summon accessors instead.
|
/// Use the summon accessors instead.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Api14ToDo("Declare our own enum for this to avoid CS type.")]
|
[Api14ToDo("Declare our own enum for this to avoid CS type.")]
|
||||||
|
[Obsolete("Use specific accessors instead until API14.")]
|
||||||
public AetherFlags AetherFlags => this.Struct->AetherFlags;
|
public AetherFlags AetherFlags => this.Struct->AetherFlags;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a value indicating whether Bahamut is ready to be summoned.
|
/// Gets a value indicating whether Bahamut is ready to be summoned.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns><c>true</c> or <c>false</c>.</returns>
|
/// <returns><c>true</c> or <c>false</c>.</returns>
|
||||||
public bool IsBahamutReady => !this.AetherFlags.HasFlag(AetherFlags.PhoenixReady);
|
public bool IsBahamutReady => !this.Struct->AetherFlags.HasFlag(AetherFlags.PhoenixReady);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a value indicating whether if Phoenix is ready to be summoned.
|
/// Gets a value indicating whether if Phoenix is ready to be summoned.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns><c>true</c> or <c>false</c>.</returns>
|
/// <returns><c>true</c> or <c>false</c>.</returns>
|
||||||
public bool IsPhoenixReady => this.AetherFlags.HasFlag(AetherFlags.PhoenixReady);
|
public bool IsPhoenixReady => this.Struct->AetherFlags.HasFlag(AetherFlags.PhoenixReady);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a value indicating whether if Ifrit is ready to be summoned.
|
/// Gets a value indicating whether if Ifrit is ready to be summoned.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns><c>true</c> or <c>false</c>.</returns>
|
/// <returns><c>true</c> or <c>false</c>.</returns>
|
||||||
public bool IsIfritReady => this.AetherFlags.HasFlag(AetherFlags.IfritReady);
|
public bool IsIfritReady => this.Struct->AetherFlags.HasFlag(AetherFlags.IfritReady);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a value indicating whether if Titan is ready to be summoned.
|
/// Gets a value indicating whether if Titan is ready to be summoned.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns><c>true</c> or <c>false</c>.</returns>
|
/// <returns><c>true</c> or <c>false</c>.</returns>
|
||||||
public bool IsTitanReady => this.AetherFlags.HasFlag(AetherFlags.TitanReady);
|
public bool IsTitanReady => this.Struct->AetherFlags.HasFlag(AetherFlags.TitanReady);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a value indicating whether if Garuda is ready to be summoned.
|
/// Gets a value indicating whether if Garuda is ready to be summoned.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns><c>true</c> or <c>false</c>.</returns>
|
/// <returns><c>true</c> or <c>false</c>.</returns>
|
||||||
public bool IsGarudaReady => this.AetherFlags.HasFlag(AetherFlags.GarudaReady);
|
public bool IsGarudaReady => this.Struct->AetherFlags.HasFlag(AetherFlags.GarudaReady);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a value indicating whether if Ifrit is currently attuned.
|
/// Gets a value indicating whether if Ifrit is currently attuned.
|
||||||
|
|
@ -131,5 +132,5 @@ public unsafe class SMNGauge : JobGaugeBase<SummonerGauge>
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the amount of Aetherflow available.
|
/// Gets the amount of Aetherflow available.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public byte AetherflowStacks => (byte)(this.AetherFlags & AetherFlags.Aetherflow);
|
public byte AetherflowStacks => (byte)(this.Struct->AetherFlags & AetherFlags.Aetherflow);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@ using Dalamud.Utility;
|
||||||
|
|
||||||
using FFXIVClientStructs.FFXIV.Common.Math;
|
using FFXIVClientStructs.FFXIV.Common.Math;
|
||||||
|
|
||||||
|
#pragma warning disable CS0618 // Type or member is obsolete. To be fixed with API14.
|
||||||
|
|
||||||
namespace Dalamud.Interface.Components;
|
namespace Dalamud.Interface.Components;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -23,15 +25,10 @@ public static partial class ImGuiComponents
|
||||||
/// <param name="helpText">The text to display on hover.</param>
|
/// <param name="helpText">The text to display on hover.</param>
|
||||||
/// <param name="icon">The icon to use.</param>
|
/// <param name="icon">The icon to use.</param>
|
||||||
/// <param name="color">The color of the icon.</param>
|
/// <param name="color">The color of the icon.</param>
|
||||||
[Api14ToDo("Replace CS Vector4 with System.Numerics.Vector4")]
|
public static void HelpMarker(string helpText, FontAwesomeIcon icon, System.Numerics.Vector4 color)
|
||||||
public static void HelpMarker(string helpText, FontAwesomeIcon icon, Vector4? color = null)
|
|
||||||
{
|
{
|
||||||
using var col = new ImRaii.Color();
|
using var col = new ImRaii.Color();
|
||||||
|
col.Push(ImGuiCol.TextDisabled, color);
|
||||||
if (color.HasValue)
|
|
||||||
{
|
|
||||||
col.Push(ImGuiCol.TextDisabled, color.Value);
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
|
|
||||||
|
|
@ -51,4 +48,40 @@ public static partial class ImGuiComponents
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// HelpMarker component to add a custom icon with text on hover.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="helpText">The text to display on hover.</param>
|
||||||
|
/// <param name="icon">The icon to use.</param>
|
||||||
|
/// <param name="color">The color of the icon.</param>
|
||||||
|
[Api14ToDo(Api14ToDoAttribute.Remove)]
|
||||||
|
[Obsolete("CS type is deprecated. Use System.Numerics.Vector4 instead.")]
|
||||||
|
public static void HelpMarker(string helpText, FontAwesomeIcon icon, Vector4? color = null)
|
||||||
|
{
|
||||||
|
if (color.HasValue)
|
||||||
|
{
|
||||||
|
HelpMarker(helpText, icon, color.Value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME: Code duplication is easier than splitting up the Nullable in a way that doesn't break the API.
|
||||||
|
ImGui.SameLine();
|
||||||
|
|
||||||
|
using (ImRaii.PushFont(UiBuilder.IconFont))
|
||||||
|
{
|
||||||
|
ImGui.TextDisabled(icon.ToIconString());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui.IsItemHovered())
|
||||||
|
{
|
||||||
|
using (ImRaii.Tooltip())
|
||||||
|
{
|
||||||
|
using (ImRaii.TextWrapPos(ImGui.GetFontSize() * 35.0f))
|
||||||
|
{
|
||||||
|
ImGui.Text(helpText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue