mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-13 12:14:16 +01:00
deps: upgrade StyleCop, fix warnings
...fixes new array initializer expression
This commit is contained in:
parent
02022599e5
commit
31e541fae5
17 changed files with 307 additions and 286 deletions
|
|
@ -1,6 +1,9 @@
|
||||||
namespace Dalamud.Configuration.Internal;
|
namespace Dalamud.Configuration.Internal;
|
||||||
|
|
||||||
public record PluginTestingOptIn
|
/// <summary>
|
||||||
|
/// Represents a plugin that has opted in to testing.
|
||||||
|
/// </summary>
|
||||||
|
internal record PluginTestingOptIn
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="PluginTestingOptIn"/> class.
|
/// Initializes a new instance of the <see cref="PluginTestingOptIn"/> class.
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ public interface IConsoleCommand : IConsoleEntry
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Interface representing a variable in the console.
|
/// Interface representing a variable in the console.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T">The type of the variable</typeparam>
|
/// <typeparam name="T">The type of the variable.</typeparam>
|
||||||
public interface IConsoleVariable<T> : IConsoleEntry
|
public interface IConsoleVariable<T> : IConsoleEntry
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@ using Dalamud.Plugin.Services;
|
||||||
|
|
||||||
namespace Dalamud.Console;
|
namespace Dalamud.Console;
|
||||||
|
|
||||||
|
#pragma warning disable Dalamud001
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Plugin-scoped version of the console service.
|
/// Plugin-scoped version of the console service.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@
|
||||||
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
|
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
|
||||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||||
<PackageReference Include="sqlite-net-pcl" Version="1.8.116" />
|
<PackageReference Include="sqlite-net-pcl" Version="1.8.116" />
|
||||||
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.333">
|
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ internal unsafe class AddonEventEntry
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the pointer to the addons AtkUnitBase.
|
/// Gets the pointer to the addons AtkUnitBase.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
required public nint Addon { get; init; }
|
public required nint Addon { get; init; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the name of the addon this args referrers to.
|
/// Gets the name of the addon this args referrers to.
|
||||||
|
|
@ -30,27 +30,27 @@ internal unsafe class AddonEventEntry
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the pointer to the event source.
|
/// Gets the pointer to the event source.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
required public nint Node { get; init; }
|
public required nint Node { get; init; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the handler that gets called when this event is triggered.
|
/// Gets the handler that gets called when this event is triggered.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
required public IAddonEventManager.AddonEventHandler Handler { get; init; }
|
public required IAddonEventManager.AddonEventHandler Handler { get; init; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the unique id for this event.
|
/// Gets the unique id for this event.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
required public uint ParamKey { get; init; }
|
public required uint ParamKey { get; init; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the event type for this event.
|
/// Gets the event type for this event.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
required public AddonEventType EventType { get; init; }
|
public required AddonEventType EventType { get; init; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the event handle for this event.
|
/// Gets the event handle for this event.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
required internal IAddonEventHandle Handle { get; init; }
|
internal required IAddonEventHandle Handle { get; init; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the formatted log string for this AddonEventEntry.
|
/// Gets the formatted log string for this AddonEventEntry.
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,14 @@
|
||||||
namespace Dalamud.Game.Config;
|
namespace Dalamud.Game.Config;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a change in the configuration.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Option">The option tha twas changed.</param>
|
||||||
public abstract record ConfigChangeEvent(Enum Option);
|
public abstract record ConfigChangeEvent(Enum Option);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a generic change in the configuration.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ConfigOption">The option that was changed.</param>
|
||||||
|
/// <typeparam name="T">The type of the option.</typeparam>
|
||||||
public record ConfigChangeEvent<T>(T ConfigOption) : ConfigChangeEvent(ConfigOption) where T : Enum;
|
public record ConfigChangeEvent<T>(T ConfigOption) : ConfigChangeEvent(ConfigOption) where T : Enum;
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,24 @@
|
||||||
|
|
||||||
namespace Dalamud.Game.Config;
|
namespace Dalamud.Game.Config;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a string configuration property.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Default">The default value.</param>
|
||||||
public record StringConfigProperties(SeString? Default);
|
public record StringConfigProperties(SeString? Default);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a uint configuration property.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Default">The default value.</param>
|
||||||
|
/// <param name="Minimum">The minimum value.</param>
|
||||||
|
/// <param name="Maximum">The maximum value.</param>
|
||||||
public record UIntConfigProperties(uint Default, uint Minimum, uint Maximum);
|
public record UIntConfigProperties(uint Default, uint Minimum, uint Maximum);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a floating point configuration property.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Default">The default value.</param>
|
||||||
|
/// <param name="Minimum">The minimum value.</param>
|
||||||
|
/// <param name="Maximum">The maximum value.</param>
|
||||||
public record FloatConfigProperties(float Default, float Minimum, float Maximum);
|
public record FloatConfigProperties(float Default, float Minimum, float Maximum);
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ using Dalamud.Utility;
|
||||||
using FFXIVClientStructs.FFXIV.Client.Graphics.Kernel;
|
using FFXIVClientStructs.FFXIV.Client.Graphics.Kernel;
|
||||||
using FFXIVClientStructs.FFXIV.Client.System.String;
|
using FFXIVClientStructs.FFXIV.Client.System.String;
|
||||||
using FFXIVClientStructs.FFXIV.Client.UI;
|
using FFXIVClientStructs.FFXIV.Client.UI;
|
||||||
|
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
|
||||||
using FFXIVClientStructs.FFXIV.Common.Component.BGCollision;
|
using FFXIVClientStructs.FFXIV.Common.Component.BGCollision;
|
||||||
using FFXIVClientStructs.FFXIV.Component.GUI;
|
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
|
|
@ -330,7 +331,7 @@ internal sealed unsafe class GameGui : IInternalDisposableService, IGameGui
|
||||||
var index = 0;
|
var index = 0;
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
var agent = agentModule->GetAgentByInternalID((uint)index++);
|
var agent = agentModule->GetAgentByInternalId((AgentId)index++);
|
||||||
if (agent == uiModule || agent == null)
|
if (agent == uiModule || agent == null)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,57 @@ using Lumina.Excel.GeneratedSheets;
|
||||||
|
|
||||||
namespace Dalamud.Game.Network.Structures.InfoProxy;
|
namespace Dalamud.Game.Network.Structures.InfoProxy;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Display group of a character. Used for friends.
|
||||||
|
/// </summary>
|
||||||
|
public enum DisplayGroup : sbyte
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// All display groups.
|
||||||
|
/// </summary>
|
||||||
|
All = -1,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// No display group.
|
||||||
|
/// </summary>
|
||||||
|
None,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Star display group.
|
||||||
|
/// </summary>
|
||||||
|
Star,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Circle display group.
|
||||||
|
/// </summary>
|
||||||
|
Circle,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Triangle display group.
|
||||||
|
/// </summary>
|
||||||
|
Triangle,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Diamond display group.
|
||||||
|
/// </summary>
|
||||||
|
Diamond,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Heart display group.
|
||||||
|
/// </summary>
|
||||||
|
Heart,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Spade display group.
|
||||||
|
/// </summary>
|
||||||
|
Spade,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Club display group.
|
||||||
|
/// </summary>
|
||||||
|
Club,
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Dalamud wrapper around a client structs <see cref="InfoProxyCommonList.CharacterData"/>.
|
/// Dalamud wrapper around a client structs <see cref="InfoProxyCommonList.CharacterData"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -144,54 +195,3 @@ public unsafe class CharacterData
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal InfoProxyCommonList.CharacterData* Struct => (InfoProxyCommonList.CharacterData*)this.Address;
|
internal InfoProxyCommonList.CharacterData* Struct => (InfoProxyCommonList.CharacterData*)this.Address;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Display group of a character. Used for friends.
|
|
||||||
/// </summary>
|
|
||||||
public enum DisplayGroup : sbyte
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// All display groups.
|
|
||||||
/// </summary>
|
|
||||||
All = -1,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// No display group.
|
|
||||||
/// </summary>
|
|
||||||
None,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Star display group.
|
|
||||||
/// </summary>
|
|
||||||
Star,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Circle display group.
|
|
||||||
/// </summary>
|
|
||||||
Circle,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Triangle display group.
|
|
||||||
/// </summary>
|
|
||||||
Triangle,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Diamond display group.
|
|
||||||
/// </summary>
|
|
||||||
Diamond,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Heart display group.
|
|
||||||
/// </summary>
|
|
||||||
Heart,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Spade display group.
|
|
||||||
/// </summary>
|
|
||||||
Spade,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Club display group.
|
|
||||||
/// </summary>
|
|
||||||
Club,
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -13,13 +13,7 @@ namespace Dalamud.Game.Text.SeStringHandling.Payloads;
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class AutoTranslatePayload : Payload, ITextProvider
|
public class AutoTranslatePayload : Payload, ITextProvider
|
||||||
{
|
{
|
||||||
private string text;
|
private string? text;
|
||||||
|
|
||||||
[JsonProperty("group")]
|
|
||||||
public uint Group { get; private set; }
|
|
||||||
|
|
||||||
[JsonProperty("key")]
|
|
||||||
public uint Key { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="AutoTranslatePayload"/> class.
|
/// Initializes a new instance of the <see cref="AutoTranslatePayload"/> class.
|
||||||
|
|
@ -45,6 +39,18 @@ public class AutoTranslatePayload : Payload, ITextProvider
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the autotranslate group.
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("group")]
|
||||||
|
public uint Group { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the autotranslate key.
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("key")]
|
||||||
|
public uint Key { get; private set; }
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override PayloadType Type => PayloadType.AutoTranslateText;
|
public override PayloadType Type => PayloadType.AutoTranslateText;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,8 @@ using System.Diagnostics.CodeAnalysis;
|
||||||
[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.MaintainabilityRules", "SA1407:ArithmeticExpressionsMustDeclarePrecedence", Justification = "I don't care anymore")]
|
||||||
[assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1116:SplitParametersMustStartOnLineAfterDeclaration", Justification = "Reviewed.")]
|
[assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1116:SplitParametersMustStartOnLineAfterDeclaration", Justification = "Reviewed.")]
|
||||||
|
[assembly: SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:FileMayOnlyContainASingleType", Justification = "This would be nice, but a big refactor")]
|
||||||
|
[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1649:FileNameMustMatchTypeName", Justification = "I don't like this one so much")]
|
||||||
|
|
||||||
// ImRAII stuff
|
// ImRAII stuff
|
||||||
[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", Justification = "Reviewed.", Scope = "namespaceanddescendants", Target = "Dalamud.Interface.Utility.Raii")]
|
[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", Justification = "Reviewed.", Scope = "namespaceanddescendants", Target = "Dalamud.Interface.Utility.Raii")]
|
||||||
|
|
|
||||||
|
|
@ -9,17 +9,6 @@ namespace Dalamud.Interface;
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class ColorHelpers
|
public static class ColorHelpers
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// A struct representing a color using HSVA coordinates.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="H">The hue represented by this struct.</param>
|
|
||||||
/// <param name="S">The saturation represented by this struct.</param>
|
|
||||||
/// <param name="V">The value represented by this struct.</param>
|
|
||||||
/// <param name="A">The alpha represented by this struct.</param>
|
|
||||||
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1313:Parameter names should begin with lower-case letter",
|
|
||||||
Justification = "I don't like it.")]
|
|
||||||
public record struct HsvaColor(float H, float S, float V, float A);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Pack a vector4 color into a uint for use in ImGui APIs.
|
/// Pack a vector4 color into a uint for use in ImGui APIs.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -305,4 +294,15 @@ public static class ColorHelpers
|
||||||
|
|
||||||
_ => color / 255.0f,
|
_ => color / 255.0f,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A struct representing a color using HSVA coordinates.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="H">The hue represented by this struct.</param>
|
||||||
|
/// <param name="S">The saturation represented by this struct.</param>
|
||||||
|
/// <param name="V">The value represented by this struct.</param>
|
||||||
|
/// <param name="A">The alpha represented by this struct.</param>
|
||||||
|
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1313:Parameter names should begin with lower-case letter",
|
||||||
|
Justification = "I don't like it.")]
|
||||||
|
public record struct HsvaColor(float H, float S, float V, float A);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,17 +17,6 @@ namespace Dalamud.Interface.Internal.Windows.Data.Widgets;
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal class NetworkMonitorWidget : IDataWindowWidget
|
internal class NetworkMonitorWidget : IDataWindowWidget
|
||||||
{
|
{
|
||||||
#pragma warning disable SA1313
|
|
||||||
private readonly record struct NetworkPacketData(ushort OpCode, NetworkMessageDirection Direction, uint SourceActorId, uint TargetActorId)
|
|
||||||
#pragma warning restore SA1313
|
|
||||||
{
|
|
||||||
public readonly IReadOnlyList<byte> Data = Array.Empty<byte>();
|
|
||||||
|
|
||||||
public NetworkPacketData(NetworkMonitorWidget widget, ushort opCode, NetworkMessageDirection direction, uint sourceActorId, uint targetActorId, nint dataPtr)
|
|
||||||
: this(opCode, direction, sourceActorId, targetActorId)
|
|
||||||
=> this.Data = MemoryHelper.Read<byte>(dataPtr, widget.GetSizeFromOpCode(opCode), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private readonly ConcurrentQueue<NetworkPacketData> packets = new();
|
private readonly ConcurrentQueue<NetworkPacketData> packets = new();
|
||||||
|
|
||||||
private bool trackNetwork;
|
private bool trackNetwork;
|
||||||
|
|
@ -214,4 +203,15 @@ internal class NetworkMonitorWidget : IDataWindowWidget
|
||||||
/// <remarks> The filter should find opCodes by number (decimal and hex) and name, if existing. </remarks>
|
/// <remarks> The filter should find opCodes by number (decimal and hex) and name, if existing. </remarks>
|
||||||
private string OpCodeToString(ushort opCode)
|
private string OpCodeToString(ushort opCode)
|
||||||
=> $"{opCode}\0{opCode:X}";
|
=> $"{opCode}\0{opCode:X}";
|
||||||
|
|
||||||
|
#pragma warning disable SA1313
|
||||||
|
private readonly record struct NetworkPacketData(ushort OpCode, NetworkMessageDirection Direction, uint SourceActorId, uint TargetActorId)
|
||||||
|
#pragma warning restore SA1313
|
||||||
|
{
|
||||||
|
public readonly IReadOnlyList<byte> Data = Array.Empty<byte>();
|
||||||
|
|
||||||
|
public NetworkPacketData(NetworkMonitorWidget widget, ushort opCode, NetworkMessageDirection direction, uint sourceActorId, uint targetActorId, nint dataPtr)
|
||||||
|
: this(opCode, direction, sourceActorId, targetActorId)
|
||||||
|
=> this.Data = MemoryHelper.Read<byte>(dataPtr, widget.GetSizeFromOpCode(opCode), false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,166 +10,6 @@ using JetBrains.Annotations;
|
||||||
|
|
||||||
namespace Dalamud.Interface.Utility;
|
namespace Dalamud.Interface.Utility;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Utility methods for <see cref="ImVectorWrapper{T}"/>.
|
|
||||||
/// </summary>
|
|
||||||
public static class ImVectorWrapper
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Creates a new instance of the <see cref="ImVectorWrapper{T}"/> struct, initialized with
|
|
||||||
/// <paramref name="sourceEnumerable"/>.<br />
|
|
||||||
/// You must call <see cref="ImVectorWrapper{T}.Dispose"/> after use.
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T">The item type.</typeparam>
|
|
||||||
/// <param name="sourceEnumerable">The initial data.</param>
|
|
||||||
/// <param name="destroyer">The destroyer function to call on item removal.</param>
|
|
||||||
/// <param name="minCapacity">The minimum capacity of the new vector.</param>
|
|
||||||
/// <returns>The new wrapped vector, that has to be disposed after use.</returns>
|
|
||||||
public static ImVectorWrapper<T> CreateFromEnumerable<T>(
|
|
||||||
IEnumerable<T> sourceEnumerable,
|
|
||||||
ImVectorWrapper<T>.ImGuiNativeDestroyDelegate? destroyer = null,
|
|
||||||
int minCapacity = 0)
|
|
||||||
where T : unmanaged
|
|
||||||
{
|
|
||||||
var res = new ImVectorWrapper<T>(0, destroyer);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
switch (sourceEnumerable)
|
|
||||||
{
|
|
||||||
case T[] c:
|
|
||||||
res.SetCapacity(Math.Max(minCapacity, c.Length + 1));
|
|
||||||
res.LengthUnsafe = c.Length;
|
|
||||||
c.AsSpan().CopyTo(res.DataSpan);
|
|
||||||
break;
|
|
||||||
case ICollection c:
|
|
||||||
res.SetCapacity(Math.Max(minCapacity, c.Count + 1));
|
|
||||||
res.AddRange(sourceEnumerable);
|
|
||||||
break;
|
|
||||||
case ICollection<T> c:
|
|
||||||
res.SetCapacity(Math.Max(minCapacity, c.Count + 1));
|
|
||||||
res.AddRange(sourceEnumerable);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
res.SetCapacity(minCapacity);
|
|
||||||
res.AddRange(sourceEnumerable);
|
|
||||||
res.EnsureCapacity(res.LengthUnsafe + 1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Null termination
|
|
||||||
Debug.Assert(res.LengthUnsafe < res.CapacityUnsafe, "Capacity must be more than source length + 1");
|
|
||||||
res.StorageSpan[res.LengthUnsafe] = default;
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
res.Dispose();
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates a new instance of the <see cref="ImVectorWrapper{T}"/> struct, initialized with
|
|
||||||
/// <paramref name="sourceSpan"/>.<br />
|
|
||||||
/// You must call <see cref="ImVectorWrapper{T}.Dispose"/> after use.
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T">The item type.</typeparam>
|
|
||||||
/// <param name="sourceSpan">The initial data.</param>
|
|
||||||
/// <param name="destroyer">The destroyer function to call on item removal.</param>
|
|
||||||
/// <param name="minCapacity">The minimum capacity of the new vector.</param>
|
|
||||||
/// <returns>The new wrapped vector, that has to be disposed after use.</returns>
|
|
||||||
public static ImVectorWrapper<T> CreateFromSpan<T>(
|
|
||||||
ReadOnlySpan<T> sourceSpan,
|
|
||||||
ImVectorWrapper<T>.ImGuiNativeDestroyDelegate? destroyer = null,
|
|
||||||
int minCapacity = 0)
|
|
||||||
where T : unmanaged
|
|
||||||
{
|
|
||||||
var res = new ImVectorWrapper<T>(Math.Max(minCapacity, sourceSpan.Length + 1), destroyer);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
res.LengthUnsafe = sourceSpan.Length;
|
|
||||||
sourceSpan.CopyTo(res.DataSpan);
|
|
||||||
|
|
||||||
// Null termination
|
|
||||||
Debug.Assert(res.LengthUnsafe < res.CapacityUnsafe, "Capacity must be more than source length + 1");
|
|
||||||
res.StorageSpan[res.LengthUnsafe] = default;
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
res.Dispose();
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Wraps <see cref="ImFontAtlas.ConfigData"/> into a <see cref="ImVectorWrapper{T}"/>.<br />
|
|
||||||
/// This does not need to be disposed.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="obj">The owner object.</param>
|
|
||||||
/// <returns>The wrapped vector.</returns>
|
|
||||||
public static unsafe ImVectorWrapper<ImFontConfig> ConfigDataWrapped(this ImFontAtlasPtr obj) =>
|
|
||||||
obj.NativePtr is null
|
|
||||||
? throw new NullReferenceException()
|
|
||||||
: new(&obj.NativePtr->ConfigData, ImGuiNative.ImFontConfig_destroy);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Wraps <see cref="ImFontAtlas.Fonts"/> into a <see cref="ImVectorWrapper{T}"/>.<br />
|
|
||||||
/// This does not need to be disposed.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="obj">The owner object.</param>
|
|
||||||
/// <returns>The wrapped vector.</returns>
|
|
||||||
public static unsafe ImVectorWrapper<ImFontPtr> FontsWrapped(this ImFontAtlasPtr obj) =>
|
|
||||||
obj.NativePtr is null
|
|
||||||
? throw new NullReferenceException()
|
|
||||||
: new(&obj.NativePtr->Fonts, x => ImGuiNative.ImFont_destroy(x->NativePtr));
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Wraps <see cref="ImFontAtlas.Textures"/> into a <see cref="ImVectorWrapper{T}"/>.<br />
|
|
||||||
/// This does not need to be disposed.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="obj">The owner object.</param>
|
|
||||||
/// <returns>The wrapped vector.</returns>
|
|
||||||
public static unsafe ImVectorWrapper<ImFontAtlasTexture> TexturesWrapped(this ImFontAtlasPtr obj) =>
|
|
||||||
obj.NativePtr is null
|
|
||||||
? throw new NullReferenceException()
|
|
||||||
: new(&obj.NativePtr->Textures);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Wraps <see cref="ImFont.Glyphs"/> into a <see cref="ImVectorWrapper{T}"/>.<br />
|
|
||||||
/// This does not need to be disposed.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="obj">The owner object.</param>
|
|
||||||
/// <returns>The wrapped vector.</returns>
|
|
||||||
public static unsafe ImVectorWrapper<ImGuiHelpers.ImFontGlyphReal> GlyphsWrapped(this ImFontPtr obj) =>
|
|
||||||
obj.NativePtr is null
|
|
||||||
? throw new NullReferenceException()
|
|
||||||
: new(&obj.NativePtr->Glyphs);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Wraps <see cref="ImFont.IndexedHotData"/> into a <see cref="ImVectorWrapper{T}"/>.<br />
|
|
||||||
/// This does not need to be disposed.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="obj">The owner object.</param>
|
|
||||||
/// <returns>The wrapped vector.</returns>
|
|
||||||
public static unsafe ImVectorWrapper<ImGuiHelpers.ImFontGlyphHotDataReal> IndexedHotDataWrapped(this ImFontPtr obj)
|
|
||||||
=> obj.NativePtr is null
|
|
||||||
? throw new NullReferenceException()
|
|
||||||
: new(&obj.NativePtr->IndexedHotData);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Wraps <see cref="ImFont.IndexLookup"/> into a <see cref="ImVectorWrapper{T}"/>.<br />
|
|
||||||
/// This does not need to be disposed.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="obj">The owner object.</param>
|
|
||||||
/// <returns>The wrapped vector.</returns>
|
|
||||||
public static unsafe ImVectorWrapper<ushort> IndexLookupWrapped(this ImFontPtr obj) =>
|
|
||||||
obj.NativePtr is null
|
|
||||||
? throw new NullReferenceException()
|
|
||||||
: new(&obj.NativePtr->IndexLookup);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Wrapper for ImVector.
|
/// Wrapper for ImVector.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -744,3 +584,163 @@ public unsafe struct ImVectorWrapper<T> : IList<T>, IList, IReadOnlyList<T>, IDi
|
||||||
|
|
||||||
private int EnsureIndex(int i) => i >= 0 && i < this.LengthUnsafe ? i : throw new IndexOutOfRangeException();
|
private int EnsureIndex(int i) => i >= 0 && i < this.LengthUnsafe ? i : throw new IndexOutOfRangeException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Utility methods for <see cref="ImVectorWrapper{T}"/>.
|
||||||
|
/// </summary>
|
||||||
|
public static class ImVectorWrapper
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new instance of the <see cref="ImVectorWrapper{T}"/> struct, initialized with
|
||||||
|
/// <paramref name="sourceEnumerable"/>.<br />
|
||||||
|
/// You must call <see cref="ImVectorWrapper{T}.Dispose"/> after use.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">The item type.</typeparam>
|
||||||
|
/// <param name="sourceEnumerable">The initial data.</param>
|
||||||
|
/// <param name="destroyer">The destroyer function to call on item removal.</param>
|
||||||
|
/// <param name="minCapacity">The minimum capacity of the new vector.</param>
|
||||||
|
/// <returns>The new wrapped vector, that has to be disposed after use.</returns>
|
||||||
|
public static ImVectorWrapper<T> CreateFromEnumerable<T>(
|
||||||
|
IEnumerable<T> sourceEnumerable,
|
||||||
|
ImVectorWrapper<T>.ImGuiNativeDestroyDelegate? destroyer = null,
|
||||||
|
int minCapacity = 0)
|
||||||
|
where T : unmanaged
|
||||||
|
{
|
||||||
|
var res = new ImVectorWrapper<T>(0, destroyer);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
switch (sourceEnumerable)
|
||||||
|
{
|
||||||
|
case T[] c:
|
||||||
|
res.SetCapacity(Math.Max(minCapacity, c.Length + 1));
|
||||||
|
res.LengthUnsafe = c.Length;
|
||||||
|
c.AsSpan().CopyTo(res.DataSpan);
|
||||||
|
break;
|
||||||
|
case ICollection c:
|
||||||
|
res.SetCapacity(Math.Max(minCapacity, c.Count + 1));
|
||||||
|
res.AddRange(sourceEnumerable);
|
||||||
|
break;
|
||||||
|
case ICollection<T> c:
|
||||||
|
res.SetCapacity(Math.Max(minCapacity, c.Count + 1));
|
||||||
|
res.AddRange(sourceEnumerable);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res.SetCapacity(minCapacity);
|
||||||
|
res.AddRange(sourceEnumerable);
|
||||||
|
res.EnsureCapacity(res.LengthUnsafe + 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Null termination
|
||||||
|
Debug.Assert(res.LengthUnsafe < res.CapacityUnsafe, "Capacity must be more than source length + 1");
|
||||||
|
res.StorageSpan[res.LengthUnsafe] = default;
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
res.Dispose();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new instance of the <see cref="ImVectorWrapper{T}"/> struct, initialized with
|
||||||
|
/// <paramref name="sourceSpan"/>.<br />
|
||||||
|
/// You must call <see cref="ImVectorWrapper{T}.Dispose"/> after use.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">The item type.</typeparam>
|
||||||
|
/// <param name="sourceSpan">The initial data.</param>
|
||||||
|
/// <param name="destroyer">The destroyer function to call on item removal.</param>
|
||||||
|
/// <param name="minCapacity">The minimum capacity of the new vector.</param>
|
||||||
|
/// <returns>The new wrapped vector, that has to be disposed after use.</returns>
|
||||||
|
public static ImVectorWrapper<T> CreateFromSpan<T>(
|
||||||
|
ReadOnlySpan<T> sourceSpan,
|
||||||
|
ImVectorWrapper<T>.ImGuiNativeDestroyDelegate? destroyer = null,
|
||||||
|
int minCapacity = 0)
|
||||||
|
where T : unmanaged
|
||||||
|
{
|
||||||
|
var res = new ImVectorWrapper<T>(Math.Max(minCapacity, sourceSpan.Length + 1), destroyer);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
res.LengthUnsafe = sourceSpan.Length;
|
||||||
|
sourceSpan.CopyTo(res.DataSpan);
|
||||||
|
|
||||||
|
// Null termination
|
||||||
|
Debug.Assert(res.LengthUnsafe < res.CapacityUnsafe, "Capacity must be more than source length + 1");
|
||||||
|
res.StorageSpan[res.LengthUnsafe] = default;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
res.Dispose();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Wraps <see cref="ImFontAtlas.ConfigData"/> into a <see cref="ImVectorWrapper{T}"/>.<br />
|
||||||
|
/// This does not need to be disposed.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="obj">The owner object.</param>
|
||||||
|
/// <returns>The wrapped vector.</returns>
|
||||||
|
public static unsafe ImVectorWrapper<ImFontConfig> ConfigDataWrapped(this ImFontAtlasPtr obj) =>
|
||||||
|
obj.NativePtr is null
|
||||||
|
? throw new NullReferenceException()
|
||||||
|
: new(&obj.NativePtr->ConfigData, ImGuiNative.ImFontConfig_destroy);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Wraps <see cref="ImFontAtlas.Fonts"/> into a <see cref="ImVectorWrapper{T}"/>.<br />
|
||||||
|
/// This does not need to be disposed.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="obj">The owner object.</param>
|
||||||
|
/// <returns>The wrapped vector.</returns>
|
||||||
|
public static unsafe ImVectorWrapper<ImFontPtr> FontsWrapped(this ImFontAtlasPtr obj) =>
|
||||||
|
obj.NativePtr is null
|
||||||
|
? throw new NullReferenceException()
|
||||||
|
: new(&obj.NativePtr->Fonts, x => ImGuiNative.ImFont_destroy(x->NativePtr));
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Wraps <see cref="ImFontAtlas.Textures"/> into a <see cref="ImVectorWrapper{T}"/>.<br />
|
||||||
|
/// This does not need to be disposed.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="obj">The owner object.</param>
|
||||||
|
/// <returns>The wrapped vector.</returns>
|
||||||
|
public static unsafe ImVectorWrapper<ImFontAtlasTexture> TexturesWrapped(this ImFontAtlasPtr obj) =>
|
||||||
|
obj.NativePtr is null
|
||||||
|
? throw new NullReferenceException()
|
||||||
|
: new(&obj.NativePtr->Textures);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Wraps <see cref="ImFont.Glyphs"/> into a <see cref="ImVectorWrapper{T}"/>.<br />
|
||||||
|
/// This does not need to be disposed.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="obj">The owner object.</param>
|
||||||
|
/// <returns>The wrapped vector.</returns>
|
||||||
|
public static unsafe ImVectorWrapper<ImGuiHelpers.ImFontGlyphReal> GlyphsWrapped(this ImFontPtr obj) =>
|
||||||
|
obj.NativePtr is null
|
||||||
|
? throw new NullReferenceException()
|
||||||
|
: new(&obj.NativePtr->Glyphs);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Wraps <see cref="ImFont.IndexedHotData"/> into a <see cref="ImVectorWrapper{T}"/>.<br />
|
||||||
|
/// This does not need to be disposed.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="obj">The owner object.</param>
|
||||||
|
/// <returns>The wrapped vector.</returns>
|
||||||
|
public static unsafe ImVectorWrapper<ImGuiHelpers.ImFontGlyphHotDataReal> IndexedHotDataWrapped(this ImFontPtr obj)
|
||||||
|
=> obj.NativePtr is null
|
||||||
|
? throw new NullReferenceException()
|
||||||
|
: new(&obj.NativePtr->IndexedHotData);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Wraps <see cref="ImFont.IndexLookup"/> into a <see cref="ImVectorWrapper{T}"/>.<br />
|
||||||
|
/// This does not need to be disposed.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="obj">The owner object.</param>
|
||||||
|
/// <returns>The wrapped vector.</returns>
|
||||||
|
public static unsafe ImVectorWrapper<ushort> IndexLookupWrapped(this ImFontPtr obj) =>
|
||||||
|
obj.NativePtr is null
|
||||||
|
? throw new NullReferenceException()
|
||||||
|
: new(&obj.NativePtr->IndexLookup);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,5 +2,12 @@
|
||||||
|
|
||||||
namespace Dalamud.Plugin;
|
namespace Dalamud.Plugin;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// State of an installed plugin.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Name">The name of the plugin.</param>
|
||||||
|
/// <param name="InternalName">The internal name of the plugin.</param>
|
||||||
|
/// <param name="IsLoaded">Whether or not the plugin is loaded.</param>
|
||||||
|
/// <param name="Version">The version of the plugin.</param>
|
||||||
[Api10ToDo("Refactor into an interface, add wrappers for OpenMainUI and OpenConfigUI")]
|
[Api10ToDo("Refactor into an interface, add wrappers for OpenMainUI and OpenConfigUI")]
|
||||||
public record InstalledPluginState(string Name, string InternalName, bool IsLoaded, Version Version);
|
public record InstalledPluginState(string Name, string InternalName, bool IsLoaded, Version Version);
|
||||||
|
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
using System.IO;
|
|
||||||
|
|
||||||
namespace Dalamud.Plugin.Internal.Types;
|
|
||||||
|
|
||||||
internal record PluginPatchData
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="PluginPatchData"/> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="dllFile">DLL file being loaded.</param>
|
|
||||||
public PluginPatchData(FileSystemInfo dllFile)
|
|
||||||
{
|
|
||||||
this.Location = dllFile.FullName;
|
|
||||||
this.CodeBase = new Uri(dllFile.FullName).AbsoluteUri;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets simulated Assembly.Location output.
|
|
||||||
/// </summary>
|
|
||||||
public string Location { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets simulated Assembly.CodeBase output.
|
|
||||||
/// </summary>
|
|
||||||
public string CodeBase { get; }
|
|
||||||
}
|
|
||||||
|
|
@ -1,14 +1,20 @@
|
||||||
#define BORDER_MATCHING
|
#define BORDER_MATCHING
|
||||||
|
|
||||||
namespace Dalamud.Utility;
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
|
namespace Dalamud.Utility;
|
||||||
|
|
||||||
#pragma warning disable SA1600
|
#pragma warning disable SA1600
|
||||||
#pragma warning disable SA1602
|
#pragma warning disable SA1602
|
||||||
|
|
||||||
|
internal enum MatchMode
|
||||||
|
{
|
||||||
|
Simple,
|
||||||
|
Fuzzy,
|
||||||
|
FuzzyParts,
|
||||||
|
}
|
||||||
|
|
||||||
internal readonly ref struct FuzzyMatcher
|
internal readonly ref struct FuzzyMatcher
|
||||||
{
|
{
|
||||||
private static readonly (int, int)[] EmptySegArray = Array.Empty<(int, int)>();
|
private static readonly (int, int)[] EmptySegArray = Array.Empty<(int, int)>();
|
||||||
|
|
@ -272,12 +278,5 @@ internal readonly ref struct FuzzyMatcher
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal enum MatchMode
|
|
||||||
{
|
|
||||||
Simple,
|
|
||||||
Fuzzy,
|
|
||||||
FuzzyParts,
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma warning restore SA1600
|
#pragma warning restore SA1600
|
||||||
#pragma warning restore SA1602
|
#pragma warning restore SA1602
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue