diff --git a/Dalamud/Configuration/PluginConfigurations.cs b/Dalamud/Configuration/PluginConfigurations.cs
index c3b5c0d60..48522ea56 100644
--- a/Dalamud/Configuration/PluginConfigurations.cs
+++ b/Dalamud/Configuration/PluginConfigurations.cs
@@ -21,36 +21,6 @@ namespace Dalamud.Configuration
this.configDirectory.Create();
}
- ///
- /// Serializes a plugin configuration object.
- ///
- /// The configuration object.
- /// A string representing the serialized configuration object.
- internal static string SerializeConfig(object? config)
- {
- return JsonConvert.SerializeObject(config, Formatting.Indented, new JsonSerializerSettings
- {
- TypeNameAssemblyFormatHandling = TypeNameAssemblyFormatHandling.Simple,
- TypeNameHandling = TypeNameHandling.Objects,
- });
- }
-
- ///
- /// Deserializes a plugin configuration from a string.
- ///
- /// The serialized configuration.
- /// The configuration object, or null.
- internal static IPluginConfiguration? DeserializeConfig(string data)
- {
- return JsonConvert.DeserializeObject(
- data,
- new JsonSerializerSettings
- {
- TypeNameAssemblyFormatHandling = TypeNameAssemblyFormatHandling.Simple,
- TypeNameHandling = TypeNameHandling.Objects,
- });
- }
-
///
/// Save/Load plugin configuration.
/// NOTE: Save/Load are still using Type information for now,
@@ -145,6 +115,36 @@ namespace Dalamud.Configuration
/// FileInfo of the config file.
public FileInfo GetConfigFile(string pluginName) => new(Path.Combine(this.configDirectory.FullName, $"{pluginName}.json"));
+ ///
+ /// Serializes a plugin configuration object.
+ ///
+ /// The configuration object.
+ /// A string representing the serialized configuration object.
+ internal static string SerializeConfig(object? config)
+ {
+ return JsonConvert.SerializeObject(config, Formatting.Indented, new JsonSerializerSettings
+ {
+ TypeNameAssemblyFormatHandling = TypeNameAssemblyFormatHandling.Simple,
+ TypeNameHandling = TypeNameHandling.Objects,
+ });
+ }
+
+ ///
+ /// Deserializes a plugin configuration from a string.
+ ///
+ /// The serialized configuration.
+ /// The configuration object, or null.
+ internal static IPluginConfiguration? DeserializeConfig(string data)
+ {
+ return JsonConvert.DeserializeObject(
+ data,
+ new JsonSerializerSettings
+ {
+ TypeNameAssemblyFormatHandling = TypeNameAssemblyFormatHandling.Simple,
+ TypeNameHandling = TypeNameHandling.Objects,
+ });
+ }
+
private DirectoryInfo GetDirectoryPath(string pluginName) => new(Path.Combine(this.configDirectory.FullName, pluginName));
}
}
diff --git a/Dalamud/Dalamud.cs b/Dalamud/Dalamud.cs
index cc858eee8..d78c36692 100644
--- a/Dalamud/Dalamud.cs
+++ b/Dalamud/Dalamud.cs
@@ -4,6 +4,7 @@ using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
+
using Dalamud.Configuration.Internal;
using Dalamud.Game;
using Dalamud.Game.Gui.Internal;
diff --git a/Dalamud/Game/BaseAddressResolver.cs b/Dalamud/Game/BaseAddressResolver.cs
index c616e47fd..81449bb07 100644
--- a/Dalamud/Game/BaseAddressResolver.cs
+++ b/Dalamud/Game/BaseAddressResolver.cs
@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
+
using JetBrains.Annotations;
namespace Dalamud.Game
diff --git a/Dalamud/Game/ClientState/ClientState.cs b/Dalamud/Game/ClientState/ClientState.cs
index 2dc687aa2..b58da8ad5 100644
--- a/Dalamud/Game/ClientState/ClientState.cs
+++ b/Dalamud/Game/ClientState/ClientState.cs
@@ -35,11 +35,6 @@ namespace Dalamud.Game.ClientState
private bool lastConditionNone = true;
private bool lastFramePvP = false;
- ///
- /// Gets client state address resolver.
- ///
- internal ClientStateAddressResolver AddressResolver => this.address;
-
[ServiceManager.ServiceConstructor]
private ClientState(SigScanner sigScanner, DalamudStartInfo startInfo)
{
@@ -127,6 +122,11 @@ namespace Dalamud.Game.ClientState
///
public bool IsPvPExcludingDen { get; private set; }
+ ///
+ /// Gets client state address resolver.
+ ///
+ internal ClientStateAddressResolver AddressResolver => this.address;
+
///
/// Dispose of managed and unmanaged resources.
///
diff --git a/Dalamud/Game/Command/CommandManager.cs b/Dalamud/Game/Command/CommandManager.cs
index bb4b4f810..7d46b0842 100644
--- a/Dalamud/Game/Command/CommandManager.cs
+++ b/Dalamud/Game/Command/CommandManager.cs
@@ -149,6 +149,12 @@ namespace Dalamud.Game.Command
return this.commandMap.Remove(command);
}
+ ///
+ void IDisposable.Dispose()
+ {
+ this.chatGui.CheckMessageHandled -= this.OnCheckMessageHandled;
+ }
+
private void OnCheckMessageHandled(XivChatType type, uint senderId, ref SeString sender, ref SeString message, ref bool isHandled)
{
if (type == XivChatType.ErrorMessage && senderId == 0)
@@ -173,10 +179,5 @@ namespace Dalamud.Game.Command
}
}
}
-
- public void Dispose()
- {
- this.chatGui.CheckMessageHandled -= this.OnCheckMessageHandled;
- }
}
}
diff --git a/Dalamud/Game/Framework.cs b/Dalamud/Game/Framework.cs
index b9acf6a0d..cb1f4e2a9 100644
--- a/Dalamud/Game/Framework.cs
+++ b/Dalamud/Game/Framework.cs
@@ -168,7 +168,6 @@ namespace Dalamud.Game
///
/// Run given function right away if this function has been called from game's Framework.Update thread, or otherwise run on next Framework.Update call.
///
- /// Return type.
/// Function to call.
/// Task representing the pending or already completed function.
public Task RunOnFrameworkThread(Func func) =>
@@ -287,7 +286,6 @@ namespace Dalamud.Game
///
/// Run given function in upcoming Framework.Tick call.
///
- /// Return type.
/// Function to call.
/// Wait for given timespan before calling this function.
/// Count given number of Framework.Tick calls before calling this function. This takes precedence over delay parameter.
diff --git a/Dalamud/Game/Gui/FlyText/FlyTextGui.cs b/Dalamud/Game/Gui/FlyText/FlyTextGui.cs
index 9c8d7a87c..cdb65fa78 100644
--- a/Dalamud/Game/Gui/FlyText/FlyTextGui.cs
+++ b/Dalamud/Game/Gui/FlyText/FlyTextGui.cs
@@ -177,12 +177,6 @@ namespace Dalamud.Game.Gui.FlyText
}
}
- [ServiceManager.CallWhenServicesReady]
- private void ContinueConstruction(GameGui gameGui)
- {
- this.createFlyTextHook.Enable();
- }
-
private static byte[] Terminate(byte[] source)
{
var terminated = new byte[source.Length + 1];
@@ -192,6 +186,12 @@ namespace Dalamud.Game.Gui.FlyText
return terminated;
}
+ [ServiceManager.CallWhenServicesReady]
+ private void ContinueConstruction(GameGui gameGui)
+ {
+ this.createFlyTextHook.Enable();
+ }
+
private IntPtr CreateFlyTextDetour(
IntPtr addonFlyText,
FlyTextKind kind,
diff --git a/Dalamud/Game/Gui/FlyText/FlyTextKind.cs b/Dalamud/Game/Gui/FlyText/FlyTextKind.cs
index 6f598f354..ae5e8a3fb 100644
--- a/Dalamud/Game/Gui/FlyText/FlyTextKind.cs
+++ b/Dalamud/Game/Gui/FlyText/FlyTextKind.cs
@@ -85,7 +85,7 @@ namespace Dalamud.Game.Gui.FlyText
/// Serif Val1 with all caps condensed font EXP with Text2 in sans-serif as subtitle.
///
Exp = 14,
-
+
///
/// Serif Val1 with all caps condensed font ISLAND EXP with Text2 in sans-serif as subtitle.
///
diff --git a/Dalamud/Game/Gui/GameGui.cs b/Dalamud/Game/Gui/GameGui.cs
index 8272a6ce7..3576c66a0 100644
--- a/Dalamud/Game/Gui/GameGui.cs
+++ b/Dalamud/Game/Gui/GameGui.cs
@@ -406,25 +406,6 @@ namespace Dalamud.Game.Gui
return IntPtr.Zero;
}
- ///
- /// Set the current background music.
- ///
- /// The background music key.
- public void SetBgm(ushort bgmKey) => this.setGlobalBgmHook.Original(bgmKey, 0, 0, 0, 0, 0);
-
- [ServiceManager.CallWhenServicesReady]
- private void ContinueConstruction()
- {
- this.setGlobalBgmHook.Enable();
- this.handleItemHoverHook.Enable();
- this.handleItemOutHook.Enable();
- this.handleImmHook.Enable();
- this.toggleUiHideHook.Enable();
- this.handleActionHoverHook.Enable();
- this.handleActionOutHook.Enable();
- this.utf8StringFromSequenceHook.Enable();
- }
-
///
/// Disables the hooks and submodules of this module.
///
@@ -440,6 +421,12 @@ namespace Dalamud.Game.Gui
this.utf8StringFromSequenceHook.Dispose();
}
+ ///
+ /// Set the current background music.
+ ///
+ /// The background music key.
+ public void SetBgm(ushort bgmKey) => this.setGlobalBgmHook.Original(bgmKey, 0, 0, 0, 0, 0);
+
///
/// Reset the stored "UI hide" state.
///
@@ -448,6 +435,19 @@ namespace Dalamud.Game.Gui
this.GameUiHidden = false;
}
+ [ServiceManager.CallWhenServicesReady]
+ private void ContinueConstruction()
+ {
+ this.setGlobalBgmHook.Enable();
+ this.handleItemHoverHook.Enable();
+ this.handleItemOutHook.Enable();
+ this.handleImmHook.Enable();
+ this.toggleUiHideHook.Enable();
+ this.handleActionHoverHook.Enable();
+ this.handleActionOutHook.Enable();
+ this.utf8StringFromSequenceHook.Enable();
+ }
+
private IntPtr HandleSetGlobalBgmDetour(ushort bgmKey, byte a2, uint a3, uint a4, uint a5, byte a6)
{
var retVal = this.setGlobalBgmHook.Original(bgmKey, a2, a3, a4, a5, a6);
diff --git a/Dalamud/Game/Gui/Internal/DalamudIME.cs b/Dalamud/Game/Gui/Internal/DalamudIME.cs
index ed8dcdfcd..4304bb791 100644
--- a/Dalamud/Game/Gui/Internal/DalamudIME.cs
+++ b/Dalamud/Game/Gui/Internal/DalamudIME.cs
@@ -11,6 +11,7 @@ using Dalamud.Interface.Internal;
using Dalamud.Logging.Internal;
using ImGuiNET;
using PInvoke;
+
using static Dalamud.NativeFunctions;
namespace Dalamud.Game.Gui.Internal
@@ -58,64 +59,6 @@ namespace Dalamud.Game.Gui.Internal
Marshal.FreeHGlobal((IntPtr)this.cursorPos);
}
- private unsafe void LoadCand(IntPtr hWnd)
- {
- if (hWnd == IntPtr.Zero)
- return;
-
- var hIMC = ImmGetContext(hWnd);
- if (hIMC == IntPtr.Zero)
- return;
-
- var size = ImmGetCandidateListW(hIMC, 0, IntPtr.Zero, 0);
- if (size == 0)
- return;
-
- var candlistPtr = Marshal.AllocHGlobal((int)size);
- size = ImmGetCandidateListW(hIMC, 0, candlistPtr, (uint)size);
-
- var candlist = this.ImmCandNative = Marshal.PtrToStructure(candlistPtr);
- var pageSize = candlist.PageSize;
- var candCount = candlist.Count;
-
- if (pageSize > 0 && candCount > 1)
- {
- var dwOffsets = new int[candCount];
- for (var i = 0; i < candCount; i++)
- {
- dwOffsets[i] = Marshal.ReadInt32(candlistPtr + ((i + 6) * sizeof(int)));
- }
-
- var pageStart = candlist.PageStart;
-
- var cand = new string[pageSize];
- this.ImmCand.Clear();
-
- for (var i = 0; i < pageSize; i++)
- {
- var offStart = dwOffsets[i + pageStart];
- var offEnd = i + pageStart + 1 < candCount ? dwOffsets[i + pageStart + 1] : size;
-
- var pStrStart = candlistPtr + (int)offStart;
- var pStrEnd = candlistPtr + (int)offEnd;
-
- var len = (int)(pStrEnd.ToInt64() - pStrStart.ToInt64());
- if (len > 0)
- {
- var candBytes = new byte[len];
- Marshal.Copy(pStrStart, candBytes, 0, len);
-
- var candStr = Encoding.Unicode.GetString(candBytes);
- cand[i] = candStr;
-
- this.ImmCand.Add(candStr);
- }
- }
-
- Marshal.FreeHGlobal(candlistPtr);
- }
- }
-
///
/// Processes window messages.
///
@@ -137,13 +80,19 @@ namespace Dalamud.Game.Gui.Internal
{
wParam = Marshal.ReadInt32((IntPtr)wParamPtr);
}
- catch { }
+ catch
+ {
+ // ignored
+ }
try
{
lParam = Marshal.ReadInt32((IntPtr)lParamPtr);
}
- catch { }
+ catch
+ {
+ // ignored
+ }
switch (wmsg)
{
@@ -246,6 +195,64 @@ namespace Dalamud.Game.Gui.Internal
return new Vector2(this.cursorPos->X, this.cursorPos->Y);
}
+ private unsafe void LoadCand(IntPtr hWnd)
+ {
+ if (hWnd == IntPtr.Zero)
+ return;
+
+ var hImc = ImmGetContext(hWnd);
+ if (hImc == IntPtr.Zero)
+ return;
+
+ var size = ImmGetCandidateListW(hImc, 0, IntPtr.Zero, 0);
+ if (size == 0)
+ return;
+
+ var candlistPtr = Marshal.AllocHGlobal((int)size);
+ size = ImmGetCandidateListW(hImc, 0, candlistPtr, (uint)size);
+
+ var candlist = this.ImmCandNative = Marshal.PtrToStructure(candlistPtr);
+ var pageSize = candlist.PageSize;
+ var candCount = candlist.Count;
+
+ if (pageSize > 0 && candCount > 1)
+ {
+ var dwOffsets = new int[candCount];
+ for (var i = 0; i < candCount; i++)
+ {
+ dwOffsets[i] = Marshal.ReadInt32(candlistPtr + ((i + 6) * sizeof(int)));
+ }
+
+ var pageStart = candlist.PageStart;
+
+ var cand = new string[pageSize];
+ this.ImmCand.Clear();
+
+ for (var i = 0; i < pageSize; i++)
+ {
+ var offStart = dwOffsets[i + pageStart];
+ var offEnd = i + pageStart + 1 < candCount ? dwOffsets[i + pageStart + 1] : size;
+
+ var pStrStart = candlistPtr + (int)offStart;
+ var pStrEnd = candlistPtr + (int)offEnd;
+
+ var len = (int)(pStrEnd.ToInt64() - pStrStart.ToInt64());
+ if (len > 0)
+ {
+ var candBytes = new byte[len];
+ Marshal.Copy(pStrStart, candBytes, 0, len);
+
+ var candStr = Encoding.Unicode.GetString(candBytes);
+ cand[i] = candStr;
+
+ this.ImmCand.Add(candStr);
+ }
+ }
+
+ Marshal.FreeHGlobal(candlistPtr);
+ }
+ }
+
[ServiceManager.CallWhenServicesReady]
private void ContinueConstruction(InterfaceManager.InterfaceManagerWithScene interfaceManagerWithScene)
{
diff --git a/Dalamud/Game/Gui/PartyFinder/PartyFinderGui.cs b/Dalamud/Game/Gui/PartyFinder/PartyFinderGui.cs
index 2e9fa8c0e..c6a7dad04 100644
--- a/Dalamud/Game/Gui/PartyFinder/PartyFinderGui.cs
+++ b/Dalamud/Game/Gui/PartyFinder/PartyFinderGui.cs
@@ -26,7 +26,7 @@ namespace Dalamud.Game.Gui.PartyFinder
///
/// Initializes a new instance of the class.
///
- /// Tag.
+ /// Sig scanner to use.
[ServiceManager.ServiceConstructor]
private PartyFinderGui(SigScanner sigScanner)
{
diff --git a/Dalamud/Game/Gui/Toast/ToastGui.cs b/Dalamud/Game/Gui/Toast/ToastGui.cs
index 31f7711ba..05954553a 100644
--- a/Dalamud/Game/Gui/Toast/ToastGui.cs
+++ b/Dalamud/Game/Gui/Toast/ToastGui.cs
@@ -32,7 +32,7 @@ namespace Dalamud.Game.Gui.Toast
///
/// Initializes a new instance of the class.
///
- /// Tag.
+ /// Sig scanner to use.
[ServiceManager.ServiceConstructor]
private ToastGui(SigScanner sigScanner)
{
diff --git a/Dalamud/Game/Internal/DalamudAtkTweaks.cs b/Dalamud/Game/Internal/DalamudAtkTweaks.cs
index 15a58cb99..cf2af2eb5 100644
--- a/Dalamud/Game/Internal/DalamudAtkTweaks.cs
+++ b/Dalamud/Game/Internal/DalamudAtkTweaks.cs
@@ -3,8 +3,6 @@ using System.Runtime.InteropServices;
using CheapLoc;
using Dalamud.Configuration.Internal;
-//using Dalamud.Data;
-//using Dalamud.Game.Gui.ContextMenus;
using Dalamud.Game.Text;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Game.Text.SeStringHandling.Payloads;
@@ -12,7 +10,6 @@ using Dalamud.Hooking;
using Dalamud.Interface.Internal;
using Dalamud.Interface.Windowing;
using FFXIVClientStructs.FFXIV.Component.GUI;
-//using Lumina.Excel.GeneratedSheets;
using Serilog;
using ValueType = FFXIVClientStructs.FFXIV.Component.GUI.ValueType;
@@ -142,7 +139,7 @@ namespace Dalamud.Game.Internal
return;
}
- if (!configuration.DoButtonsSystemMenu || !interfaceManager.IsDispatchingEvents)
+ if (!this.configuration.DoButtonsSystemMenu || !interfaceManager.IsDispatchingEvents)
{
this.hookAgentHudOpenSystemMenu.Original(thisPtr, atkValueArgs, menuSize);
return;
diff --git a/Dalamud/Game/Text/SeStringHandling/BitmapFontIcon.cs b/Dalamud/Game/Text/SeStringHandling/BitmapFontIcon.cs
index c760af979..3209d1496 100644
--- a/Dalamud/Game/Text/SeStringHandling/BitmapFontIcon.cs
+++ b/Dalamud/Game/Text/SeStringHandling/BitmapFontIcon.cs
@@ -457,6 +457,7 @@ namespace Dalamud.Game.Text.SeStringHandling
///
/// The Island Sanctuary icon.
+ ///
IslandSanctuary = 116,
}
}
diff --git a/Dalamud/Hooking/Hook.cs b/Dalamud/Hooking/Hook.cs
index 104d4f5a7..8c12d5563 100644
--- a/Dalamud/Hooking/Hook.cs
+++ b/Dalamud/Hooking/Hook.cs
@@ -15,8 +15,12 @@ namespace Dalamud.Hooking
/// Delegate type to represents a function prototype. This must be the same prototype as original function do.
public class Hook : IDisposable, IDalamudHook where T : Delegate
{
+#pragma warning disable SA1310
+ // ReSharper disable once InconsistentNaming
private const ulong IMAGE_ORDINAL_FLAG64 = 0x8000000000000000;
+ // ReSharper disable once InconsistentNaming
private const uint IMAGE_ORDINAL_FLAG32 = 0x80000000;
+#pragma warning restore SA1310
private readonly IntPtr address;
diff --git a/Dalamud/Hooking/Internal/FunctionPointerVariableHook.cs b/Dalamud/Hooking/Internal/FunctionPointerVariableHook.cs
index d34072f52..fcdba357a 100644
--- a/Dalamud/Hooking/Internal/FunctionPointerVariableHook.cs
+++ b/Dalamud/Hooking/Internal/FunctionPointerVariableHook.cs
@@ -2,6 +2,7 @@ using System;
using System.ComponentModel;
using System.Reflection;
using System.Runtime.InteropServices;
+
using Dalamud.Memory;
namespace Dalamud.Hooking.Internal
@@ -96,8 +97,7 @@ namespace Dalamud.Hooking.Internal
{
lock (HookManager.HookEnableSyncRoot)
{
- if (!NativeFunctions.VirtualProtect(this.Address, (UIntPtr)Marshal.SizeOf(),
- MemoryProtection.ExecuteReadWrite, out var oldProtect))
+ if (!NativeFunctions.VirtualProtect(this.Address, (UIntPtr)Marshal.SizeOf(), MemoryProtection.ExecuteReadWrite, out var oldProtect))
throw new Win32Exception(Marshal.GetLastWin32Error());
Marshal.WriteIntPtr(this.Address, Marshal.GetFunctionPointerForDelegate(this.detourDelegate));
@@ -115,8 +115,7 @@ namespace Dalamud.Hooking.Internal
{
lock (HookManager.HookEnableSyncRoot)
{
- if (!NativeFunctions.VirtualProtect(this.Address, (UIntPtr)Marshal.SizeOf(),
- MemoryProtection.ExecuteReadWrite, out var oldProtect))
+ if (!NativeFunctions.VirtualProtect(this.Address, (UIntPtr)Marshal.SizeOf(), MemoryProtection.ExecuteReadWrite, out var oldProtect))
throw new Win32Exception(Marshal.GetLastWin32Error());
Marshal.WriteIntPtr(this.Address, this.pfnOriginal);
diff --git a/Dalamud/Hooking/Internal/ReloadedHook.cs b/Dalamud/Hooking/Internal/ReloadedHook.cs
index 28c22b4f8..68c23e14f 100644
--- a/Dalamud/Hooking/Internal/ReloadedHook.cs
+++ b/Dalamud/Hooking/Internal/ReloadedHook.cs
@@ -6,6 +6,10 @@ using Reloaded.Hooks;
namespace Dalamud.Hooking.Internal
{
+ ///
+ /// Class facilitating hooks via reloaded.
+ ///
+ /// Delegate of the hook.
internal class ReloadedHook : Hook where T : Delegate
{
private readonly Reloaded.Hooks.Definitions.IHook hookImpl;
diff --git a/Dalamud/Interface/GameFonts/FdtReader.cs b/Dalamud/Interface/GameFonts/FdtReader.cs
index db373d221..167cacf2d 100644
--- a/Dalamud/Interface/GameFonts/FdtReader.cs
+++ b/Dalamud/Interface/GameFonts/FdtReader.cs
@@ -9,16 +9,6 @@ namespace Dalamud.Interface.GameFonts
///
public class FdtReader
{
- private static unsafe T StructureFromByteArray (byte[] data, int offset)
- {
- var len = Marshal.SizeOf();
- if (offset + len > data.Length)
- throw new Exception("Data too short");
-
- fixed (byte* ptr = data)
- return Marshal.PtrToStructure(new(ptr + offset));
- }
-
///
/// Initializes a new instance of the class.
///
@@ -33,7 +23,7 @@ namespace Dalamud.Interface.GameFonts
this.Glyphs.Add(StructureFromByteArray(data, this.FileHeader.FontTableHeaderOffset + Marshal.SizeOf() + (Marshal.SizeOf() * i)));
for (int i = 0, i_ = Math.Min(this.FontHeader.KerningTableEntryCount, this.KerningHeader.Count); i < i_; i++)
- this.Distances.Add(StructureFromByteArray(data, this.FileHeader.KerningTableHeaderOffset+ Marshal.SizeOf() + (Marshal.SizeOf() * i)));
+ this.Distances.Add(StructureFromByteArray(data, this.FileHeader.KerningTableHeaderOffset + Marshal.SizeOf() + (Marshal.SizeOf() * i)));
}
///
@@ -68,7 +58,7 @@ namespace Dalamud.Interface.GameFonts
/// Corresponding FontTableEntry, or null if not found.
public FontTableEntry? FindGlyph(int codepoint)
{
- var i = this.Glyphs.BinarySearch(new FontTableEntry { CharUtf8 = CodePointToUtf8int32(codepoint) });
+ var i = this.Glyphs.BinarySearch(new FontTableEntry { CharUtf8 = CodePointToUtf8Int32(codepoint) });
if (i < 0 || i == this.Glyphs.Count)
return null;
return this.Glyphs[i];
@@ -95,13 +85,23 @@ namespace Dalamud.Interface.GameFonts
/// Supposed distance adjustment between given characters.
public int GetDistance(int codepoint1, int codepoint2)
{
- var i = this.Distances.BinarySearch(new KerningTableEntry { LeftUtf8 = CodePointToUtf8int32(codepoint1), RightUtf8 = CodePointToUtf8int32(codepoint2) });
+ var i = this.Distances.BinarySearch(new KerningTableEntry { LeftUtf8 = CodePointToUtf8Int32(codepoint1), RightUtf8 = CodePointToUtf8Int32(codepoint2) });
if (i < 0 || i == this.Distances.Count)
return 0;
return this.Distances[i].RightOffset;
}
- private static int CodePointToUtf8int32(int codepoint)
+ private static unsafe T StructureFromByteArray(byte[] data, int offset)
+ {
+ var len = Marshal.SizeOf();
+ if (offset + len > data.Length)
+ throw new Exception("Data too short");
+
+ fixed (byte* ptr = data)
+ return Marshal.PtrToStructure(new(ptr + offset));
+ }
+
+ private static int CodePointToUtf8Int32(int codepoint)
{
if (codepoint <= 0x7F)
{
diff --git a/Dalamud/Interface/GameFonts/GameFontManager.cs b/Dalamud/Interface/GameFonts/GameFontManager.cs
index efa390e46..bd6e9bc99 100644
--- a/Dalamud/Interface/GameFonts/GameFontManager.cs
+++ b/Dalamud/Interface/GameFonts/GameFontManager.cs
@@ -5,6 +5,7 @@ using System.Numerics;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
+
using Dalamud.Data;
using Dalamud.Game;
using Dalamud.Interface.Internal;
@@ -12,6 +13,7 @@ using Dalamud.Utility.Timing;
using ImGuiNET;
using Lumina.Data.Files;
using Serilog;
+
using static Dalamud.Interface.ImGuiHelpers;
namespace Dalamud.Interface.GameFonts
@@ -40,7 +42,9 @@ namespace Dalamud.Interface.GameFonts
private readonly Dictionary fontUseCounter = new();
private readonly Dictionary>> glyphRectIds = new();
+#pragma warning disable CS0414
private bool isBetweenBuildFontsAndRightAfterImGuiIoFontsBuild = false;
+#pragma warning restore CS0414
[ServiceManager.ServiceConstructor]
private GameFontManager(DataManager dataManager)
diff --git a/Dalamud/Interface/ImGuiExtensions.cs b/Dalamud/Interface/ImGuiExtensions.cs
index 0e3c58925..be1b99430 100644
--- a/Dalamud/Interface/ImGuiExtensions.cs
+++ b/Dalamud/Interface/ImGuiExtensions.cs
@@ -1,31 +1,43 @@
using System;
using System.Numerics;
using System.Text;
+
using ImGuiNET;
namespace Dalamud.Interface;
+///
+/// Class containing various extensions to ImGui, aiding with building custom widgets.
+///
public static class ImGuiExtensions
{
- public static void AddTextClippedEx(
- this ImDrawListPtr drawListPtr, Vector2 posMin, Vector2 posMax, string text, Vector2? textSizeIfKnown,
- Vector2 align, Vector4? clipRect)
+ ///
+ /// Draw clipped text.
+ ///
+ /// Pointer to the draw list.
+ /// Minimum position.
+ /// Maximum position.
+ /// Text to draw.
+ /// Size of the text, if known.
+ /// Alignment.
+ /// Clip rect to use.
+ public static void AddTextClippedEx(this ImDrawListPtr drawListPtr, Vector2 posMin, Vector2 posMax, string text, Vector2? textSizeIfKnown, Vector2 align, Vector4? clipRect)
{
var pos = posMin;
var textSize = textSizeIfKnown ?? ImGui.CalcTextSize(text, false, 0);
-
+
var clipMin = clipRect.HasValue ? new Vector2(clipRect.Value.X, clipRect.Value.Y) : posMin;
var clipMax = clipRect.HasValue ? new Vector2(clipRect.Value.Z, clipRect.Value.W) : posMax;
-
+
var needClipping = (pos.X + textSize.X >= clipMax.X) || (pos.Y + textSize.Y >= clipMax.Y);
if (clipRect.HasValue)
needClipping |= (pos.X < clipMin.X) || (pos.Y < clipMin.Y);
-
+
if (align.X > 0)
{
pos.X = Math.Max(pos.X, pos.X + ((posMax.X - pos.X - textSize.X) * align.X));
}
-
+
if (align.Y > 0)
{
pos.Y = Math.Max(pos.Y, pos.Y + ((posMax.Y - pos.Y - textSize.Y) * align.Y));
@@ -42,22 +54,32 @@ public static class ImGuiExtensions
}
}
+ ///
+ /// Add text to a draw list.
+ ///
+ /// Pointer to the draw list.
+ /// Font to use.
+ /// Font size.
+ /// Position to draw at.
+ /// Color to use.
+ /// Text to draw.
+ /// Clip rect to use.
// TODO: This should go into ImDrawList.Manual.cs in ImGui.NET...
public static unsafe void AddText(this ImDrawListPtr drawListPtr, ImFontPtr font, float fontSize, Vector2 pos, uint col, string textBegin, ref Vector4 cpuFineClipRect)
{
var nativeFont = font.NativePtr;
var textBeginByteCount = Encoding.UTF8.GetByteCount(textBegin);
var nativeTextBegin = stackalloc byte[textBeginByteCount + 1];
-
+
fixed (char* textBeginPtr = textBegin)
{
var nativeTextBeginOffset = Encoding.UTF8.GetBytes(textBeginPtr, textBegin.Length, nativeTextBegin, textBeginByteCount);
nativeTextBegin[nativeTextBeginOffset] = 0;
}
-
+
byte* nativeTextEnd = null;
var wrapWidth = 0.0f;
-
+
fixed (Vector4* nativeCpuFineClipRect = &cpuFineClipRect)
{
ImGuiNative.ImDrawList_AddText_FontPtr(drawListPtr.NativePtr, nativeFont, fontSize, pos, col, nativeTextBegin, nativeTextEnd, wrapWidth, nativeCpuFineClipRect);
diff --git a/Dalamud/Interface/ImGuiFileDialog/FileDialog.Structs.cs b/Dalamud/Interface/ImGuiFileDialog/FileDialog.Structs.cs
index 9dd5151bf..8671a2736 100644
--- a/Dalamud/Interface/ImGuiFileDialog/FileDialog.Structs.cs
+++ b/Dalamud/Interface/ImGuiFileDialog/FileDialog.Structs.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
+
using Dalamud.Utility;
namespace Dalamud.Interface.ImGuiFileDialog
diff --git a/Dalamud/Interface/ImGuiFileDialog/FileDialog.UI.cs b/Dalamud/Interface/ImGuiFileDialog/FileDialog.UI.cs
index a81f55b2f..5f51d2739 100644
--- a/Dalamud/Interface/ImGuiFileDialog/FileDialog.UI.cs
+++ b/Dalamud/Interface/ImGuiFileDialog/FileDialog.UI.cs
@@ -313,7 +313,6 @@ namespace Dalamud.Interface.ImGuiFileDialog
{
if (ImGui.BeginChild("##FileDialog_SideBar", size))
{
-
ImGui.SetCursorPosY(ImGui.GetCursorPosY() + Scaled(5));
var idx = 0;
@@ -508,6 +507,7 @@ namespace Dalamud.Interface.ImGuiFileDialog
this.pathClicked = this.SelectDirectory(file);
return true;
}
+
if (this.IsDirectoryMode())
{
this.SelectFileName(file);
diff --git a/Dalamud/Interface/ImGuiFileDialog/FileDialog.cs b/Dalamud/Interface/ImGuiFileDialog/FileDialog.cs
index 8308c7116..de42e9e9d 100644
--- a/Dalamud/Interface/ImGuiFileDialog/FileDialog.cs
+++ b/Dalamud/Interface/ImGuiFileDialog/FileDialog.cs
@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
+
using ImGuiNET;
namespace Dalamud.Interface.ImGuiFileDialog
@@ -14,7 +15,9 @@ namespace Dalamud.Interface.ImGuiFileDialog
///
/// The flags used to draw the file picker window.
///
+#pragma warning disable SA1401
public ImGuiWindowFlags WindowFlags;
+#pragma warning restore SA1401
private readonly string title;
private readonly int selectionCountMax;
diff --git a/Dalamud/Interface/ImGuiFileDialog/FileDialogManager.cs b/Dalamud/Interface/ImGuiFileDialog/FileDialogManager.cs
index 05d6a040e..eff871d30 100644
--- a/Dalamud/Interface/ImGuiFileDialog/FileDialogManager.cs
+++ b/Dalamud/Interface/ImGuiFileDialog/FileDialogManager.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+
using ImGuiNET;
namespace Dalamud.Interface.ImGuiFileDialog
@@ -9,11 +10,13 @@ namespace Dalamud.Interface.ImGuiFileDialog
///
public class FileDialogManager
{
+#pragma warning disable SA1401
/// Additional quick access items for the side bar.
public readonly List<(string Name, string Path, FontAwesomeIcon Icon, int Position)> CustomSideBarItems = new();
/// Additional flags with which to draw the window.
public ImGuiWindowFlags AddedWindowFlags = ImGuiWindowFlags.None;
+#pragma warning restore SA1401
private FileDialog? dialog;
private Action? callback;
diff --git a/Dalamud/Interface/ImGuiHelpers.cs b/Dalamud/Interface/ImGuiHelpers.cs
index ec2236695..19704bd77 100644
--- a/Dalamud/Interface/ImGuiHelpers.cs
+++ b/Dalamud/Interface/ImGuiHelpers.cs
@@ -28,7 +28,7 @@ namespace Dalamud.Interface
///
/// Gets a that is pre-scaled with the multiplier.
///
- /// Vector2 X & Y parameter.
+ /// Vector2 X/Y parameter.
/// A scaled Vector2.
public static Vector2 ScaledVector2(float x) => new Vector2(x, x) * GlobalScale;
@@ -381,7 +381,7 @@ namespace Dalamud.Interface
public ushort Height;
public ushort X;
public ushort Y;
- public uint TextureIndexAndGlyphID;
+ public uint TextureIndexAndGlyphId;
public float GlyphAdvanceX;
public Vector2 GlyphOffset;
public ImFont* Font;
@@ -394,15 +394,15 @@ namespace Dalamud.Interface
public int TextureIndex
{
- get => (int)(this.TextureIndexAndGlyphID & TextureIndexMask) >> TextureIndexShift;
- set => this.TextureIndexAndGlyphID = (this.TextureIndexAndGlyphID & ~TextureIndexMask) | ((uint)value << TextureIndexShift);
+ get => (int)(this.TextureIndexAndGlyphId & TextureIndexMask) >> TextureIndexShift;
+ set => this.TextureIndexAndGlyphId = (this.TextureIndexAndGlyphId & ~TextureIndexMask) | ((uint)value << TextureIndexShift);
}
- public int GlyphID
+ public int GlyphId
{
- get => (int)(this.TextureIndexAndGlyphID & GlyphIDMask) >> GlyphIDShift;
- set => this.TextureIndexAndGlyphID = (this.TextureIndexAndGlyphID & ~GlyphIDMask) | ((uint)value << GlyphIDShift);
+ get => (int)(this.TextureIndexAndGlyphId & GlyphIDMask) >> GlyphIDShift;
+ set => this.TextureIndexAndGlyphId = (this.TextureIndexAndGlyphId & ~GlyphIDMask) | ((uint)value << GlyphIDShift);
}
- };
+ }
}
}
diff --git a/Dalamud/Interface/Internal/DalamudInterface.cs b/Dalamud/Interface/Internal/DalamudInterface.cs
index d008c9dd2..a8808e54f 100644
--- a/Dalamud/Interface/Internal/DalamudInterface.cs
+++ b/Dalamud/Interface/Internal/DalamudInterface.cs
@@ -48,7 +48,7 @@ namespace Dalamud.Interface.Internal
private readonly CreditsWindow creditsWindow;
private readonly DataWindow dataWindow;
private readonly GamepadModeNotifierWindow gamepadModeNotifierWindow;
- private readonly IMEWindow imeWindow;
+ private readonly ImeWindow imeWindow;
private readonly ConsoleWindow consoleWindow;
private readonly PluginStatWindow pluginStatWindow;
private readonly PluginInstallerWindow pluginWindow;
@@ -93,7 +93,7 @@ namespace Dalamud.Interface.Internal
this.creditsWindow = new CreditsWindow() { IsOpen = false };
this.dataWindow = new DataWindow() { IsOpen = false };
this.gamepadModeNotifierWindow = new GamepadModeNotifierWindow() { IsOpen = false };
- this.imeWindow = new IMEWindow() { IsOpen = false };
+ this.imeWindow = new ImeWindow() { IsOpen = false };
this.consoleWindow = new ConsoleWindow() { IsOpen = configuration.LogOpenAtStartup };
this.pluginStatWindow = new PluginStatWindow() { IsOpen = false };
this.pluginWindow = new PluginInstallerWindow(pluginImageCache) { IsOpen = false };
@@ -231,7 +231,7 @@ namespace Dalamud.Interface.Internal
public void OpenGamepadModeNotifierWindow() => this.gamepadModeNotifierWindow.IsOpen = true;
///
- /// Opens the .
+ /// Opens the .
///
public void OpenImeWindow() => this.imeWindow.IsOpen = true;
@@ -276,7 +276,7 @@ namespace Dalamud.Interface.Internal
public void OpenProfiler() => this.profilerWindow.IsOpen = true;
///
- /// Opens the
+ /// Opens the .
///
public void OpenBranchSwitcher() => this.branchSwitcherWindow.IsOpen = true;
@@ -285,7 +285,7 @@ namespace Dalamud.Interface.Internal
#region Close
///
- /// Closes the .
+ /// Closes the .
///
public void CloseImeWindow() => this.imeWindow.IsOpen = false;
@@ -342,7 +342,7 @@ namespace Dalamud.Interface.Internal
public void ToggleGamepadModeNotifierWindow() => this.gamepadModeNotifierWindow.Toggle();
///
- /// Toggles the .
+ /// Toggles the .
///
public void ToggleIMEWindow() => this.imeWindow.Toggle();
diff --git a/Dalamud/Interface/Internal/InterfaceManager.cs b/Dalamud/Interface/Internal/InterfaceManager.cs
index 53bcfcf3d..62abeaf1d 100644
--- a/Dalamud/Interface/Internal/InterfaceManager.cs
+++ b/Dalamud/Interface/Internal/InterfaceManager.cs
@@ -7,6 +7,7 @@ using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
+
using Dalamud.Configuration.Internal;
using Dalamud.Game;
using Dalamud.Game.ClientState.GamePad;
@@ -100,6 +101,7 @@ namespace Dalamud.Interface.Internal
[UnmanagedFunctionPointer(CallingConvention.ThisCall)]
private delegate IntPtr ProcessMessageDelegate(IntPtr hWnd, uint msg, ulong wParam, ulong lParam, IntPtr handeled);
+
///
/// This event gets called each frame to facilitate ImGui drawing.
///
@@ -1135,7 +1137,7 @@ namespace Dalamud.Interface.Internal
}
///
- /// Associated InterfaceManager.
+ /// Gets the associated InterfaceManager.
///
public InterfaceManager Manager { get; init; }
}
diff --git a/Dalamud/Interface/Internal/ManagedAsserts/ImGuiManagedAsserts.cs b/Dalamud/Interface/Internal/ManagedAsserts/ImGuiManagedAsserts.cs
index 03f544ef9..5940a42a3 100644
--- a/Dalamud/Interface/Internal/ManagedAsserts/ImGuiManagedAsserts.cs
+++ b/Dalamud/Interface/Internal/ManagedAsserts/ImGuiManagedAsserts.cs
@@ -51,6 +51,7 @@ namespace Dalamud.Interface.Internal.ManagedAsserts
// TODO: Needs to be updated for ImGui 1.88
return;
+#pragma warning disable CS0162
if (!AssertsEnabled)
{
return;
@@ -93,6 +94,7 @@ namespace Dalamud.Interface.Internal.ManagedAsserts
ShowAssert(source, $"Mismatched Begin/BeginChild vs End/EndChild calls: did you call End/EndChild too much?\n\ncSnap.WindowStackSize = {cSnap.WindowStackSize}");
}
}
+#pragma warning restore CS0162
}
private static void ShowAssert(string source, string message)
diff --git a/Dalamud/Interface/Internal/Windows/CreditsWindow.cs b/Dalamud/Interface/Internal/Windows/CreditsWindow.cs
index 07a678e81..9051642ca 100644
--- a/Dalamud/Interface/Internal/Windows/CreditsWindow.cs
+++ b/Dalamud/Interface/Internal/Windows/CreditsWindow.cs
@@ -19,7 +19,8 @@ namespace Dalamud.Interface.Internal.Windows
///
internal class CreditsWindow : Window, IDisposable
{
- private const float CreditFPS = 60.0f;
+ private const float CreditFps = 60.0f;
+ private const string ThankYouText = "Thank you!";
private const string CreditsTextTempl = @"
Dalamud
A FFXIV Plugin Framework
@@ -163,7 +164,6 @@ Contribute at: https://github.com/goatsoft/Dalamud
private string creditsText;
private GameFontHandle? thankYouFont;
- private const string thankYouText = "Thank you!";
///
/// Initializes a new instance of the class.
@@ -265,11 +265,11 @@ Contribute at: https://github.com/goatsoft/Dalamud
if (this.thankYouFont != null)
{
ImGui.PushFont(this.thankYouFont.ImFont);
- var thankYouLenX = ImGui.CalcTextSize(thankYouText).X;
+ var thankYouLenX = ImGui.CalcTextSize(ThankYouText).X;
ImGui.Dummy(new Vector2((windowX / 2) - (thankYouLenX / 2), 0f));
ImGui.SameLine();
- ImGui.TextUnformatted(thankYouText);
+ ImGui.TextUnformatted(ThankYouText);
ImGui.PopFont();
}
@@ -278,7 +278,7 @@ Contribute at: https://github.com/goatsoft/Dalamud
ImGui.PopStyleVar();
- if (this.creditsThrottler.Elapsed.TotalMilliseconds > (1000.0f / CreditFPS))
+ if (this.creditsThrottler.Elapsed.TotalMilliseconds > (1000.0f / CreditFps))
{
var curY = ImGui.GetScrollY();
var maxY = ImGui.GetScrollMaxY();
diff --git a/Dalamud/Interface/Internal/Windows/IMEWindow.cs b/Dalamud/Interface/Internal/Windows/IMEWindow.cs
index 7f15733ea..d9e508357 100644
--- a/Dalamud/Interface/Internal/Windows/IMEWindow.cs
+++ b/Dalamud/Interface/Internal/Windows/IMEWindow.cs
@@ -10,14 +10,14 @@ namespace Dalamud.Interface.Internal.Windows
///
/// A window for displaying IME details.
///
- internal unsafe class IMEWindow : Window
+ internal unsafe class ImeWindow : Window
{
private const int ImePageSize = 9;
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
- public IMEWindow()
+ public ImeWindow()
: base("Dalamud IME", ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoFocusOnAppearing | ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoBackground)
{
this.Size = new Vector2(100, 200);
@@ -38,8 +38,8 @@ namespace Dalamud.Interface.Internal.Windows
return;
}
- //ImGui.Text($"{ime.GetCursorPos()}");
- //ImGui.Text($"{ImGui.GetWindowViewport().WorkSize}");
+ // ImGui.Text($"{ime.GetCursorPos()}");
+ // ImGui.Text($"{ImGui.GetWindowViewport().WorkSize}");
}
///
diff --git a/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs b/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs
index 40b44d217..f48417ea0 100644
--- a/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs
+++ b/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs
@@ -1518,8 +1518,9 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller
ImGui.TextWrapped(Locs.PluginBody_Outdated);
ImGui.PopStyleColor();
}
- else if (plugin is { IsBanned: true }) // Banned warning
+ else if (plugin is { IsBanned: true })
{
+ // Banned warning
ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudRed);
ImGuiHelpers.SafeTextWrapped(plugin.BanReason.IsNullOrEmpty()
? Locs.PluginBody_Banned
@@ -1539,8 +1540,9 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller
ImGui.TextWrapped(Locs.PluginBody_Policy);
ImGui.PopStyleColor();
}
- else if (plugin is { State: PluginState.LoadError or PluginState.DependencyResolutionFailed }) // Load failed warning
+ else if (plugin is { State: PluginState.LoadError or PluginState.DependencyResolutionFailed })
{
+ // Load failed warning
ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudRed);
ImGui.TextWrapped(Locs.PluginBody_LoadFailed);
ImGui.PopStyleColor();
@@ -1803,7 +1805,7 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller
var configuration = Service.Get();
var commandManager = Service.Get();
- var testingOptIn =
+ var testingOptIn =
configuration.PluginTestingOptIns?.FirstOrDefault(x => x.InternalName == plugin.Manifest.InternalName);
var trouble = false;
@@ -2179,9 +2181,10 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller
plugin.ReloadManifest();
}
- var enableTask = Task.Run(() => plugin.Enable())
- .ContinueWith(this.DisplayErrorContinuation,
- Locs.ErrorModal_EnableFail(plugin.Name));
+ var enableTask = Task.Run(plugin.Enable)
+ .ContinueWith(
+ this.DisplayErrorContinuation,
+ Locs.ErrorModal_EnableFail(plugin.Name));
enableTask.Wait();
if (!enableTask.Result)
@@ -2191,8 +2194,9 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller
}
var loadTask = Task.Run(() => plugin.LoadAsync(PluginLoadReason.Installer))
- .ContinueWith(this.DisplayErrorContinuation,
- Locs.ErrorModal_LoadFail(plugin.Name));
+ .ContinueWith(
+ this.DisplayErrorContinuation,
+ Locs.ErrorModal_LoadFail(plugin.Name));
loadTask.Wait();
this.enableDisableStatus = OperationStatus.Complete;
@@ -2200,9 +2204,10 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller
if (!loadTask.Result)
return;
- notifications.AddNotification(Locs.Notifications_PluginEnabled(plugin.Manifest.Name),
- Locs.Notifications_PluginEnabledTitle,
- NotificationType.Success);
+ notifications.AddNotification(
+ Locs.Notifications_PluginEnabled(plugin.Manifest.Name),
+ Locs.Notifications_PluginEnabledTitle,
+ NotificationType.Success);
});
if (availableUpdate != default && !availableUpdate.InstalledPlugin.IsDev)
@@ -2833,6 +2838,7 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller
public static string PluginBody_Plugin3rdPartyRepo(string url) => Loc.Localize("InstallerPlugin3rdPartyRepo", "From custom plugin repository {0}").Format(url);
public static string PluginBody_AvailableDevPlugin => Loc.Localize("InstallerDevPlugin", " This plugin is available in one of your repos, please remove it from the devPlugins folder.");
+
public static string PluginBody_Outdated => Loc.Localize("InstallerOutdatedPluginBody ", "This plugin is outdated and incompatible at the moment. Please wait for it to be updated by its author.");
public static string PluginBody_Orphaned => Loc.Localize("InstallerOrphanedPluginBody ", "This plugin's source repository is no longer available. You may need to reinstall it from its repository, or re-add the repository.");
diff --git a/Dalamud/Interface/Internal/Windows/PluginStatWindow.cs b/Dalamud/Interface/Internal/Windows/PluginStatWindow.cs
index 3aa16586f..4ae3655b2 100644
--- a/Dalamud/Interface/Internal/Windows/PluginStatWindow.cs
+++ b/Dalamud/Interface/Internal/Windows/PluginStatWindow.cs
@@ -188,7 +188,6 @@ namespace Dalamud.Interface.Internal.Windows
ImGui.TableNextColumn();
ImGui.Text($"{handlerHistory.Key}");
-
ImGui.TableNextColumn();
ImGui.Text($"{handlerHistory.Value.Last():F4}ms");
diff --git a/Dalamud/Interface/Internal/Windows/ProfilerWindow.cs b/Dalamud/Interface/Internal/Windows/ProfilerWindow.cs
index 91c53efe5..2d0f54912 100644
--- a/Dalamud/Interface/Internal/Windows/ProfilerWindow.cs
+++ b/Dalamud/Interface/Internal/Windows/ProfilerWindow.cs
@@ -1,7 +1,9 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Numerics;
+
using Dalamud.Interface.Colors;
using Dalamud.Interface.Windowing;
using Dalamud.Utility.Numerics;
@@ -10,29 +12,30 @@ using ImGuiNET;
namespace Dalamud.Interface.Internal.Windows;
+///
+/// Class used to draw the Dalamud profiler.
+///
public class ProfilerWindow : Window
{
private double min;
private double max;
private List>> occupied = new();
- public ProfilerWindow() : base("Profiler", forceMainWindow: true) { }
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public ProfilerWindow()
+ : base("Profiler", forceMainWindow: true)
+ {
+ }
+ ///
public override void OnOpen()
{
this.min = Timings.AllTimings.Keys.Min(x => x.StartTime);
this.max = Timings.AllTimings.Keys.Max(x => x.EndTime);
}
- private class RectInfo
- {
- internal TimingHandle Timing;
- internal Vector2 MinPos;
- internal Vector2 MaxPos;
- internal Vector4 RectColor;
- internal bool Hover;
- }
-
///
public override void Draw()
{
@@ -249,4 +252,14 @@ public class ProfilerWindow : Window
ImGui.Text("Max: " + actualMax.ToString("0.000"));
ImGui.Text("Timings: " + Timings.AllTimings.Count);
}
+
+ [SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:Fields should be private", Justification = "Internals")]
+ private class RectInfo
+ {
+ internal TimingHandle Timing;
+ internal Vector2 MinPos;
+ internal Vector2 MaxPos;
+ internal Vector4 RectColor;
+ internal bool Hover;
+ }
}
diff --git a/Dalamud/Interface/Internal/Windows/SelfTest/AgingSteps/ContextMenuAgingStep.cs b/Dalamud/Interface/Internal/Windows/SelfTest/AgingSteps/ContextMenuAgingStep.cs
index 66683373d..1931be5dc 100644
--- a/Dalamud/Interface/Internal/Windows/SelfTest/AgingSteps/ContextMenuAgingStep.cs
+++ b/Dalamud/Interface/Internal/Windows/SelfTest/AgingSteps/ContextMenuAgingStep.cs
@@ -13,6 +13,7 @@ namespace Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps
///
internal class ContextMenuAgingStep : IAgingStep
{
+ /*
private SubStep currentSubStep;
private uint clickedItemId;
@@ -36,6 +37,7 @@ namespace Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps
TestMultiple,
Finish,
}
+ */
///
public string Name => "Test Context Menu";
@@ -141,13 +143,15 @@ namespace Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps
///
public void CleanUp()
{
- // var contextMenu = Service.Get();
- // contextMenu.ContextMenuOpened -= this.ContextMenuOnContextMenuOpened;
+ /*
+ var contextMenu = Service.Get();
+ contextMenu.ContextMenuOpened -= this.ContextMenuOnContextMenuOpened;
this.currentSubStep = SubStep.Start;
this.clickedItemId = 0;
this.clickedPlayerName = null;
this.multipleTriggerOne = this.multipleTriggerTwo = false;
+ */
}
/*
diff --git a/Dalamud/Interface/Style/StyleModel.cs b/Dalamud/Interface/Style/StyleModel.cs
index a66a8ff81..339ce52ea 100644
--- a/Dalamud/Interface/Style/StyleModel.cs
+++ b/Dalamud/Interface/Style/StyleModel.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
+
using Dalamud.Configuration.Internal;
using Dalamud.Interface.Colors;
using Dalamud.Utility;
@@ -16,9 +17,9 @@ namespace Dalamud.Interface.Style
///
public abstract class StyleModel
{
- private static int NumPushedStyles = 0;
- private static int NumPushedColors = 0;
- private static bool HasPushedOnce = false;
+ private static int numPushedStyles = 0;
+ private static int numPushedColors = 0;
+ private static bool hasPushedOnce = false;
///
/// Gets or sets the name of the style model.
@@ -130,11 +131,11 @@ namespace Dalamud.Interface.Style
///
public void Pop()
{
- if (!HasPushedOnce)
+ if (!hasPushedOnce)
throw new InvalidOperationException("Wasn't pushed at least once.");
- ImGui.PopStyleVar(NumPushedStyles);
- ImGui.PopStyleColor(NumPushedColors);
+ ImGui.PopStyleVar(numPushedStyles);
+ ImGui.PopStyleColor(numPushedColors);
}
///
@@ -146,8 +147,8 @@ namespace Dalamud.Interface.Style
{
ImGui.PushStyleVar(style, arg);
- if (!HasPushedOnce)
- NumPushedStyles++;
+ if (!hasPushedOnce)
+ numPushedStyles++;
}
///
@@ -159,8 +160,8 @@ namespace Dalamud.Interface.Style
{
ImGui.PushStyleVar(style, arg);
- if (!HasPushedOnce)
- NumPushedStyles++;
+ if (!hasPushedOnce)
+ numPushedStyles++;
}
///
@@ -172,8 +173,8 @@ namespace Dalamud.Interface.Style
{
ImGui.PushStyleColor(color, value);
- if (!HasPushedOnce)
- NumPushedColors++;
+ if (!hasPushedOnce)
+ numPushedColors++;
}
///
@@ -181,7 +182,7 @@ namespace Dalamud.Interface.Style
///
protected void DonePushing()
{
- HasPushedOnce = true;
+ hasPushedOnce = true;
}
}
}
diff --git a/Dalamud/Interface/TitleScreenMenu.cs b/Dalamud/Interface/TitleScreenMenu.cs
index 5b1e204f8..60ab5253e 100644
--- a/Dalamud/Interface/TitleScreenMenu.cs
+++ b/Dalamud/Interface/TitleScreenMenu.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
+
using Dalamud.IoC;
using Dalamud.IoC.Internal;
using ImGuiScene;
@@ -202,14 +203,6 @@ namespace Dalamud.Interface
///
internal Guid Id { get; init; } = Guid.NewGuid();
- ///
- /// Trigger the action associated with this entry.
- ///
- internal void Trigger()
- {
- this.onTriggered();
- }
-
///
public int CompareTo(TitleScreenMenuEntry? other)
{
@@ -235,6 +228,14 @@ namespace Dalamud.Interface
return string.Compare(this.Name, other.Name, StringComparison.InvariantCultureIgnoreCase);
return string.Compare(this.Name, other.Name, StringComparison.InvariantCulture);
}
+
+ ///
+ /// Trigger the action associated with this entry.
+ ///
+ internal void Trigger()
+ {
+ this.onTriggered();
+ }
}
}
}
diff --git a/Dalamud/Interface/UiBuilder.cs b/Dalamud/Interface/UiBuilder.cs
index 22d620c8e..73a5c1f79 100644
--- a/Dalamud/Interface/UiBuilder.cs
+++ b/Dalamud/Interface/UiBuilder.cs
@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading.Tasks;
+
using Dalamud.Configuration.Internal;
using Dalamud.Game;
using Dalamud.Game.ClientState.Conditions;
diff --git a/Dalamud/NativeFunctions.cs b/Dalamud/NativeFunctions.cs
index 05e2feabc..ce46a69a6 100644
--- a/Dalamud/NativeFunctions.cs
+++ b/Dalamud/NativeFunctions.cs
@@ -1815,6 +1815,7 @@ namespace Dalamud
///
/// Native dbghelp functions.
///
+ [SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1201:Elements should appear in the correct order", Justification = "Native funcs")]
internal static partial class NativeFunctions
{
///
diff --git a/Dalamud/Plugin/Internal/StartupPluginLoader.cs b/Dalamud/Plugin/Internal/StartupPluginLoader.cs
index 3c1b80363..4f68d39fc 100644
--- a/Dalamud/Plugin/Internal/StartupPluginLoader.cs
+++ b/Dalamud/Plugin/Internal/StartupPluginLoader.cs
@@ -1,5 +1,6 @@
using System;
using System.Threading.Tasks;
+
using Dalamud.Logging.Internal;
using Dalamud.Support;
using Dalamud.Utility.Timing;
diff --git a/Dalamud/Plugin/Internal/Types/LocalPlugin.cs b/Dalamud/Plugin/Internal/Types/LocalPlugin.cs
index f34990b94..4cfff9b9e 100644
--- a/Dalamud/Plugin/Internal/Types/LocalPlugin.cs
+++ b/Dalamud/Plugin/Internal/Types/LocalPlugin.cs
@@ -4,6 +4,7 @@ using System.Linq;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
+
using Dalamud.Configuration.Internal;
using Dalamud.Game;
using Dalamud.Game.Gui.Dtr;
diff --git a/Dalamud/Plugin/Internal/Types/LocalPluginManifest.cs b/Dalamud/Plugin/Internal/Types/LocalPluginManifest.cs
index 136ca8c19..b4f8e3e91 100644
--- a/Dalamud/Plugin/Internal/Types/LocalPluginManifest.cs
+++ b/Dalamud/Plugin/Internal/Types/LocalPluginManifest.cs
@@ -12,9 +12,12 @@ namespace Dalamud.Plugin.Internal.Types;
///
internal record LocalPluginManifest : PluginManifest
{
+ ///
+ /// Flag indicating that a plugin was installed from the official repo.
+ ///
[JsonIgnore]
public const string FlagMainRepo = "OFFICIAL";
-
+
///
/// Gets or sets a value indicating whether the plugin is disabled and should not be loaded.
/// This value supersedes the ".disabled" file functionality and should not be included in the plugin master.
diff --git a/Dalamud/Plugin/Internal/Types/PluginManifest.cs b/Dalamud/Plugin/Internal/Types/PluginManifest.cs
index a1b0e6a71..66b17ed73 100644
--- a/Dalamud/Plugin/Internal/Types/PluginManifest.cs
+++ b/Dalamud/Plugin/Internal/Types/PluginManifest.cs
@@ -137,9 +137,9 @@ internal record PluginManifest
///
/// Gets the required Dalamud load step for this plugin to load. Takes precedence over LoadPriority.
/// Valid values are:
- /// 0. During Framework.Tick, when drawing facilities are available
- /// 1. During Framework.Tick
- /// 2. No requirement
+ /// 0. During Framework.Tick, when drawing facilities are available.
+ /// 1. During Framework.Tick.
+ /// 2. No requirement.
///
[JsonProperty]
public int LoadRequiredState { get; init; }
@@ -157,7 +157,7 @@ internal record PluginManifest
public int LoadPriority { get; init; }
///
- /// Gets a value indicating whether the plugin can be unloaded asynchronously.
+ /// Gets a value indicating whether the plugin can be unloaded asynchronously.
///
[JsonProperty]
public bool CanUnloadAsync { get; init; }
diff --git a/Dalamud/Plugin/Ipc/Internal/DataShare.cs b/Dalamud/Plugin/Ipc/Internal/DataShare.cs
index 4594b6159..dab01e45b 100644
--- a/Dalamud/Plugin/Ipc/Internal/DataShare.cs
+++ b/Dalamud/Plugin/Ipc/Internal/DataShare.cs
@@ -99,7 +99,6 @@ internal class DataShare : IServiceType
cache.UserAssemblyNames.Add(callerName);
return true;
-
}
///
@@ -108,7 +107,7 @@ internal class DataShare : IServiceType
///
/// The type of the stored data - needs to be a reference type that is shared through Dalamud itself, not loaded by the plugin.
/// The name for the data cache.
- /// The requested data
+ /// The requested data.
/// Thrown if is not registered.
/// Thrown if a cache for exists, but contains data of a type not assignable to .
/// Thrown if the stored data for a cache is null.
diff --git a/Dalamud/ServiceManager.cs b/Dalamud/ServiceManager.cs
index 738b80a19..224cf6145 100644
--- a/Dalamud/ServiceManager.cs
+++ b/Dalamud/ServiceManager.cs
@@ -4,6 +4,7 @@ using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
+
using Dalamud.Configuration.Internal;
using Dalamud.Game;
using Dalamud.IoC.Internal;
diff --git a/Dalamud/Service{T}.cs b/Dalamud/Service{T}.cs
index 72751316d..aa014878d 100644
--- a/Dalamud/Service{T}.cs
+++ b/Dalamud/Service{T}.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
+
using Dalamud.IoC;
using Dalamud.IoC.Internal;
using Dalamud.Utility.Timing;
@@ -95,7 +96,7 @@ namespace Dalamud
///
/// Attempt to pull the instance out of the service locator.
///
- /// Specifies which exceptions to propagate.
+ /// Specifies which exceptions to propagate.
/// The object if registered, null otherwise.
public static T? GetNullable(ExceptionPropagationMode propagateException = ExceptionPropagationMode.PropagateNonUnloaded)
{
diff --git a/Dalamud/Utility/Hash.cs b/Dalamud/Utility/Hash.cs
index 92f03da7e..2fe5fd1d6 100644
--- a/Dalamud/Utility/Hash.cs
+++ b/Dalamud/Utility/Hash.cs
@@ -1,4 +1,5 @@
using System;
+using System.Security.Cryptography;
namespace Dalamud.Utility
{
@@ -24,7 +25,7 @@ namespace Dalamud.Utility
/// The computed hash.
internal static string GetSha256Hash(byte[] buffer)
{
- using var sha = new System.Security.Cryptography.SHA256Managed();
+ using var sha = SHA256.Create();
var hash = sha.ComputeHash(buffer);
return ByteArrayToString(hash);
}
diff --git a/Dalamud/Utility/Timing/TimingEvent.cs b/Dalamud/Utility/Timing/TimingEvent.cs
index 2fa7e72c0..c4c14ddba 100644
--- a/Dalamud/Utility/Timing/TimingEvent.cs
+++ b/Dalamud/Utility/Timing/TimingEvent.cs
@@ -2,15 +2,24 @@ using System.Threading;
namespace Dalamud.Utility.Timing;
+///
+/// Class representing a timing event.
+///
public class TimingEvent
{
- private static long IdCounter = 0;
-
///
/// Id of this timing event.
///
- public readonly long Id = Interlocked.Increment(ref IdCounter);
+#pragma warning disable SA1401
+ public readonly long Id = Interlocked.Increment(ref idCounter);
+#pragma warning restore SA1401
+ private static long idCounter = 0;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Name of the event.
internal TimingEvent(string name)
{
this.Name = name;
diff --git a/Dalamud/Utility/Timing/TimingHandle.cs b/Dalamud/Utility/Timing/TimingHandle.cs
index 80c2bd310..e06836c8a 100644
--- a/Dalamud/Utility/Timing/TimingHandle.cs
+++ b/Dalamud/Utility/Timing/TimingHandle.cs
@@ -15,7 +15,8 @@ public sealed class TimingHandle : TimingEvent, IDisposable, IComparable class.
///
/// The name of this timing.
- internal TimingHandle(string name) : base(name)
+ internal TimingHandle(string name)
+ : base(name)
{
this.Stack = Timings.TaskTimingHandles;
diff --git a/Dalamud/Utility/Timing/Timings.cs b/Dalamud/Utility/Timing/Timings.cs
index c35edf1ce..0709be4e7 100644
--- a/Dalamud/Utility/Timing/Timings.cs
+++ b/Dalamud/Utility/Timing/Timings.cs
@@ -22,9 +22,12 @@ public static class Timings
///
internal static readonly SortedList AllTimings = new();
+ ///
+ /// List of all timing events.
+ ///
internal static readonly List Events = new();
- private static readonly AsyncLocal>> taskTimingHandleStorage = new();
+ private static readonly AsyncLocal>> TaskTimingHandleStorage = new();
///
/// Gets or sets all active timings of current thread.
@@ -33,11 +36,11 @@ public static class Timings
{
get
{
- if (taskTimingHandleStorage.Value == null || taskTimingHandleStorage.Value.Item1 != Task.CurrentId)
- taskTimingHandleStorage.Value = Tuple.Create>(Task.CurrentId, new());
- return taskTimingHandleStorage.Value!.Item2!;
+ if (TaskTimingHandleStorage.Value == null || TaskTimingHandleStorage.Value.Item1 != Task.CurrentId)
+ TaskTimingHandleStorage.Value = Tuple.Create>(Task.CurrentId, new());
+ return TaskTimingHandleStorage.Value!.Item2!;
}
- set => taskTimingHandleStorage.Value = Tuple.Create(Task.CurrentId, value);
+ set => TaskTimingHandleStorage.Value = Tuple.Create(Task.CurrentId, value);
}
///
@@ -115,9 +118,11 @@ public static class Timings
/// Name of the calling member.
/// Name of the calling file.
/// Name of the calling line number.
- /// Disposable that stops the timing once disposed.
- public static void Event(string name, [CallerMemberName] string memberName = "", [CallerFilePath] string sourceFilePath = "",
- [CallerLineNumber] int sourceLineNumber = 0)
+ public static void Event(
+ string name,
+ [CallerMemberName] string memberName = "",
+ [CallerFilePath] string sourceFilePath = "",
+ [CallerLineNumber] int sourceLineNumber = 0)
{
lock (Events)
{