Repository navigation
Expand file tree
/
Copy pathminimap.lua
More file actions
111 lines (87 loc) · 3.29 KB
/
Copy pathminimap.lua
File metadata and controls
111 lines (87 loc) · 3.29 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
106
107
108
109
110
111
--[[ Stash / minimap -----------------------------------------------------------
The button. Left click opens the cached bank, right click the cached guild
bank. Drag it around the minimap to move it.
-----------------------------------------------------------------------------]]
Stash.modules.minimap = true
local RADIUS = 80
local DEFAULT_ANGLE = 205
local button = CreateFrame("Button", "StashMinimapButton", Minimap)
button:SetWidth(31)
button:SetHeight(31)
button:SetFrameStrata("LOW")
button:RegisterForClicks("LeftButtonUp", "RightButtonUp")
button:RegisterForDrag("LeftButton")
button:SetMovable(true)
local icon = button:CreateTexture(nil, "BACKGROUND")
icon:SetTexture("Interface\\Icons\\INV_Misc_Bag_08")
icon:SetWidth(20)
icon:SetHeight(20)
icon:SetPoint("CENTER", 0, 1)
icon:SetTexCoord(0.07, 0.93, 0.07, 0.93)
local border = button:CreateTexture(nil, "OVERLAY")
border:SetTexture("Interface\\Minimap\\MiniMap-TrackingBorder")
border:SetWidth(53)
border:SetHeight(53)
border:SetPoint("TOPLEFT", 0, 0)
button:SetHighlightTexture("Interface\\Minimap\\UI-Minimap-ZoomButton-Highlight")
-- --------------------------------------------------------------------------
-- placement
-- --------------------------------------------------------------------------
local function UpdatePosition()
local angle = math.rad(StashDB and StashDB.minimapangle or DEFAULT_ANGLE)
button:ClearAllPoints()
button:SetPoint("CENTER", Minimap, "CENTER", math.cos(angle) * RADIUS, math.sin(angle) * RADIUS)
end
local function OnDragUpdate()
local mx, my = Minimap:GetCenter()
local scale = UIParent:GetEffectiveScale()
local px, py = GetCursorPosition()
px, py = px / scale, py / scale
local angle = math.deg(math.atan2(py - my, px - mx))
if StashDB then
StashDB.minimapangle = angle
end
UpdatePosition()
end
button:SetScript("OnDragStart", function()
this:SetScript("OnUpdate", OnDragUpdate)
end)
button:SetScript("OnDragStop", function()
this:SetScript("OnUpdate", nil)
end)
-- --------------------------------------------------------------------------
-- interaction
-- --------------------------------------------------------------------------
button:SetScript("OnClick", function()
if arg1 == "RightButton" then
Stash:ShowGuildBank()
else
Stash:ShowBank()
end
end)
button:SetScript("OnEnter", function()
GameTooltip:SetOwner(this, "ANCHOR_LEFT")
GameTooltip:SetText("|cffffcc00Stash|r")
local items, slots = Stash:CountItems()
GameTooltip:AddLine(items .. " items cached in " .. slots .. " bank slots", 1, 1, 1)
GameTooltip:AddLine(" ")
GameTooltip:AddLine("|cffffcc00Left click|r your bank", 0.8, 0.8, 0.8)
if Stash:HasGuildBank() then
GameTooltip:AddLine("|cffffcc00Right click|r guild bank", 0.8, 0.8, 0.8)
else
GameTooltip:AddLine("|cff888888Right click guild bank (not on this client)|r", 0.5, 0.5, 0.5)
end
GameTooltip:AddLine("|cffffcc00Drag|r move this button", 0.8, 0.8, 0.8)
GameTooltip:Show()
end)
button:SetScript("OnLeave", function()
GameTooltip:Hide()
end)
-- --------------------------------------------------------------------------
-- init
-- --------------------------------------------------------------------------
local init = CreateFrame("Frame")
init:RegisterEvent("PLAYER_LOGIN")
init:SetScript("OnEvent", function()
UpdatePosition()
end)