Skip to content

Commit

Permalink
Buttons: Alternative fix for the expansion button moving (closes #377)
Browse files Browse the repository at this point in the history
  • Loading branch information
funkydude committed Jul 26, 2024
1 parent cafb3ab commit 4005d92
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions Buttons.lua
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,11 @@ function mod:OnEnable()
sm.core.button.SetSize(ExpansionLandingPageMinimapButton, 36, 36)
end)
-- Stop Blizz moving the icon || Minimap.lua ExpansionLandingPageMinimapButtonMixin:UpdateIcon()>> self:UpdateIconForGarrison() >> ApplyGarrisonTypeAnchor() >> anchor:SetPoint()
hooksecurefunc(ExpansionLandingPageMinimapButton, "SetPoint", function()
hooksecurefunc(ExpansionLandingPageMinimapButton, "UpdateIconForGarrison", function()
mod:UpdateDraggables(ExpansionLandingPageMinimapButton)
end)
-- Stop Blizz moving the icon || Minimap.lua ExpansionLandingPageMinimapButtonMixin:SetLandingPageIconOffset() >> anchor:SetPoint()
hooksecurefunc(ExpansionLandingPageMinimapButton, "SetLandingPageIconOffset", function()
mod:UpdateDraggables(ExpansionLandingPageMinimapButton)
end)
sm.core:RegisterModuleOptions("Buttons", options, L["Buttons"])
Expand Down Expand Up @@ -577,19 +581,19 @@ do
end

local setPosition = function(frame, angle)
local radius = (dragFrame.GetWidth(Minimap) / 2) + mod.db.radius
local radius = (Minimap:GetWidth() / 2) + mod.db.radius
local bx, by = sm.shapes:GetPosition(angle, radius)
dragFrame.SetScale(frame, mod.db.scale)
frame:SetScale(mod.db.scale)

dragFrame.ClearAllPoints(frame)
dragFrame.SetPoint(frame, "CENTER", Minimap, "CENTER", bx, by)
frame:ClearAllPoints()
frame:SetPoint("CENTER", Minimap, "CENTER", bx, by)
end

local updatePosition = function()
local x, y = GetCursorPosition()
x, y = x / dragFrame.GetEffectiveScale(Minimap), y / dragFrame.GetEffectiveScale(Minimap)
x, y = x / Minimap:GetEffectiveScale(), y / Minimap:GetEffectiveScale()
local angle = getCurrentAngle(Minimap, x, y)
local name = buttonNicknames[moving] or dragFrame.GetName(moving)
local name = buttonNicknames[moving] or moving:GetName()
mod.db.dragPositions[name] = angle
setPosition(moving, angle)
end
Expand Down Expand Up @@ -623,19 +627,19 @@ do
end

function mod:MakeMovable(frame, altFrame)
dragFrame.EnableMouse(frame, true)
dragFrame.RegisterForDrag(frame, "LeftButton")
frame:EnableMouse(true)
frame:RegisterForDrag("LeftButton")
if altFrame then
dragFrame.SetScript(frame, "OnDragStart", function()
frame:SetScript("OnDragStart", function()
if mod.db.lockDragging or not mod.db.allowDragging then return end

moving = altFrame
dragFrame:SetScript("OnUpdate", updatePosition)
end)
else
dragFrame.SetScript(frame, "OnDragStart", OnDragStart)
frame:SetScript("OnDragStart", OnDragStart)
end
dragFrame.SetScript(frame, "OnDragStop", OnDragStop)
frame:SetScript("OnDragStop", OnDragStop)
self:UpdateDraggables(altFrame or frame)
end

Expand Down

0 comments on commit 4005d92

Please sign in to comment.