-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMinimap.lua
More file actions
91 lines (76 loc) · 2.8 KB
/
Copy pathMinimap.lua
File metadata and controls
91 lines (76 loc) · 2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
local _, SNEK = ...
SNEK.Minimap = {}
local M = SNEK.Minimap
local button
local RADIUS = 105
local function UpdatePosition()
if not button then return end
local angle = math.rad(SNEK.DB.Get().minimapAngle or 220)
local x = math.cos(angle) * RADIUS
local y = math.sin(angle) * RADIUS
button:ClearAllPoints()
button:SetPoint("CENTER", Minimap, "CENTER", x, y)
end
function M.UpdateVisibility()
if not button then return end
if SNEK.DB.Get().showMinimap then
button:Show()
UpdatePosition()
else
button:Hide()
end
end
function M.Create()
if button then return end
button = CreateFrame("Button", "SNEKMinimapButton", Minimap)
button:SetSize(32, 32)
button:SetFrameStrata("MEDIUM")
button:SetFrameLevel(8)
button:RegisterForClicks("LeftButtonUp", "RightButtonUp")
button:RegisterForDrag("LeftButton")
button:SetClampedToScreen(true)
local icon = button:CreateTexture(nil, "BACKGROUND")
icon:SetSize(20, 20)
icon:SetTexture("Interface\\AddOns\\SNEK\\media\\minimap.png")
icon:SetPoint("TOPLEFT", 7, -5)
icon:SetMask("Interface\\CharacterFrame\\TempPortraitAlphaMask")
local border = button:CreateTexture(nil, "OVERLAY")
border:SetSize(52, 52)
border:SetTexture("Interface\\Minimap\\MiniMap-TrackingBorder")
border:SetPoint("TOPLEFT", -1, 1)
button:SetHighlightTexture("Interface\\Minimap\\UI-Minimap-ZoomButton-Highlight")
button:SetScript("OnClick", function(_, mouseButton)
if mouseButton == "RightButton" then
SNEK.DB.Get().showMinimap = false
M.UpdateVisibility()
print("|cff00ff00S.N.E.K.:|r Minimap icon hidden.")
else
SNEK.Options.Toggle()
end
end)
button:SetScript("OnDragStart", function(self)
self:SetScript("OnUpdate", function()
local mx, my = GetCursorPosition()
local cx, cy = Minimap:GetCenter()
local scale = Minimap:GetEffectiveScale()
local angle = math.deg(math.atan2(my / scale - cy, mx / scale - cx))
SNEK.DB.Get().minimapAngle = angle
UpdatePosition()
end)
end)
button:SetScript("OnDragStop", function(self)
self:SetScript("OnUpdate", nil)
end)
button:SetScript("OnEnter", function(self)
GameTooltip:SetOwner(self, "ANCHOR_LEFT")
GameTooltip:AddLine("S.N.E.K.", 0, 1, 0)
GameTooltip:AddLine("Left-click: Open options", 1, 1, 1)
GameTooltip:AddLine("Right-click: Hide icon", 1, 1, 1)
GameTooltip:AddLine("Drag to move", 0.7, 0.7, 0.7)
GameTooltip:Show()
end)
button:SetScript("OnLeave", function()
GameTooltip:Hide()
end)
M.UpdateVisibility()
end