From b18b8b40e5b5505bc85c4895af2aa20e922e1ef8 Mon Sep 17 00:00:00 2001 From: Kaz Wolfe Date: Mon, 25 Aug 2025 13:14:13 -0700 Subject: [PATCH 01/17] feat: Add IPC Context - Demo of the ipc context idea - Accessible via ipcPub.GetContext() --- .../Windows/Data/Widgets/PluginIpcWidget.cs | 36 +++++++---- Dalamud/Plugin/DalamudPluginInterface.cs | 36 +++++------ Dalamud/Plugin/Ipc/ICallGateProvider.cs | 3 + .../Plugin/Ipc/Internal/CallGateChannel.cs | 1 + Dalamud/Plugin/Ipc/Internal/CallGatePubSub.cs | 56 +++++++++--------- .../Plugin/Ipc/Internal/CallGatePubSubBase.cs | 59 +++++++++++++++++-- Dalamud/Plugin/Ipc/IpcContext.cs | 15 +++++ 7 files changed, 143 insertions(+), 63 deletions(-) create mode 100644 Dalamud/Plugin/Ipc/IpcContext.cs diff --git a/Dalamud/Interface/Internal/Windows/Data/Widgets/PluginIpcWidget.cs b/Dalamud/Interface/Internal/Windows/Data/Widgets/PluginIpcWidget.cs index 6c581604e..446a5e7a9 100644 --- a/Dalamud/Interface/Internal/Windows/Data/Widgets/PluginIpcWidget.cs +++ b/Dalamud/Interface/Internal/Windows/Data/Widgets/PluginIpcWidget.cs @@ -5,6 +5,7 @@ using Dalamud.Game.ClientState.Objects.Types; using Dalamud.Plugin.Ipc; using Dalamud.Plugin.Ipc.Internal; using Dalamud.Utility; + using Serilog; namespace Dalamud.Interface.Internal.Windows.Data.Widgets; @@ -48,12 +49,20 @@ internal class PluginIpcWidget : IDataWindowWidget this.ipcPub.RegisterAction(msg => { - Log.Information("Data action was called: {Msg}", msg); + Log.Information( + "Data action was called: {Msg}\n" + + " Context: {Context}", + msg, + this.ipcPub.GetContext()); }); this.ipcPub.RegisterFunc(msg => { - Log.Information("Data func was called: {Msg}", msg); + Log.Information( + "Data func was called: {Msg}\n" + + " Context: {Context}", + msg, + this.ipcPub.GetContext()); return Guid.NewGuid().ToString(); }); } @@ -61,14 +70,8 @@ internal class PluginIpcWidget : IDataWindowWidget if (this.ipcSub == null) { this.ipcSub = new CallGatePubSub("dataDemo1"); - this.ipcSub.Subscribe(_ => - { - Log.Information("PONG1"); - }); - this.ipcSub.Subscribe(_ => - { - Log.Information("PONG2"); - }); + this.ipcSub.Subscribe(_ => { Log.Information("PONG1"); }); + this.ipcSub.Subscribe(_ => { Log.Information("PONG2"); }); this.ipcSub.Subscribe(_ => throw new Exception("PONG3")); } @@ -78,12 +81,21 @@ internal class PluginIpcWidget : IDataWindowWidget this.ipcPubGo.RegisterAction(go => { - Log.Information("Data action was called: {Name}", go?.Name); + Log.Information( + "Data action was called: {Name}" + + "\n Context: {Context}", + go?.Name, + this.ipcPubGo.GetContext()); }); this.ipcPubGo.RegisterFunc(go => { - Log.Information("Data func was called: {Name}", go?.Name); + Log.Information( + "Data func was called: {Name}\n" + + " Context: {Context}", + go?.Name, + this.ipcPubGo.GetContext()); + return "test"; }); } diff --git a/Dalamud/Plugin/DalamudPluginInterface.cs b/Dalamud/Plugin/DalamudPluginInterface.cs index 541071b63..db9320079 100644 --- a/Dalamud/Plugin/DalamudPluginInterface.cs +++ b/Dalamud/Plugin/DalamudPluginInterface.cs @@ -293,39 +293,39 @@ internal sealed class DalamudPluginInterface : IDalamudPluginInterface, IDisposa /// An IPC provider. /// This is thrown when the requested types do not match the previously registered types are different. public ICallGateProvider GetIpcProvider(string name) - => new CallGatePubSub(name); + => new CallGatePubSub(name, this.plugin); /// public ICallGateProvider GetIpcProvider(string name) - => new CallGatePubSub(name); + => new CallGatePubSub(name, this.plugin); /// public ICallGateProvider GetIpcProvider(string name) - => new CallGatePubSub(name); + => new CallGatePubSub(name, this.plugin); /// public ICallGateProvider GetIpcProvider(string name) - => new CallGatePubSub(name); + => new CallGatePubSub(name, this.plugin); /// public ICallGateProvider GetIpcProvider(string name) - => new CallGatePubSub(name); + => new CallGatePubSub(name, this.plugin); /// public ICallGateProvider GetIpcProvider(string name) - => new CallGatePubSub(name); + => new CallGatePubSub(name, this.plugin); /// public ICallGateProvider GetIpcProvider(string name) - => new CallGatePubSub(name); + => new CallGatePubSub(name, this.plugin); /// public ICallGateProvider GetIpcProvider(string name) - => new CallGatePubSub(name); + => new CallGatePubSub(name, this.plugin); /// public ICallGateProvider GetIpcProvider(string name) - => new CallGatePubSub(name); + => new CallGatePubSub(name, this.plugin); /// /// Gets an IPC subscriber. @@ -334,39 +334,39 @@ internal sealed class DalamudPluginInterface : IDalamudPluginInterface, IDisposa /// The name of the IPC registration. /// An IPC subscriber. public ICallGateSubscriber GetIpcSubscriber(string name) - => new CallGatePubSub(name); + => new CallGatePubSub(name, this.plugin); /// public ICallGateSubscriber GetIpcSubscriber(string name) - => new CallGatePubSub(name); + => new CallGatePubSub(name, this.plugin); /// public ICallGateSubscriber GetIpcSubscriber(string name) - => new CallGatePubSub(name); + => new CallGatePubSub(name, this.plugin); /// public ICallGateSubscriber GetIpcSubscriber(string name) - => new CallGatePubSub(name); + => new CallGatePubSub(name, this.plugin); /// public ICallGateSubscriber GetIpcSubscriber(string name) - => new CallGatePubSub(name); + => new CallGatePubSub(name, this.plugin); /// public ICallGateSubscriber GetIpcSubscriber(string name) - => new CallGatePubSub(name); + => new CallGatePubSub(name, this.plugin); /// public ICallGateSubscriber GetIpcSubscriber(string name) - => new CallGatePubSub(name); + => new CallGatePubSub(name, this.plugin); /// public ICallGateSubscriber GetIpcSubscriber(string name) - => new CallGatePubSub(name); + => new CallGatePubSub(name, this.plugin); /// public ICallGateSubscriber GetIpcSubscriber(string name) - => new CallGatePubSub(name); + => new CallGatePubSub(name, this.plugin); #endregion diff --git a/Dalamud/Plugin/Ipc/ICallGateProvider.cs b/Dalamud/Plugin/Ipc/ICallGateProvider.cs index f4e5c76d7..387f0adf9 100644 --- a/Dalamud/Plugin/Ipc/ICallGateProvider.cs +++ b/Dalamud/Plugin/Ipc/ICallGateProvider.cs @@ -19,6 +19,9 @@ public interface ICallGateProvider /// public void UnregisterFunc(); + + /// + public IpcContext? GetContext(); } /// diff --git a/Dalamud/Plugin/Ipc/Internal/CallGateChannel.cs b/Dalamud/Plugin/Ipc/Internal/CallGateChannel.cs index ea94103f7..698f0917e 100644 --- a/Dalamud/Plugin/Ipc/Internal/CallGateChannel.cs +++ b/Dalamud/Plugin/Ipc/Internal/CallGateChannel.cs @@ -3,6 +3,7 @@ using System.Collections.Immutable; using System.Linq; using System.Reflection; +using Dalamud.Plugin.Internal.Types; using Dalamud.Plugin.Ipc.Exceptions; using Dalamud.Plugin.Ipc.Internal.Converters; diff --git a/Dalamud/Plugin/Ipc/Internal/CallGatePubSub.cs b/Dalamud/Plugin/Ipc/Internal/CallGatePubSub.cs index cc54a563b..8725ef733 100644 --- a/Dalamud/Plugin/Ipc/Internal/CallGatePubSub.cs +++ b/Dalamud/Plugin/Ipc/Internal/CallGatePubSub.cs @@ -1,3 +1,5 @@ +using Dalamud.Plugin.Internal.Types; + #pragma warning disable SA1402 // File may only contain a single type namespace Dalamud.Plugin.Ipc.Internal; @@ -5,9 +7,9 @@ namespace Dalamud.Plugin.Ipc.Internal; /// internal class CallGatePubSub : CallGatePubSubBase, ICallGateProvider, ICallGateSubscriber { - /// - public CallGatePubSub(string name) - : base(name) + /// + public CallGatePubSub(string name, LocalPlugin? owningPlugin = null) + : base(name, owningPlugin) { } @@ -43,9 +45,9 @@ internal class CallGatePubSub : CallGatePubSubBase, ICallGateProvider internal class CallGatePubSub : CallGatePubSubBase, ICallGateProvider, ICallGateSubscriber { - /// - public CallGatePubSub(string name) - : base(name) + /// + public CallGatePubSub(string name, LocalPlugin? owningPlugin = null) + : base(name, owningPlugin) { } @@ -81,9 +83,9 @@ internal class CallGatePubSub : CallGatePubSubBase, ICallGateProvider< /// internal class CallGatePubSub : CallGatePubSubBase, ICallGateProvider, ICallGateSubscriber { - /// - public CallGatePubSub(string name) - : base(name) + /// + public CallGatePubSub(string name, LocalPlugin? owningPlugin = null) + : base(name, owningPlugin) { } @@ -119,9 +121,9 @@ internal class CallGatePubSub : CallGatePubSubBase, ICallGateProvi /// internal class CallGatePubSub : CallGatePubSubBase, ICallGateProvider, ICallGateSubscriber { - /// - public CallGatePubSub(string name) - : base(name) + /// + public CallGatePubSub(string name, LocalPlugin? owningPlugin = null) + : base(name, owningPlugin) { } @@ -157,9 +159,9 @@ internal class CallGatePubSub : CallGatePubSubBase, ICallGateP /// internal class CallGatePubSub : CallGatePubSubBase, ICallGateProvider, ICallGateSubscriber { - /// - public CallGatePubSub(string name) - : base(name) + /// + public CallGatePubSub(string name, LocalPlugin? owningPlugin = null) + : base(name, owningPlugin) { } @@ -195,9 +197,9 @@ internal class CallGatePubSub : CallGatePubSubBase, ICallG /// internal class CallGatePubSub : CallGatePubSubBase, ICallGateProvider, ICallGateSubscriber { - /// - public CallGatePubSub(string name) - : base(name) + /// + public CallGatePubSub(string name, LocalPlugin? owningPlugin = null) + : base(name, owningPlugin) { } @@ -233,9 +235,9 @@ internal class CallGatePubSub : CallGatePubSubBase, IC /// internal class CallGatePubSub : CallGatePubSubBase, ICallGateProvider, ICallGateSubscriber { - /// - public CallGatePubSub(string name) - : base(name) + /// + public CallGatePubSub(string name, LocalPlugin? owningPlugin = null) + : base(name, owningPlugin) { } @@ -271,9 +273,9 @@ internal class CallGatePubSub : CallGatePubSubBase /// internal class CallGatePubSub : CallGatePubSubBase, ICallGateProvider, ICallGateSubscriber { - /// - public CallGatePubSub(string name) - : base(name) + /// + public CallGatePubSub(string name, LocalPlugin? owningPlugin = null) + : base(name, owningPlugin) { } @@ -309,9 +311,9 @@ internal class CallGatePubSub : CallGatePubSub /// internal class CallGatePubSub : CallGatePubSubBase, ICallGateProvider, ICallGateSubscriber { - /// - public CallGatePubSub(string name) - : base(name) + /// + public CallGatePubSub(string name, LocalPlugin? owningPlugin = null) + : base(name, owningPlugin) { } diff --git a/Dalamud/Plugin/Ipc/Internal/CallGatePubSubBase.cs b/Dalamud/Plugin/Ipc/Internal/CallGatePubSubBase.cs index 308457373..24cb5ca11 100644 --- a/Dalamud/Plugin/Ipc/Internal/CallGatePubSubBase.cs +++ b/Dalamud/Plugin/Ipc/Internal/CallGatePubSubBase.cs @@ -1,4 +1,11 @@ +using System.Reactive.Disposables; +using System.Threading; + +using Dalamud.Plugin.Internal.Types; using Dalamud.Plugin.Ipc.Exceptions; +using Dalamud.Utility; + +using Serilog; namespace Dalamud.Plugin.Ipc.Internal; @@ -7,13 +14,18 @@ namespace Dalamud.Plugin.Ipc.Internal; /// internal abstract class CallGatePubSubBase { + [ThreadStatic] + private static IpcContext? ipcExecutionContext; + /// /// Initializes a new instance of the class. /// /// The name of the IPC registration. - protected CallGatePubSubBase(string name) + /// The plugin that owns this IPC pubsub. + protected CallGatePubSubBase(string name, LocalPlugin? owningPlugin) { this.Channel = Service.Get().GetOrCreateChannel(name); + this.OwningPlugin = owningPlugin; } /// @@ -21,7 +33,7 @@ internal abstract class CallGatePubSubBase /// s. /// public bool HasAction => this.Channel.Action != null; - + /// /// Gets a value indicating whether this IPC call gate has an associated Function. Only exposed to /// s. @@ -33,12 +45,17 @@ internal abstract class CallGatePubSubBase /// s, and can be used to determine if messages should be sent through the gate. /// public int SubscriptionCount => this.Channel.Subscriptions.Count; - + /// /// Gets the underlying channel implementation. /// protected CallGateChannel Channel { get; init; } - + + /// + /// Gets the plugin that owns this pubsub instance. + /// + protected LocalPlugin? OwningPlugin { get; init; } + /// /// Removes the associated Action from this call gate, effectively disabling RPC calls. /// @@ -53,6 +70,16 @@ internal abstract class CallGatePubSubBase public void UnregisterFunc() => this.Channel.Func = null; + /// + /// Gets the current context for this IPC call. This will only be present when called from within an IPC action + /// or function handler, and will be null otherwise. + /// + /// Returns a potential IPC context. + public IpcContext? GetContext() + { + return ipcExecutionContext; + } + /// /// Registers a for use by other plugins via RPC. This Delegate must satisfy the constraints /// of an type as defined by the interface, meaning they may not return a value and must have @@ -105,7 +132,12 @@ internal abstract class CallGatePubSubBase /// /// private protected void InvokeAction(params object?[]? args) - => this.Channel.InvokeAction(args); + { + using (this.BuildContext()) + { + this.Channel.InvokeAction(args); + } + } /// /// Executes the Function registered for this IPC call gate via . This method is intended @@ -120,7 +152,12 @@ internal abstract class CallGatePubSubBase /// /// private protected TRet InvokeFunc(params object?[]? args) - => this.Channel.InvokeFunc(args); + { + using (this.BuildContext()) + { + return this.Channel.InvokeFunc(args); + } + } /// /// Send the given arguments to all subscribers (through ) of this IPC call gate. This method @@ -132,4 +169,14 @@ internal abstract class CallGatePubSubBase /// Delegate arguments. private protected void SendMessage(params object?[]? args) => this.Channel.SendMessage(args); + + private IDisposable BuildContext() + { + ipcExecutionContext = new IpcContext + { + SourcePlugin = this.OwningPlugin != null ? new ExposedPlugin(this.OwningPlugin) : null, + }; + + return Disposable.Create(() => { ipcExecutionContext = null; }); + } } diff --git a/Dalamud/Plugin/Ipc/IpcContext.cs b/Dalamud/Plugin/Ipc/IpcContext.cs new file mode 100644 index 000000000..25fde6a36 --- /dev/null +++ b/Dalamud/Plugin/Ipc/IpcContext.cs @@ -0,0 +1,15 @@ +namespace Dalamud.Plugin.Ipc; + +/// +/// The context associated for an IPC call. Reads from ThreadLocal. +/// +public class IpcContext +{ + /// + /// Gets the plugin that initiated this IPC call. + /// + public IExposedPlugin? SourcePlugin { get; init; } + + /// + public override string ToString() => $""; +} From 8cced4c1d7bece877a12cf69d0f1448a5b352c01 Mon Sep 17 00:00:00 2001 From: Kaz Wolfe Date: Mon, 25 Aug 2025 13:31:05 -0700 Subject: [PATCH 02/17] fix: use channel threadlocal instead of a ThreadStatic --- Dalamud/Plugin/Ipc/Internal/CallGateChannel.cs | 18 ++++++++++++++++++ .../Plugin/Ipc/Internal/CallGatePubSubBase.cs | 11 ++++------- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/Dalamud/Plugin/Ipc/Internal/CallGateChannel.cs b/Dalamud/Plugin/Ipc/Internal/CallGateChannel.cs index 698f0917e..e177abab7 100644 --- a/Dalamud/Plugin/Ipc/Internal/CallGateChannel.cs +++ b/Dalamud/Plugin/Ipc/Internal/CallGateChannel.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; using System.Reflection; +using System.Threading; using Dalamud.Plugin.Internal.Types; using Dalamud.Plugin.Ipc.Exceptions; @@ -17,6 +18,8 @@ namespace Dalamud.Plugin.Ipc.Internal; /// internal class CallGateChannel { + private readonly ThreadLocal ipcExecutionContext = new(); + /// /// The actual storage. /// @@ -146,6 +149,21 @@ internal class CallGateChannel return (TRet)result; } + internal void SetInvocationContext(IpcContext ipcContext) + { + this.ipcExecutionContext.Value = ipcContext; + } + + internal IpcContext? GetInvocationContext() + { + return this.ipcExecutionContext.IsValueCreated ? this.ipcExecutionContext.Value : null; + } + + internal void ClearInvocationContext() + { + this.ipcExecutionContext.Value = null; + } + private void CheckAndConvertArgs(object?[]? args, MethodInfo methodInfo) { var paramTypes = methodInfo.GetParameters() diff --git a/Dalamud/Plugin/Ipc/Internal/CallGatePubSubBase.cs b/Dalamud/Plugin/Ipc/Internal/CallGatePubSubBase.cs index 24cb5ca11..521824b7b 100644 --- a/Dalamud/Plugin/Ipc/Internal/CallGatePubSubBase.cs +++ b/Dalamud/Plugin/Ipc/Internal/CallGatePubSubBase.cs @@ -14,9 +14,6 @@ namespace Dalamud.Plugin.Ipc.Internal; /// internal abstract class CallGatePubSubBase { - [ThreadStatic] - private static IpcContext? ipcExecutionContext; - /// /// Initializes a new instance of the class. /// @@ -77,7 +74,7 @@ internal abstract class CallGatePubSubBase /// Returns a potential IPC context. public IpcContext? GetContext() { - return ipcExecutionContext; + return this.Channel.GetInvocationContext(); } /// @@ -172,11 +169,11 @@ internal abstract class CallGatePubSubBase private IDisposable BuildContext() { - ipcExecutionContext = new IpcContext + this.Channel.SetInvocationContext(new IpcContext { SourcePlugin = this.OwningPlugin != null ? new ExposedPlugin(this.OwningPlugin) : null, - }; + }); - return Disposable.Create(() => { ipcExecutionContext = null; }); + return Disposable.Create(() => { this.Channel.ClearInvocationContext(); }); } } From 2029a0f8a69e0d10b32b8795ce180ebf3c6eb8e5 Mon Sep 17 00:00:00 2001 From: goaaats Date: Sun, 7 Dec 2025 21:31:25 +0100 Subject: [PATCH 03/17] Also add fallback for SeStringDrawState.ScreenOffset for now, make sure that it is populated --- .../SeStringDrawParams.cs | 4 +++- .../ImGuiSeStringRenderer/SeStringDrawState.cs | 3 ++- .../Data/Widgets/SeStringRendererTestWidget.cs | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Dalamud/Interface/ImGuiSeStringRenderer/SeStringDrawParams.cs b/Dalamud/Interface/ImGuiSeStringRenderer/SeStringDrawParams.cs index 972013328..09c3e9ed9 100644 --- a/Dalamud/Interface/ImGuiSeStringRenderer/SeStringDrawParams.cs +++ b/Dalamud/Interface/ImGuiSeStringRenderer/SeStringDrawParams.cs @@ -25,7 +25,9 @@ public record struct SeStringDrawParams public SeStringReplacementEntity.GetEntityDelegate? GetEntity { get; set; } /// Gets or sets the screen offset of the left top corner. - /// Screen offset to draw at, or null to use . + /// Screen offset to draw at, or null to use , if no + /// is specified. Otherwise, you must specify it (for example, by passing when passing the window + /// draw list. public Vector2? ScreenOffset { get; set; } /// Gets or sets the font to use. diff --git a/Dalamud/Interface/ImGuiSeStringRenderer/SeStringDrawState.cs b/Dalamud/Interface/ImGuiSeStringRenderer/SeStringDrawState.cs index 5e63ef160..5601100e9 100644 --- a/Dalamud/Interface/ImGuiSeStringRenderer/SeStringDrawState.cs +++ b/Dalamud/Interface/ImGuiSeStringRenderer/SeStringDrawState.cs @@ -63,11 +63,12 @@ public unsafe ref struct SeStringDrawState else { this.drawList = ssdp.TargetDrawList.Value; - this.ScreenOffset = Vector2.Zero; + this.ScreenOffset = ssdp.ScreenOffset ?? Vector2.Zero; // API14: Remove, always throw if (ThreadSafety.IsMainThread) { + this.ScreenOffset = ssdp.ScreenOffset ?? ImGui.GetCursorScreenPos(); this.FontSize = ssdp.FontSize ?? ImGui.GetFontSize(); } else diff --git a/Dalamud/Interface/Internal/Windows/Data/Widgets/SeStringRendererTestWidget.cs b/Dalamud/Interface/Internal/Windows/Data/Widgets/SeStringRendererTestWidget.cs index 0f51e0322..6a07152e5 100644 --- a/Dalamud/Interface/Internal/Windows/Data/Widgets/SeStringRendererTestWidget.cs +++ b/Dalamud/Interface/Internal/Windows/Data/Widgets/SeStringRendererTestWidget.cs @@ -177,6 +177,24 @@ internal unsafe class SeStringRendererTestWidget : IDataWindowWidget ImGuiHelpers.SeStringWrapped(this.logkind.Value.Data.Span, this.style); } + if (ImGui.CollapsingHeader("Draw into drawlist")) + { + ImGuiHelpers.ScaledDummy(100); + ImGui.SetCursorScreenPos(ImGui.GetItemRectMin() + ImGui.GetStyle().FramePadding); + var clipMin = ImGui.GetItemRectMin() + ImGui.GetStyle().FramePadding; + var clipMax = ImGui.GetItemRectMax() - ImGui.GetStyle().FramePadding; + clipMin.Y = MathF.Max(clipMin.Y, ImGui.GetWindowPos().Y); + clipMax.Y = MathF.Min(clipMax.Y, ImGui.GetWindowPos().Y + ImGui.GetWindowHeight()); + + var dl = ImGui.GetWindowDrawList(); + dl.PushClipRect(clipMin, clipMax); + ImGuiHelpers.CompileSeStringWrapped( + "Test test", + new SeStringDrawParams + { Color = 0xFFFFFFFF, WrapWidth = float.MaxValue, TargetDrawList = dl }); + dl.PopClipRect(); + } + if (ImGui.CollapsingHeader("Addon Table"u8)) { if (ImGui.BeginTable("Addon Sheet"u8, 3)) From c45c6aafe1a8a8561826155aae0efc46b478a2d8 Mon Sep 17 00:00:00 2001 From: goaaats Date: Sun, 7 Dec 2025 21:57:54 +0100 Subject: [PATCH 04/17] Don't consider failed index integrity checks as having "modified game data files" --- Dalamud/Data/DataManager.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dalamud/Data/DataManager.cs b/Dalamud/Data/DataManager.cs index ed0aa6c4d..559bd84dc 100644 --- a/Dalamud/Data/DataManager.cs +++ b/Dalamud/Data/DataManager.cs @@ -82,8 +82,10 @@ internal sealed class DataManager : IInternalDisposableService, IDataManager var tsInfo = JsonConvert.DeserializeObject( dalamud.StartInfo.TroubleshootingPackData); + + // Don't fail for IndexIntegrityResult.Exception, since the check during launch has a very small timeout this.HasModifiedGameDataFiles = - tsInfo?.IndexIntegrity is LauncherTroubleshootingInfo.IndexIntegrityResult.Failed or LauncherTroubleshootingInfo.IndexIntegrityResult.Exception; + tsInfo?.IndexIntegrity is LauncherTroubleshootingInfo.IndexIntegrityResult.Failed; if (this.HasModifiedGameDataFiles) Log.Verbose("Game data integrity check failed!\n{TsData}", dalamud.StartInfo.TroubleshootingPackData); From 8ed1af30dfa33c892fa1b0446054e512a4d0a760 Mon Sep 17 00:00:00 2001 From: goaaats Date: Sun, 7 Dec 2025 22:55:16 +0100 Subject: [PATCH 05/17] build: 13.0.0.14 --- Dalamud/Dalamud.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dalamud/Dalamud.csproj b/Dalamud/Dalamud.csproj index a50f12d79..a4b203406 100644 --- a/Dalamud/Dalamud.csproj +++ b/Dalamud/Dalamud.csproj @@ -6,7 +6,7 @@ XIV Launcher addon framework - 13.0.0.13 + 13.0.0.14 $(DalamudVersion) $(DalamudVersion) $(DalamudVersion) From d0110f7251d50b2a45fbc51d6a8b03662e7afa54 Mon Sep 17 00:00:00 2001 From: goaaats Date: Mon, 8 Dec 2025 20:03:22 +0100 Subject: [PATCH 06/17] Hardcode HasModifiedGameDataFiles to false for now until XL is fixed --- Dalamud/Data/DataManager.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Dalamud/Data/DataManager.cs b/Dalamud/Data/DataManager.cs index 559bd84dc..f53195a2d 100644 --- a/Dalamud/Data/DataManager.cs +++ b/Dalamud/Data/DataManager.cs @@ -84,8 +84,11 @@ internal sealed class DataManager : IInternalDisposableService, IDataManager dalamud.StartInfo.TroubleshootingPackData); // Don't fail for IndexIntegrityResult.Exception, since the check during launch has a very small timeout - this.HasModifiedGameDataFiles = - tsInfo?.IndexIntegrity is LauncherTroubleshootingInfo.IndexIntegrityResult.Failed; + // this.HasModifiedGameDataFiles = + // tsInfo?.IndexIntegrity is LauncherTroubleshootingInfo.IndexIntegrityResult.Failed; + + // TODO: Put above back when check in XL is fixed + this.HasModifiedGameDataFiles = false; if (this.HasModifiedGameDataFiles) Log.Verbose("Game data integrity check failed!\n{TsData}", dalamud.StartInfo.TroubleshootingPackData); From 5d08170333d4e460b3eeb5197e286df86d5bdffe Mon Sep 17 00:00:00 2001 From: goaaats Date: Mon, 8 Dec 2025 20:03:43 +0100 Subject: [PATCH 07/17] Keep rendering title bar buttons if one is not available clickthrough --- Dalamud/Interface/Windowing/Window.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dalamud/Interface/Windowing/Window.cs b/Dalamud/Interface/Windowing/Window.cs index b0786fbb5..7ecd5e15c 100644 --- a/Dalamud/Interface/Windowing/Window.cs +++ b/Dalamud/Interface/Windowing/Window.cs @@ -864,7 +864,7 @@ public abstract class Window foreach (var button in this.allButtons) { if (this.internalIsClickthrough && !button.AvailableClickthrough) - return; + continue; Vector2 position = new(titleBarRect.Max.X - padR - buttonSize, titleBarRect.Min.Y + style.FramePadding.Y); padR += buttonSize + style.ItemInnerSpacing.X; From 24caa1cb18f47c705b6706e718a645f3d25c056f Mon Sep 17 00:00:00 2001 From: goaaats Date: Mon, 8 Dec 2025 20:05:14 +0100 Subject: [PATCH 08/17] PresetWindow.IsDefault can be JsonIgnore --- Dalamud/Interface/Windowing/Persistence/PresetModel.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Dalamud/Interface/Windowing/Persistence/PresetModel.cs b/Dalamud/Interface/Windowing/Persistence/PresetModel.cs index f7910e0b2..4ddf55e51 100644 --- a/Dalamud/Interface/Windowing/Persistence/PresetModel.cs +++ b/Dalamud/Interface/Windowing/Persistence/PresetModel.cs @@ -53,6 +53,7 @@ internal class PresetModel /// /// Gets a value indicating whether this preset is in the default state. /// + [JsonIgnore] public bool IsDefault => !this.IsPinned && !this.IsClickThrough && From 2806e59dba4562e75f7721e40fd3d2bdd3935577 Mon Sep 17 00:00:00 2001 From: goaaats Date: Mon, 8 Dec 2025 20:09:31 +0100 Subject: [PATCH 09/17] Also remove borders for dev bar, to prevent themes from causing weirdness --- Dalamud/Interface/Internal/DalamudInterface.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dalamud/Interface/Internal/DalamudInterface.cs b/Dalamud/Interface/Internal/DalamudInterface.cs index bf55a5486..b0fbeb6c5 100644 --- a/Dalamud/Interface/Internal/DalamudInterface.cs +++ b/Dalamud/Interface/Internal/DalamudInterface.cs @@ -669,6 +669,8 @@ internal class DalamudInterface : IInternalDisposableService { using var barColor = ImRaii.PushColor(ImGuiCol.WindowBg, new Vector4(0.060f, 0.060f, 0.060f, 0.773f)); barColor.Push(ImGuiCol.MenuBarBg, Vector4.Zero); + barColor.Push(ImGuiCol.Border, Vector4.Zero); + barColor.Push(ImGuiCol.BorderShadow, Vector4.Zero); if (ImGui.BeginMainMenuBar()) { var pluginManager = Service.Get(); From 97df73acea61ddf94c135bc37e4f402b6e5a6cab Mon Sep 17 00:00:00 2001 From: goaaats Date: Mon, 8 Dec 2025 21:00:08 +0100 Subject: [PATCH 10/17] Ensure that we don't catch mouse up events without corresponding mouse down events Fixes an issue wherein the cursor could get locked by the game if WantCaptureMouse becomes true in between down and up events --- .../InputHandler/Win32InputHandler.cs | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/Dalamud/Interface/ImGuiBackend/InputHandler/Win32InputHandler.cs b/Dalamud/Interface/ImGuiBackend/InputHandler/Win32InputHandler.cs index 0b2e27b57..6b26ce37d 100644 --- a/Dalamud/Interface/ImGuiBackend/InputHandler/Win32InputHandler.cs +++ b/Dalamud/Interface/ImGuiBackend/InputHandler/Win32InputHandler.cs @@ -7,6 +7,7 @@ using System.Runtime.InteropServices; using System.Text; using Dalamud.Bindings.ImGui; +using Dalamud.Console; using Dalamud.Memory; using Dalamud.Utility; @@ -37,6 +38,8 @@ internal sealed unsafe partial class Win32InputHandler : IImGuiInputHandler private readonly WndProcDelegate wndProcDelegate; private readonly nint platformNamePtr; + private readonly IConsoleVariable cvLogMouseEvents; + private ViewportHandler viewportHandler; private int mouseButtonsDown; @@ -87,6 +90,11 @@ internal sealed unsafe partial class Win32InputHandler : IImGuiInputHandler this.cursors[(int)ImGuiMouseCursor.ResizeNwse] = LoadCursorW(default, IDC.IDC_SIZENWSE); this.cursors[(int)ImGuiMouseCursor.Hand] = LoadCursorW(default, IDC.IDC_HAND); this.cursors[(int)ImGuiMouseCursor.NotAllowed] = LoadCursorW(default, IDC.IDC_NO); + + this.cvLogMouseEvents = Service.Get().AddVariable( + "imgui.log_mouse_events", + "Log mouse events to console for debugging", + false); } /// @@ -267,11 +275,23 @@ internal sealed unsafe partial class Win32InputHandler : IImGuiInputHandler case WM.WM_XBUTTONDOWN: case WM.WM_XBUTTONDBLCLK: { + if (this.cvLogMouseEvents.Value) + { + Log.Verbose( + "Handle MouseDown {Btn} WantCaptureMouse: {Want} mouseButtonsDown: {Down}", + GetButton(msg, wParam), + io.WantCaptureMouse, + this.mouseButtonsDown); + } + var button = GetButton(msg, wParam); if (io.WantCaptureMouse) { if (this.mouseButtonsDown == 0 && GetCapture() == nint.Zero) + { SetCapture(hWndCurrent); + } + this.mouseButtonsDown |= 1 << button; io.AddMouseButtonEvent(button, true); return default(LRESULT); @@ -288,12 +308,28 @@ internal sealed unsafe partial class Win32InputHandler : IImGuiInputHandler case WM.WM_MBUTTONUP: case WM.WM_XBUTTONUP: { + if (this.cvLogMouseEvents.Value) + { + Log.Verbose( + "Handle MouseUp {Btn} WantCaptureMouse: {Want} mouseButtonsDown: {Down}", + GetButton(msg, wParam), + io.WantCaptureMouse, + this.mouseButtonsDown); + } + var button = GetButton(msg, wParam); - if (io.WantCaptureMouse) + + // Need to check if we captured the button event away from the game here, otherwise the game might get + // a down event but no up event, causing the cursor to get stuck. + // Can happen if WantCaptureMouse becomes true in between down and up + if (io.WantCaptureMouse && (this.mouseButtonsDown & (1 << button)) != 0) { this.mouseButtonsDown &= ~(1 << button); if (this.mouseButtonsDown == 0 && GetCapture() == hWndCurrent) + { ReleaseCapture(); + } + io.AddMouseButtonEvent(button, false); return default(LRESULT); } From e53ccdbcc03a4931e4594491c6250395e5a3a3e5 Mon Sep 17 00:00:00 2001 From: goaaats Date: Tue, 9 Dec 2025 00:18:28 +0100 Subject: [PATCH 11/17] build: 13.0.0.15 --- Dalamud/Dalamud.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dalamud/Dalamud.csproj b/Dalamud/Dalamud.csproj index a4b203406..5aca47e0c 100644 --- a/Dalamud/Dalamud.csproj +++ b/Dalamud/Dalamud.csproj @@ -6,7 +6,7 @@ XIV Launcher addon framework - 13.0.0.14 + 13.0.0.15 $(DalamudVersion) $(DalamudVersion) $(DalamudVersion) From b88a6bb61646d32bf2ca2df54b611f58a81a5e5b Mon Sep 17 00:00:00 2001 From: nebel <9887+nebel@users.noreply.github.com> Date: Wed, 10 Dec 2025 23:12:44 +0900 Subject: [PATCH 12/17] Always pop DalamudStandard style if pushed earlier in Draw --- Dalamud/Interface/Windowing/Window.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Dalamud/Interface/Windowing/Window.cs b/Dalamud/Interface/Windowing/Window.cs index 7ecd5e15c..ed9318e49 100644 --- a/Dalamud/Interface/Windowing/Window.cs +++ b/Dalamud/Interface/Windowing/Window.cs @@ -672,16 +672,13 @@ public abstract class Window Task.FromResult(tex)); } - if (!this.hasError) + if (isErrorStylePushed) { - this.PostDraw(); + Style.StyleModelV1.DalamudStandard.Pop(); } else { - if (isErrorStylePushed) - { - Style.StyleModelV1.DalamudStandard.Pop(); - } + this.PostDraw(); } this.PostHandlePreset(persistence); From 201c9cfcf25c578f3bb2a3964b8674708b35d634 Mon Sep 17 00:00:00 2001 From: goaaats Date: Wed, 10 Dec 2025 01:42:45 +0100 Subject: [PATCH 13/17] Use game window to calculate offsets in fallback mouse position code --- .../ImGuiBackend/InputHandler/Win32InputHandler.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Dalamud/Interface/ImGuiBackend/InputHandler/Win32InputHandler.cs b/Dalamud/Interface/ImGuiBackend/InputHandler/Win32InputHandler.cs index 6b26ce37d..8417a90e5 100644 --- a/Dalamud/Interface/ImGuiBackend/InputHandler/Win32InputHandler.cs +++ b/Dalamud/Interface/ImGuiBackend/InputHandler/Win32InputHandler.cs @@ -494,7 +494,12 @@ internal sealed unsafe partial class Win32InputHandler : IImGuiInputHandler // (This is the position you can get with ::GetCursorPos() or WM_MOUSEMOVE + ::ClientToScreen(). In theory adding viewport->Pos to a client position would also be the same.) var mousePos = mouseScreenPos; if ((io.ConfigFlags & ImGuiConfigFlags.ViewportsEnable) == 0) - ClientToScreen(focusedWindow, &mousePos); + { + // Use game window, otherwise, positions are calculated based on the focused window which might not be the game. + // Leads to offsets. + ClientToScreen(this.hWnd, &mousePos); + } + io.AddMousePosEvent(mousePos.x, mousePos.y); } From a39763f161b893e5735b0dbe3bd7dde42bb38d5f Mon Sep 17 00:00:00 2001 From: goaaats Date: Wed, 10 Dec 2025 18:32:18 +0100 Subject: [PATCH 14/17] Mark preset dirty when disabling clickthrough for a window --- Dalamud/Interface/Windowing/Window.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dalamud/Interface/Windowing/Window.cs b/Dalamud/Interface/Windowing/Window.cs index ed9318e49..5a79a017a 100644 --- a/Dalamud/Interface/Windowing/Window.cs +++ b/Dalamud/Interface/Windowing/Window.cs @@ -84,7 +84,7 @@ public abstract class Window Click = _ => { this.internalIsClickthrough = false; - this.presetDirty = false; + this.presetDirty = true; ImGui.OpenPopup(AdditionsPopupName); }, Priority = int.MinValue, @@ -905,7 +905,7 @@ public abstract class Window private void DrawErrorMessage() { // TODO: Once window systems are services, offer to reload the plugin - ImGui.TextColoredWrapped(ImGuiColors.DalamudRed,Loc.Localize("WindowSystemErrorOccurred", "An error occurred while rendering this window. Please contact the developer for details.")); + ImGui.TextColoredWrapped(ImGuiColors.DalamudRed, Loc.Localize("WindowSystemErrorOccurred", "An error occurred while rendering this window. Please contact the developer for details.")); ImGuiHelpers.ScaledDummy(5); From 0b55dc3e10b1a43013fee7893ed3dd88762a2f60 Mon Sep 17 00:00:00 2001 From: Haselnussbomber Date: Thu, 11 Dec 2025 22:59:50 +0100 Subject: [PATCH 15/17] Clear ImDrawListSplitter when disposing SeStringDrawState --- .../ImGuiSeStringRenderer/Internal/SeStringRenderer.cs | 2 +- .../Interface/ImGuiSeStringRenderer/SeStringDrawState.cs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Dalamud/Interface/ImGuiSeStringRenderer/Internal/SeStringRenderer.cs b/Dalamud/Interface/ImGuiSeStringRenderer/Internal/SeStringRenderer.cs index 397502b30..4a8e6517e 100644 --- a/Dalamud/Interface/ImGuiSeStringRenderer/Internal/SeStringRenderer.cs +++ b/Dalamud/Interface/ImGuiSeStringRenderer/Internal/SeStringRenderer.cs @@ -170,7 +170,7 @@ internal class SeStringRenderer : IServiceType // This also does argument validation for drawParams. Do it here. // `using var` makes a struct read-only, but we do want to modify it. - var stateStorage = new SeStringDrawState( + using var stateStorage = new SeStringDrawState( sss, drawParams, ThreadSafety.IsMainThread ? this.colorStackSetMainThread : new(this.colorStackSetMainThread.ColorTypes), diff --git a/Dalamud/Interface/ImGuiSeStringRenderer/SeStringDrawState.cs b/Dalamud/Interface/ImGuiSeStringRenderer/SeStringDrawState.cs index 5601100e9..885508bed 100644 --- a/Dalamud/Interface/ImGuiSeStringRenderer/SeStringDrawState.cs +++ b/Dalamud/Interface/ImGuiSeStringRenderer/SeStringDrawState.cs @@ -10,6 +10,7 @@ using Dalamud.Interface.Utility; using Dalamud.Utility; using FFXIVClientStructs.FFXIV.Component.GUI; + using Lumina.Text.Payloads; using Lumina.Text.ReadOnly; @@ -17,7 +18,7 @@ namespace Dalamud.Interface.ImGuiSeStringRenderer; /// Calculated values from using ImGui styles. [StructLayout(LayoutKind.Sequential)] -public unsafe ref struct SeStringDrawState +public unsafe ref struct SeStringDrawState : IDisposable { private static readonly int ChannelCount = Enum.GetValues().Length; @@ -194,6 +195,9 @@ public unsafe ref struct SeStringDrawState /// Gets the text fragments. internal List Fragments { get; } + /// + public void Dispose() => this.splitter.ClearFreeMemory(); + /// Sets the current channel in the ImGui draw list splitter. /// Channel to switch to. [MethodImpl(MethodImplOptions.AggressiveInlining)] From e100ec2abdc490838f3422bf5fd5cda695a886fd Mon Sep 17 00:00:00 2001 From: goaaats Date: Fri, 12 Dec 2025 00:57:04 +0100 Subject: [PATCH 16/17] build: 13.0.0.16 --- Dalamud/Dalamud.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dalamud/Dalamud.csproj b/Dalamud/Dalamud.csproj index 5aca47e0c..3ec3c0865 100644 --- a/Dalamud/Dalamud.csproj +++ b/Dalamud/Dalamud.csproj @@ -6,7 +6,7 @@ XIV Launcher addon framework - 13.0.0.15 + 13.0.0.16 $(DalamudVersion) $(DalamudVersion) $(DalamudVersion) From 2d096d9b334ee485764a1e00589cba65c273af3e Mon Sep 17 00:00:00 2001 From: Haselnussbomber Date: Sat, 13 Dec 2025 05:05:03 +0100 Subject: [PATCH 17/17] Properly initialize GameInventoryItems (#2504) --- Dalamud/Game/Inventory/GameInventory.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dalamud/Game/Inventory/GameInventory.cs b/Dalamud/Game/Inventory/GameInventory.cs index 535b84372..5390c2707 100644 --- a/Dalamud/Game/Inventory/GameInventory.cs +++ b/Dalamud/Game/Inventory/GameInventory.cs @@ -305,7 +305,8 @@ internal class GameInventory : IInternalDisposableService private GameInventoryItem[] CreateItemsArray(int length) { var items = new GameInventoryItem[length]; - items.Initialize(); + foreach (ref var item in items.AsSpan()) + item = new(); return items; }