-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathTrackingEye.lua
More file actions
159 lines (140 loc) · 5.3 KB
/
Copy pathTrackingEye.lua
File metadata and controls
159 lines (140 loc) · 5.3 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
--====================================================================================================================================================
-- TrackingEye-1.0
--
-- A simple addon to add a tracking button to the minimap.
--
-- License: MIT
--====================================================================================================================================================
local TrackingEye = LibStub("AceAddon-3.0"):NewAddon("TrackingEye", "AceConsole-3.0", "AceEvent-3.0")
local LibDD = LibStub:GetLibrary("LibUIDropDownMenu-4.0")
------------------------------------------------------------------------------------------------------------------------------------------------------
-- Initialise Tracking Eye
--
-- Setups up default profile values, and registers for all events etc.
------------------------------------------------------------------------------------------------------------------------------------------------------
function TrackingEye:OnInitialize()
self:RegisterChatCommand("te", "MinimapButton_ChatCommand")
MiniMapTracking:GetScript("OnMouseUp");
MiniMapTracking:SetScript("OnMouseUp", function( self, button )
if (button == "RightButton") then
TrackingEye:TrackingMenu_Open();
else
ToggleDropDownMenu(1,nil,MiniMapTrackingDropDown,"cursor")
end
end)
local Minimap_OnMouseUp = Minimap:GetScript("OnMouseUp");
Minimap:SetScript("OnMouseUp", function( self, button )
if (button == "RightButton") then
TrackingEye:TargetMenu_Open()
else
Minimap_OnMouseUp(self, button)
end
end)
end
------------------------------------------------------------------------------------------------------------------------------------------------------
-- Create the Tracking Eye tracking context menu.
--
-- Will check what spells are known and populate the menu with all usable tracking types.
------------------------------------------------------------------------------------------------------------------------------------------------------
function TrackingEye:TrackingMenu_Open()
local menu =
{
{
text = "Select Tracking", isTitle = true
}
}
-- In level order, with racial/professions last
local spells =
{
1494, --Track Beasts
19883, --Track Humanoids
19884, --Track Undead
19885, --Track Hidden
19880, --Track Elementals
19878, --Track Demons
19882, --Track Giants
19879, --Track Dragonkin
5225, --Track Humanoids: Druid
5500, --Sense Demons
5502, --Sense Undead
2383, --Find Herbs
2580, --Find Minerals
2481 --Find Treasure
}
for key,spellId in ipairs(spells) do
spellName = GetSpellInfo(spellId)
if IsPlayerSpell(spellId) then
table.insert(menu,
{
text = spellName,
icon = GetSpellTexture(spellId),
func = function()
CastSpellByID(spellId)
end
})
end
end
table.insert(menu,
{
text = "None",
func = function()
CancelTrackingBuff()
end
})
local menuFrame = CreateFrame("Frame", "TrackingEyeTrackingMenu", UIParent, "UIDropDownMenuTemplate")
EasyMenu(menu, menuFrame, "cursor", 0 , 0, "MENU");
end
------------------------------------------------------------------------------------------------------------------------------------------------------
-- Create the Tracking Eye target context menu.
--
-- Will search for a context menu and then convert it to a targeting menu.
------------------------------------------------------------------------------------------------------------------------------------------------------
function TrackingEye:TargetMenu_Open()
if UnitAffectingCombat('player') then
print("|c00ff0000Tracking eye menu can't be used in combat.")
return
end
local targets = GameTooltipTextLeft1:GetText();
if (targets == nil or targets == '') then
return
end
local lines = split(targets, "\n")
local menu =
{
{
text = "Select Target", isTitle = true
}
}
for i, line in ipairs(lines) do
table.insert(menu,
{
attributes =
{
type = "macro",
macrotext = "/target " .. stripColour(line)
},
text = line
})
end
-- I have added some custom code to LibUIDropDownMenu that handle an "attributes" entry using secure buttons for macro support.
local menuFrame = LibDD:Create_UIDropDownMenu("TrackingEyeTargetMenu", UIParent)
LibDD:EasyMenu(menu, menuFrame, "cursor", 0 , 0, "MENU");
end
------------------------------------------------------------------------------------------------------------------------------------------------------
-- Split the passed string into a table using the passed delimiter to mark the end of each item.
------------------------------------------------------------------------------------------------------------------------------------------------------
function split(str, delimiter)
local result = {};
for match in (str..delimiter):gmatch("(.-)"..delimiter) do
table.insert(result, match);
end
return result;
end
------------------------------------------------------------------------------------------------------------------------------------------------------
-- Remove colour markers from a string
------------------------------------------------------------------------------------------------------------------------------------------------------
function stripColour(str)
stripped, count = str:gsub("|c[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]", "")
stripped, count = stripped:gsub("|r", "")
return stripped
end