From 8d342488253081087fad0789d512b5caeb30e6e2 Mon Sep 17 00:00:00 2001 From: Conrado Sampaio <102433904+sampconrad@users.noreply.github.com> Date: Sat, 21 Sep 2024 15:58:31 -0300 Subject: [PATCH] Fix: updating btn position when nameplate changes --- .vscode/settings.json | 2 +- NameplateContextMenu.lua | 22 +++++++++++++++------- NameplateContextMenu.toc | 2 +- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 3f03230..bc44c4f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -12,6 +12,6 @@ "utf8": "disable" }, "Lua.workspace.library": [ - "~\\.vscode\\extensions\\ketho.wow-api-0.17.5\\Annotations" + "~\\.vscode\\extensions\\ketho.wow-api-0.17.6\\Annotations" ] } \ No newline at end of file diff --git a/NameplateContextMenu.lua b/NameplateContextMenu.lua index 4a8e27b..f88f217 100644 --- a/NameplateContextMenu.lua +++ b/NameplateContextMenu.lua @@ -11,6 +11,7 @@ NameplateContextFrame:Hide() NameplateContextFrame.attachedVisibleFrames = {} NameplateContextFrame:RegisterEvent("NAME_PLATE_UNIT_ADDED") NameplateContextFrame:RegisterEvent("NAME_PLATE_UNIT_REMOVED") +NameplateContextFrame:RegisterEvent("PLAYER_REGEN_ENABLED") -- Create buttons for the player's and enemy/target nameplates local function CreatePlateButton(name) @@ -54,6 +55,8 @@ local function HandlePlate_Removed(unit) end local function UpdateBtnPosition() + if InCombatLockdown() then return end + local playerFrame = GetNamePlateForUnit("player") if playerFrame and Plater and playerFrame.unitFrame.PlaterOnScreen then AnchorBtn(PersonalPlate_Btn, playerFrame, "player") @@ -68,15 +71,20 @@ local function UpdateBtnPosition() end local function OnEvent_Callback(_, event, unit) - if InCombatLockdown() then return end -- Ensure no actions happen during combat lockdown - - if event == "NAME_PLATE_UNIT_ADDED" then - HandlePlate_Added(unit) + if event == "PLAYER_REGEN_ENABLED" then + -- Update buttons and positions after combat ends + UpdateBtnPosition() + elseif event == "NAME_PLATE_UNIT_ADDED" then + if not InCombatLockdown() then + HandlePlate_Added(unit) + UpdateBtnPosition() + end elseif event == "NAME_PLATE_UNIT_REMOVED" then - HandlePlate_Removed(unit) + if not InCombatLockdown() then + HandlePlate_Removed(unit) + UpdateBtnPosition() + end end - - UpdateBtnPosition() end -- Register the callback function diff --git a/NameplateContextMenu.toc b/NameplateContextMenu.toc index 8fa3928..0456256 100644 --- a/NameplateContextMenu.toc +++ b/NameplateContextMenu.toc @@ -1,5 +1,5 @@ ## Interface: 110002 -## Version: 1.3.1 +## Version: 1.4.0 ## IconTexture: Interface\ICONS\Pet_Type_Mechanical ## Title: NameplateContextMenu