-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLayerbeacon_Minimap.lua
More file actions
105 lines (88 loc) · 3.78 KB
/
Layerbeacon_Minimap.lua
File metadata and controls
105 lines (88 loc) · 3.78 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
local addonName, _ = ...
Layerbeacon = Layerbeacon or {}
Layerbeacon.Minimap = Layerbeacon.Minimap or {}
-------------------------------------------------------------------------------
-- Update Button Position
-------------------------------------------------------------------------------
function Layerbeacon.Minimap.UpdateButtonPosition(button, angle, radius)
angle = angle or 0
radius = radius or 80
local radians = math.rad(angle)
local xOffset = math.cos(radians) * radius
local yOffset = math.sin(radians) * radius
button:ClearAllPoints()
button:SetPoint("CENTER", Minimap, "CENTER", xOffset, yOffset)
end
-------------------------------------------------------------------------------
-- Update Minimap Button Texture
-------------------------------------------------------------------------------
function Layerbeacon.Minimap.UpdateButtonTexture(minimapButton)
local texturePath
-- Ensure saved variables exist
_G.LayerbeaconSavedVariables = _G.LayerbeaconSavedVariables or {}
if _G.LayerbeaconSavedVariables.isAddonActive then
if Layerbeacon.Handlers.ExtractLayerText() then
local layer = tonumber(Layerbeacon.Handlers.layerText)
if layer and layer >= 1 and layer <= 9 then
texturePath = "Interface/AddOns/Layerbeacon/textures/Layerbeacon_" .. layer .. ".tga"
else
texturePath = "Interface/AddOns/Layerbeacon/textures/Layerbeacon_question.tga"
end
else
texturePath = "Interface/AddOns/Layerbeacon/textures/Layerbeacon_question.tga"
end
else
texturePath = "Interface/AddOns/Layerbeacon/textures/Layerbeacon_question.tga"
end
minimapButton:SetNormalTexture(texturePath)
minimapButton:SetPushedTexture(texturePath)
end
-------------------------------------------------------------------------------
-- Create Minimap Button
-------------------------------------------------------------------------------
function Layerbeacon.Minimap.CreateButton()
local minimapButton = CreateFrame("Button", "LayerbeaconMinimapButton", Minimap)
minimapButton:SetSize(32, 32)
minimapButton:SetFrameStrata("MEDIUM")
minimapButton:SetFrameLevel(8)
minimapButton:SetHighlightTexture("Interface/Minimap/UI-Minimap-ZoomButton-Highlight")
Layerbeacon.Minimap.UpdateButtonTexture(minimapButton)
Layerbeacon.Minimap.UpdateButtonPosition(
minimapButton,
Layerbeacon.Config.DEFAULT_ANGLE,
Layerbeacon.Config.RADIUS
)
-- Button scripts
minimapButton:SetScript("OnEnter", function(self)
GameTooltip:SetOwner(self, "ANCHOR_LEFT")
GameTooltip:SetText("Layerbeacon")
GameTooltip:Show()
end)
minimapButton:SetScript("OnLeave", function(self)
GameTooltip:Hide()
end)
minimapButton:SetMovable(true)
minimapButton:EnableMouse(true)
minimapButton:RegisterForDrag("LeftButton")
minimapButton:SetScript("OnDragStart", function(self)
self:StartMoving()
end)
minimapButton:SetScript("OnDragStop", function(self)
self:StopMovingOrSizing()
end)
minimapButton:SetScript("OnClick", function(self)
Layerbeacon.Main.ToggleAddon(self)
end)
-- Store reference
Layerbeacon.Minimap.Button = minimapButton
return minimapButton
end
-------------------------------------------------------------------------------
-- Initialization Stub
-------------------------------------------------------------------------------
function Layerbeacon.Minimap.Initialize()
-- Create the minimap button or do any additional minimap-related setup here
Layerbeacon.Minimap.CreateButton()
-- If you need to do anything else when the addon loads, do it here
Layerbeacon.Handlers.DebugPrintf("Layerbeacon.Minimap.Initialize called.")
end