From 3062d2d930b8de8f53404bf309d9b9fade7d3c33 Mon Sep 17 00:00:00 2001 From: goaaats Date: Mon, 11 Apr 2022 19:53:07 +0200 Subject: [PATCH 01/16] ci: support multiple tracks --- .github/workflows/main.yml | 39 +++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 70c0b33ea..09ab225ee 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -49,27 +49,44 @@ jobs: name: dalamud-artifact path: .\scratch + - name: Extract branch name + shell: bash + run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" + id: extract_branch + - name: Generate dalamud-distrib version file shell: pwsh + env: + GH_BRANCH: ${{ steps.extract_branch.outputs.branch }} run: | Compress-Archive .\scratch\* .\canary.zip # Recreate the release zip + $branchName = $env:GH_BRANCH + + if ($branchName -eq "master") { + $branchName = "stg" + } + $dllBytes = [System.IO.File]::ReadAllBytes("$(Get-Location)\scratch\Dalamud.dll") $assembly = [System.Reflection.Assembly]::Load($dllBytes) $newVersion = $assembly.GetCustomAttributes([System.Reflection.AssemblyMetadataAttribute]) | Where { $_.GetType() -eq [System.Reflection.AssemblyMetadataAttribute] } | Select -First 1 | Select -ExpandProperty "Value" Remove-Item -Force -Recurse .\scratch - - $versionData = Get-Content .\stg\version | ConvertFrom-Json - $oldVersion = $versionData.AssemblyVersion - if ($oldVersion -eq $newVersion) { - Remove-Item .\canary.zip - } else { - Move-Item -Force .\canary.zip .\stg\latest.zip - $versionData.AssemblyVersion = $newVersion - $versionData | ConvertTo-Json -Compress | Out-File .\stg\version - } - echo "DVER=${newVersion}" >> $Env:GITHUB_ENV + if (Test-Path -Path $branchName) { + $versionData = Get-Content ".\${branchName}\version" | ConvertFrom-Json + $oldVersion = $versionData.AssemblyVersion + if ($oldVersion -eq $newVersion) { + Remove-Item .\canary.zip + } else { + Move-Item -Force ".\canary.zip" ".\${branchName}\latest.zip" + $versionData.AssemblyVersion = $newVersion + $versionData | ConvertTo-Json -Compress | Out-File ".\${branchName}\version" + } + + echo "DVER=${newVersion}" >> $Env:GITHUB_ENV + } else { + Write-Host "Deployment folder doesn't exist. Not doing anything." + } - name: Commit changes shell: bash From a24e81bee3c2bc808091e40d8ea64f51ae9b1872 Mon Sep 17 00:00:00 2001 From: goaaats Date: Mon, 11 Apr 2022 19:54:06 +0200 Subject: [PATCH 02/16] ci: add track name to commit --- .github/workflows/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 09ab225ee..f6620cbc1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -93,6 +93,7 @@ jobs: env: DEPLOY_SSH: ${{ secrets.DEPLOY_SSH }} GIT_SSH_COMMAND: "ssh -o StrictHostKeyChecking=no" + GH_BRANCH: ${{ steps.extract_branch.outputs.branch }} run: | eval "$(ssh-agent -s)" ssh-add - <<< "${DEPLOY_SSH}" @@ -101,6 +102,6 @@ jobs: git config --global user.email "actions@github.com" git add . - git commit -m "[CI] Update staging for ${DVER}" || true + git commit -m "[CI] Update staging for ${DVER} on ${GH_BRANCH}" || true git push origin main || true From 36f0d1d87d9f3f70406a32bd9de1d896ef44c4d2 Mon Sep 17 00:00:00 2001 From: goaaats Date: Mon, 11 Apr 2022 20:32:56 +0200 Subject: [PATCH 03/16] chore: FontGamma => FontGammaLevel --- Dalamud/Configuration/Internal/DalamudConfiguration.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dalamud/Configuration/Internal/DalamudConfiguration.cs b/Dalamud/Configuration/Internal/DalamudConfiguration.cs index a5bbe6c9f..222dccab6 100644 --- a/Dalamud/Configuration/Internal/DalamudConfiguration.cs +++ b/Dalamud/Configuration/Internal/DalamudConfiguration.cs @@ -141,7 +141,7 @@ namespace Dalamud.Configuration.Internal /// * ...TTF fonts loaded with stb or FreeType are in linear space. /// * ...the game's prebaked AXIS fonts are in gamma space with gamma value of 1.4. /// - public float FontGamma { get; set; } = 1.4f; + public float FontGammaLevel { get; set; } = 1.4f; /// /// Gets or sets a value indicating the level of font resolution between 1 to 5. From c2bce23fc3583750fa1f73aae50819dc8be1849b Mon Sep 17 00:00:00 2001 From: goaaats Date: Mon, 11 Apr 2022 20:43:51 +0200 Subject: [PATCH 04/16] chore: fix old references, Rider didn't bother refactoring the rest --- Dalamud/Interface/Internal/InterfaceManager.cs | 2 +- Dalamud/Interface/Internal/Windows/SettingsWindow.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Dalamud/Interface/Internal/InterfaceManager.cs b/Dalamud/Interface/Internal/InterfaceManager.cs index 67a7027b3..21b5de793 100644 --- a/Dalamud/Interface/Internal/InterfaceManager.cs +++ b/Dalamud/Interface/Internal/InterfaceManager.cs @@ -213,7 +213,7 @@ namespace Dalamud.Interface.Internal /// /// Gets the font gamma value to use. /// - public float FontGamma => Math.Max(0.1f, this.FontGammaOverride.GetValueOrDefault(Service.Get().FontGamma)); + public float FontGamma => Math.Max(0.1f, this.FontGammaOverride.GetValueOrDefault(Service.Get().FontGammaLevel)); /// /// Gets or sets a value indicating whether to override configuration for FontResolutionLevel. diff --git a/Dalamud/Interface/Internal/Windows/SettingsWindow.cs b/Dalamud/Interface/Internal/Windows/SettingsWindow.cs index 1fc8a4586..4dffd0148 100644 --- a/Dalamud/Interface/Internal/Windows/SettingsWindow.cs +++ b/Dalamud/Interface/Internal/Windows/SettingsWindow.cs @@ -99,7 +99,7 @@ namespace Dalamud.Interface.Internal.Windows this.doMbCollect = configuration.IsMbCollect; this.globalUiScale = configuration.GlobalUiScale; - this.fontGamma = configuration.FontGamma; + this.fontGamma = configuration.FontGammaLevel; this.doUseAxisFontsFromGame = configuration.UseAxisFontsFromGame; this.fontResolutionLevel = configuration.FontResolutionLevel; this.doToggleUiHide = configuration.ToggleUiHide; @@ -197,7 +197,7 @@ namespace Dalamud.Interface.Internal.Windows var configuration = Service.Get(); var interfaceManager = Service.Get(); - var rebuildFont = interfaceManager.FontGamma != configuration.FontGamma; + var rebuildFont = interfaceManager.FontGamma != configuration.FontGammaLevel; ImGui.GetIO().FontGlobalScale = configuration.GlobalUiScale; interfaceManager.FontGammaOverride = null; @@ -930,7 +930,7 @@ namespace Dalamud.Interface.Internal.Windows configuration.UseAxisFontsFromGame = this.doUseAxisFontsFromGame; configuration.FontResolutionLevel = this.fontResolutionLevel; - configuration.FontGamma = this.fontGamma; + configuration.FontGammaLevel = this.fontGamma; // This is applied every frame in InterfaceManager::CheckViewportState() configuration.IsDisableViewport = !this.doViewport; From 99f007a92fbf73a165debf529b854964a0cd2860 Mon Sep 17 00:00:00 2001 From: goaaats Date: Mon, 11 Apr 2022 19:59:44 +0200 Subject: [PATCH 05/16] ci: deploy from all branches --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f6620cbc1..335353b4f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -36,7 +36,7 @@ jobs: deploy_stg: name: Deploy dalamud-distrib staging - if: ${{ github.ref == 'refs/heads/master' && github.event_name == 'push' }} + if: ${{ github.event_name == 'push' }} needs: build runs-on: windows-latest steps: From dbbcc0f287c2c6ad73e8815b68857d179572eb0b Mon Sep 17 00:00:00 2001 From: goaaats Date: Mon, 11 Apr 2022 21:16:50 +0200 Subject: [PATCH 06/16] ci: remove canary zip when branch is not applicable --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 335353b4f..6de36a06e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -86,6 +86,7 @@ jobs: echo "DVER=${newVersion}" >> $Env:GITHUB_ENV } else { Write-Host "Deployment folder doesn't exist. Not doing anything." + Remove-Item .\canary.zip } - name: Commit changes From bbdc1bd603a028531f0787ff3c724daf24a06f56 Mon Sep 17 00:00:00 2001 From: goaaats Date: Wed, 13 Apr 2022 03:52:54 +0200 Subject: [PATCH 07/16] deps: update FFXIVClientStructs --- lib/FFXIVClientStructs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/FFXIVClientStructs b/lib/FFXIVClientStructs index db6e7c4a7..1f5cdf653 160000 --- a/lib/FFXIVClientStructs +++ b/lib/FFXIVClientStructs @@ -1 +1 @@ -Subproject commit db6e7c4a7b2638bedc2888c546009c7292c5de45 +Subproject commit 1f5cdf653ebfb32e2ae25891a0737462d92ba96e From ebe35095f5915cc77c04d07697b808186b9a2530 Mon Sep 17 00:00:00 2001 From: goaaats Date: Wed, 13 Apr 2022 03:53:05 +0200 Subject: [PATCH 08/16] fix: increase system menu size --- Dalamud/Game/Internal/DalamudAtkTweaks.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Dalamud/Game/Internal/DalamudAtkTweaks.cs b/Dalamud/Game/Internal/DalamudAtkTweaks.cs index a39cbe998..111d1364c 100644 --- a/Dalamud/Game/Internal/DalamudAtkTweaks.cs +++ b/Dalamud/Game/Internal/DalamudAtkTweaks.cs @@ -138,18 +138,18 @@ namespace Dalamud.Game.Internal return; } - // the max size (hardcoded) is 0xE/15, but the system menu currently uses 0xC/12 + // the max size (hardcoded) is 0x11/17, but the system menu currently uses 0xC/12 // this is a just in case that doesnt really matter // see if we can add 2 entries - if (menuSize >= 0xD) + if (menuSize >= 0x11) { this.hookAgentHudOpenSystemMenu.Original(thisPtr, atkValueArgs, menuSize); return; } // atkValueArgs is actually an array of AtkValues used as args. all their UI code works like this. - // in this case, menu size is stored in atkValueArgs[4], and the next 15 slots are the MainCommand - // the 15 slots after that, if they exist, are the entry names, but they are otherwise pulled from MainCommand EXD + // in this case, menu size is stored in atkValueArgs[4], and the next 17 slots are the MainCommand + // the 17 slots after that, if they exist, are the entry names, but they are otherwise pulled from MainCommand EXD // reference the original function for more details :) // step 1) move all the current menu items down so we can put Dalamud at the top like it deserves @@ -173,9 +173,9 @@ namespace Dalamud.Game.Internal // step 3) create strings for them // since the game first checks for strings in the AtkValue argument before pulling them from the exd, if we create strings we dont have to worry // about hooking the exd reader, thank god - var firstStringEntry = &atkValueArgs[5 + 15]; + var firstStringEntry = &atkValueArgs[5 + 17]; this.atkValueChangeType(firstStringEntry, ValueType.String); - var secondStringEntry = &atkValueArgs[6 + 15]; + var secondStringEntry = &atkValueArgs[6 + 17]; this.atkValueChangeType(secondStringEntry, ValueType.String); const int color = 539; From 47a096a252d981b00fe62e890f09494298c8cb75 Mon Sep 17 00:00:00 2001 From: goaaats Date: Wed, 13 Apr 2022 03:53:24 +0200 Subject: [PATCH 09/16] fix: ContextMenu adjustments to new client structs --- Dalamud/Game/Gui/ContextMenus/ContextMenu.cs | 25 +++++++------- .../Gui/ContextMenus/ContextMenuOpenedArgs.cs | 6 ++-- .../ContextMenus/ContextMenuReaderWriter.cs | 26 +++++++-------- .../OldStructs/OldAgentContext.cs | 33 +++++++++++++++++++ .../OldStructs/OldAgentContextInterface.cs | 17 ++++++++++ Dalamud/Game/Gui/GameGui.cs | 2 +- 6 files changed, 80 insertions(+), 29 deletions(-) create mode 100644 Dalamud/Game/Gui/ContextMenus/OldStructs/OldAgentContext.cs create mode 100644 Dalamud/Game/Gui/ContextMenus/OldStructs/OldAgentContextInterface.cs diff --git a/Dalamud/Game/Gui/ContextMenus/ContextMenu.cs b/Dalamud/Game/Gui/ContextMenus/ContextMenu.cs index 44307b48a..3d02634ab 100644 --- a/Dalamud/Game/Gui/ContextMenus/ContextMenu.cs +++ b/Dalamud/Game/Gui/ContextMenus/ContextMenu.cs @@ -2,12 +2,13 @@ using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; - +using Dalamud.Game.Gui.ContextMenus.OldStructs; using Dalamud.Hooking; using Dalamud.IoC; using Dalamud.IoC.Internal; using Dalamud.Logging; using Dalamud.Memory; +using FFXIVClientStructs.FFXIV.Client.Game; using FFXIVClientStructs.FFXIV.Client.UI; using FFXIVClientStructs.FFXIV.Client.UI.Agent; using FFXIVClientStructs.FFXIV.Component.GUI; @@ -38,7 +39,7 @@ namespace Dalamud.Game.Gui.ContextMenus #endregion - private unsafe AgentContextInterface* currentAgentContextInterface; + private unsafe OldAgentContextInterface* currentAgentContextInterface; private IntPtr currentSubContextMenuTitle; @@ -67,15 +68,15 @@ namespace Dalamud.Game.Gui.ContextMenus #region Delegates - private unsafe delegate bool OpenSubContextMenuDelegate(AgentContext* agentContext); + private unsafe delegate bool OpenSubContextMenuDelegate(OldAgentContext* agentContext); - private unsafe delegate IntPtr ContextMenuOpeningDelegate(IntPtr a1, IntPtr a2, IntPtr a3, uint a4, IntPtr a5, AgentContextInterface* agentContextInterface, IntPtr a7, ushort a8); + private unsafe delegate IntPtr ContextMenuOpeningDelegate(IntPtr a1, IntPtr a2, IntPtr a3, uint a4, IntPtr a5, OldAgentContextInterface* agentContextInterface, IntPtr a7, ushort a8); private unsafe delegate bool ContextMenuOpenedDelegate(AddonContextMenu* addonContextMenu, int menuSize, AtkValue* atkValueArgs); private unsafe delegate bool ContextMenuItemSelectedDelegate(AddonContextMenu* addonContextMenu, int selectedIndex, byte a3); - private unsafe delegate bool SubContextMenuOpeningDelegate(AgentContext* agentContext); + private unsafe delegate bool SubContextMenuOpeningDelegate(OldAgentContext* agentContext); #endregion @@ -108,7 +109,7 @@ namespace Dalamud.Game.Gui.ContextMenus this.subContextMenuOpenedHook.Enable(); } - private static unsafe bool IsInventoryContext(AgentContextInterface* agentContextInterface) + private static unsafe bool IsInventoryContext(OldAgentContextInterface* agentContextInterface) { return agentContextInterface == AgentInventoryContext.Instance(); } @@ -121,7 +122,7 @@ namespace Dalamud.Game.Gui.ContextMenus } } - private unsafe IntPtr ContextMenuOpeningDetour(IntPtr a1, IntPtr a2, IntPtr a3, uint a4, IntPtr a5, AgentContextInterface* agentContextInterface, IntPtr a7, ushort a8) + private unsafe IntPtr ContextMenuOpeningDetour(IntPtr a1, IntPtr a2, IntPtr a3, uint a4, IntPtr a5, OldAgentContextInterface* agentContextInterface, IntPtr a7, ushort a8) { this.currentAgentContextInterface = agentContextInterface; return this.contextMenuOpeningHook!.Original(a1, a2, a3, a4, a5, agentContextInterface, a7, a8); @@ -212,12 +213,12 @@ namespace Dalamud.Game.Gui.ContextMenus } } - private unsafe bool SubContextMenuOpeningDetour(AgentContext* agentContext) + private unsafe bool SubContextMenuOpeningDetour(OldAgentContext* agentContext) { return this.SubContextMenuOpeningImplementation(agentContext) || this.subContextMenuOpeningHook.Original(agentContext); } - private unsafe bool SubContextMenuOpeningImplementation(AgentContext* agentContext) + private unsafe bool SubContextMenuOpeningImplementation(OldAgentContext* agentContext) { if (this.openSubContextMenu == null || this.selectedOpenSubContextMenuItem == null) { @@ -274,7 +275,7 @@ namespace Dalamud.Game.Gui.ContextMenus this.ContextMenuOpenedImplementation(addonContextMenu, ref atkValueCount, ref atkValues); } - private unsafe ContextMenuOpenedArgs? NotifyContextMenuOpened(AddonContextMenu* addonContextMenu, AgentContextInterface* agentContextInterface, string? title, ContextMenus.ContextMenuOpenedDelegate contextMenuOpenedDelegate, IEnumerable initialContextMenuItems) + private unsafe ContextMenuOpenedArgs? NotifyContextMenuOpened(AddonContextMenu* addonContextMenu, OldAgentContextInterface* agentContextInterface, string? title, ContextMenus.ContextMenuOpenedDelegate contextMenuOpenedDelegate, IEnumerable initialContextMenuItems) { var parentAddonName = this.GetParentAddonName(&addonContextMenu->AtkUnitBase); @@ -285,11 +286,11 @@ namespace Dalamud.Game.Gui.ContextMenus if (IsInventoryContext(agentContextInterface)) { var agentInventoryContext = (AgentInventoryContext*)agentContextInterface; - inventoryItemContext = new InventoryItemContext(agentInventoryContext->InventoryItemId, agentInventoryContext->InventoryItemCount, agentInventoryContext->InventoryItemIsHighQuality); + inventoryItemContext = new InventoryItemContext(agentInventoryContext->TargetDummyItem.ItemID, agentInventoryContext->TargetDummyItem.Quantity, agentInventoryContext->TargetDummyItem.Flags.HasFlag(InventoryItem.ItemFlags.HQ)); } else { - var agentContext = (AgentContext*)agentContextInterface; + var agentContext = (OldAgentContext*)agentContextInterface; uint? id = agentContext->GameObjectId; if (id == 0) diff --git a/Dalamud/Game/Gui/ContextMenus/ContextMenuOpenedArgs.cs b/Dalamud/Game/Gui/ContextMenus/ContextMenuOpenedArgs.cs index 05293bacd..4ecc3e4b9 100644 --- a/Dalamud/Game/Gui/ContextMenus/ContextMenuOpenedArgs.cs +++ b/Dalamud/Game/Gui/ContextMenus/ContextMenuOpenedArgs.cs @@ -1,5 +1,5 @@ using System.Collections.Generic; - +using Dalamud.Game.Gui.ContextMenus.OldStructs; using Dalamud.Game.Text.SeStringHandling; using FFXIVClientStructs.FFXIV.Client.UI; using FFXIVClientStructs.FFXIV.Client.UI.Agent; @@ -18,7 +18,7 @@ namespace Dalamud.Game.Gui.ContextMenus /// The agent associated with the context menu. /// The the name of the parent addon associated with the context menu. /// The items in the context menu. - public ContextMenuOpenedArgs(AddonContextMenu* addon, AgentContextInterface* agent, string? parentAddonName, IEnumerable items) + public ContextMenuOpenedArgs(AddonContextMenu* addon, OldAgentContextInterface* agent, string? parentAddonName, IEnumerable items) { this.Addon = addon; this.Agent = agent; @@ -34,7 +34,7 @@ namespace Dalamud.Game.Gui.ContextMenus /// /// Gets the agent associated with the context menu. /// - public AgentContextInterface* Agent { get; } + public OldAgentContextInterface* Agent { get; } /// /// Gets the name of the parent addon associated with the context menu. diff --git a/Dalamud/Game/Gui/ContextMenus/ContextMenuReaderWriter.cs b/Dalamud/Game/Gui/ContextMenus/ContextMenuReaderWriter.cs index 16f24365d..75310d7d7 100644 --- a/Dalamud/Game/Gui/ContextMenus/ContextMenuReaderWriter.cs +++ b/Dalamud/Game/Gui/ContextMenus/ContextMenuReaderWriter.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Numerics; using System.Runtime.InteropServices; - +using Dalamud.Game.Gui.ContextMenus.OldStructs; using Dalamud.Game.Text.SeStringHandling; using Dalamud.Logging; using Dalamud.Memory; @@ -19,7 +19,7 @@ namespace Dalamud.Game.Gui.ContextMenus /// internal unsafe class ContextMenuReaderWriter { - private readonly AgentContextInterface* agentContextInterface; + private readonly OldAgentContextInterface* agentContextInterface; private int atkValueCount; private AtkValue* atkValues; @@ -30,7 +30,7 @@ namespace Dalamud.Game.Gui.ContextMenus /// The AgentContextInterface to act upon. /// The number of ATK values to consider. /// Pointer to the array of ATK values. - public ContextMenuReaderWriter(AgentContextInterface* agentContextInterface, int atkValueCount, AtkValue* atkValues) + public ContextMenuReaderWriter(OldAgentContextInterface* agentContextInterface, int atkValueCount, AtkValue* atkValues) { PluginLog.Warning($"{(IntPtr)atkValues:X}"); @@ -306,17 +306,17 @@ namespace Dalamud.Game.Gui.ContextMenus byte action; if (this.IsInventoryContext) { - var actions = &((AgentInventoryContext*)this.agentContextInterface)->Actions; - action = *(actions + contextMenuItemAtkValueBaseIndex); + var actions = &((AgentInventoryContext*)this.agentContextInterface)->EventIdArray; + action = *actions[contextMenuItemAtkValueBaseIndex]; } else if (this.StructLayout is SubContextMenuStructLayout.Alternate) { - var redButtonActions = &((AgentContext*)this.agentContextInterface)->Items->RedButtonActions; + var redButtonActions = &((OldAgentContext*)this.agentContextInterface)->Items->RedButtonActions; action = (byte)*(redButtonActions + contextMenuItemIndex); } else { - var actions = &((AgentContext*)this.agentContextInterface)->Items->Actions; + var actions = &((OldAgentContext*)this.agentContextInterface)->Items->Actions; action = *(actions + contextMenuItemAtkValueBaseIndex); } @@ -438,27 +438,27 @@ namespace Dalamud.Game.Gui.ContextMenus if (this.IsInventoryContext) { - var actions = &((AgentInventoryContext*)this.agentContextInterface)->Actions; - *(actions + this.FirstContextMenuItemIndex + contextMenuItemIndex) = action; + var actions = &((AgentInventoryContext*)this.agentContextInterface)->EventIdArray; + *actions[this.FirstContextMenuItemIndex + contextMenuItemIndex] = action; } else if (this.StructLayout is SubContextMenuStructLayout.Alternate && this.FirstUnhandledAction != null) { // Some weird placeholder goes here - var actions = &((AgentContext*)this.agentContextInterface)->Items->Actions; + var actions = &((OldAgentContext*)this.agentContextInterface)->Items->Actions; *(actions + this.FirstContextMenuItemIndex + contextMenuItemIndex) = (byte)(this.FirstUnhandledAction.Value + contextMenuItemIndex); // Make sure there's one of these function pointers for every item. // The function needs to be the same, so we just copy the first one into every index. - var unkFunctionPointers = &((AgentContext*)this.agentContextInterface)->Items->UnkFunctionPointers; + var unkFunctionPointers = &((OldAgentContext*)this.agentContextInterface)->Items->UnkFunctionPointers; *(unkFunctionPointers + this.FirstContextMenuItemIndex + contextMenuItemIndex) = *(unkFunctionPointers + this.FirstContextMenuItemIndex); // The real action goes here - var redButtonActions = &((AgentContext*)this.agentContextInterface)->Items->RedButtonActions; + var redButtonActions = &((OldAgentContext*)this.agentContextInterface)->Items->RedButtonActions; *(redButtonActions + contextMenuItemIndex) = action; } else { - var actions = &((AgentContext*)this.agentContextInterface)->Items->Actions; + var actions = &((OldAgentContext*)this.agentContextInterface)->Items->Actions; *(actions + this.FirstContextMenuItemIndex + contextMenuItemIndex) = action; } diff --git a/Dalamud/Game/Gui/ContextMenus/OldStructs/OldAgentContext.cs b/Dalamud/Game/Gui/ContextMenus/OldStructs/OldAgentContext.cs new file mode 100644 index 000000000..d0c59b616 --- /dev/null +++ b/Dalamud/Game/Gui/ContextMenus/OldStructs/OldAgentContext.cs @@ -0,0 +1,33 @@ +using System.Runtime.InteropServices; + +using FFXIVClientStructs.FFXIV.Client.System.String; +using FFXIVClientStructs.FFXIV.Client.UI.Agent; +using FFXIVClientStructs.FFXIV.Component.GUI; + +namespace Dalamud.Game.Gui.ContextMenus.OldStructs; + +// TODO: This is transplanted from client structs before the rework. Need to take some time to sort all of this out soon. + +[StructLayout(LayoutKind.Explicit)] +public unsafe struct OldAgentContext +{ + public static OldAgentContext* Instance() => (OldAgentContext*)FFXIVClientStructs.FFXIV.Client.System.Framework.Framework.Instance()->GetUiModule()->GetAgentModule()->GetAgentByInternalId(AgentId.Context); + + [FieldOffset(0x0)] public AgentInterface AgentInterface; + [FieldOffset(0x0)] public OldAgentContextInterface AgentContextInterface; + [FieldOffset(0xD18)] public unsafe OldAgentContextMenuItems* Items; + [FieldOffset(0xE08)] public Utf8String GameObjectName; + [FieldOffset(0xEE0)] public ulong GameObjectContentId; + [FieldOffset(0xEF0)] public uint GameObjectId; + [FieldOffset(0xF00)] public ushort GameObjectWorldId; +} + +[StructLayout(LayoutKind.Explicit)] +public struct OldAgentContextMenuItems +{ + [FieldOffset(0x0)] public ushort AtkValueCount; + [FieldOffset(0x8)] public AtkValue AtkValues; + [FieldOffset(0x428)] public byte Actions; + [FieldOffset(0x450)] public ulong UnkFunctionPointers; + [FieldOffset(0x598)] public ulong RedButtonActions; +} diff --git a/Dalamud/Game/Gui/ContextMenus/OldStructs/OldAgentContextInterface.cs b/Dalamud/Game/Gui/ContextMenus/OldStructs/OldAgentContextInterface.cs new file mode 100644 index 000000000..2dde22dfb --- /dev/null +++ b/Dalamud/Game/Gui/ContextMenus/OldStructs/OldAgentContextInterface.cs @@ -0,0 +1,17 @@ +using System.Runtime.InteropServices; + +using FFXIVClientStructs.FFXIV.Component.GUI; + +namespace Dalamud.Game.Gui.ContextMenus.OldStructs; + +// TODO: This is transplanted from client structs before the rework. Need to take some time to sort all of this out soon. + +[StructLayout(LayoutKind.Explicit)] +public unsafe struct OldAgentContextInterface +{ + [FieldOffset(0x0)] public AgentInterface AgentInterface; + [FieldOffset(0x670)] public unsafe byte SelectedIndex; + [FieldOffset(0x690)] public byte* Unk1; + [FieldOffset(0xD08)] public byte* SubContextMenuTitle; + [FieldOffset(0x1740)] public bool IsSubContextMenu; +} diff --git a/Dalamud/Game/Gui/GameGui.cs b/Dalamud/Game/Gui/GameGui.cs index 94e195ef0..5638f8b50 100644 --- a/Dalamud/Game/Gui/GameGui.cs +++ b/Dalamud/Game/Gui/GameGui.cs @@ -412,7 +412,7 @@ namespace Dalamud.Game.Gui var unitBase = (FFXIVClientStructs.FFXIV.Component.GUI.AtkUnitBase*)addon; var id = unitBase->ParentID; if (id == 0) - id = unitBase->IDu; + id = unitBase->ID; if (id == 0) return IntPtr.Zero; From 40e6289321d5c8c8eb5e6450aafcc7ec697ae170 Mon Sep 17 00:00:00 2001 From: Kaz Wolfe Date: Tue, 12 Apr 2022 18:07:22 -0700 Subject: [PATCH 10/16] fix: allow window list edits at any time Slightly tweak the logic of the WindowSystem Draw() to make a shallow copy of the window list before iterating over it. This allows for the list to be edited at any time, but has a trade-off that modifications to the list won't take effect until the next frame, which is negligible and would have been the case anyways. This change does not break any existing APIs, and should incur minimal (if any) performance penalty. --- Dalamud/Interface/Windowing/WindowSystem.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dalamud/Interface/Windowing/WindowSystem.cs b/Dalamud/Interface/Windowing/WindowSystem.cs index 0e3e2d5eb..b43194b22 100644 --- a/Dalamud/Interface/Windowing/WindowSystem.cs +++ b/Dalamud/Interface/Windowing/WindowSystem.cs @@ -106,7 +106,8 @@ namespace Dalamud.Interface.Windowing if (hasNamespace) ImGui.PushID(this.Namespace); - foreach (var window in this.windows) + // Shallow clone the list of windows so that we can edit it without modifying it while the loop is iterating + foreach (var window in this.windows.ToArray()) { #if DEBUG // Log.Verbose($"[WS{(hasNamespace ? "/" + this.Namespace : string.Empty)}] Drawing {window.WindowName}"); From 3ae19ab32db58c1be79e8c2ea9e6c69c2c922b4d Mon Sep 17 00:00:00 2001 From: goaaats Date: Wed, 13 Apr 2022 21:10:02 +0200 Subject: [PATCH 11/16] deps: update FFXIVClientStructs --- lib/FFXIVClientStructs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/FFXIVClientStructs b/lib/FFXIVClientStructs index 1f5cdf653..ef1967272 160000 --- a/lib/FFXIVClientStructs +++ b/lib/FFXIVClientStructs @@ -1 +1 @@ -Subproject commit 1f5cdf653ebfb32e2ae25891a0737462d92ba96e +Subproject commit ef196727291f79602aa43bdd8a96f4df12b8b90e From 0fb01b1b84633b73f983ea13c5f8f1dd714134e1 Mon Sep 17 00:00:00 2001 From: goaaats Date: Thu, 14 Apr 2022 00:49:40 +0200 Subject: [PATCH 12/16] deps: update Lumina & Lumina.Excel --- Dalamud.CorePlugin/Dalamud.CorePlugin.csproj | 4 ++-- Dalamud/Dalamud.csproj | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Dalamud.CorePlugin/Dalamud.CorePlugin.csproj b/Dalamud.CorePlugin/Dalamud.CorePlugin.csproj index 3b7556af7..f2a3e537f 100644 --- a/Dalamud.CorePlugin/Dalamud.CorePlugin.csproj +++ b/Dalamud.CorePlugin/Dalamud.CorePlugin.csproj @@ -27,8 +27,8 @@ - - + + all diff --git a/Dalamud/Dalamud.csproj b/Dalamud/Dalamud.csproj index 7000fda4a..a949a6912 100644 --- a/Dalamud/Dalamud.csproj +++ b/Dalamud/Dalamud.csproj @@ -65,8 +65,8 @@ - - + + From dbcf13ee310c4d9b8cae3823e3b144fe23f730b3 Mon Sep 17 00:00:00 2001 From: goaaats Date: Thu, 14 Apr 2022 01:06:05 +0200 Subject: [PATCH 13/16] deps: update FFXIVClientStructs --- lib/FFXIVClientStructs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/FFXIVClientStructs b/lib/FFXIVClientStructs index ef1967272..e2068a5fe 160000 --- a/lib/FFXIVClientStructs +++ b/lib/FFXIVClientStructs @@ -1 +1 @@ -Subproject commit ef196727291f79602aa43bdd8a96f4df12b8b90e +Subproject commit e2068a5feda06ae596f3d69cac0e6ed370e3a533 From b2a79420dced23917e149aff85b8b10061b07e63 Mon Sep 17 00:00:00 2001 From: goaaats Date: Thu, 14 Apr 2022 01:30:04 +0200 Subject: [PATCH 14/16] deps: update Reloaded.Hooks to 3.5.2 --- Dalamud/Dalamud.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dalamud/Dalamud.csproj b/Dalamud/Dalamud.csproj index a949a6912..0acb00e72 100644 --- a/Dalamud/Dalamud.csproj +++ b/Dalamud/Dalamud.csproj @@ -73,7 +73,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive From 82963d7e5c3ed7710965668f0d15c7c1179f7590 Mon Sep 17 00:00:00 2001 From: goaaats Date: Thu, 14 Apr 2022 01:43:16 +0200 Subject: [PATCH 15/16] fix: only show loaded devplugins in login message --- Dalamud/Game/ChatHandlers.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dalamud/Game/ChatHandlers.cs b/Dalamud/Game/ChatHandlers.cs index 931ff8949..e1dcad965 100644 --- a/Dalamud/Game/ChatHandlers.cs +++ b/Dalamud/Game/ChatHandlers.cs @@ -243,11 +243,11 @@ namespace Dalamud.Game var assemblyVersion = Assembly.GetAssembly(typeof(ChatHandlers)).GetName().Version.ToString(); chatGui.Print(string.Format(Loc.Localize("DalamudWelcome", "Dalamud vD{0} loaded."), assemblyVersion) - + string.Format(Loc.Localize("PluginsWelcome", " {0} plugin(s) loaded."), pluginManager.InstalledPlugins.Count)); + + string.Format(Loc.Localize("PluginsWelcome", " {0} plugin(s) loaded."), pluginManager.InstalledPlugins.Count(x => x.IsLoaded))); if (configuration.PrintPluginsWelcomeMsg) { - foreach (var plugin in pluginManager.InstalledPlugins.OrderBy(plugin => plugin.Name)) + foreach (var plugin in pluginManager.InstalledPlugins.OrderBy(plugin => plugin.Name).Where(x => x.IsLoaded)) { chatGui.Print(string.Format(Loc.Localize("DalamudPluginLoaded", " 》 {0} v{1} loaded."), plugin.Name, plugin.Manifest.AssemblyVersion)); } From 2371d728e26602eb4d948299d58376cb76b3724d Mon Sep 17 00:00:00 2001 From: goaaats Date: Thu, 14 Apr 2022 01:52:47 +0200 Subject: [PATCH 16/16] fix: FindAgentInterface use client structs UIModule --- Dalamud/Game/Gui/GameGui.cs | 25 ++++++++++------------ Dalamud/Game/Gui/GameGuiAddressResolver.cs | 8 ------- 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/Dalamud/Game/Gui/GameGui.cs b/Dalamud/Game/Gui/GameGui.cs index 5638f8b50..10960677c 100644 --- a/Dalamud/Game/Gui/GameGui.cs +++ b/Dalamud/Game/Gui/GameGui.cs @@ -15,6 +15,7 @@ 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; @@ -31,7 +32,6 @@ namespace Dalamud.Game.Gui private readonly GetMatrixSingletonDelegate getMatrixSingleton; private readonly ScreenToWorldNativeDelegate screenToWorldNative; - private readonly GetAgentModuleDelegate getAgentModule; private readonly Hook setGlobalBgmHook; private readonly Hook handleItemHoverHook; @@ -60,7 +60,6 @@ namespace Dalamud.Game.Gui Log.Verbose($"HandleItemHover address 0x{this.address.HandleItemHover.ToInt64():X}"); Log.Verbose($"HandleItemOut address 0x{this.address.HandleItemOut.ToInt64():X}"); Log.Verbose($"HandleImm address 0x{this.address.HandleImm.ToInt64():X}"); - Log.Verbose($"GetAgentModule address 0x{this.address.GetAgentModule.ToInt64():X}"); Service.Set(new ChatGui(this.address.ChatManager)); Service.Set(); @@ -85,8 +84,6 @@ namespace Dalamud.Game.Gui this.toggleUiHideHook = new Hook(this.address.ToggleUiHide, this.ToggleUiHideDetour); - this.getAgentModule = Marshal.GetDelegateForFunctionPointer(this.address.GetAgentModule); - this.utf8StringFromSequenceHook = new Hook(this.address.Utf8StringFromSequence, this.Utf8StringFromSequenceDetour); } @@ -397,14 +394,14 @@ namespace Dalamud.Game.Gui if (addon == IntPtr.Zero) return IntPtr.Zero; - var uiModule = Service.Get().GetUIModule(); - if (uiModule == IntPtr.Zero) + var uiModule = (UIModule*)Service.Get().GetUIModule(); + if (uiModule == null) { return IntPtr.Zero; } - var agentModule = this.getAgentModule(uiModule); - if (agentModule == IntPtr.Zero) + var agentModule = uiModule->GetAgentModule(); + if (agentModule == null) { return IntPtr.Zero; } @@ -417,13 +414,13 @@ namespace Dalamud.Game.Gui if (id == 0) return IntPtr.Zero; - for (var i = 0; i < 380; i++) + // Patch 6.1, 398 agents + for (var i = 0; i < 398; i++) { - var agent = Marshal.ReadIntPtr(agentModule, 0x20 + (i * 8)); - if (agent == IntPtr.Zero) - continue; - if (Marshal.ReadInt32(agent, 0x20) == id) - return agent; + var agent = &agentModule->AgentArray[i]; + + if (agent->GetAddonID() == id) + return new IntPtr(agent); } return IntPtr.Zero; diff --git a/Dalamud/Game/Gui/GameGuiAddressResolver.cs b/Dalamud/Game/Gui/GameGuiAddressResolver.cs index adeaab1af..299d59ce2 100644 --- a/Dalamud/Game/Gui/GameGuiAddressResolver.cs +++ b/Dalamud/Game/Gui/GameGuiAddressResolver.cs @@ -71,11 +71,6 @@ namespace Dalamud.Game.Gui /// public IntPtr ToggleUiHide { get; private set; } - /// - /// Gets the address of the native GetAgentModule method. - /// - public IntPtr GetAgentModule { get; private set; } - /// /// Gets the address of the native Utf8StringFromSequence method. /// @@ -94,9 +89,6 @@ namespace Dalamud.Game.Gui this.ScreenToWorld = sig.ScanText("48 83 EC 48 48 8B 05 ?? ?? ?? ?? 4D 8B D1"); this.ToggleUiHide = sig.ScanText("48 89 5C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 0F B6 B9 ?? ?? ?? ?? B8 ?? ?? ?? ??"); this.Utf8StringFromSequence = sig.ScanText("48 89 5C 24 ?? 48 89 74 24 ?? 57 48 83 EC 20 48 8D 41 22 66 C7 41 ?? ?? ?? 48 89 01 49 8B D8"); - - var uiModuleVtableSig = sig.GetStaticAddressFromSig("48 8D 05 ?? ?? ?? ?? 4C 89 61 28"); - this.GetAgentModule = Marshal.ReadIntPtr(uiModuleVtableSig, 34 * IntPtr.Size); } ///