diff --git a/Dalamud.Test/Compliance/PublicApiTests.cs b/Dalamud.Test/Compliance/PublicApiTests.cs index 05a05fe3f..93a3da514 100644 --- a/Dalamud.Test/Compliance/PublicApiTests.cs +++ b/Dalamud.Test/Compliance/PublicApiTests.cs @@ -14,6 +14,11 @@ namespace Dalamud.Test.Compliance; public class PublicApiTests { + private static List IgnoredTypes { get; } = + [ + typeof(Utility.CStringExtensions), + ]; + private static List PermittedAssemblies { get; } = [ typeof(object).Assembly, @@ -38,7 +43,7 @@ public class PublicApiTests [Fact] 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() != null) continue; @@ -48,14 +53,14 @@ public class PublicApiTests 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()) { 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)) { 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)) { Assert.Fail( - $"Field {type.FullName}.{f.Name} is invalid type: {f.FieldType.FullName}"); + $"Field {type.FullName}.{f.Name} is unapproved type: {f.FieldType.FullName}"); } } } diff --git a/Dalamud/Game/ClientState/JobGauge/Types/SMNGauge.cs b/Dalamud/Game/ClientState/JobGauge/Types/SMNGauge.cs index 0bb5d2463..55b08cf2e 100644 --- a/Dalamud/Game/ClientState/JobGauge/Types/SMNGauge.cs +++ b/Dalamud/Game/ClientState/JobGauge/Types/SMNGauge.cs @@ -72,37 +72,38 @@ public unsafe class SMNGauge : JobGaugeBase /// Use the summon accessors instead. /// [Api14ToDo("Declare our own enum for this to avoid CS type.")] + [Obsolete("Use specific accessors instead until API14.")] public AetherFlags AetherFlags => this.Struct->AetherFlags; /// /// Gets a value indicating whether Bahamut is ready to be summoned. /// /// true or false. - public bool IsBahamutReady => !this.AetherFlags.HasFlag(AetherFlags.PhoenixReady); + public bool IsBahamutReady => !this.Struct->AetherFlags.HasFlag(AetherFlags.PhoenixReady); /// /// Gets a value indicating whether if Phoenix is ready to be summoned. /// /// true or false. - public bool IsPhoenixReady => this.AetherFlags.HasFlag(AetherFlags.PhoenixReady); + public bool IsPhoenixReady => this.Struct->AetherFlags.HasFlag(AetherFlags.PhoenixReady); /// /// Gets a value indicating whether if Ifrit is ready to be summoned. /// /// true or false. - public bool IsIfritReady => this.AetherFlags.HasFlag(AetherFlags.IfritReady); + public bool IsIfritReady => this.Struct->AetherFlags.HasFlag(AetherFlags.IfritReady); /// /// Gets a value indicating whether if Titan is ready to be summoned. /// /// true or false. - public bool IsTitanReady => this.AetherFlags.HasFlag(AetherFlags.TitanReady); + public bool IsTitanReady => this.Struct->AetherFlags.HasFlag(AetherFlags.TitanReady); /// /// Gets a value indicating whether if Garuda is ready to be summoned. /// /// true or false. - public bool IsGarudaReady => this.AetherFlags.HasFlag(AetherFlags.GarudaReady); + public bool IsGarudaReady => this.Struct->AetherFlags.HasFlag(AetherFlags.GarudaReady); /// /// Gets a value indicating whether if Ifrit is currently attuned. @@ -131,5 +132,5 @@ public unsafe class SMNGauge : JobGaugeBase /// /// Gets the amount of Aetherflow available. /// - public byte AetherflowStacks => (byte)(this.AetherFlags & AetherFlags.Aetherflow); + public byte AetherflowStacks => (byte)(this.Struct->AetherFlags & AetherFlags.Aetherflow); } diff --git a/Dalamud/Interface/Components/ImGuiComponents.HelpMarker.cs b/Dalamud/Interface/Components/ImGuiComponents.HelpMarker.cs index 71edfc759..19e6eced8 100644 --- a/Dalamud/Interface/Components/ImGuiComponents.HelpMarker.cs +++ b/Dalamud/Interface/Components/ImGuiComponents.HelpMarker.cs @@ -4,6 +4,8 @@ using Dalamud.Utility; using FFXIVClientStructs.FFXIV.Common.Math; +#pragma warning disable CS0618 // Type or member is obsolete. To be fixed with API14. + namespace Dalamud.Interface.Components; /// @@ -23,15 +25,10 @@ public static partial class ImGuiComponents /// The text to display on hover. /// The icon to use. /// The color of the icon. - [Api14ToDo("Replace CS Vector4 with System.Numerics.Vector4")] - public static void HelpMarker(string helpText, FontAwesomeIcon icon, Vector4? color = null) + public static void HelpMarker(string helpText, FontAwesomeIcon icon, System.Numerics.Vector4 color) { using var col = new ImRaii.Color(); - - if (color.HasValue) - { - col.Push(ImGuiCol.TextDisabled, color.Value); - } + col.Push(ImGuiCol.TextDisabled, color); ImGui.SameLine(); @@ -51,4 +48,40 @@ public static partial class ImGuiComponents } } } + + /// + /// HelpMarker component to add a custom icon with text on hover. + /// + /// The text to display on hover. + /// The icon to use. + /// The color of the icon. + [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); + } + } + } + } }