-
Notifications
You must be signed in to change notification settings - Fork 0
/
Portals.lua
208 lines (180 loc) · 6.7 KB
/
Portals.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
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
local _, core = ...
-- table to contain known spells and also the headers
local menu = {}
local menuItems = {
-- {type = "item", id = HEARTHSTONE_ITEM_ID}, -- Hearthstone
{text = "Teleports"},
{type = "spell", id = 3561}, -- Stormwind
{type = "spell", id = 3562}, -- Ironforge
{type = "spell", id = 3565}, -- Darnassus
{type = "spell", id = 32271}, -- Exodar
{type = "spell", id = 49359}, -- Theramore
{type = "spell", id = 3567}, -- Orgrimmar
{type = "spell", id = 3563}, -- Undercity
{type = "spell", id = 3566}, -- Thunder Bluff
{type = "spell", id = 32272}, -- Silvermoon
{type = "spell", id = 49358}, -- Stonard
{type = "spell", id = 33690}, -- Shattrath (Alliance)
{type = "spell", id = 35715}, -- Shattrath (Horde)
{type = "spell", id = 53140}, -- Dalaran - Northrend
{type = "spell", id = 88342}, -- Tol Barad (Alliance)
{type = "spell", id = 88344}, -- Tol Barad (Horde)
{type = "spell", id = 132621}, -- Vale of Eternal Blossoms
{type = "spell", id = 176248}, -- Stormshield
{type = "spell", id = 224869}, -- Dalaran - Broken Isles
{type = "spell", id = 281403}, -- Boralus
{type = "spell", id = 344587}, -- Oribos
{type = "spell", id = 395277}, -- Valdrakken
{type = "spell", id = 18960}, -- Moonglade
{type = "spell", id = 120145}, -- Dalaran crater
{type = "spell", id = 193759}, -- Hall of the Guardian
{text = "Portals"},
{type = "spell", id = 10059}, -- Stormwind
{type = "spell", id = 11416}, -- Ironforge
{type = "spell", id = 11419}, -- Darnassus
{type = "spell", id = 32266}, -- Exodar
{type = "spell", id = 49360}, -- Theramore
{type = "spell", id = 11417}, -- Orgrimmar
{type = "spell", id = 11418}, -- Undercity
{type = "spell", id = 11420}, -- Thunder Bluff
{type = "spell", id = 32267}, -- Silvermoon
{type = "spell", id = 49361}, -- Stonard
{type = "spell", id = 33691}, -- Shattrath (Alliance)
{type = "spell", id = 35717}, -- Shattrath (Horde)
{type = "spell", id = 53142}, -- Dalaran - Northrend
{type = "spell", id = 88345}, -- Tol Barad (Alliance)
{type = "spell", id = 88346}, -- Tol Barad (Horde)
{type = "spell", id = 132620}, -- Vale of Eternal Blossoms
{type = "spell", id = 176246}, -- Stormshield
{type = "spell", id = 224871}, -- Dalaran - Broken Isles
{type = "spell", id = 281400}, -- Boralus
{type = "spell", id = 344597}, -- Oribos
{type = "spell", id = 395289}, -- Valdrakken
{type = "spell", id = 120146}, -- Dalaran crater
{text = "Challenger's Path"},
{type = "spell", id = 131228}, -- Path of the Black Ox
{type = "spell", id = 131204}, -- Path of the Jade Serpent
{type = "spell", id = 131222}, -- Path of the Mogu King
{type = "spell", id = 131232}, -- Path of the Necromancer
{type = "spell", id = 131231}, -- Path of the Scarlet Blade
{type = "spell", id = 131229}, -- Path of the Scarlet Mitre
{type = "spell", id = 131225}, -- Path of the Setting Sun
{type = "spell", id = 131206}, -- Path of the Shado-Pan
{type = "spell", id = 131205}, -- Path of the Stout Brew
{text = "Warlord's Path"},
{type = "spell", id = 159895}, -- Path of the Bloodmaul
{type = "spell", id = 159896}, -- Path of the Iron Prow
{type = "spell", id = 159897}, -- Path of the Vigilant
{type = "spell", id = 159898}, -- Path of the Skies
{type = "spell", id = 159901}, -- Path of the Verdant
{type = "spell", id = 159900}, -- Path of the Dark Rail
{type = "spell", id = 159899}, -- Path of the Crescent Moon
{type = "spell", id = 159902}, -- Path of the Burning Mountain
{text = "Items"},
{type = "toy", id = 18986}, -- Ultrasafe Transporter: Gadgetzan
{type = "toy", id = 18984}, -- Dimensional Ripper: Everlook
{type = "toy", id = 30544}, -- Ultrasafe Transporter: Toshley's Station
{type = "toy", id = 30542}, -- Dimensional Ripper: Area 52
{type = "toy", id = 48933}, -- Wormhole Generator: Northrend
{type = "toy", id = 87215}, -- Wormhole Generator: Pandaria
{type = "toy", id = 112059}, -- Wormhole Centrifuge
{type = "toy", id = 110560}, -- Garrison Hearthstone
{type = "toy", id = 140192}, -- Dalaran Hearthstone
}
local dropdown = core:CreateDropdown("Menu")
dropdown.initialize = function(self)
for i, v in ipairs(menu) do
self:AddButton(v)
end
end
local module = core:NewModule("Portals", {
type = "data source",
text = "Ready",
label = "Portals",
icon = [[Interface\Icons\Spell_Arcane_TeleportDalaran]],
OnClick = function(self)
if not InCombatLockdown() then
dropdown:Toggle(nil, self)
end
end,
})
function module:OnInitialize()
self:RegisterEvent("PLAYER_LOGIN")
self:RegisterEvent("PLAYER_REGEN_DISABLED")
self:RegisterEvent("PLAYER_REGEN_ENABLED")
end
function module:PLAYER_LOGIN()
for index, value in ipairs(menuItems) do
if value.id then
local name, icon
if value.type == "spell" then
local spellInfo = C_Spell.GetSpellInfo(value.id)
name = spellInfo.name
icon = spellInfo.iconID
elseif value.type == "item" then
name = "item:"..value.id
icon = C_Item.GetItemIconByID(value.id)
elseif value.type == "toy" then
name = value.id
icon = C_Item.GetItemIconByID(value.id)
end
value.text = name
value.icon = icon
value.attributes = {
["type"] = value.type,
[value.type] = name,
}
else
value.isTitle = true
end
value.notCheckable = true
end
self:SetMenuItemVisibility()
self:RegisterEvent("LEARNED_SPELL_IN_TAB")
self:RegisterEvent("BAG_UPDATE_DELAYED", "SetMenuItemVisibility")
end
function module:PLAYER_REGEN_ENABLED()
self.text = "Ready"
end
-- portals cannot be cast in combat, so hide overlay buttons and disable menu
function module:PLAYER_REGEN_DISABLED()
self.text = "|cffff0000In combat|r"
dropdown:Close()
end
local function onUpdate(self)
self:SetMenuItemVisibility()
self:RemoveOnUpdate()
end
function module:LEARNED_SPELL_IN_TAB()
self:SetOnUpdate(onUpdate)
end
-- update menu items, to deterrmine which items should actually be visible
function module:SetMenuItemVisibility()
if InCombatLockdown() then
return
end
wipe(menu)
local previousItem
for index, value in ipairs(menuItems) do
if not value.id then
-- items without an ID will be headers
tinsert(menu, value)
elseif value.type == "spell" and IsSpellKnown(value.id) then
value.disabled = not C_Spell.IsSpellUsable(value.text)
tinsert(menu, value)
elseif value.type == "item" and C_Item.GetItemCount(value.id) > 0 then
value.text = C_Item.GetItemInfo(value.id)
tinsert(menu, value)
elseif value.type == "toy" and PlayerHasToy(value.id) and C_ToyBox.IsToyUsable(value.id) then
value.text = C_Item.GetItemInfo(value.id)
tinsert(menu, value)
end
end
for i = #menu, 1, -1 do
-- if a header has no following spells or next button is another header, we want to hide it
local _, next = next(menu, i)
if menu[i].isTitle and (not next or next.isTitle) then
tremove(menu, i)
end
end
end