forked from Dicebar/Raven
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Shims.lua
308 lines (240 loc) · 7.41 KB
/
Shims.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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
local MOD = Raven
local SHIM = MOD.SHIM
-- C_Container
function SHIM:GetContainerItemID(bag, slot)
if _G.C_Container.GetContainerItemID ~= nil then
return C_Container.GetContainerItemID(bag, slot)
end
return GetContainerItemID(bag, slot)
end
function SHIM:GetContainerNumSlots(bag)
if _G.C_Container.GetContainerNumSlots ~= nil then
return C_Container.GetContainerNumSlots(bag)
end
return GetContainerNumSlots(bag)
end
-- C_CurrencyInfo
function SHIM:GetCoinTextureString(amount)
if _G.C_CurrencyInfo.GetCoinTextureString ~= nil then
return C_CurrencyInfo.GetCoinTextureString(amount)
end
return C_Item.GetCoinTextureString(amount)
end
-- C_Item
function SHIM:GetItemCooldown(item)
-- Retail
if _G.C_Item.GetItemCooldown ~= nil then
return C_Item.GetItemCooldown(item)
end
-- Classic
if _G.C_Container.GetItemCooldown ~= nil then
return C_Container.GetItemCooldown(item)
end
-- Wrath
return C_Item.GetItemCooldown(item)
end
function SHIM:GetItemCount(item, includeBank, includeCharges)
if _G.C_Item.GetItemCount ~= nil then
return C_Item.GetItemCount(item, includeBank, includeCharges)
end
return C_Item.GetItemCount(item, includeBank, includeCharges)
end
function SHIM:GetItemIconByID(itemID)
if _G.C_Item.GetItemIconByID ~= nil then
return C_Item.GetItemIconByID(itemID)
end
return C_Item.GetItemIcon(itemID)
end
function SHIM:GetItemInfo(itemID)
if _G.C_Item.GetItemInfo ~= nil then
return C_Item.GetItemInfo(itemID)
end
return GetItemInfo(itemID)
end
function SHIM:GetItemSpell(itemID)
if _G.C_Item.GetItemSpell ~= nil then
return C_Item.GetItemSpell(itemID)
end
return C_Item.GetItemSpell(itemID)
end
function SHIM:IsUsableItem(item)
if _G.C_Item.IsUsableItem ~= nil then
return C_Item.IsUsableItem(item)
end
return C_Item.IsUsableItem(item)
end
function SHIM:GetSpellInfo(spellID)
if _G.C_Spell.GetSpellInfo ~= nil then
local info = C_Spell.GetSpellInfo(spellID)
if info == nil then
return nil
end
return info.name,
nil, -- rank
info.iconID,
info.castTime,
info.minRange,
info.maxRange,
info.spellID
end
return GetSpellInfo(spellID)
end
function SHIM:GetNumSpellTabs()
if _G.C_SpellBook.GetNumSpellBookSkillLines ~= nil then
return C_SpellBook.GetNumSpellBookSkillLines()
end
return GetNumSpellTabs()
end
function SHIM:GetSpellTabInfo(tabIndex)
if _G.C_SpellBook.GetSpellBookSkillLineInfo ~= nil then
local info = C_SpellBook.GetSpellBookSkillLineInfo(tabIndex)
if info == nil then
return nil
end
return info.name,
info.iconID,
info.itemIndexOffset,
info.numSpellBookItems,
info.isGuild,
info.shouldHide,
info.specID,
info.offSpecID
end
return GetSpellTabInfo(tabIndex)
end
function SHIM:GetSpellBookItemName(index, bookType)
if _G.C_SpellBook.GetSpellBookItemName ~= nil then
if bookType == "spell" then
bookType = Enum.SpellBookSpellBank.Player
elseif bookType == "pet" then
bookType = Enum.SpellBookSpellBank.Pet
end
return C_SpellBook.GetSpellBookItemName(index, bookType)
end
return GetSpellBookItemName(index, bookType)
end
function SHIM:GetSpellBookItemInfo(index, bookType)
if _G.C_SpellBook.GetSpellBookItemInfo ~= nil then
if bookType == "spell" then
bookType = Enum.SpellBookSpellBank.Player
elseif bookType == "pet" then
bookType = Enum.SpellBookSpellBank.Pet
end
local info = C_SpellBook.GetSpellBookItemInfo(index, bookType)
if info == nil then
return nil
end
local spellID = info.actionID
local itemType = "UNKNOWN"
if info.itemType == Enum.SpellBookItemType.Spell then
itemType = "SPELL"
elseif info.itemType == Enum.SpellBookItemType.None then
itemType = "NONE"
elseif info.itemType == Enum.SpellBookItemType.Flyout then
itemType = "FLYOUT"
elseif info.itemType == Enum.SpellBookItemType.FutureSpell then
itemType = "FUTURESPELL"
elseif info.itemType == Enum.SpellBookItemType.PetAction then
itemType = "PETACTION"
spellID = bit.band(0xFFFFFF, info.actionID)
end
local spellOverrideID
if info.spellID ~= nil and info.spellID ~= spellID then
spellOverrideID = info.spellID
end
return itemType, spellID, info.isPassive, spellOverrideID
end
local itemType, spellID = C_SpellBook.GetSpellBookItemInfo(index, bookType)
if itemType == "PETACTION" then
spellID = bit.band(0xFFFFFF, spellID)
end
return itemType, spellID, C_SpellBook.IsPassiveSpell(spellID)
end
function SHIM:HasPetSpells()
if _G.C_SpellBook.HasPetSpells ~= nil then
return C_SpellBook.HasPetSpells()
end
return HasPetSpells()
end
function SHIM:GetSpellTexture(spellID)
if C_Spell.GetSpellTexture == nil then
local info = C_Spell.GetSpellInfo(spellID)
if info == nil then
return nil
end
return info.iconID
end
return C_Spell.GetSpellTexture(spellID)
end
function SHIM:GetSpellCooldown(spellID)
if _G.C_Spell.GetSpellCooldown ~= nil then
local info = C_Spell.GetSpellCooldown(spellID)
if info == nil then
return nil
end
local isEnabled = 1
if not info.isEnabled then
isEnabled = 0
end
return info.startTime,
info.duration,
isEnabled,
info.modRate
end
return GetSpellCooldown(spellID)
end
function SHIM:GetSpellBookItemCooldown(index, spellBank)
if _G.C_SpellBook.GetSpellBookItemCooldown ~= nil then
if spellBank == "spell" then
spellBank = Enum.SpellBookSpellBank.Player
end
local info = C_SpellBook.GetSpellBookItemCooldown(index, spellBank)
if info == nil then
return nil
end
return info.startTime,
info.duration,
info.isEnabled,
info.modRate
end
return GetSpellCooldown(index, spellBank)
end
function SHIM:IsUsableSpell(spell)
if _G.C_Spell.IsSpellUsable ~= nil then
return C_Spell.IsSpellUsable(spell)
end
return IsUsableSpell(spell)
end
function SHIM:GetSpellCharges(index, book)
if _G.C_SpellBook.GetSpellBookItemCharges ~= nil then
if book == "spell" then
book = Enum.SpellBookSpellBank.Player
elseif book == "pet" then
book = Enum.SpellBookSpellBank.Pet
end
local info = C_SpellBook.GetSpellBookItemCharges(index, book)
if info == nil then
return nil
end
return info.currentCharges,
info.maxCharges,
info.cooldownStartTime,
info.cooldownDuration,
info.chargeModRate
end
return GetSpellCharges(index, book)
end
function SHIM:GetSpellChargesByID(spellID)
if _G.C_Spell.GetSpellCharges ~= nil then
local info = C_Spell.GetSpellCharges(spellID)
if info == nil then
return nil
end
return info.currentCharges,
info.maxCharges,
info.cooldownStartTime,
info.cooldownDuration,
info.chargeModRate
end
return GetSpellCharges(spellID)
end