-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathToys.lua
51 lines (45 loc) · 1.27 KB
/
Toys.lua
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
local _, core = ...
local dropdown = core:CreateDropdown("Menu")
dropdown.initialize = function(self)
-- API sometimes doesn't return stuff until we call this
-- C_ToyBox.ForceToyRefilter()
for i = 1, C_ToyBox.GetNumToys() do
local itemID, toyName, icon, isFavorite = C_ToyBox.GetToyInfo(C_ToyBox.GetToyFromIndex(i))
if isFavorite then
local info = UIDropDownMenu_CreateInfo()
info.text = toyName
info.icon = icon
info.notCheckable = true
info.attributes = {
["type"] = "toy",
["toy"] = itemID,
}
self:AddButton(info)
end
end
end
local module = core:NewModule("Toys", {
type = "data source",
label = "Toys",
icon = [[Interface\Icons\Trade_Archaeology_ChestofTinyGlassAnimals]],
OnClick = function(self)
if not InCombatLockdown() then
dropdown:Toggle(nil, self)
end
end,
})
function module:OnInitialize()
self:RegisterEvent("PLAYER_REGEN_DISABLED")
self:RegisterEvent("PLAYER_REGEN_ENABLED")
self:RegisterEvent("TOYS_UPDATED")
end
function module:PLAYER_REGEN_ENABLED()
self.text = "Ready"
end
function module:PLAYER_REGEN_DISABLED()
self.text = "|cffff0000In combat|r"
dropdown:Close()
end
function module:TOYS_UPDATED()
RunNextFrame(GenerateClosure(dropdown.Rebuild, dropdown))
end