Skip to content

Commit

Permalink
Fix: updating btn position when nameplate changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sampconrad committed Sep 21, 2024
1 parent 56928a4 commit 8d34248
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
22 changes: 15 additions & 7 deletions NameplateContextMenu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion NameplateContextMenu.toc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## Interface: 110002
## Version: 1.3.1
## Version: 1.4.0
## IconTexture: Interface\ICONS\Pet_Type_Mechanical

## Title: NameplateContextMenu
Expand Down

0 comments on commit 8d34248

Please sign in to comment.