From 02e1f2502e5031e5c2897c04d931643014c99390 Mon Sep 17 00:00:00 2001 From: goat Date: Fri, 4 Aug 2023 19:36:09 +0200 Subject: [PATCH] refactor: move Dalamud.Interface utils into main assembly, warnings pass --- .editorconfig | 2 +- Dalamud.Interface/Dalamud.Interface.csproj | 17 ---- Dalamud.Interface/ImGuiTable.cs | 41 --------- Dalamud.Interface/InterfaceHelpers.cs | 6 -- Dalamud.sln | 14 --- Dalamud/Dalamud.csproj | 1 - Dalamud/Data/DataManager.cs | 18 ++-- Dalamud/Game/Config/GameConfig.cs | 3 +- Dalamud/Game/Config/GameConfigSection.cs | 13 ++- Dalamud/Game/Gui/GameGui.cs | 1 + Dalamud/GlobalSuppressions.cs | 19 ++++ Dalamud/GlobalUsings.cs | 1 + .../ImGuiComponents.ColorPickerWithPalette.cs | 1 + Dalamud/Interface/DragDrop/DragDropInterop.cs | 4 +- Dalamud/Interface/DragDrop/DragDropManager.cs | 2 + Dalamud/Interface/DragDrop/DragDropTarget.cs | 6 +- .../Interface/DragDrop/IDragDropManager.cs | 13 ++- .../Interface/GameFonts/GameFontManager.cs | 3 +- .../ImGuiFileDialog/FileDialog.UI.cs | 1 + .../Interface/Internal/DalamudInterface.cs | 3 +- .../Interface/Internal/InterfaceManager.cs | 1 + .../Notifications/NotificationManager.cs | 1 + Dalamud/Interface/Internal/TextureManager.cs | 2 +- Dalamud/Interface/Internal/UiDebug.cs | 1 + .../Internal/Windows/BranchSwitcherWindow.cs | 1 + .../Internal/Windows/ChangelogWindow.cs | 1 + .../Internal/Windows/ComponentDemoWindow.cs | 1 + .../Internal/Windows/ConsoleWindow.cs | 1 + .../Internal/Windows/Data/DataWindow.cs | 1 + .../Windows/Data/Widgets/DataShareWidget.cs | 3 +- .../Data/Widgets/FontAwesomeTestWidget.cs | 4 +- .../Data/Widgets/NetworkMonitorWidget.cs | 3 +- .../Windows/Data/Widgets/TargetWidget.cs | 1 + .../Data/Widgets/TaskSchedulerWidget.cs | 1 + .../Windows/Data/Widgets/TexWidget.cs | 4 +- .../Windows/Data/Widgets/ToastWidget.cs | 1 + .../Windows/GamepadModeNotifierWindow.cs | 1 + .../PluginInstaller/PluginInstallerWindow.cs | 3 +- .../PluginInstaller/ProfileManagerWidget.cs | 3 +- .../Internal/Windows/ProfilerWindow.cs | 1 + .../Windows/SelfTest/SelfTestWindow.cs | 1 + .../Internal/Windows/Settings/SettingsTab.cs | 5 +- .../Windows/Settings/SettingsWindow.cs | 3 +- .../Windows/Settings/Tabs/SettingsTabAbout.cs | 3 +- .../Windows/Settings/Tabs/SettingsTabDtr.cs | 1 + .../Settings/Tabs/SettingsTabExperimental.cs | 1 + .../Windows/Settings/Tabs/SettingsTabLook.cs | 1 + .../Settings/Widgets/ButtonSettingsEntry.cs | 1 + .../Widgets/DevPluginsSettingsEntry.cs | 3 +- .../Settings/Widgets/GapSettingsEntry.cs | 1 + .../Settings/Widgets/HintSettingsEntry.cs | 1 + .../Widgets/LanguageChooserSettingsEntry.cs | 1 + .../Settings/Widgets/SettingsEntry{T}.cs | 3 +- .../Widgets/ThirdRepoSettingsEntry.cs | 3 +- .../Windows/StyleEditor/StyleEditorWindow.cs | 1 + .../Internal/Windows/TitleScreenMenuWindow.cs | 3 +- .../Interface/Utility}/ImGuiClip.cs | 8 +- .../{ => Utility}/ImGuiExtensions.cs | 3 +- .../Interface/{ => Utility}/ImGuiHelpers.cs | 6 +- Dalamud/Interface/Utility/ImGuiTable.cs | 56 ++++++++++++ .../Interface/Utility}/Raii/Color.cs | 17 ++-- .../Interface/Utility}/Raii/EndObjects.cs | 42 +++++---- .../Interface/Utility}/Raii/Font.cs | 14 +-- .../Interface/Utility}/Raii/Id.cs | 16 ++-- .../Interface/Utility}/Raii/Indent.cs | 6 +- .../Interface/Utility}/Raii/Style.cs | 19 ++-- .../Interface/Utility}/Table/Column.cs | 5 +- .../Interface/Utility}/Table/ColumnFlags.cs | 13 +-- .../Interface/Utility}/Table/ColumnSelect.cs | 22 ++--- .../Interface/Utility}/Table/ColumnString.cs | 17 ++-- .../Interface/Utility}/Table/Table.cs | 88 ++++++++++--------- Dalamud/Interface/Windowing/Window.cs | 2 + Dalamud/Plugin/Internal/PluginManager.cs | 17 ++-- Dalamud/Plugin/Services/IGameConfig.cs | 6 +- Dalamud/Plugin/Services/IKeyState.cs | 5 +- .../Utility}/ArrayExtensions.cs | 9 +- Dalamud/Utility/FuzzyMatcher.cs | 68 ++++++++------ .../Utility}/StableInsertionSortExtension.cs | 20 ++++- Dalamud/Utility/Util.cs | 1 + targets/Dalamud.Plugin.targets | 1 - 80 files changed, 394 insertions(+), 303 deletions(-) delete mode 100644 Dalamud.Interface/Dalamud.Interface.csproj delete mode 100644 Dalamud.Interface/ImGuiTable.cs delete mode 100644 Dalamud.Interface/InterfaceHelpers.cs create mode 100644 Dalamud/GlobalUsings.cs rename {Dalamud.Interface => Dalamud/Interface/Utility}/ImGuiClip.cs (97%) rename Dalamud/Interface/{ => Utility}/ImGuiExtensions.cs (98%) rename Dalamud/Interface/{ => Utility}/ImGuiHelpers.cs (99%) create mode 100644 Dalamud/Interface/Utility/ImGuiTable.cs rename {Dalamud.Interface => Dalamud/Interface/Utility}/Raii/Color.cs (83%) rename {Dalamud.Interface => Dalamud/Interface/Utility}/Raii/EndObjects.cs (94%) rename {Dalamud.Interface => Dalamud/Interface/Utility}/Raii/Font.cs (81%) rename {Dalamud.Interface => Dalamud/Interface/Utility}/Raii/Id.cs (82%) rename {Dalamud.Interface => Dalamud/Interface/Utility}/Raii/Indent.cs (91%) rename {Dalamud.Interface => Dalamud/Interface/Utility}/Raii/Style.cs (95%) rename {Dalamud.Interface => Dalamud/Interface/Utility}/Table/Column.cs (92%) rename {Dalamud.Interface => Dalamud/Interface/Utility}/Table/ColumnFlags.cs (89%) rename {Dalamud.Interface => Dalamud/Interface/Utility}/Table/ColumnSelect.cs (66%) rename {Dalamud.Interface => Dalamud/Interface/Utility}/Table/ColumnString.cs (75%) rename {Dalamud.Interface => Dalamud/Interface/Utility}/Table/Table.cs (64%) rename {Dalamud.Interface => Dalamud/Utility}/ArrayExtensions.cs (80%) rename {Dalamud.Interface => Dalamud/Utility}/StableInsertionSortExtension.cs (57%) diff --git a/.editorconfig b/.editorconfig index 829de8f05..0e4f800e0 100644 --- a/.editorconfig +++ b/.editorconfig @@ -35,7 +35,7 @@ dotnet_naming_rule.private_instance_fields_rule.severity = warning dotnet_naming_rule.private_instance_fields_rule.style = lower_camel_case_style dotnet_naming_rule.private_instance_fields_rule.symbols = private_instance_fields_symbols dotnet_naming_rule.private_static_fields_rule.severity = warning -dotnet_naming_rule.private_static_fields_rule.style = upper_camel_case_style +dotnet_naming_rule.private_static_fields_rule.style = lower_camel_case_style dotnet_naming_rule.private_static_fields_rule.symbols = private_static_fields_symbols dotnet_naming_rule.private_static_readonly_rule.severity = warning dotnet_naming_rule.private_static_readonly_rule.style = upper_camel_case_style diff --git a/Dalamud.Interface/Dalamud.Interface.csproj b/Dalamud.Interface/Dalamud.Interface.csproj deleted file mode 100644 index 1dd8468be..000000000 --- a/Dalamud.Interface/Dalamud.Interface.csproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - net7.0-windows - x64 - x64;AnyCPU - enable - enable - true - Dalamud.Interface - - - - - - - diff --git a/Dalamud.Interface/ImGuiTable.cs b/Dalamud.Interface/ImGuiTable.cs deleted file mode 100644 index 5ea6a2c9a..000000000 --- a/Dalamud.Interface/ImGuiTable.cs +++ /dev/null @@ -1,41 +0,0 @@ -using Dalamud.Interface.Raii; -using ImGuiNET; - -namespace Dalamud.Interface; - -public static class ImGuiTable -{ - // Draw a simple table with the given data using the drawRow action. - // Headers and thus columns and column count are defined by columnTitles. - public static void DrawTable(string label, IEnumerable data, Action drawRow, ImGuiTableFlags flags = ImGuiTableFlags.None, - params string[] columnTitles) - { - if (columnTitles.Length == 0) - return; - - using var table = ImRaii.Table(label, columnTitles.Length, flags); - if (!table) - return; - - foreach (var title in columnTitles) - { - ImGui.TableNextColumn(); - ImGui.TableHeader(title); - } - - foreach (var datum in data) - { - ImGui.TableNextRow(); - drawRow(datum); - } - } - - // Draw a simple table with the given data using the drawRow action inside a collapsing header. - // Headers and thus columns and column count are defined by columnTitles. - public static void DrawTabbedTable(string label, IEnumerable data, Action drawRow, ImGuiTableFlags flags = ImGuiTableFlags.None, - params string[] columnTitles) - { - if (ImGui.CollapsingHeader(label)) - DrawTable($"{label}##Table", data, drawRow, flags, columnTitles); - } -} diff --git a/Dalamud.Interface/InterfaceHelpers.cs b/Dalamud.Interface/InterfaceHelpers.cs deleted file mode 100644 index 26f09bedb..000000000 --- a/Dalamud.Interface/InterfaceHelpers.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Dalamud.Interface; - -public static class InterfaceHelpers -{ - public static float GlobalScale = 1.0f; -} diff --git a/Dalamud.sln b/Dalamud.sln index 20442e52d..443f38496 100644 --- a/Dalamud.sln +++ b/Dalamud.sln @@ -38,8 +38,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FFXIVClientStructs.InteropS EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DalamudCrashHandler", "DalamudCrashHandler\DalamudCrashHandler.vcxproj", "{317A264C-920B-44A1-8A34-F3A6827B0705}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dalamud.Interface", "Dalamud.Interface\Dalamud.Interface.csproj", "{757C997D-AA58-4241-8299-243C56514917}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -204,18 +202,6 @@ Global {317A264C-920B-44A1-8A34-F3A6827B0705}.Release|x64.Build.0 = Release|x64 {317A264C-920B-44A1-8A34-F3A6827B0705}.Release|x86.ActiveCfg = Release|x64 {317A264C-920B-44A1-8A34-F3A6827B0705}.Release|x86.Build.0 = Release|x64 - {757C997D-AA58-4241-8299-243C56514917}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {757C997D-AA58-4241-8299-243C56514917}.Debug|Any CPU.Build.0 = Debug|Any CPU - {757C997D-AA58-4241-8299-243C56514917}.Debug|x64.ActiveCfg = Debug|Any CPU - {757C997D-AA58-4241-8299-243C56514917}.Debug|x64.Build.0 = Debug|Any CPU - {757C997D-AA58-4241-8299-243C56514917}.Debug|x86.ActiveCfg = Debug|Any CPU - {757C997D-AA58-4241-8299-243C56514917}.Debug|x86.Build.0 = Debug|Any CPU - {757C997D-AA58-4241-8299-243C56514917}.Release|Any CPU.ActiveCfg = Release|Any CPU - {757C997D-AA58-4241-8299-243C56514917}.Release|Any CPU.Build.0 = Release|Any CPU - {757C997D-AA58-4241-8299-243C56514917}.Release|x64.ActiveCfg = Release|Any CPU - {757C997D-AA58-4241-8299-243C56514917}.Release|x64.Build.0 = Release|Any CPU - {757C997D-AA58-4241-8299-243C56514917}.Release|x86.ActiveCfg = Release|Any CPU - {757C997D-AA58-4241-8299-243C56514917}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Dalamud/Dalamud.csproj b/Dalamud/Dalamud.csproj index 6e6a01fa9..b147dc961 100644 --- a/Dalamud/Dalamud.csproj +++ b/Dalamud/Dalamud.csproj @@ -87,7 +87,6 @@ - diff --git a/Dalamud/Data/DataManager.cs b/Dalamud/Data/DataManager.cs index 8c8a2de29..fb167283f 100644 --- a/Dalamud/Data/DataManager.cs +++ b/Dalamud/Data/DataManager.cs @@ -1,27 +1,19 @@ -using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.IO; using System.Threading; -using Dalamud.Interface.Internal; using Dalamud.IoC; using Dalamud.IoC.Internal; using Dalamud.Plugin.Services; -using Dalamud.Utility; using Dalamud.Utility.Timing; -using ImGuiScene; using JetBrains.Annotations; using Lumina; using Lumina.Data; -using Lumina.Data.Files; -using Lumina.Data.Parsing.Tex.Buffers; using Lumina.Excel; using Newtonsoft.Json; using Serilog; -using SharpDX.DXGI; namespace Dalamud.Data; @@ -131,11 +123,6 @@ public sealed class DataManager : IDisposable, IServiceType, IDataManager } } - /// - /// Gets a value indicating whether Game Data is ready to be read. - /// - internal bool IsDataReady { get; private set; } - /// public ClientLanguage Language { get; private set; } @@ -155,6 +142,11 @@ public sealed class DataManager : IDisposable, IServiceType, IDataManager /// public bool HasModifiedGameDataFiles { get; private set; } + /// + /// Gets a value indicating whether Game Data is ready to be read. + /// + internal bool IsDataReady { get; private set; } + #region Lumina Wrappers /// diff --git a/Dalamud/Game/Config/GameConfig.cs b/Dalamud/Game/Config/GameConfig.cs index dfdb8b5d2..49d24c2a5 100644 --- a/Dalamud/Game/Config/GameConfig.cs +++ b/Dalamud/Game/Config/GameConfig.cs @@ -1,5 +1,4 @@ -using System; -using Dalamud.Hooking; +using Dalamud.Hooking; using Dalamud.IoC; using Dalamud.IoC.Internal; using Dalamud.Plugin.Services; diff --git a/Dalamud/Game/Config/GameConfigSection.cs b/Dalamud/Game/Config/GameConfigSection.cs index 6c87ad3cf..ea79a7fc8 100644 --- a/Dalamud/Game/Config/GameConfigSection.cs +++ b/Dalamud/Game/Config/GameConfigSection.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Concurrent; +using System.Collections.Concurrent; using System.Diagnostics; using Dalamud.Memory; @@ -18,11 +17,6 @@ public class GameConfigSection private readonly ConcurrentDictionary indexMap = new(); private readonly ConcurrentDictionary enumMap = new(); - /// - /// Event which is fired when a game config option is changed within the section. - /// - public event EventHandler Changed; - /// /// Initializes a new instance of the class. /// @@ -54,6 +48,11 @@ public class GameConfigSection /// Pointer to unmanaged ConfigBase. internal unsafe delegate ConfigBase* GetConfigBaseDelegate(); + /// + /// Event which is fired when a game config option is changed within the section. + /// + public event EventHandler? Changed; + /// /// Gets the number of config entries contained within the section. /// Some entries may be empty with no data. diff --git a/Dalamud/Game/Gui/GameGui.cs b/Dalamud/Game/Gui/GameGui.cs index 0235bef5a..3954954a3 100644 --- a/Dalamud/Game/Gui/GameGui.cs +++ b/Dalamud/Game/Gui/GameGui.cs @@ -5,6 +5,7 @@ using System.Runtime.InteropServices; using Dalamud.Game.Text.SeStringHandling.Payloads; using Dalamud.Hooking; using Dalamud.Interface; +using Dalamud.Interface.Utility; using Dalamud.IoC; using Dalamud.IoC.Internal; using Dalamud.Plugin.Services; diff --git a/Dalamud/GlobalSuppressions.cs b/Dalamud/GlobalSuppressions.cs index 7426ed5c8..1b869295b 100644 --- a/Dalamud/GlobalSuppressions.cs +++ b/Dalamud/GlobalSuppressions.cs @@ -15,3 +15,22 @@ using System.Diagnostics.CodeAnalysis; [assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1127:Generic type constraints should be on their own line", Justification = "I like this better")] [assembly: SuppressMessage("StyleCop.CSharp.SpacingRules", "SA1028:Code should not contain trailing whitespace", Justification = "I don't care anymore")] [assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1633:File should have header", Justification = "We don't do those yet")] +[assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1117:ParametersMustBeOnSameLineOrSeparateLines", Justification = "I don't care anymore")] +[assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1117:ParametersMustBeOnSameLineOrSeparateLines", Justification = "I don't care anymore")] +[assembly: SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1407:ArithmeticExpressionsMustDeclarePrecedence", Justification = "I don't care anymore")] +[assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1116:SplitParametersMustStartOnLineAfterDeclaration", Justification = "Reviewed.")] + +// ImRAII stuff +[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", Justification = "Reviewed.", Scope = "namespaceanddescendants", Target = "Dalamud.Interface.Utility.Raii")] +[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1601:PartialElementsMustBeDocumented", Justification = "Reviewed.", Scope = "namespaceanddescendants", Target = "Dalamud.Interface.Utility.Raii")] +[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", Justification = "Reviewed.", Scope = "namespaceanddescendants", Target = "Dalamud.Interface.Utility.Table")] +[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1601:PartialElementsMustBeDocumented", Justification = "Reviewed.", Scope = "namespaceanddescendants", Target = "Dalamud.Interface.Utility.Table")] +[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", Justification = "Reviewed.", Scope = "type", Target = "Dalamud.Interface.Utility.ImGuiClip")] +[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1601:PartialElementsMustBeDocumented", Justification = "Reviewed.", Scope = "type", Target = "Dalamud.Interface.Utility.ImGuiClip")] +[assembly: SuppressMessage("StyleCop.CSharp.SpacingRules", "SA1025:CodeMustNotContainMultipleWhitespaceInARow", Justification = "Reviewed.", Scope = "namespaceanddescendants", Target = "Dalamud.Interface.Utility")] +[assembly: SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate", Justification = "Reviewed.", Scope = "namespaceanddescendants", Target = "Dalamud.Interface.Utility.Raii")] +[assembly: SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate", Justification = "Reviewed.", Scope = "namespaceanddescendants", Target = "Dalamud.Interface.Utility.Table")] +[assembly: SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1201:ElementsMustAppearInTheCorrectOrder", Justification = "Reviewed.", Scope = "namespaceanddescendants", Target = "Dalamud.Interface.Utility.Raii")] +[assembly: SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1201:ElementsMustAppearInTheCorrectOrder", Justification = "Reviewed.", Scope = "namespaceanddescendants", Target = "Dalamud.Interface.Utility.Table")] +[assembly: SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1202:ElementsMustBeOrderedByAccess", Justification = "Reviewed.", Scope = "namespaceanddescendants", Target = "Dalamud.Interface.Utility.Raii")] +[assembly: SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1202:ElementsMustBeOrderedByAccess", Justification = "Reviewed.", Scope = "namespaceanddescendants", Target = "Dalamud.Interface.Utility.Table")] diff --git a/Dalamud/GlobalUsings.cs b/Dalamud/GlobalUsings.cs new file mode 100644 index 000000000..062a3f981 --- /dev/null +++ b/Dalamud/GlobalUsings.cs @@ -0,0 +1 @@ +global using System; diff --git a/Dalamud/Interface/Components/ImGuiComponents.ColorPickerWithPalette.cs b/Dalamud/Interface/Components/ImGuiComponents.ColorPickerWithPalette.cs index e9db345cb..aa707aecb 100644 --- a/Dalamud/Interface/Components/ImGuiComponents.ColorPickerWithPalette.cs +++ b/Dalamud/Interface/Components/ImGuiComponents.ColorPickerWithPalette.cs @@ -1,5 +1,6 @@ using System.Numerics; +using Dalamud.Interface.Utility; using ImGuiNET; namespace Dalamud.Interface.Components; diff --git a/Dalamud/Interface/DragDrop/DragDropInterop.cs b/Dalamud/Interface/DragDrop/DragDropInterop.cs index 28a2644a5..6edd5642e 100644 --- a/Dalamud/Interface/DragDrop/DragDropInterop.cs +++ b/Dalamud/Interface/DragDrop/DragDropInterop.cs @@ -34,9 +34,9 @@ internal partial class DragDropManager internal struct POINTL { [ComAliasName("Microsoft.VisualStudio.OLE.Interop.LONG")] - public int x; + public int X; [ComAliasName("Microsoft.VisualStudio.OLE.Interop.LONG")] - public int y; + public int Y; } private static class DragDropInterop diff --git a/Dalamud/Interface/DragDrop/DragDropManager.cs b/Dalamud/Interface/DragDrop/DragDropManager.cs index 8336edc11..e8641035f 100644 --- a/Dalamud/Interface/DragDrop/DragDropManager.cs +++ b/Dalamud/Interface/DragDrop/DragDropManager.cs @@ -16,7 +16,9 @@ namespace Dalamud.Interface.DragDrop; /// [PluginInterface] [ServiceManager.EarlyLoadedService] +#pragma warning disable SA1015 [ResolveVia] +#pragma warning restore SA1015 internal partial class DragDropManager : IDisposable, IDragDropManager, IServiceType { private nint windowHandlePtr = nint.Zero; diff --git a/Dalamud/Interface/DragDrop/DragDropTarget.cs b/Dalamud/Interface/DragDrop/DragDropTarget.cs index 5e7166fb3..628f1100c 100644 --- a/Dalamud/Interface/DragDrop/DragDropTarget.cs +++ b/Dalamud/Interface/DragDrop/DragDropTarget.cs @@ -51,7 +51,7 @@ internal partial class DragDropManager : DragDropManager.IDropTarget this.Extensions = this.Files.Select(Path.GetExtension).Where(p => !p.IsNullOrEmpty()).Distinct().ToHashSet(); } - Log.Debug("[DragDrop] Entering external Drag and Drop with {KeyState} at {PtX}, {PtY} and with {N} files.", (DragDropInterop.ModifierKeys)grfKeyState, pt.x, pt.y, this.Files.Count + this.Directories.Count); + Log.Debug("[DragDrop] Entering external Drag and Drop with {KeyState} at {PtX}, {PtY} and with {N} files.", (DragDropInterop.ModifierKeys)grfKeyState, pt.X, pt.Y, this.Files.Count + this.Directories.Count); } /// Invoked every windows update-frame as long as the drag and drop process keeps hovering over an FFXIV-related viewport. @@ -67,7 +67,7 @@ internal partial class DragDropManager : DragDropManager.IDropTarget this.lastUpdateFrame = frame; this.lastKeyState = UpdateIo((DragDropInterop.ModifierKeys)grfKeyState, false); pdwEffect &= (uint)DragDropInterop.DropEffects.Copy; - Log.Verbose("[DragDrop] External Drag and Drop with {KeyState} at {PtX}, {PtY}.", (DragDropInterop.ModifierKeys)grfKeyState, pt.x, pt.y); + Log.Verbose("[DragDrop] External Drag and Drop with {KeyState} at {PtX}, {PtY}.", (DragDropInterop.ModifierKeys)grfKeyState, pt.X, pt.Y); } } @@ -101,7 +101,7 @@ internal partial class DragDropManager : DragDropManager.IDropTarget pdwEffect = 0; } - Log.Debug("[DragDrop] Dropping {N} files with {KeyState} at {PtX}, {PtY}.", this.Files.Count + this.Directories.Count, (DragDropInterop.ModifierKeys)grfKeyState, pt.x, pt.y); + Log.Debug("[DragDrop] Dropping {N} files with {KeyState} at {PtX}, {PtY}.", this.Files.Count + this.Directories.Count, (DragDropInterop.ModifierKeys)grfKeyState, pt.X, pt.Y); } private static DragDropInterop.ModifierKeys UpdateIo(DragDropInterop.ModifierKeys keys, bool entering) diff --git a/Dalamud/Interface/DragDrop/IDragDropManager.cs b/Dalamud/Interface/DragDrop/IDragDropManager.cs index 736c8af24..a8a0d63b0 100644 --- a/Dalamud/Interface/DragDrop/IDragDropManager.cs +++ b/Dalamud/Interface/DragDrop/IDragDropManager.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; namespace Dalamud.Interface.DragDrop; @@ -23,20 +22,20 @@ public interface IDragDropManager /// Gets the list of directories currently being dragged from an external application over any of the games viewports. public IReadOnlyList Directories { get; } - /// Create an ImGui drag & drop source that is active only if anything is being dragged from an external source. - /// The label used for the drag & drop payload. + /// Create an ImGui drag and drop source that is active only if anything is being dragged from an external source. + /// The label used for the drag and drop payload. /// A function returning whether the current status is relevant for this source. Checked before creating the source but only if something is being dragged. public void CreateImGuiSource(string label, Func validityCheck) => this.CreateImGuiSource(label, validityCheck, _ => false); - /// Create an ImGui drag & drop source that is active only if anything is being dragged from an external source. - /// The label used for the drag & drop payload. + /// Create an ImGui drag and drop source that is active only if anything is being dragged from an external source. + /// The label used for the drag and drop payload. /// A function returning whether the current status is relevant for this source. Checked before creating the source but only if something is being dragged. /// Executes ImGui functions to build a tooltip. Should return true if it creates any tooltip and false otherwise. If multiple sources are active, only the first non-empty tooltip type drawn in a frame will be used. public void CreateImGuiSource(string label, Func validityCheck, Func tooltipBuilder); - /// Create an ImGui drag & drop target on the last ImGui object. - /// The label used for the drag & drop payload. + /// Create an ImGui drag and drop target on the last ImGui object. + /// The label used for the drag and drop payload. /// On success, contains the list of file paths dropped onto the target. /// On success, contains the list of directory paths dropped onto the target. /// True if items were dropped onto the target this frame, false otherwise. diff --git a/Dalamud/Interface/GameFonts/GameFontManager.cs b/Dalamud/Interface/GameFonts/GameFontManager.cs index ad0e47273..d8130f692 100644 --- a/Dalamud/Interface/GameFonts/GameFontManager.cs +++ b/Dalamud/Interface/GameFonts/GameFontManager.cs @@ -9,12 +9,13 @@ using System.Threading.Tasks; using Dalamud.Data; using Dalamud.Game; using Dalamud.Interface.Internal; +using Dalamud.Interface.Utility; using Dalamud.Utility.Timing; using ImGuiNET; using Lumina.Data.Files; using Serilog; -using static Dalamud.Interface.ImGuiHelpers; +using static Dalamud.Interface.Utility.ImGuiHelpers; namespace Dalamud.Interface.GameFonts; diff --git a/Dalamud/Interface/ImGuiFileDialog/FileDialog.UI.cs b/Dalamud/Interface/ImGuiFileDialog/FileDialog.UI.cs index d3be8da95..0dd1410d5 100644 --- a/Dalamud/Interface/ImGuiFileDialog/FileDialog.UI.cs +++ b/Dalamud/Interface/ImGuiFileDialog/FileDialog.UI.cs @@ -3,6 +3,7 @@ using System.IO; using System.Linq; using System.Numerics; +using Dalamud.Interface.Utility; using Dalamud.Utility; using ImGuiNET; diff --git a/Dalamud/Interface/Internal/DalamudInterface.cs b/Dalamud/Interface/Internal/DalamudInterface.cs index 479297c20..a7f7e6209 100644 --- a/Dalamud/Interface/Internal/DalamudInterface.cs +++ b/Dalamud/Interface/Internal/DalamudInterface.cs @@ -21,8 +21,9 @@ using Dalamud.Interface.Internal.Windows.PluginInstaller; using Dalamud.Interface.Internal.Windows.SelfTest; using Dalamud.Interface.Internal.Windows.Settings; using Dalamud.Interface.Internal.Windows.StyleEditor; -using Dalamud.Interface.Raii; using Dalamud.Interface.Style; +using Dalamud.Interface.Utility; +using Dalamud.Interface.Utility.Raii; using Dalamud.Interface.Windowing; using Dalamud.Logging; using Dalamud.Logging.Internal; diff --git a/Dalamud/Interface/Internal/InterfaceManager.cs b/Dalamud/Interface/Internal/InterfaceManager.cs index ad1e514c7..794b6c6b3 100644 --- a/Dalamud/Interface/Internal/InterfaceManager.cs +++ b/Dalamud/Interface/Internal/InterfaceManager.cs @@ -19,6 +19,7 @@ using Dalamud.Interface.GameFonts; using Dalamud.Interface.Internal.ManagedAsserts; using Dalamud.Interface.Internal.Notifications; using Dalamud.Interface.Style; +using Dalamud.Interface.Utility; using Dalamud.Interface.Windowing; using Dalamud.Utility; using Dalamud.Utility.Timing; diff --git a/Dalamud/Interface/Internal/Notifications/NotificationManager.cs b/Dalamud/Interface/Internal/Notifications/NotificationManager.cs index e941db7a4..9d20d6d3e 100644 --- a/Dalamud/Interface/Internal/Notifications/NotificationManager.cs +++ b/Dalamud/Interface/Internal/Notifications/NotificationManager.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Numerics; using Dalamud.Interface.Colors; +using Dalamud.Interface.Utility; using Dalamud.Utility; using ImGuiNET; diff --git a/Dalamud/Interface/Internal/TextureManager.cs b/Dalamud/Interface/Internal/TextureManager.cs index de5613eed..983ae9963 100644 --- a/Dalamud/Interface/Internal/TextureManager.cs +++ b/Dalamud/Interface/Internal/TextureManager.cs @@ -215,7 +215,7 @@ internal class TextureManager : IDisposable, IServiceType, ITextureSubstitutionP (int)TexFile.TextureFormat.BppShift); var (dxgiFormat, conversion) = TexFile.GetDxgiFormatFromTextureFormat(file.Header.Format, false); - if (conversion != TexFile.DxgiFormatConversion.NoConversion || !im.SupportsDxgiFormat((Format)dxgiFormat)) + if (conversion != TexFile.DxgiFormatConversion.NoConversion || !this.im.SupportsDxgiFormat((Format)dxgiFormat)) { dxgiFormat = (int)Format.B8G8R8A8_UNorm; buffer = buffer.Filter(0, 0, TexFile.TextureFormat.B8G8R8A8); diff --git a/Dalamud/Interface/Internal/UiDebug.cs b/Dalamud/Interface/Internal/UiDebug.cs index d1e7a6b78..b1f27828c 100644 --- a/Dalamud/Interface/Internal/UiDebug.cs +++ b/Dalamud/Interface/Internal/UiDebug.cs @@ -4,6 +4,7 @@ using System.Runtime.InteropServices; using Dalamud.Game; using Dalamud.Game.Gui; +using Dalamud.Interface.Utility; using Dalamud.Utility; using FFXIVClientStructs.FFXIV.Component.GUI; using ImGuiNET; diff --git a/Dalamud/Interface/Internal/Windows/BranchSwitcherWindow.cs b/Dalamud/Interface/Internal/Windows/BranchSwitcherWindow.cs index b599fb58f..05d8d04e8 100644 --- a/Dalamud/Interface/Internal/Windows/BranchSwitcherWindow.cs +++ b/Dalamud/Interface/Internal/Windows/BranchSwitcherWindow.cs @@ -8,6 +8,7 @@ using System.Threading.Tasks; using Dalamud.Configuration.Internal; using Dalamud.Interface.Colors; +using Dalamud.Interface.Utility; using Dalamud.Interface.Windowing; using Dalamud.Networking.Http; using ImGuiNET; diff --git a/Dalamud/Interface/Internal/Windows/ChangelogWindow.cs b/Dalamud/Interface/Internal/Windows/ChangelogWindow.cs index 05854210e..e61cb400b 100644 --- a/Dalamud/Interface/Internal/Windows/ChangelogWindow.cs +++ b/Dalamud/Interface/Internal/Windows/ChangelogWindow.cs @@ -3,6 +3,7 @@ using System.IO; using System.Numerics; using Dalamud.Interface.Colors; +using Dalamud.Interface.Utility; using Dalamud.Interface.Windowing; using Dalamud.Utility; using ImGuiNET; diff --git a/Dalamud/Interface/Internal/Windows/ComponentDemoWindow.cs b/Dalamud/Interface/Internal/Windows/ComponentDemoWindow.cs index 638b30e66..8c5458557 100644 --- a/Dalamud/Interface/Internal/Windows/ComponentDemoWindow.cs +++ b/Dalamud/Interface/Internal/Windows/ComponentDemoWindow.cs @@ -6,6 +6,7 @@ using Dalamud.Interface.Animation; using Dalamud.Interface.Animation.EasingFunctions; using Dalamud.Interface.Colors; using Dalamud.Interface.Components; +using Dalamud.Interface.Utility; using Dalamud.Interface.Windowing; using ImGuiNET; diff --git a/Dalamud/Interface/Internal/Windows/ConsoleWindow.cs b/Dalamud/Interface/Internal/Windows/ConsoleWindow.cs index 872fdcd37..bcbad1a21 100644 --- a/Dalamud/Interface/Internal/Windows/ConsoleWindow.cs +++ b/Dalamud/Interface/Internal/Windows/ConsoleWindow.cs @@ -10,6 +10,7 @@ using Dalamud.Configuration.Internal; using Dalamud.Game.Command; using Dalamud.Interface.Colors; using Dalamud.Interface.Components; +using Dalamud.Interface.Utility; using Dalamud.Interface.Windowing; using Dalamud.Logging.Internal; using Dalamud.Plugin.Internal; diff --git a/Dalamud/Interface/Internal/Windows/Data/DataWindow.cs b/Dalamud/Interface/Internal/Windows/Data/DataWindow.cs index 9d8dc1e93..54ff4a5ca 100644 --- a/Dalamud/Interface/Internal/Windows/Data/DataWindow.cs +++ b/Dalamud/Interface/Internal/Windows/Data/DataWindow.cs @@ -5,6 +5,7 @@ using System.Numerics; using Dalamud.Game.Gui; using Dalamud.Interface.Components; +using Dalamud.Interface.Utility; using Dalamud.Interface.Windowing; using ImGuiNET; using Serilog; diff --git a/Dalamud/Interface/Internal/Windows/Data/Widgets/DataShareWidget.cs b/Dalamud/Interface/Internal/Windows/Data/Widgets/DataShareWidget.cs index ec7124042..dc18dbd55 100644 --- a/Dalamud/Interface/Internal/Windows/Data/Widgets/DataShareWidget.cs +++ b/Dalamud/Interface/Internal/Windows/Data/Widgets/DataShareWidget.cs @@ -1,4 +1,5 @@ -using Dalamud.Plugin.Ipc.Internal; +using Dalamud.Interface.Utility; +using Dalamud.Plugin.Ipc.Internal; using ImGuiNET; namespace Dalamud.Interface.Internal.Windows.Data; diff --git a/Dalamud/Interface/Internal/Windows/Data/Widgets/FontAwesomeTestWidget.cs b/Dalamud/Interface/Internal/Windows/Data/Widgets/FontAwesomeTestWidget.cs index 1ed5e9e83..e4284a98e 100644 --- a/Dalamud/Interface/Internal/Windows/Data/Widgets/FontAwesomeTestWidget.cs +++ b/Dalamud/Interface/Internal/Windows/Data/Widgets/FontAwesomeTestWidget.cs @@ -1,8 +1,8 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using System.Numerics; +using Dalamud.Interface.Utility; using ImGuiNET; namespace Dalamud.Interface.Internal.Windows.Data; diff --git a/Dalamud/Interface/Internal/Windows/Data/Widgets/NetworkMonitorWidget.cs b/Dalamud/Interface/Internal/Windows/Data/Widgets/NetworkMonitorWidget.cs index 01d0b1759..6f19404ad 100644 --- a/Dalamud/Interface/Internal/Windows/Data/Widgets/NetworkMonitorWidget.cs +++ b/Dalamud/Interface/Internal/Windows/Data/Widgets/NetworkMonitorWidget.cs @@ -7,7 +7,8 @@ using System.Text.RegularExpressions; using Dalamud.Data; using Dalamud.Game.Network; -using Dalamud.Interface.Raii; +using Dalamud.Interface.Utility; +using Dalamud.Interface.Utility.Raii; using Dalamud.Memory; using ImGuiNET; diff --git a/Dalamud/Interface/Internal/Windows/Data/Widgets/TargetWidget.cs b/Dalamud/Interface/Internal/Windows/Data/Widgets/TargetWidget.cs index 57fd03300..64ae041ed 100644 --- a/Dalamud/Interface/Internal/Windows/Data/Widgets/TargetWidget.cs +++ b/Dalamud/Interface/Internal/Windows/Data/Widgets/TargetWidget.cs @@ -1,5 +1,6 @@ using Dalamud.Game.ClientState; using Dalamud.Game.ClientState.Objects; +using Dalamud.Interface.Utility; using Dalamud.Utility; using ImGuiNET; diff --git a/Dalamud/Interface/Internal/Windows/Data/Widgets/TaskSchedulerWidget.cs b/Dalamud/Interface/Internal/Windows/Data/Widgets/TaskSchedulerWidget.cs index 7d91cd154..59ca617f5 100644 --- a/Dalamud/Interface/Internal/Windows/Data/Widgets/TaskSchedulerWidget.cs +++ b/Dalamud/Interface/Internal/Windows/Data/Widgets/TaskSchedulerWidget.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using Dalamud.Game; using Dalamud.Interface.Colors; +using Dalamud.Interface.Utility; using Dalamud.Logging.Internal; using ImGuiNET; using Serilog; diff --git a/Dalamud/Interface/Internal/Windows/Data/Widgets/TexWidget.cs b/Dalamud/Interface/Internal/Windows/Data/Widgets/TexWidget.cs index 5ad5868c3..cc38a58ae 100644 --- a/Dalamud/Interface/Internal/Windows/Data/Widgets/TexWidget.cs +++ b/Dalamud/Interface/Internal/Windows/Data/Widgets/TexWidget.cs @@ -1,8 +1,8 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.IO; using System.Numerics; +using Dalamud.Interface.Utility; using Dalamud.Plugin.Services; using ImGuiNET; using ImGuiScene; diff --git a/Dalamud/Interface/Internal/Windows/Data/Widgets/ToastWidget.cs b/Dalamud/Interface/Internal/Windows/Data/Widgets/ToastWidget.cs index c75230e73..7f020acae 100644 --- a/Dalamud/Interface/Internal/Windows/Data/Widgets/ToastWidget.cs +++ b/Dalamud/Interface/Internal/Windows/Data/Widgets/ToastWidget.cs @@ -1,6 +1,7 @@ using System.Numerics; using Dalamud.Game.Gui.Toast; +using Dalamud.Interface.Utility; using ImGuiNET; namespace Dalamud.Interface.Internal.Windows.Data; diff --git a/Dalamud/Interface/Internal/Windows/GamepadModeNotifierWindow.cs b/Dalamud/Interface/Internal/Windows/GamepadModeNotifierWindow.cs index e95c510d3..ff5af1556 100644 --- a/Dalamud/Interface/Internal/Windows/GamepadModeNotifierWindow.cs +++ b/Dalamud/Interface/Internal/Windows/GamepadModeNotifierWindow.cs @@ -1,6 +1,7 @@ using System.Numerics; using CheapLoc; +using Dalamud.Interface.Utility; using Dalamud.Interface.Windowing; using ImGuiNET; diff --git a/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs b/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs index 35fa40013..2b0e27673 100644 --- a/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs +++ b/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs @@ -15,8 +15,9 @@ using Dalamud.Game.Command; using Dalamud.Interface.Colors; using Dalamud.Interface.Components; using Dalamud.Interface.Internal.Notifications; -using Dalamud.Interface.Raii; using Dalamud.Interface.Style; +using Dalamud.Interface.Utility; +using Dalamud.Interface.Utility.Raii; using Dalamud.Interface.Windowing; using Dalamud.Logging.Internal; using Dalamud.Plugin; diff --git a/Dalamud/Interface/Internal/Windows/PluginInstaller/ProfileManagerWidget.cs b/Dalamud/Interface/Internal/Windows/PluginInstaller/ProfileManagerWidget.cs index 301e43473..6c17a8522 100644 --- a/Dalamud/Interface/Internal/Windows/PluginInstaller/ProfileManagerWidget.cs +++ b/Dalamud/Interface/Internal/Windows/PluginInstaller/ProfileManagerWidget.cs @@ -8,7 +8,8 @@ using Dalamud.Configuration.Internal; using Dalamud.Interface.Colors; using Dalamud.Interface.Components; using Dalamud.Interface.Internal.Notifications; -using Dalamud.Interface.Raii; +using Dalamud.Interface.Utility; +using Dalamud.Interface.Utility.Raii; using Dalamud.Plugin.Internal; using Dalamud.Plugin.Internal.Profiles; using Dalamud.Utility; diff --git a/Dalamud/Interface/Internal/Windows/ProfilerWindow.cs b/Dalamud/Interface/Internal/Windows/ProfilerWindow.cs index 2d0f54912..16f253da9 100644 --- a/Dalamud/Interface/Internal/Windows/ProfilerWindow.cs +++ b/Dalamud/Interface/Internal/Windows/ProfilerWindow.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Numerics; using Dalamud.Interface.Colors; +using Dalamud.Interface.Utility; using Dalamud.Interface.Windowing; using Dalamud.Utility.Numerics; using Dalamud.Utility.Timing; diff --git a/Dalamud/Interface/Internal/Windows/SelfTest/SelfTestWindow.cs b/Dalamud/Interface/Internal/Windows/SelfTest/SelfTestWindow.cs index 3e25b6f5a..4a7bb0413 100644 --- a/Dalamud/Interface/Internal/Windows/SelfTest/SelfTestWindow.cs +++ b/Dalamud/Interface/Internal/Windows/SelfTest/SelfTestWindow.cs @@ -6,6 +6,7 @@ using System.Numerics; using Dalamud.Interface.Colors; using Dalamud.Interface.Components; using Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps; +using Dalamud.Interface.Utility; using Dalamud.Interface.Windowing; using Dalamud.Logging.Internal; using ImGuiNET; diff --git a/Dalamud/Interface/Internal/Windows/Settings/SettingsTab.cs b/Dalamud/Interface/Internal/Windows/Settings/SettingsTab.cs index 16b7749cb..a3ece0d04 100644 --- a/Dalamud/Interface/Internal/Windows/Settings/SettingsTab.cs +++ b/Dalamud/Interface/Internal/Windows/Settings/SettingsTab.cs @@ -1,5 +1,6 @@ -using System; -using System.Diagnostics.CodeAnalysis; +using System.Diagnostics.CodeAnalysis; + +using Dalamud.Interface.Utility; namespace Dalamud.Interface.Internal.Windows.Settings; diff --git a/Dalamud/Interface/Internal/Windows/Settings/SettingsWindow.cs b/Dalamud/Interface/Internal/Windows/Settings/SettingsWindow.cs index 97d9eac5c..4f77c0502 100644 --- a/Dalamud/Interface/Internal/Windows/Settings/SettingsWindow.cs +++ b/Dalamud/Interface/Internal/Windows/Settings/SettingsWindow.cs @@ -5,7 +5,8 @@ using CheapLoc; using Dalamud.Configuration.Internal; using Dalamud.Interface.Colors; using Dalamud.Interface.Internal.Windows.Settings.Tabs; -using Dalamud.Interface.Raii; +using Dalamud.Interface.Utility; +using Dalamud.Interface.Utility.Raii; using Dalamud.Interface.Windowing; using Dalamud.Plugin.Internal; using Dalamud.Utility; diff --git a/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabAbout.cs b/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabAbout.cs index 325d0b8b7..9a7236f2f 100644 --- a/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabAbout.cs +++ b/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabAbout.cs @@ -8,7 +8,8 @@ using System.Numerics; using CheapLoc; using Dalamud.Game.Gui; using Dalamud.Interface.GameFonts; -using Dalamud.Interface.Raii; +using Dalamud.Interface.Utility; +using Dalamud.Interface.Utility.Raii; using Dalamud.Plugin.Internal; using Dalamud.Utility; using FFXIVClientStructs.FFXIV.Client.Game.UI; diff --git a/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabDtr.cs b/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabDtr.cs index 85cb8219f..7dd0fa5d1 100644 --- a/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabDtr.cs +++ b/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabDtr.cs @@ -8,6 +8,7 @@ using Dalamud.Configuration.Internal; using Dalamud.Game.Gui.Dtr; using Dalamud.Interface.Colors; using Dalamud.Interface.Components; +using Dalamud.Interface.Utility; using ImGuiNET; namespace Dalamud.Interface.Internal.Windows.Settings.Tabs; diff --git a/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabExperimental.cs b/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabExperimental.cs index 62981f4a2..0a0e2528d 100644 --- a/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabExperimental.cs +++ b/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabExperimental.cs @@ -6,6 +6,7 @@ using Dalamud.Configuration.Internal; using Dalamud.Interface.Colors; using Dalamud.Interface.Internal.Windows.PluginInstaller; using Dalamud.Interface.Internal.Windows.Settings.Widgets; +using Dalamud.Interface.Utility; using Dalamud.Plugin.Internal; using Dalamud.Utility; diff --git a/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabLook.cs b/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabLook.cs index 3e801a8c3..b34a13cc5 100644 --- a/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabLook.cs +++ b/Dalamud/Interface/Internal/Windows/Settings/Tabs/SettingsTabLook.cs @@ -5,6 +5,7 @@ using CheapLoc; using Dalamud.Configuration.Internal; using Dalamud.Interface.Colors; using Dalamud.Interface.Internal.Windows.Settings.Widgets; +using Dalamud.Interface.Utility; using Dalamud.Utility; using ImGuiNET; using Serilog; diff --git a/Dalamud/Interface/Internal/Windows/Settings/Widgets/ButtonSettingsEntry.cs b/Dalamud/Interface/Internal/Windows/Settings/Widgets/ButtonSettingsEntry.cs index 9c635fb99..6adddbc82 100644 --- a/Dalamud/Interface/Internal/Windows/Settings/Widgets/ButtonSettingsEntry.cs +++ b/Dalamud/Interface/Internal/Windows/Settings/Widgets/ButtonSettingsEntry.cs @@ -2,6 +2,7 @@ using System.Diagnostics.CodeAnalysis; using Dalamud.Interface.Colors; +using Dalamud.Interface.Utility; using ImGuiNET; namespace Dalamud.Interface.Internal.Windows.Settings.Widgets; diff --git a/Dalamud/Interface/Internal/Windows/Settings/Widgets/DevPluginsSettingsEntry.cs b/Dalamud/Interface/Internal/Windows/Settings/Widgets/DevPluginsSettingsEntry.cs index 3e73454f3..55deb61bc 100644 --- a/Dalamud/Interface/Internal/Windows/Settings/Widgets/DevPluginsSettingsEntry.cs +++ b/Dalamud/Interface/Internal/Windows/Settings/Widgets/DevPluginsSettingsEntry.cs @@ -11,7 +11,8 @@ using Dalamud.Configuration; using Dalamud.Configuration.Internal; using Dalamud.Interface.Colors; using Dalamud.Interface.Components; -using Dalamud.Interface.Raii; +using Dalamud.Interface.Utility; +using Dalamud.Interface.Utility.Raii; using Dalamud.Plugin.Internal; using ImGuiNET; diff --git a/Dalamud/Interface/Internal/Windows/Settings/Widgets/GapSettingsEntry.cs b/Dalamud/Interface/Internal/Windows/Settings/Widgets/GapSettingsEntry.cs index bc5c2fd0a..1db3c4756 100644 --- a/Dalamud/Interface/Internal/Windows/Settings/Widgets/GapSettingsEntry.cs +++ b/Dalamud/Interface/Internal/Windows/Settings/Widgets/GapSettingsEntry.cs @@ -1,5 +1,6 @@ using System.Diagnostics.CodeAnalysis; +using Dalamud.Interface.Utility; using ImGuiNET; namespace Dalamud.Interface.Internal.Windows.Settings.Widgets; diff --git a/Dalamud/Interface/Internal/Windows/Settings/Widgets/HintSettingsEntry.cs b/Dalamud/Interface/Internal/Windows/Settings/Widgets/HintSettingsEntry.cs index d1eb43c1f..3edd3ae1d 100644 --- a/Dalamud/Interface/Internal/Windows/Settings/Widgets/HintSettingsEntry.cs +++ b/Dalamud/Interface/Internal/Windows/Settings/Widgets/HintSettingsEntry.cs @@ -2,6 +2,7 @@ using System.Numerics; using Dalamud.Interface.Colors; +using Dalamud.Interface.Utility; namespace Dalamud.Interface.Internal.Windows.Settings.Widgets; diff --git a/Dalamud/Interface/Internal/Windows/Settings/Widgets/LanguageChooserSettingsEntry.cs b/Dalamud/Interface/Internal/Windows/Settings/Widgets/LanguageChooserSettingsEntry.cs index 0bb373576..85f8a826f 100644 --- a/Dalamud/Interface/Internal/Windows/Settings/Widgets/LanguageChooserSettingsEntry.cs +++ b/Dalamud/Interface/Internal/Windows/Settings/Widgets/LanguageChooserSettingsEntry.cs @@ -7,6 +7,7 @@ using System.Linq; using CheapLoc; using Dalamud.Configuration.Internal; using Dalamud.Interface.Colors; +using Dalamud.Interface.Utility; using ImGuiNET; namespace Dalamud.Interface.Internal.Windows.Settings.Widgets; diff --git a/Dalamud/Interface/Internal/Windows/Settings/Widgets/SettingsEntry{T}.cs b/Dalamud/Interface/Internal/Windows/Settings/Widgets/SettingsEntry{T}.cs index 83be6a052..dcbb42089 100644 --- a/Dalamud/Interface/Internal/Windows/Settings/Widgets/SettingsEntry{T}.cs +++ b/Dalamud/Interface/Internal/Windows/Settings/Widgets/SettingsEntry{T}.cs @@ -7,7 +7,8 @@ using System.Linq; using Dalamud.Configuration.Internal; using Dalamud.Interface.Colors; -using Dalamud.Interface.Raii; +using Dalamud.Interface.Utility; +using Dalamud.Interface.Utility.Raii; using Dalamud.Utility; using ImGuiNET; diff --git a/Dalamud/Interface/Internal/Windows/Settings/Widgets/ThirdRepoSettingsEntry.cs b/Dalamud/Interface/Internal/Windows/Settings/Widgets/ThirdRepoSettingsEntry.cs index be2e34a57..114de1148 100644 --- a/Dalamud/Interface/Internal/Windows/Settings/Widgets/ThirdRepoSettingsEntry.cs +++ b/Dalamud/Interface/Internal/Windows/Settings/Widgets/ThirdRepoSettingsEntry.cs @@ -10,7 +10,8 @@ using Dalamud.Configuration; using Dalamud.Configuration.Internal; using Dalamud.Interface.Colors; using Dalamud.Interface.Components; -using Dalamud.Interface.Raii; +using Dalamud.Interface.Utility; +using Dalamud.Interface.Utility.Raii; using Dalamud.Plugin.Internal; using ImGuiNET; diff --git a/Dalamud/Interface/Internal/Windows/StyleEditor/StyleEditorWindow.cs b/Dalamud/Interface/Internal/Windows/StyleEditor/StyleEditorWindow.cs index 419361b3b..3a3e871b0 100644 --- a/Dalamud/Interface/Internal/Windows/StyleEditor/StyleEditorWindow.cs +++ b/Dalamud/Interface/Internal/Windows/StyleEditor/StyleEditorWindow.cs @@ -10,6 +10,7 @@ using Dalamud.Data; using Dalamud.Interface.Colors; using Dalamud.Interface.Components; using Dalamud.Interface.Style; +using Dalamud.Interface.Utility; using Dalamud.Interface.Windowing; using Dalamud.Utility; using ImGuiNET; diff --git a/Dalamud/Interface/Internal/Windows/TitleScreenMenuWindow.cs b/Dalamud/Interface/Internal/Windows/TitleScreenMenuWindow.cs index 10180f0c3..f11f124cc 100644 --- a/Dalamud/Interface/Internal/Windows/TitleScreenMenuWindow.cs +++ b/Dalamud/Interface/Internal/Windows/TitleScreenMenuWindow.cs @@ -9,7 +9,8 @@ using Dalamud.Game; using Dalamud.Game.ClientState; using Dalamud.Game.Gui; using Dalamud.Interface.Animation.EasingFunctions; -using Dalamud.Interface.Raii; +using Dalamud.Interface.Utility; +using Dalamud.Interface.Utility.Raii; using Dalamud.Interface.Windowing; using ImGuiNET; using ImGuiScene; diff --git a/Dalamud.Interface/ImGuiClip.cs b/Dalamud/Interface/Utility/ImGuiClip.cs similarity index 97% rename from Dalamud.Interface/ImGuiClip.cs rename to Dalamud/Interface/Utility/ImGuiClip.cs index dc1845a35..e36970885 100644 --- a/Dalamud.Interface/ImGuiClip.cs +++ b/Dalamud/Interface/Utility/ImGuiClip.cs @@ -1,8 +1,11 @@ +using System.Collections.Generic; +using System.Linq; using System.Numerics; -using Dalamud.Interface.Raii; + +using Dalamud.Interface.Utility.Raii; using ImGuiNET; -namespace Dalamud.Interface; +namespace Dalamud.Interface.Utility; public static class ImGuiClip { @@ -132,7 +135,6 @@ public static class ImGuiClip return ~idx; } - // Draw non-random-access data that gets filtered without storing state. // Use GetNecessarySkips first and use its return value for skips. // checkFilter should return true for items that should be displayed and false for those that should be skipped. diff --git a/Dalamud/Interface/ImGuiExtensions.cs b/Dalamud/Interface/Utility/ImGuiExtensions.cs similarity index 98% rename from Dalamud/Interface/ImGuiExtensions.cs rename to Dalamud/Interface/Utility/ImGuiExtensions.cs index be1b99430..21a0d3747 100644 --- a/Dalamud/Interface/ImGuiExtensions.cs +++ b/Dalamud/Interface/Utility/ImGuiExtensions.cs @@ -1,10 +1,9 @@ -using System; using System.Numerics; using System.Text; using ImGuiNET; -namespace Dalamud.Interface; +namespace Dalamud.Interface.Utility; /// /// Class containing various extensions to ImGui, aiding with building custom widgets. diff --git a/Dalamud/Interface/ImGuiHelpers.cs b/Dalamud/Interface/Utility/ImGuiHelpers.cs similarity index 99% rename from Dalamud/Interface/ImGuiHelpers.cs rename to Dalamud/Interface/Utility/ImGuiHelpers.cs index 2356d90e2..dbb873edf 100644 --- a/Dalamud/Interface/ImGuiHelpers.cs +++ b/Dalamud/Interface/Utility/ImGuiHelpers.cs @@ -1,15 +1,14 @@ -using System; using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Numerics; using Dalamud.Game.ClientState.Keys; -using Dalamud.Interface.Raii; +using Dalamud.Interface.Utility.Raii; using ImGuiNET; using ImGuiScene; -namespace Dalamud.Interface; +namespace Dalamud.Interface.Utility; /// /// Class containing various helper methods for use with ImGui inside Dalamud. @@ -300,7 +299,6 @@ public static class ImGuiHelpers internal static void NewFrame() { GlobalScale = ImGui.GetIO().FontGlobalScale; - InterfaceHelpers.GlobalScale = GlobalScale; } /// diff --git a/Dalamud/Interface/Utility/ImGuiTable.cs b/Dalamud/Interface/Utility/ImGuiTable.cs new file mode 100644 index 000000000..c74bc0a2f --- /dev/null +++ b/Dalamud/Interface/Utility/ImGuiTable.cs @@ -0,0 +1,56 @@ +using System.Collections.Generic; + +using Dalamud.Interface.Utility.Raii; +using ImGuiNET; + +namespace Dalamud.Interface.Utility; + +#pragma warning disable SA1618 // GenericTypeParametersMustBeDocumented +#pragma warning disable SA1611 // ElementParametersMustBeDocumented + +/// +/// Helpers for drawing tables. +/// +public static class ImGuiTable +{ + /// + /// Draw a simple table with the given data using the drawRow action. + /// Headers and thus columns and column count are defined by columnTitles. + /// + public static void DrawTable(string label, IEnumerable data, Action drawRow, ImGuiTableFlags flags = ImGuiTableFlags.None, + params string[] columnTitles) + { + if (columnTitles.Length == 0) + return; + + using var table = ImRaii.Table(label, columnTitles.Length, flags); + if (!table) + return; + + foreach (var title in columnTitles) + { + ImGui.TableNextColumn(); + ImGui.TableHeader(title); + } + + foreach (var datum in data) + { + ImGui.TableNextRow(); + drawRow(datum); + } + } + + /// + /// Draw a simple table with the given data using the drawRow action inside a collapsing header. + /// Headers and thus columns and column count are defined by columnTitles. + /// + public static void DrawTabbedTable(string label, IEnumerable data, Action drawRow, ImGuiTableFlags flags = ImGuiTableFlags.None, + params string[] columnTitles) + { + if (ImGui.CollapsingHeader(label)) + DrawTable($"{label}##Table", data, drawRow, flags, columnTitles); + } +} + +#pragma warning restore SA1611 // ElementParametersMustBeDocumented +#pragma warning restore SA1618 // GenericTypeParametersMustBeDocumented diff --git a/Dalamud.Interface/Raii/Color.cs b/Dalamud/Interface/Utility/Raii/Color.cs similarity index 83% rename from Dalamud.Interface/Raii/Color.cs rename to Dalamud/Interface/Utility/Raii/Color.cs index 388e6e737..3cf93b65c 100644 --- a/Dalamud.Interface/Raii/Color.cs +++ b/Dalamud/Interface/Utility/Raii/Color.cs @@ -1,7 +1,10 @@ +using System.Collections.Generic; +using System.Linq; using System.Numerics; + using ImGuiNET; -namespace Dalamud.Interface.Raii; +namespace Dalamud.Interface.Utility.Raii; // Push an arbitrary amount of colors into an object that are all popped when it is disposed. // If condition is false, no color is pushed. @@ -26,7 +29,7 @@ public static partial class ImRaii public sealed class Color : IDisposable { internal static readonly List<(ImGuiCol, uint)> Stack = new(); - private int _count; + private int count; public Color Push(ImGuiCol idx, uint color, bool condition = true) { @@ -34,7 +37,7 @@ public static partial class ImRaii { Stack.Add((idx, ImGui.GetColorU32(idx))); ImGui.PushStyleColor(idx, color); - ++this._count; + ++this.count; } return this; @@ -46,7 +49,7 @@ public static partial class ImRaii { Stack.Add((idx, ImGui.GetColorU32(idx))); ImGui.PushStyleColor(idx, color); - ++this._count; + ++this.count; } return this; @@ -54,13 +57,13 @@ public static partial class ImRaii public void Pop(int num = 1) { - num = Math.Min(num, this._count); - this._count -= num; + num = Math.Min(num, this.count); + this.count -= num; ImGui.PopStyleColor(num); Stack.RemoveRange(Stack.Count - num, num); } public void Dispose() - => this.Pop(this._count); + => this.Pop(this.count); } } diff --git a/Dalamud.Interface/Raii/EndObjects.cs b/Dalamud/Interface/Utility/Raii/EndObjects.cs similarity index 94% rename from Dalamud.Interface/Raii/EndObjects.cs rename to Dalamud/Interface/Utility/Raii/EndObjects.cs index 032f09621..3f2a016b3 100644 --- a/Dalamud.Interface/Raii/EndObjects.cs +++ b/Dalamud/Interface/Utility/Raii/EndObjects.cs @@ -1,13 +1,14 @@ using System.Numerics; + using ImGuiNET; -namespace Dalamud.Interface.Raii; +namespace Dalamud.Interface.Utility.Raii; // Most ImGui widgets with IDisposable interface that automatically destroys them // when created with using variables. public static partial class ImRaii { - private static int _disabledCount = 0; + private static int disabledCount = 0; public static IEndObject Child(string strId) => new EndUnconditionally(ImGui.EndChild, ImGui.BeginChild(strId)); @@ -120,7 +121,7 @@ public static partial class ImRaii public static IEndObject Disabled() { ImGui.BeginDisabled(); - ++_disabledCount; + ++disabledCount; return DisabledEnd(); } @@ -130,24 +131,24 @@ public static partial class ImRaii return new EndConditionally(Nop, false); ImGui.BeginDisabled(); - ++_disabledCount; + ++disabledCount; return DisabledEnd(); } public static IEndObject Enabled() { - var oldCount = _disabledCount; + var oldCount = disabledCount; if (oldCount == 0) return new EndConditionally(Nop, false); void Restore() { - _disabledCount += oldCount; + disabledCount += oldCount; while (--oldCount >= 0) ImGui.BeginDisabled(); } - for (; _disabledCount > 0; --_disabledCount) + for (; disabledCount > 0; --disabledCount) ImGui.EndDisabled(); return new EndUnconditionally(Restore, true); @@ -156,7 +157,7 @@ public static partial class ImRaii private static IEndObject DisabledEnd() => new EndUnconditionally(() => { - --_disabledCount; + --disabledCount; ImGui.EndDisabled(); }, true); @@ -173,6 +174,11 @@ public static partial class ImRaii return new EndUnconditionally(Widget.EndFramedGroup, true); } */ + + // Used to avoid tree pops when flag for no push is set. + private static void Nop() + { + } // Exported interface for RAII. public interface IEndObject : IDisposable @@ -203,7 +209,9 @@ public static partial class ImRaii private struct EndUnconditionally : IEndObject { private Action EndAction { get; } + public bool Success { get; } + public bool Disposed { get; private set; } public EndUnconditionally(Action endAction, bool success) @@ -226,16 +234,18 @@ public static partial class ImRaii // Use end-function only on success. private struct EndConditionally : IEndObject { - private Action EndAction { get; } - public bool Success { get; } - public bool Disposed { get; private set; } - public EndConditionally(Action endAction, bool success) { this.EndAction = endAction; - this.Success = success; - this.Disposed = false; + this.Success = success; + this.Disposed = false; } + + public bool Success { get; } + + public bool Disposed { get; private set; } + + private Action EndAction { get; } public void Dispose() { @@ -247,8 +257,4 @@ public static partial class ImRaii this.Disposed = true; } } - - // Used to avoid tree pops when flag for no push is set. - private static void Nop() - { } } diff --git a/Dalamud.Interface/Raii/Font.cs b/Dalamud/Interface/Utility/Raii/Font.cs similarity index 81% rename from Dalamud.Interface/Raii/Font.cs rename to Dalamud/Interface/Utility/Raii/Font.cs index cdecf457c..2d11bb071 100644 --- a/Dalamud.Interface/Raii/Font.cs +++ b/Dalamud/Interface/Utility/Raii/Font.cs @@ -1,6 +1,6 @@ using ImGuiNET; -namespace Dalamud.Interface.Raii; +namespace Dalamud.Interface.Utility.Raii; // Push an arbitrary amount of fonts into an object that are all popped when it is disposed. // If condition is false, no font is pushed. @@ -18,10 +18,10 @@ public static partial class ImRaii internal static int FontPushCounter = 0; internal static ImFontPtr DefaultPushed; - private int _count; + private int count; public Font() - => this._count = 0; + => this.count = 0; public Font Push(ImFontPtr font, bool condition = true) { @@ -30,7 +30,7 @@ public static partial class ImRaii if (FontPushCounter++ == 0) DefaultPushed = ImGui.GetFont(); ImGui.PushFont(font); - ++this._count; + ++this.count; } return this; @@ -38,14 +38,14 @@ public static partial class ImRaii public void Pop(int num = 1) { - num = Math.Min(num, this._count); - this._count -= num; + num = Math.Min(num, this.count); + this.count -= num; FontPushCounter -= num; while (num-- > 0) ImGui.PopFont(); } public void Dispose() - => this.Pop(this._count); + => this.Pop(this.count); } } diff --git a/Dalamud.Interface/Raii/Id.cs b/Dalamud/Interface/Utility/Raii/Id.cs similarity index 82% rename from Dalamud.Interface/Raii/Id.cs rename to Dalamud/Interface/Utility/Raii/Id.cs index 1248b92f3..51c6438c4 100644 --- a/Dalamud.Interface/Raii/Id.cs +++ b/Dalamud/Interface/Utility/Raii/Id.cs @@ -1,6 +1,6 @@ using ImGuiNET; -namespace Dalamud.Interface.Raii; +namespace Dalamud.Interface.Utility.Raii; // Push an arbitrary amount of ids into an object that are all popped when it is disposed. // If condition is false, no id is pushed. @@ -17,14 +17,14 @@ public static partial class ImRaii public sealed class Id : IDisposable { - private int _count; + private int count; public Id Push(string id, bool condition = true) { if (condition) { ImGui.PushID(id); - ++this._count; + ++this.count; } return this; @@ -35,7 +35,7 @@ public static partial class ImRaii if (condition) { ImGui.PushID(id); - ++this._count; + ++this.count; } return this; @@ -46,7 +46,7 @@ public static partial class ImRaii if (condition) { ImGui.PushID(id); - ++this._count; + ++this.count; } return this; @@ -54,13 +54,13 @@ public static partial class ImRaii public void Pop(int num = 1) { - num = Math.Min(num, this._count); - this._count -= num; + num = Math.Min(num, this.count); + this.count -= num; while (num-- > 0) ImGui.PopID(); } public void Dispose() - => this.Pop(this._count); + => this.Pop(this.count); } } diff --git a/Dalamud.Interface/Raii/Indent.cs b/Dalamud/Interface/Utility/Raii/Indent.cs similarity index 91% rename from Dalamud.Interface/Raii/Indent.cs rename to Dalamud/Interface/Utility/Raii/Indent.cs index 99eab8783..3c8f0f1da 100644 --- a/Dalamud.Interface/Raii/Indent.cs +++ b/Dalamud/Interface/Utility/Raii/Indent.cs @@ -1,6 +1,6 @@ using ImGuiNET; -namespace Dalamud.Interface.Raii; +namespace Dalamud.Interface.Utility.Raii; public static partial class ImRaii { @@ -19,7 +19,7 @@ public static partial class ImRaii if (condition) { if (scaled) - indent *= InterfaceHelpers.GlobalScale; + indent *= ImGuiHelpers.GlobalScale; IndentInternal(indent); this.Indentation += indent; @@ -43,7 +43,7 @@ public static partial class ImRaii public void Pop(float indent, bool scaled = true) { if (scaled) - indent *= InterfaceHelpers.GlobalScale; + indent *= ImGuiHelpers.GlobalScale; IndentInternal(-indent); this.Indentation -= indent; diff --git a/Dalamud.Interface/Raii/Style.cs b/Dalamud/Interface/Utility/Raii/Style.cs similarity index 95% rename from Dalamud.Interface/Raii/Style.cs rename to Dalamud/Interface/Utility/Raii/Style.cs index 2f1fea538..82f51bf88 100644 --- a/Dalamud.Interface/Raii/Style.cs +++ b/Dalamud/Interface/Utility/Raii/Style.cs @@ -1,7 +1,10 @@ +using System.Collections.Generic; +using System.Linq; using System.Numerics; + using ImGuiNET; -namespace Dalamud.Interface.Raii; +namespace Dalamud.Interface.Utility.Raii; // Push an arbitrary amount of styles into an object that are all popped when it is disposed. // If condition is false, no style is pushed. @@ -17,7 +20,7 @@ public static partial class ImRaii // Push styles that revert all current style changes made temporarily. public static Style DefaultStyle() { - var ret = new Style(); + var ret = new Style(); var reverseStack = Style.Stack.GroupBy(p => p.Item1).Select(p => (p.Key, p.First().Item2)).ToArray(); foreach (var (idx, val) in reverseStack) { @@ -34,7 +37,7 @@ public static partial class ImRaii { internal static readonly List<(ImGuiStyleVar, Vector2)> Stack = new(); - private int _count; + private int count; [System.Diagnostics.Conditional("DEBUG")] private static void CheckStyleIdx(ImGuiStyleVar idx, Type type) @@ -115,7 +118,7 @@ public static partial class ImRaii CheckStyleIdx(idx, typeof(float)); Stack.Add((idx, GetStyle(idx))); ImGui.PushStyleVar(idx, value); - ++this._count; + ++this.count; return this; } @@ -128,20 +131,20 @@ public static partial class ImRaii CheckStyleIdx(idx, typeof(Vector2)); Stack.Add((idx, GetStyle(idx))); ImGui.PushStyleVar(idx, value); - ++this._count; + ++this.count; return this; } public void Pop(int num = 1) { - num = Math.Min(num, this._count); - this._count -= num; + num = Math.Min(num, this.count); + this.count -= num; ImGui.PopStyleVar(num); Stack.RemoveRange(Stack.Count - num, num); } public void Dispose() - => this.Pop(this._count); + => this.Pop(this.count); } } diff --git a/Dalamud.Interface/Table/Column.cs b/Dalamud/Interface/Utility/Table/Column.cs similarity index 92% rename from Dalamud.Interface/Table/Column.cs rename to Dalamud/Interface/Utility/Table/Column.cs index 7460ec189..412ba87dc 100644 --- a/Dalamud.Interface/Table/Column.cs +++ b/Dalamud/Interface/Utility/Table/Column.cs @@ -1,6 +1,6 @@ using ImGuiNET; -namespace Dalamud.Interface.Table; +namespace Dalamud.Interface.Utility.Table; public class Column { @@ -27,7 +27,8 @@ public class Column => 0; public virtual void DrawColumn(TItem item, int idx) - { } + { + } public int CompareInv(TItem lhs, TItem rhs) => this.Compare(rhs, lhs); diff --git a/Dalamud.Interface/Table/ColumnFlags.cs b/Dalamud/Interface/Utility/Table/ColumnFlags.cs similarity index 89% rename from Dalamud.Interface/Table/ColumnFlags.cs rename to Dalamud/Interface/Utility/Table/ColumnFlags.cs index 815ddcf76..24670adfc 100644 --- a/Dalamud.Interface/Table/ColumnFlags.cs +++ b/Dalamud/Interface/Utility/Table/ColumnFlags.cs @@ -1,7 +1,9 @@ -using ImGuiNET; -using ImRaii = Dalamud.Interface.Raii.ImRaii; +using System.Collections.Generic; -namespace Dalamud.Interface.Table; +using Dalamud.Interface.Utility.Raii; +using ImGuiNET; + +namespace Dalamud.Interface.Utility.Table; public class ColumnFlags : Column where T : struct, Enum { @@ -17,13 +19,14 @@ public class ColumnFlags : Column where T : struct, Enum => default; protected virtual void SetValue(T value, bool enable) - { } + { + } public override bool DrawFilter() { using var id = ImRaii.PushId(this.FilterLabel); using var style = ImRaii.PushStyle(ImGuiStyleVar.FrameRounding, 0); - ImGui.SetNextItemWidth(-Table.ArrowWidth * InterfaceHelpers.GlobalScale); + ImGui.SetNextItemWidth(-Table.ArrowWidth * ImGuiHelpers.GlobalScale); var all = this.FilterValue.HasFlag(this.AllFlags); using var color = ImRaii.PushColor(ImGuiCol.FrameBg, 0x803030A0, !all); using var combo = ImRaii.Combo(string.Empty, this.Label, ImGuiComboFlags.NoArrowButton); diff --git a/Dalamud.Interface/Table/ColumnSelect.cs b/Dalamud/Interface/Utility/Table/ColumnSelect.cs similarity index 66% rename from Dalamud.Interface/Table/ColumnSelect.cs rename to Dalamud/Interface/Utility/Table/ColumnSelect.cs index 5ef276b06..fb463700c 100644 --- a/Dalamud.Interface/Table/ColumnSelect.cs +++ b/Dalamud/Interface/Utility/Table/ColumnSelect.cs @@ -1,7 +1,9 @@ -using ImGuiNET; -using ImRaii = Dalamud.Interface.Raii.ImRaii; +using System.Collections.Generic; -namespace Dalamud.Interface.Table; +using Dalamud.Interface.Utility.Raii; +using ImGuiNET; + +namespace Dalamud.Interface.Utility.Table; public class ColumnSelect : Column where T : struct, Enum, IEquatable { @@ -18,26 +20,26 @@ public class ColumnSelect : Column where T : struct, Enum, IEqu => this.FilterValue = value; public T FilterValue; - protected int Idx = -1; + protected int idx = -1; public override bool DrawFilter() { using var id = ImRaii.PushId(this.FilterLabel); using var style = ImRaii.PushStyle(ImGuiStyleVar.FrameRounding, 0); - ImGui.SetNextItemWidth(-Table.ArrowWidth * InterfaceHelpers.GlobalScale); - using var combo = ImRaii.Combo(string.Empty, this.Idx < 0 ? this.Label : this.Names[this.Idx]); - if(!combo) + ImGui.SetNextItemWidth(-Table.ArrowWidth * ImGuiHelpers.GlobalScale); + using var combo = ImRaii.Combo(string.Empty, this.idx < 0 ? this.Label : this.Names[this.idx]); + if (!combo) return false; var ret = false; for (var i = 0; i < this.Names.Length; ++i) { if (this.FilterValue.Equals(this.Values[i])) - this.Idx = i; - if (!ImGui.Selectable(this.Names[i], this.Idx == i) || this.Idx == i) + this.idx = i; + if (!ImGui.Selectable(this.Names[i], this.idx == i) || this.idx == i) continue; - this.Idx = i; + this.idx = i; this.SetValue(this.Values[i]); ret = true; } diff --git a/Dalamud.Interface/Table/ColumnString.cs b/Dalamud/Interface/Utility/Table/ColumnString.cs similarity index 75% rename from Dalamud.Interface/Table/ColumnString.cs rename to Dalamud/Interface/Utility/Table/ColumnString.cs index dcd43b23c..3f9d2df91 100644 --- a/Dalamud.Interface/Table/ColumnString.cs +++ b/Dalamud/Interface/Utility/Table/ColumnString.cs @@ -1,8 +1,9 @@ using System.Text.RegularExpressions; -using Dalamud.Interface.Raii; + +using Dalamud.Interface.Utility.Raii; using ImGuiNET; -namespace Dalamud.Interface.Table; +namespace Dalamud.Interface.Utility.Table; public class ColumnString : Column { @@ -10,7 +11,7 @@ public class ColumnString : Column => this.Flags &= ~ImGuiTableColumnFlags.NoResize; public string FilterValue = string.Empty; - protected Regex? FilterRegex; + protected Regex? filterRegex; public virtual string ToName(TItem item) => item!.ToString() ?? string.Empty; @@ -22,7 +23,7 @@ public class ColumnString : Column { using var style = ImRaii.PushStyle(ImGuiStyleVar.FrameRounding, 0); - ImGui.SetNextItemWidth(-Table.ArrowWidth * InterfaceHelpers.GlobalScale); + ImGui.SetNextItemWidth(-Table.ArrowWidth * ImGuiHelpers.GlobalScale); var tmp = this.FilterValue; if (!ImGui.InputTextWithHint(this.FilterLabel, this.Label, ref tmp, 256) || tmp == this.FilterValue) return false; @@ -30,11 +31,11 @@ public class ColumnString : Column this.FilterValue = tmp; try { - this.FilterRegex = new Regex(this.FilterValue, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant); + this.filterRegex = new Regex(this.FilterValue, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant); } catch { - this.FilterRegex = null; + this.filterRegex = null; } return true; @@ -46,10 +47,10 @@ public class ColumnString : Column if (this.FilterValue.Length == 0) return true; - return this.FilterRegex?.IsMatch(name) ?? name.Contains(this.FilterValue, StringComparison.OrdinalIgnoreCase); + return this.filterRegex?.IsMatch(name) ?? name.Contains(this.FilterValue, StringComparison.OrdinalIgnoreCase); } - public override void DrawColumn(TItem item, int _) + public override void DrawColumn(TItem item, int idx) { ImGui.TextUnformatted(this.ToName(item)); } diff --git a/Dalamud.Interface/Table/Table.cs b/Dalamud/Interface/Utility/Table/Table.cs similarity index 64% rename from Dalamud.Interface/Table/Table.cs rename to Dalamud/Interface/Utility/Table/Table.cs index 74fb0bc5c..86653e834 100644 --- a/Dalamud.Interface/Table/Table.cs +++ b/Dalamud/Interface/Utility/Table/Table.cs @@ -1,8 +1,12 @@ +using System.Collections.Generic; +using System.Linq; using System.Numerics; -using ImGuiNET; -using ImRaii = Dalamud.Interface.Raii.ImRaii; -namespace Dalamud.Interface.Table; +using Dalamud.Interface.Utility.Raii; +using Dalamud.Utility; +using ImGuiNET; + +namespace Dalamud.Interface.Utility.Table; public static class Table { @@ -11,18 +15,20 @@ public static class Table public class Table { - protected bool FilterDirty = true; - protected bool SortDirty = true; protected readonly ICollection Items; - internal readonly List<(T, int)> FilteredItems; + internal readonly List<(T, int)> FilteredItems; - protected readonly string Label; + protected readonly string Label; protected readonly Column[] Headers; - protected float ItemHeight { get; set; } - public float ExtraHeight { get; set; } = 0; + protected bool filterDirty = true; + protected bool sortDirty = true; - private int _currentIdx = 0; + protected float ItemHeight { get; set; } + + public float ExtraHeight { get; set; } = 0; + + private int currentIdx = 0; protected bool Sortable { @@ -30,7 +36,7 @@ public class Table set => this.Flags = value ? this.Flags | ImGuiTableFlags.Sortable : this.Flags & ~ImGuiTableFlags.Sortable; } - protected int SortIdx = -1; + protected int sortIdx = -1; public ImGuiTableFlags Flags = ImGuiTableFlags.RowBg | ImGuiTableFlags.Sortable @@ -54,10 +60,10 @@ public class Table public Table(string label, ICollection items, params Column[] headers) { - this.Label = label; - this.Items = items; - this.Headers = headers; - this.FilteredItems = new List<(T, int)>(this.Items.Count); + this.Label = label; + this.Items = items; + this.Headers = headers; + this.FilteredItems = new List<(T, int)>(this.Items.Count); this.VisibleColumns = this.Headers.Length; } @@ -73,7 +79,8 @@ public class Table => throw new NotImplementedException(); protected virtual void PreDraw() - { } + { + } private void SortInternal() { @@ -81,29 +88,30 @@ public class Table return; var sortSpecs = ImGui.TableGetSortSpecs(); - this.SortDirty |= sortSpecs.SpecsDirty; + this.sortDirty |= sortSpecs.SpecsDirty; - if (!this.SortDirty) + if (!this.sortDirty) return; - this.SortIdx = sortSpecs.Specs.ColumnIndex; + this.sortIdx = sortSpecs.Specs.ColumnIndex; - if (this.Headers.Length <= this.SortIdx) - this.SortIdx = 0; + if (this.Headers.Length <= this.sortIdx) + this.sortIdx = 0; - if (sortSpecs.Specs.SortDirection == ImGuiSortDirection.Ascending) - this.FilteredItems.StableSort((a, b) => this.Headers[this.SortIdx].Compare(a.Item1, b.Item1)); - else if (sortSpecs.Specs.SortDirection == ImGuiSortDirection.Descending) - this.FilteredItems.StableSort((a, b) => this.Headers[this.SortIdx].CompareInv(a.Item1, b.Item1)); - else - this.SortIdx = -1; - this.SortDirty = false; - sortSpecs.SpecsDirty = false; + if (sortSpecs.Specs.SortDirection == ImGuiSortDirection.Ascending) + this.FilteredItems.StableSort((a, b) => this.Headers[this.sortIdx].Compare(a.Item1, b.Item1)); + else if (sortSpecs.Specs.SortDirection == ImGuiSortDirection.Descending) + this.FilteredItems.StableSort((a, b) => this.Headers[this.sortIdx].CompareInv(a.Item1, b.Item1)); + else + this.sortIdx = -1; + + this.sortDirty = false; + sortSpecs.SpecsDirty = false; } private void UpdateFilter() { - if (!this.FilterDirty) + if (!this.filterDirty) return; this.FilteredItems.Clear(); @@ -115,20 +123,20 @@ public class Table idx++; } - this.FilterDirty = false; - this.SortDirty = true; + this.filterDirty = false; + this.sortDirty = true; } - private void DrawItem((T, int) pair) + private void DrawItem((T Item, int Index) pair) { - var column = 0; - using var id = ImRaii.PushId(this._currentIdx); - this._currentIdx = pair.Item2; + var column = 0; + using var id = ImRaii.PushId(this.currentIdx); + this.currentIdx = pair.Index; foreach (var header in this.Headers) { id.Push(column++); if (ImGui.TableNextColumn()) - header.DrawColumn(pair.Item1, pair.Item2); + header.DrawColumn(pair.Item, pair.Index); id.Pop(); } } @@ -136,7 +144,7 @@ public class Table private void DrawTableInternal() { using var table = ImRaii.Table("Table", this.Headers.Length, this.Flags, - ImGui.GetContentRegionAvail() - this.ExtraHeight * Vector2.UnitY * InterfaceHelpers.GlobalScale); + ImGui.GetContentRegionAvail() - this.ExtraHeight * Vector2.UnitY * ImGuiHelpers.GlobalScale); if (!table) return; @@ -162,11 +170,11 @@ public class Table ImGui.SameLine(); style.Pop(); if (header.DrawFilter()) - this.FilterDirty = true; + this.filterDirty = true; } this.SortInternal(); - this._currentIdx = 0; + this.currentIdx = 0; ImGuiClip.ClippedDraw(this.FilteredItems, this.DrawItem, this.ItemHeight); } } diff --git a/Dalamud/Interface/Windowing/Window.cs b/Dalamud/Interface/Windowing/Window.cs index 39c61566b..a339b807d 100644 --- a/Dalamud/Interface/Windowing/Window.cs +++ b/Dalamud/Interface/Windowing/Window.cs @@ -2,6 +2,7 @@ using System.Numerics; using Dalamud.Configuration.Internal; using Dalamud.Game.ClientState.Keys; +using Dalamud.Interface.Utility; using FFXIVClientStructs.FFXIV.Client.UI; using ImGuiNET; @@ -223,6 +224,7 @@ public abstract class Window /// /// Draw the window via ImGui. /// + /// Configuration instance used to check if certain window management features should be enabled. internal void DrawInternal(DalamudConfiguration? configuration) { this.PreOpenCheck(); diff --git a/Dalamud/Plugin/Internal/PluginManager.cs b/Dalamud/Plugin/Internal/PluginManager.cs index 887994f30..e91195793 100644 --- a/Dalamud/Plugin/Internal/PluginManager.cs +++ b/Dalamud/Plugin/Internal/PluginManager.cs @@ -53,12 +53,6 @@ namespace Dalamud.Plugin.Internal; #pragma warning restore SA1015 internal partial class PluginManager : IDisposable, IServiceType { - /// - /// The current Dalamud API level, used to handle breaking changes. Only plugins with this level will be loaded. - /// As of Dalamud 9.x, this always matches the major version number of Dalamud. - /// - public static int DalamudApiLevel => Assembly.GetExecutingAssembly().GetName().Version!.Major; - /// /// Default time to wait between plugin unload and plugin assembly unload. /// @@ -88,6 +82,11 @@ internal partial class PluginManager : IDisposable, IServiceType [ServiceManager.ServiceDependency] private readonly HappyHttpClient happyHttpClient = Service.Get(); + static PluginManager() + { + DalamudApiLevel = typeof(PluginManager).Assembly.GetName().Version!.Major; + } + [ServiceManager.ServiceConstructor] private PluginManager() { @@ -149,6 +148,12 @@ internal partial class PluginManager : IDisposable, IServiceType /// public event Action? OnAvailablePluginsChanged; + /// + /// Gets the current Dalamud API level, used to handle breaking changes. Only plugins with this level will be loaded. + /// As of Dalamud 9.x, this always matches the major version number of Dalamud. + /// + public static int DalamudApiLevel { get; private set; } + /// /// Gets a copy of the list of all loaded plugins. /// diff --git a/Dalamud/Plugin/Services/IGameConfig.cs b/Dalamud/Plugin/Services/IGameConfig.cs index 98f6160cc..69a611114 100644 --- a/Dalamud/Plugin/Services/IGameConfig.cs +++ b/Dalamud/Plugin/Services/IGameConfig.cs @@ -83,7 +83,7 @@ public interface IGameConfig /// Attempts to get the properties of a String option from the System section. /// /// Option to get the properties of. - /// Details of the option: Default Value + /// Details of the option: Default Value. /// A value representing the success. public bool TryGet(SystemConfigOption option, out StringConfigProperties? properties); @@ -139,7 +139,7 @@ public interface IGameConfig /// Attempts to get the properties of a String option from the UiConfig section. /// /// Option to get the properties of. - /// Details of the option: Default Value + /// Details of the option: Default Value. /// A value representing the success. public bool TryGet(UiConfigOption option, out StringConfigProperties? properties); @@ -195,7 +195,7 @@ public interface IGameConfig /// Attempts to get the properties of a String option from the UiControl section. /// /// Option to get the properties of. - /// Details of the option: Default Value + /// Details of the option: Default Value. /// A value representing the success. public bool TryGet(UiControlOption option, out StringConfigProperties? properties); diff --git a/Dalamud/Plugin/Services/IKeyState.cs b/Dalamud/Plugin/Services/IKeyState.cs index c2bca7347..de78978ca 100644 --- a/Dalamud/Plugin/Services/IKeyState.cs +++ b/Dalamud/Plugin/Services/IKeyState.cs @@ -1,7 +1,6 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; + using Dalamud.Game.ClientState.Keys; -using PInvoke; namespace Dalamud.Plugin.Services; diff --git a/Dalamud.Interface/ArrayExtensions.cs b/Dalamud/Utility/ArrayExtensions.cs similarity index 80% rename from Dalamud.Interface/ArrayExtensions.cs rename to Dalamud/Utility/ArrayExtensions.cs index 68bf52a29..afb1511e3 100644 --- a/Dalamud.Interface/ArrayExtensions.cs +++ b/Dalamud/Utility/ArrayExtensions.cs @@ -1,7 +1,13 @@ +using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; +using System.Linq; -namespace Dalamud.Interface; +namespace Dalamud.Utility; +[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1618:Generic type parameters should be documented", Justification = "Reviewed,")] +[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "Reviewed,")] +[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1615:Element return value should be documented", Justification = "Reviewed,")] +[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1611:Element parameters should be documented", Justification = "Reviewed,")] internal static class ArrayExtensions { /// Iterate over enumerables with additional index. @@ -16,7 +22,6 @@ internal static class ArrayExtensions public static IEnumerable WithoutValue(this IEnumerable<(T Value, int Index)> list) => list.Select(x => x.Index); - // Find the index of the first object fulfilling predicate's criteria in the given list. // Returns -1 if no such object is found. public static int IndexOf(this IEnumerable array, Predicate predicate) diff --git a/Dalamud/Utility/FuzzyMatcher.cs b/Dalamud/Utility/FuzzyMatcher.cs index 647c9586d..9ac71d8bb 100644 --- a/Dalamud/Utility/FuzzyMatcher.cs +++ b/Dalamud/Utility/FuzzyMatcher.cs @@ -6,6 +6,9 @@ using System; using System.Collections.Generic; using System.Runtime.CompilerServices; +#pragma warning disable SA1600 +#pragma warning disable SA1602 + internal readonly ref struct FuzzyMatcher { private static readonly (int, int)[] EmptySegArray = Array.Empty<(int, int)>(); @@ -13,31 +16,31 @@ internal readonly ref struct FuzzyMatcher private readonly string needleString = string.Empty; private readonly ReadOnlySpan needleSpan = ReadOnlySpan.Empty; private readonly int needleFinalPosition = -1; - private readonly (int start, int end)[] needleSegments = EmptySegArray; + private readonly (int Start, int End)[] needleSegments = EmptySegArray; private readonly MatchMode mode = MatchMode.Simple; public FuzzyMatcher(string term, MatchMode matchMode) { - needleString = term; - needleSpan = needleString.AsSpan(); - needleFinalPosition = needleSpan.Length - 1; - mode = matchMode; + this.needleString = term; + this.needleSpan = this.needleString.AsSpan(); + this.needleFinalPosition = this.needleSpan.Length - 1; + this.mode = matchMode; switch (matchMode) { case MatchMode.FuzzyParts: - needleSegments = FindNeedleSegments(needleSpan); + this.needleSegments = FindNeedleSegments(this.needleSpan); break; case MatchMode.Fuzzy: case MatchMode.Simple: - needleSegments = EmptySegArray; + this.needleSegments = EmptySegArray; break; default: throw new ArgumentOutOfRangeException(nameof(matchMode), matchMode, null); } } - private static (int start, int end)[] FindNeedleSegments(ReadOnlySpan span) + private static (int Start, int End)[] FindNeedleSegments(ReadOnlySpan span) { var segments = new List<(int, int)>(); var wordStart = -1; @@ -66,37 +69,39 @@ internal readonly ref struct FuzzyMatcher return segments.ToArray(); } +#pragma warning disable SA1202 public int Matches(string value) +#pragma warning restore SA1202 { - if (needleFinalPosition < 0) + if (this.needleFinalPosition < 0) { return 0; } - if (mode == MatchMode.Simple) + if (this.mode == MatchMode.Simple) { - return value.Contains(needleString) ? 1 : 0; + return value.Contains(this.needleString) ? 1 : 0; } var haystack = value.AsSpan(); - if (mode == MatchMode.Fuzzy) + if (this.mode == MatchMode.Fuzzy) { - return GetRawScore(haystack, 0, needleFinalPosition); + return this.GetRawScore(haystack, 0, this.needleFinalPosition); } - if (mode == MatchMode.FuzzyParts) + if (this.mode == MatchMode.FuzzyParts) { - if (needleSegments.Length < 2) + if (this.needleSegments.Length < 2) { - return GetRawScore(haystack, 0, needleFinalPosition); + return this.GetRawScore(haystack, 0, this.needleFinalPosition); } var total = 0; - for (var i = 0; i < needleSegments.Length; i++) + for (var i = 0; i < this.needleSegments.Length; i++) { - var (start, end) = needleSegments[i]; - var cur = GetRawScore(haystack, start, end); + var (start, end) = this.needleSegments[i]; + var cur = this.GetRawScore(haystack, start, end); if (cur == 0) { return 0; @@ -116,7 +121,7 @@ internal readonly ref struct FuzzyMatcher var max = 0; for (var i = 0; i < values.Length; i++) { - var cur = Matches(values[i]); + var cur = this.Matches(values[i]); if (cur > max) { max = cur; @@ -128,7 +133,7 @@ internal readonly ref struct FuzzyMatcher private int GetRawScore(ReadOnlySpan haystack, int needleStart, int needleEnd) { - var (startPos, gaps, consecutive, borderMatches, endPos) = FindForward(haystack, needleStart, needleEnd); + var (startPos, gaps, consecutive, borderMatches, endPos) = this.FindForward(haystack, needleStart, needleEnd); if (startPos < 0) { return 0; @@ -140,7 +145,7 @@ internal readonly ref struct FuzzyMatcher // PluginLog.Debug( // $"['{needleString.Substring(needleStart, needleEnd - needleStart + 1)}' in '{haystack}'] fwd: needleSize={needleSize} startPos={startPos} gaps={gaps} consecutive={consecutive} borderMatches={borderMatches} score={score}"); - (startPos, gaps, consecutive, borderMatches) = FindReverse(haystack, endPos, needleStart, needleEnd); + (startPos, gaps, consecutive, borderMatches) = this.FindReverse(haystack, endPos, needleStart, needleEnd); var revScore = CalculateRawScore(needleSize, startPos, gaps, consecutive, borderMatches); // PluginLog.Debug( // $"['{needleString.Substring(needleStart, needleEnd - needleStart + 1)}' in '{haystack}'] rev: needleSize={needleSize} startPos={startPos} gaps={gaps} consecutive={consecutive} borderMatches={borderMatches} score={revScore}"); @@ -149,7 +154,9 @@ internal readonly ref struct FuzzyMatcher } [MethodImpl(MethodImplOptions.AggressiveInlining)] +#pragma warning disable SA1204 private static int CalculateRawScore(int needleSize, int startPos, int gaps, int consecutive, int borderMatches) +#pragma warning restore SA1204 { var score = 100 + needleSize * 3 @@ -162,7 +169,7 @@ internal readonly ref struct FuzzyMatcher return score < 1 ? 1 : score; } - private (int startPos, int gaps, int consecutive, int borderMatches, int haystackIndex) FindForward( + private (int StartPos, int Gaps, int Consecutive, int BorderMatches, int HaystackIndex) FindForward( ReadOnlySpan haystack, int needleStart, int needleEnd) { var needleIndex = needleStart; @@ -175,7 +182,7 @@ internal readonly ref struct FuzzyMatcher for (var haystackIndex = 0; haystackIndex < haystack.Length; haystackIndex++) { - if (haystack[haystackIndex] == needleSpan[needleIndex]) + if (haystack[haystackIndex] == this.needleSpan[needleIndex]) { #if BORDER_MATCHING if (haystackIndex > 0) @@ -217,8 +224,8 @@ internal readonly ref struct FuzzyMatcher return (-1, 0, 0, 0, 0); } - private (int startPos, int gaps, int consecutive, int borderMatches) FindReverse(ReadOnlySpan haystack, - int haystackLastMatchIndex, int needleStart, int needleEnd) + private (int StartPos, int Gaps, int Consecutive, int BorderMatches) FindReverse( + ReadOnlySpan haystack, int haystackLastMatchIndex, int needleStart, int needleEnd) { var needleIndex = needleEnd; var revLastMatchIndex = haystack.Length + 10; @@ -229,7 +236,7 @@ internal readonly ref struct FuzzyMatcher for (var haystackIndex = haystackLastMatchIndex; haystackIndex >= 0; haystackIndex--) { - if (haystack[haystackIndex] == needleSpan[needleIndex]) + if (haystack[haystackIndex] == this.needleSpan[needleIndex]) { #if BORDER_MATCHING if (haystackIndex > 0) @@ -265,9 +272,12 @@ internal readonly ref struct FuzzyMatcher } } -public enum MatchMode +internal enum MatchMode { Simple, Fuzzy, - FuzzyParts + FuzzyParts, } + +#pragma warning restore SA1600 +#pragma warning restore SA1602 diff --git a/Dalamud.Interface/StableInsertionSortExtension.cs b/Dalamud/Utility/StableInsertionSortExtension.cs similarity index 57% rename from Dalamud.Interface/StableInsertionSortExtension.cs rename to Dalamud/Utility/StableInsertionSortExtension.cs index d2884f838..f7c9b43be 100644 --- a/Dalamud.Interface/StableInsertionSortExtension.cs +++ b/Dalamud/Utility/StableInsertionSortExtension.cs @@ -1,9 +1,21 @@ +using System.Collections.Generic; +using System.Linq; using System.Runtime.CompilerServices; -namespace Dalamud.Interface; +namespace Dalamud.Utility; +/// +/// Extensions methods providing stable insertion sorts for IList. +/// internal static class StableInsertionSortExtension { + /// + /// Perform a stable sort on a list. + /// + /// The list to sort. + /// Selector to order by. + /// Element type. + /// Selected type. [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] public static void StableSort(this IList list, Func selector) { @@ -13,6 +25,12 @@ internal static class StableInsertionSortExtension list[i] = tmpList[i]; } + /// + /// Perform a stable sort on a list. + /// + /// The list to sort. + /// Comparer to use when comparing items. + /// Element type. [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] public static void StableSort(this IList list, Comparison comparer) { diff --git a/Dalamud/Utility/Util.cs b/Dalamud/Utility/Util.cs index 53c570e54..5f2e4d5bf 100644 --- a/Dalamud/Utility/Util.cs +++ b/Dalamud/Utility/Util.cs @@ -17,6 +17,7 @@ using Dalamud.Game.ClientState.Objects.SubKinds; using Dalamud.Game.ClientState.Objects.Types; using Dalamud.Interface; using Dalamud.Interface.Colors; +using Dalamud.Interface.Utility; using Dalamud.Logging.Internal; using Dalamud.Networking.Http; using ImGuiNET; diff --git a/targets/Dalamud.Plugin.targets b/targets/Dalamud.Plugin.targets index 4a5f9e97e..2f8e029eb 100644 --- a/targets/Dalamud.Plugin.targets +++ b/targets/Dalamud.Plugin.targets @@ -18,7 +18,6 @@ -