forked from s0h2x/Immersion-WotLK
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathInterface.lua
More file actions
436 lines (368 loc) · 10.8 KB
/
Interface.lua
File metadata and controls
436 lines (368 loc) · 10.8 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
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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
local API = {}; ImmersionAPI = API;
-- Version
local IS_CLASSIC = WOW_PROJECT_ID == WOW_PROJECT_CLASSIC
local IS_RETAIL = WOW_PROJECT_ID == WOW_PROJECT_MAINLINE
function API:IsClassic(...) return IS_CLASSIC end
function API:IsRetail(...) return IS_RETAIL end
API.ITERATORS = {
GOSSIP = 2;
ACTIVE = 4;
AVAILABLE = 5;
}
-- Chunk iterators
function API:GetGossipOptionIterator(...) return self.ITERATORS.GOSSIP end
function API:GetActiveQuestIterator(...) return self.ITERATORS.ACTIVE end
function API:GetAvailableQuestIterator(...) return self.ITERATORS.AVAILABLE end
-- Map select to table values
local function map(lambda, step, ...)
local data = {}
for i = 1, select('#', ...), step do
data[#data + 1] = lambda(nil, i, ...)
end
return data
end
function API:MapGossipAvailableQuests(i, ...)
local title, level, trivial, daily, repeatable = select(i, ...)
return {
title = title,
questLevel = level,
isTrivial = trivial,
isDaily = daily,
repeatable = repeatable,
}
end
function API:MapGossipActiveQuests(i, ...)
local title, level, trivial, complete = select(i, ...)
return {
title = title,
questLevel = level,
isTrivial = trivial,
isComplete = complete,
}
end
function API:MapGossipOptions(i, ...)
local name, icon = select(i, ...)
return {
name = name,
type = icon,
}
end
-- Quest pickup API
function API:CloseQuest(...)
return CloseQuest and CloseQuest(...)
end
function API:GetGreetingText(...)
return GetGreetingText and GetGreetingText(...)
end
function API:GetTitleText(...)
return GetTitleText and GetTitleText(...)
end
function API:GetProgressText(...)
return GetProgressText and GetProgressText(...)
end
function API:GetRewardText(...)
return GetRewardText and GetRewardText(...)
end
function API:GetQuestText(...)
return GetQuestText and GetQuestText(...)
end
function API:QuestGetAutoAccept(...)
return QuestGetAutoAccept and QuestGetAutoAccept(...)
end
function API:QuestIsFromAdventureMap(...)
return QuestIsFromAdventureMap and QuestIsFromAdventureMap(...)
end
function API:QuestIsFromAreaTrigger(...)
return QuestIsFromAreaTrigger and QuestIsFromAreaTrigger(...)
end
function API:QuestFlagsPVP(...)
return QuestFlagsPVP and QuestFlagsPVP(...)
end
function API:GetQuestIconOffer(quest)
if QuestUil and QuestUtil.GetQuestIconOffer then
return QuestUtil.GetQuestIconOffer(
quest.isLegendary,
quest.frequency,
quest.repeatable,
QuestUtil.ShouldQuestIconsUseCampaignAppearance(quest.questID)
)
end
local icon =
( quest.isDaily and 'DailyQuestIcon') or
( quest.repeatable and 'DailyActiveQuestIcon') or
( 'AvailableQuestIcon' )
return ([[Interface\GossipFrame\%s]]):format(icon)
end
function API:GetQuestIconActive(quest)
if QuestUtil and QuestUtil.GetQuestIconActive then
return QuestUtil.GetQuestIconActive(
quest.isComplete,
quest.isLegendary,
quest.frequency,
quest.repeatable,
QuestUtil.ShouldQuestIconsUseCampaignAppearance(quest.questID)
)
end
local icon =
( quest.isComplete ) and (
'ActiveQuestIcon' ) or
( 'InCompleteQuestIcon' )
return ([[Interface\GossipFrame\%s]]):format(icon)
end
-- Quest content API
function API:GetSuggestedGroupNum(...)
return GetSuggestedGroupNum and GetSuggestedGroupNum(...) or 0
end
function API:GetNumQuestRewards(...)
return GetNumQuestRewards and GetNumQuestRewards(...) or 0
end
function API:GetNumQuestChoices(...)
return GetNumQuestChoices and GetNumQuestChoices(...) or 0
end
function API:GetNumRewardCurrencies(...)
return GetNumRewardCurrencies and GetNumRewardCurrencies(...) or 0
end
function API:GetRewardMoney(...)
return GetRewardMoney and GetRewardMoney(...) or 0
end
function API:GetRewardSkillPoints(...)
return GetRewardSkillPoints and GetRewardSkillPoints(...) or 0
end
function API:GetRewardXP(...)
return GetRewardXP and GetRewardXP(...) or 0
end
function API:GetRewardArtifactXP(...)
return GetRewardArtifactXP and GetRewardArtifactXP(...) or 0
end
function API:GetRewardHonor(...)
return GetRewardHonor and GetRewardHonor(...) or 0
end
function API:GetRewardTitle(...)
return GetRewardTitle and GetRewardTitle(...)
end
function API:GetNumRewardSpells(...)
return GetRewardSpell and GetRewardSpell(...) and 1 or 0
end
function API:GetMaxRewardCurrencies(...)
return GetMaxRewardCurrencies and GetMaxRewardCurrencies(...) or 0
end
function API:GetNumQuestItems(...)
return GetNumQuestItems and GetNumQuestItems(...) or 0
end
function API:GetQuestMoneyToGet(...)
return GetQuestMoneyToGet and GetQuestMoneyToGet(...) or 0
end
function API:GetNumQuestCurrencies(...)
return GetNumQuestCurrencies and GetNumQuestCurrencies(...) or 0
end
function API:GetSuperTrackedQuestID(...)
return C_SuperTrack and C_SuperTrack.GetSuperTrackedQuestID(...)
end
function API:GetAvailableQuestInfo(...)
if GetAvailableQuestInfo then
return GetAvailableQuestInfo(...)
end
return IsAvailableQuestTrivial(...)
end
function API:IsActiveQuestLegendary(...)
return IsActiveQuestLegendary and IsActiveQuestLegendary(...)
end
function API:IsQuestCompletable(...)
return IsQuestCompletable and IsQuestCompletable(...)
end
-- Gossip API
function API:CloseGossip(...)
if CloseGossip then return CloseGossip(...) end
return C_GossipInfo.CloseGossip(...)
end
function API:ForceGossip(...)
if ForceGossip then return ForceGossip(...) end
return C_GossipInfo.ForceGossip(...)
end
function API:CanAutoSelectGossip(dontAutoSelect)
local gossip = self:GetGossipOptions()
if ( #gossip > 0 and gossip[1].type:lower() ~= 'gossip') then
if not dontAutoSelect then
self:SelectGossipOption(1)
end
return true
end
end
function API:GetGossipText(...)
if GetGossipText then return GetGossipText(...) end
return C_GossipInfo.GetText()
end
function API:GetNumGossipAvailableQuests(...)
if GetNumGossipAvailableQuests then return GetNumGossipAvailableQuests(...) end
return C_GossipInfo.GetNumAvailableQuests(...)
end
function API:GetNumGossipActiveQuests(...)
if GetNumGossipActiveQuests then return GetNumGossipActiveQuests(...) end
return C_GossipInfo.GetNumActiveQuests(...)
end
function API:GetNumGossipOptions(...)
if GetNumGossipOptions then return GetNumGossipOptions(...) end
return C_GossipInfo.GetNumOptions(...)
end
function API:GetGossipAvailableQuests(...)
if GetGossipAvailableQuests then
return map(
API.MapGossipAvailableQuests,
API:GetAvailableQuestIterator(),
GetGossipAvailableQuests(...)
)
end
return C_GossipInfo.GetAvailableQuests(...)
end
function API:GetGossipActiveQuests(...)
if GetGossipActiveQuests then
return map(
API.MapGossipActiveQuests,
API:GetActiveQuestIterator(),
GetGossipActiveQuests(...)
)
end
return C_GossipInfo.GetActiveQuests(...)
end
function API:GetGossipOptions(...)
if GetGossipOptions then
return map(
API.MapGossipOptions,
API:GetGossipOptionIterator(),
GetGossipOptions(...)
)
end
return C_GossipInfo.GetOptions(...)
end
-- Gossip/quest selectors API
function API:SelectActiveQuest(...)
if SelectActiveQuest then return SelectActiveQuest(...) end
end
function API:SelectAvailableQuest(...)
if SelectAvailableQuest then return SelectAvailableQuest(...) end
end
function API:SelectGossipOption(...)
if SelectGossipOption then return SelectGossipOption(...) end
return C_GossipInfo.SelectOption(...)
end
function API:SelectGossipActiveQuest(...)
if SelectGossipActiveQuest then return SelectGossipActiveQuest(...) end
return C_GossipInfo.SelectActiveQuest(...)
end
function API:SelectGossipAvailableQuest(...)
if SelectGossipAvailableQuest then return SelectGossipAvailableQuest(...) end
return C_GossipInfo.SelectAvailableQuest(...)
end
-- Misc
function API:GetUnitName(...)
return GetUnitName and GetUnitName(...)
end
function API:GetFriendshipReputation(...)
if GetFriendshipReputation then
return GetFriendshipReputation(...)
end
return 0
end
function API:GetScaledCursorPosition()
local uiScale = UIParent:GetEffectiveScale();
local x, y = GetCursorPosition();
return x / uiScale, y / uiScale;
end
function API:GetPortraitAtlas()
if GetAtlasInfo and GetAtlasInfo('TalkingHeads-PortraitFrame') then
return 'TalkingHeads-PortraitFrame';
end
return 'TalkingHeads-Alliance-PortraitFrame';
end
function API:IsAzeriteItem(...)
if C_AzeriteEmpoweredItem then
return C_AzeriteEmpoweredItem.IsAzeriteEmpoweredItemByID(...) and
C_AzeriteEmpoweredItem.IsAzeritePreviewSourceDisplayable(...)
end
end
function API:IsCharacterNewlyBoosted(...)
return IsCharacterNewlyBoosted and IsCharacterNewlyBoosted(...)
end
function API:IsFollowerCollected(...)
return C_Garrison and C_Garrison.IsFollowerCollected(...)
end
function API:GetNamePlateForUnit(...)
return C_NamePlate and C_NamePlate.GetNamePlateForUnit(...)
end
function API:GetCreatureID(unit)
local guid = unit and UnitGUID(unit)
return guid and select(1, strsplit('-', guid))
end
function API:CloseItemText(...)
if CloseItemText then return CloseItemText(...) end
end
function API:GetQuestIDByIndex(index)
local link = GetQuestLink(index)
if link then
local id = tonumber(link:match("quest:(%d+)"))
return id
end
end
function API:GetQuestID()
local _, numQuests = GetNumQuestLogEntries()
local toCollapse = {}
self.activeQuests = {}
self.completedQuests = {}
while numQuests > 0 do
for i = 1, GetNumQuestLogEntries() do
local title, _, _, _, isHeader, isCollapsed, isComplete = GetQuestLogTitle(i)
if isHeader then
if isCollapsed then
tinsert(toCollapse, title)
ExpandQuestHeader(i)
end
else
local id = self:GetQuestIDByIndex(i)
self.activeQuests[id] = true
if isComplete then
self.completedQuests[id] = true
end
numQuests = numQuests - 1
end
end
end
while #toCollapse > 0 do
for i = 1, GetNumQuestLogEntries() do
local header = toCollapse[1]
local title, _, _, _, isHeader, isCollapsed = GetQuestLogTitle(i)
if header == title and isHeader and not isCollapsed then
CollapseQuestHeader(i)
tremove(toCollapse, 1)
end
end
end
-- return self.activeQuests, self.completedQuests
-- for k, v in pairs(self.activeQuests) do
-- return k
-- end
return pairs(self.activeQuests)
end
--[[
function API:GetAtlasInfo(atlasName)
assert(atlasName, "GetAtlasInfo: atlas must be specified")
assert(AtlasInfo[atlasName], "GetAtlasInfo: name ["..atlasName.."]: does not exist")
local atlas, info = AtlasInfo[atlasName], {}
info.file = atlas[1];
info.width = atlas[2];
info.height = atlas[3];
info.leftTexCoord = atlas[4];
info.rightTexCoord = atlas[5];
info.topTexCoord = atlas[6];
info.bottomTexCoord = atlas[7];
info.tilesHorizontally = atlas[8];
info.tilesVertically = atlas[9];
return info
end
function API:GetFinalNameFromTextureKit(fmt, textureKits)
if type(textureKits) == "table" then
return fmt:format(unpack(textureKits))
else
return fmt:format(textureKits)
end
end
]]