forked from Linden-Ryuujin/WoW-TrackingEye
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTracking-Menu.lua
More file actions
68 lines (59 loc) · 2.49 KB
/
Tracking-Menu.lua
File metadata and controls
68 lines (59 loc) · 2.49 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
local addonName, te = ...
local LibDD = LibStub("LibUIDropDownMenu-4.0")
--------------------------------------------------------------------------------
-- State
--------------------------------------------------------------------------------
local dropdown = LibDD:Create_UIDropDownMenu(addonName .. "TrackingMenu", UIParent)
--------------------------------------------------------------------------------
-- Menu Logic
--------------------------------------------------------------------------------
local function InitMenu(_, level)
if level ~= 1 then
return
end
-- Title
local titleInfo = LibDD:UIDropDownMenu_CreateInfo()
titleInfo.text = te.GetColor("TITLE") .. te.L["TRACKING_MENU"] .. "|r"
titleInfo.isTitle = true
titleInfo.notCheckable = true
LibDD:UIDropDownMenu_AddButton(titleInfo, level)
-- Build a sorted list of spells the player knows
local list = {}
for _, id in ipairs(te.TRACKING_IDS) do
local name = te.GetSpellName(id)
if name then
table.insert(list, {id = id, name = name})
end
end
table.sort(list, function(a, b) return a.name < b.name end)
local isCat = te.GetPlayerStates()
for _, data in ipairs(list) do
-- Hide DRUID_HUMANOIDS unless the player is currently in cat form
if IsPlayerSpell(data.id) and (data.id ~= te.SPELLS.DRUID_HUMANOIDS or isCat) then
local info = LibDD:UIDropDownMenu_CreateInfo()
info.text = string.format("|T%s:16|t %s", GetSpellTexture(data.id) or "", data.name)
info.value = data.id
info.checked = (TrackingEyeDB and TrackingEyeDB.selectedSpellId == data.id)
info.func = function(button)
if TrackingEyeDB then
TrackingEyeDB.selectedSpellId = button.value
end
te.state.wasFarming = false
te.CastTracking(button.value)
LibDD:CloseDropDownMenus()
end
LibDD:UIDropDownMenu_AddButton(info, level)
end
end
end
LibDD:UIDropDownMenu_Initialize(dropdown, InitMenu, "MENU")
--------------------------------------------------------------------------------
-- Public API
--------------------------------------------------------------------------------
function te.ToggleMenu(anchor)
local xOffset = 0
if anchor and anchor.GetWidth then
xOffset = anchor:GetWidth()
end
LibDD:ToggleDropDownMenu(1, nil, dropdown, anchor, xOffset, 0)
end