From c721069b0838e9b9565a9f00778d688023e7d233 Mon Sep 17 00:00:00 2001 From: srkizer Date: Fri, 2 Aug 2024 03:23:42 +0900 Subject: [PATCH] Fix scoped in and mark experimental (#1990) --- .../Internal/SeStringRenderer.cs | 16 ++++++----- .../Data/Widgets/AtkArrayDataBrowserWidget.cs | 2 ++ .../Widgets/SeStringRendererTestWidget.cs | 2 ++ Dalamud/Interface/Utility/ImGuiHelpers.cs | 27 +++---------------- 4 files changed, 18 insertions(+), 29 deletions(-) diff --git a/Dalamud/Interface/ImGuiSeStringRenderer/Internal/SeStringRenderer.cs b/Dalamud/Interface/ImGuiSeStringRenderer/Internal/SeStringRenderer.cs index 33fcb4496..b942ef844 100644 --- a/Dalamud/Interface/ImGuiSeStringRenderer/Internal/SeStringRenderer.cs +++ b/Dalamud/Interface/ImGuiSeStringRenderer/Internal/SeStringRenderer.cs @@ -229,7 +229,7 @@ public ReadOnlySeString CompileAndCache(string text) /// Interaction result of the rendered text. public SeStringDrawResult CompileAndDrawWrapped( string text, - in SeStringDrawParams drawParams = default, + scoped in SeStringDrawParams drawParams = default, ImGuiId imGuiId = default, ImGuiButtonFlags buttonFlags = ImGuiButtonFlags.MouseButtonDefault) => this.Draw(this.CompileAndCache(text).AsSpan(), drawParams, imGuiId, buttonFlags); @@ -241,8 +241,8 @@ public SeStringDrawResult CompileAndDrawWrapped( /// Button flags to use on link interaction. /// Interaction result of the rendered text. public SeStringDrawResult Draw( - in Utf8String utf8String, - in SeStringDrawParams drawParams = default, + scoped in Utf8String utf8String, + scoped in SeStringDrawParams drawParams = default, ImGuiId imGuiId = default, ImGuiButtonFlags buttonFlags = ImGuiButtonFlags.MouseButtonDefault) => this.Draw(utf8String.AsSpan(), drawParams, imGuiId, buttonFlags); @@ -255,7 +255,7 @@ public SeStringDrawResult Draw( /// Interaction result of the rendered text. public SeStringDrawResult Draw( ReadOnlySeStringSpan sss, - in SeStringDrawParams drawParams = default, + scoped in SeStringDrawParams drawParams = default, ImGuiId imGuiId = default, ImGuiButtonFlags buttonFlags = ImGuiButtonFlags.MouseButtonDefault) { @@ -889,7 +889,7 @@ private ref struct DrawState( /// GFD entry to determine the size. /// Whether to draw the HQ texture. /// Determined size of the GFD entry when drawn. - public readonly Vector2 CalculateGfdEntrySize(in GfdFile.GfdEntry gfdEntry, out bool useHq) + public readonly Vector2 CalculateGfdEntrySize(scoped in GfdFile.GfdEntry gfdEntry, out bool useHq) { useHq = this.Params.FontSize > 20; var targetHeight = useHq ? this.Params.FontSize : 20; @@ -911,7 +911,11 @@ public readonly void SetCurrentChannel(int channelIndex) => /// Transformation for that will push top and bottom pixels to /// apply faux italicization. /// Color of the glyph. - public readonly void Draw(Vector2 offset, in ImGuiHelpers.ImFontGlyphReal g, Vector2 dyItalic, uint color) => + public readonly void Draw( + Vector2 offset, + scoped in ImGuiHelpers.ImFontGlyphReal g, + Vector2 dyItalic, + uint color) => this.Draw( offset + new Vector2( 0, diff --git a/Dalamud/Interface/Internal/Windows/Data/Widgets/AtkArrayDataBrowserWidget.cs b/Dalamud/Interface/Internal/Windows/Data/Widgets/AtkArrayDataBrowserWidget.cs index 791dc5310..c134e02c3 100644 --- a/Dalamud/Interface/Internal/Windows/Data/Widgets/AtkArrayDataBrowserWidget.cs +++ b/Dalamud/Interface/Internal/Windows/Data/Widgets/AtkArrayDataBrowserWidget.cs @@ -12,6 +12,8 @@ namespace Dalamud.Interface.Internal.Windows.Data.Widgets; +#pragma warning disable SeStringRenderer + /// /// Widget for displaying AtkArrayData. /// diff --git a/Dalamud/Interface/Internal/Windows/Data/Widgets/SeStringRendererTestWidget.cs b/Dalamud/Interface/Internal/Windows/Data/Widgets/SeStringRendererTestWidget.cs index 6e48e2d08..62c52a17f 100644 --- a/Dalamud/Interface/Internal/Windows/Data/Widgets/SeStringRendererTestWidget.cs +++ b/Dalamud/Interface/Internal/Windows/Data/Widgets/SeStringRendererTestWidget.cs @@ -18,6 +18,8 @@ namespace Dalamud.Interface.Internal.Windows.Data.Widgets; +#pragma warning disable SeStringRenderer + /// /// Widget for displaying Addon Data. /// diff --git a/Dalamud/Interface/Utility/ImGuiHelpers.cs b/Dalamud/Interface/Utility/ImGuiHelpers.cs index e64372700..5fb5b1151 100644 --- a/Dalamud/Interface/Utility/ImGuiHelpers.cs +++ b/Dalamud/Interface/Utility/ImGuiHelpers.cs @@ -180,27 +180,6 @@ public static void ClickToCopyText(string text, string? textCopy = null) if (ImGui.IsItemClicked()) ImGui.SetClipboardText($"{textCopy}"); } - /// Draws a SeString. - /// SeString to draw. - /// Wrapping width. If a non-positive number is provided, then the remainder of the width - /// will be used. - /// This function is experimental. Report any issues to GitHub issues or to Discord #dalamud-dev channel. - /// The function definition is stable; only in the next API version a function may be removed. - public static void SeStringWrapped(ReadOnlySpan sss, float wrapWidth = 0) => - Service.Get().Draw(sss, new() { WrapWidth = wrapWidth > 0 ? wrapWidth : null }); - - /// Creates and caches a SeString from a text macro representation, and then draws it. - /// SeString text macro representation. - /// Newline characters will be normalized to . - /// Wrapping width. If a non-positive number is provided, then the remainder of the width - /// will be used. - /// This function is experimental. Report any issues to GitHub issues or to Discord #dalamud-dev channel. - /// The function definition is stable; only in the next API version a function may be removed. - public static void CompileSeStringWrapped(string text, float wrapWidth = 0) => - Service.Get().CompileAndDrawWrapped( - text, - new() { WrapWidth = wrapWidth > 0 ? wrapWidth : null }); - /// Draws a SeString. /// SeString to draw. /// Initial rendering style. @@ -209,9 +188,10 @@ public static void CompileSeStringWrapped(string text, float wrapWidth = 0) => /// Interaction result of the rendered text. /// This function is experimental. Report any issues to GitHub issues or to Discord #dalamud-dev channel. /// The function definition is stable; only in the next API version a function may be removed. + [Experimental("SeStringRenderer")] public static SeStringDrawResult SeStringWrapped( ReadOnlySpan sss, - in SeStringDrawParams style = default, + scoped in SeStringDrawParams style = default, ImGuiId imGuiId = default, ImGuiButtonFlags buttonFlags = ImGuiButtonFlags.MouseButtonDefault) => Service.Get().Draw(sss, style, imGuiId, buttonFlags); @@ -225,9 +205,10 @@ public static SeStringDrawResult SeStringWrapped( /// Interaction result of the rendered text. /// This function is experimental. Report any issues to GitHub issues or to Discord #dalamud-dev channel. /// The function definition is stable; only in the next API version a function may be removed. + [Experimental("SeStringRenderer")] public static SeStringDrawResult CompileSeStringWrapped( string text, - in SeStringDrawParams style, + scoped in SeStringDrawParams style, ImGuiId imGuiId = default, ImGuiButtonFlags buttonFlags = ImGuiButtonFlags.MouseButtonDefault) => Service.Get().CompileAndDrawWrapped(text, style, imGuiId, buttonFlags);