From 0a26d64894a5f549fbf7a7e036a9e987d95cca66 Mon Sep 17 00:00:00 2001 From: Raymond Date: Wed, 13 Apr 2022 20:47:03 -0400 Subject: [PATCH 1/2] Use GetAgentByInternalID --- Dalamud/Game/Gui/GameGui.cs | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/Dalamud/Game/Gui/GameGui.cs b/Dalamud/Game/Gui/GameGui.cs index 1aec4d3b1..02afad2cd 100644 --- a/Dalamud/Game/Gui/GameGui.cs +++ b/Dalamud/Game/Gui/GameGui.cs @@ -2,7 +2,6 @@ using System; using System.Numerics; using System.Runtime.InteropServices; -using Dalamud.Configuration.Internal; using Dalamud.Game.Gui.ContextMenus; using Dalamud.Game.Gui.Dtr; using Dalamud.Game.Gui.FlyText; @@ -15,7 +14,6 @@ using Dalamud.IoC; using Dalamud.IoC.Internal; using Dalamud.Utility; using FFXIVClientStructs.FFXIV.Client.System.String; -using FFXIVClientStructs.FFXIV.Client.UI; using ImGuiNET; using Serilog; @@ -95,8 +93,6 @@ namespace Dalamud.Game.Gui [UnmanagedFunctionPointer(CallingConvention.ThisCall)] private unsafe delegate bool ScreenToWorldNativeDelegate(float* camPos, float* clipPos, float rayDistance, float* worldPos, int* unknown); - private delegate IntPtr GetAgentModuleDelegate(IntPtr uiModule); - // Hooked delegates [UnmanagedFunctionPointer(CallingConvention.ThisCall)] @@ -394,36 +390,25 @@ namespace Dalamud.Game.Gui if (addon == IntPtr.Zero) return IntPtr.Zero; - var uiModule = (UIModule*)Service.Get().GetUIModule(); + var uiModule = (FFXIVClientStructs.FFXIV.Client.UI.UIModule*)this.GetUIModule(); if (uiModule == null) - { return IntPtr.Zero; - } var agentModule = uiModule->GetAgentModule(); if (agentModule == null) - { return IntPtr.Zero; - } var unitBase = (FFXIVClientStructs.FFXIV.Component.GUI.AtkUnitBase*)addon; var id = unitBase->ParentID; if (id == 0) - id = unitBase->ID; - - if (id == 0) - return IntPtr.Zero; - - // Patch 6.1, 398 agents - for (var i = 0; i < 398; i++) { - var agent = &agentModule->AgentArray[i]; - - if (agent->AddonId == id) - return new IntPtr(agent); + id = unitBase->ID; + if (id == 0) + return IntPtr.Zero; } - return IntPtr.Zero; + var agent = agentModule->GetAgentByInternalID(id); + return (IntPtr)agent; } /// From 41a135db19a4e9d74cd154a641f6ad471cb5efe8 Mon Sep 17 00:00:00 2001 From: Aireil <33433913+Aireil@users.noreply.github.com> Date: Thu, 14 Apr 2022 13:52:34 +0200 Subject: [PATCH 2/2] fix: clamp settings sliders --- Dalamud/Interface/Internal/Windows/SettingsWindow.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dalamud/Interface/Internal/Windows/SettingsWindow.cs b/Dalamud/Interface/Internal/Windows/SettingsWindow.cs index 4dffd0148..7d088c75d 100644 --- a/Dalamud/Interface/Internal/Windows/SettingsWindow.cs +++ b/Dalamud/Interface/Internal/Windows/SettingsWindow.cs @@ -353,7 +353,7 @@ namespace Dalamud.Interface.Internal.Windows interfaceManager.RebuildFonts(); } - if (ImGui.DragFloat("##DalamudSettingsGlobalUiScaleDrag", ref this.globalUiScale, 0.005f, MinScale, MaxScale, "%.2f")) + if (ImGui.DragFloat("##DalamudSettingsGlobalUiScaleDrag", ref this.globalUiScale, 0.005f, MinScale, MaxScale, "%.2f", ImGuiSliderFlags.AlwaysClamp)) { ImGui.GetIO().FontGlobalScale = this.globalUiScale; interfaceManager.RebuildFonts(); @@ -440,7 +440,7 @@ namespace Dalamud.Interface.Internal.Windows interfaceManager.RebuildFonts(); } - if (ImGui.DragFloat("##DalamudSettingsFontGammaDrag", ref this.fontGamma, 0.005f, MinScale, MaxScale, "%.2f")) + if (ImGui.DragFloat("##DalamudSettingsFontGammaDrag", ref this.fontGamma, 0.005f, MinScale, MaxScale, "%.2f", ImGuiSliderFlags.AlwaysClamp)) { interfaceManager.FontGammaOverride = this.fontGamma; interfaceManager.RebuildFonts();