-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathInterface.lua
More file actions
377 lines (310 loc) · 9.98 KB
/
Interface.lua
File metadata and controls
377 lines (310 loc) · 9.98 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
local API = {}; ImmersionAPI = API;
-- Version
local IS_RETAIL = WOW_PROJECT_ID == WOW_PROJECT_MAINLINE or nil;
local IS_WOW10 = (function() -- WoW10 == modern API
local version = select(4, GetBuildInfo())
if version >= 30401 or ( version >= 11404 and version <= 20505 ) then
return true
end
end)();
API.IsRetail = IS_RETAIL;
API.IsWoW10 = IS_WOW10;
-- Quest pickup API
function API:CloseQuest(onQuestClosed, ...)
if onQuestClosed and IS_WOW10 then return end;
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(...)
if QuestUtil and QuestUtil.GetQuestIconOfferForQuestID then
return QuestUtil.GetQuestIconOfferForQuestID(...)
end
local isLegendary, frequency, isRepeatable = select(2, ...)
local icon =
( isLegendary and 'AvailableLegendaryQuestIcon') or
( frequency and frequency > 0 and 'DailyQuestIcon') or
( isRepeatable and 'DailyActiveQuestIcon') or
( 'AvailableQuestIcon' )
return ([[Interface\GossipFrame\%s]]):format(icon)
end
function API:GetQuestIconActive(...)
if QuestUtil and QuestUtil.GetQuestIconActiveForQuestID then
return QuestUtil.GetQuestIconActiveForQuestID(...)
end
local isComplete, isLegendary = select(2, ...)
local icon =
( isComplete ) and (
( isLegendary and 'ActiveLegendaryQuestIcon') or
( isComplete and 'ActiveQuestIcon')
) or ( 'InCompleteQuestIcon' )
return ([[Interface\GossipFrame\%s]]):format(icon)
end
-- Quest content API
function API:GetSuggestedGroupNum(...)
return (C_QuestLog and C_QuestLog.GetSuggestedGroupSize or GetSuggestedGroupNum)(...) or 0
end
function API:GetAccountCompleted(...)
if C_QuestLog and C_QuestLog.IsQuestFlaggedCompletedOnAccount then
return C_QuestLog.IsQuestFlaggedCompletedOnAccount(...)
end
end
function API:GetNumQuestRewards(...)
return GetNumQuestRewards and GetNumQuestRewards(...) or 0
end
function API:GetNumQuestChoices(...)
return GetNumQuestChoices and GetNumQuestChoices(...) or 0
end
function API:GetNumRewardCurrencies(...)
if GetNumRewardCurrencies then
return GetNumRewardCurrencies(...) or 0
end
return #(C_QuestInfoSystem and C_QuestInfoSystem.GetQuestRewardCurrencies(...) or {})
end
function API:GetQuestCurrencyInfo(itemType, index)
if C_QuestOffer and C_QuestOffer.GetQuestRequiredCurrencyInfo then
local currencyInfo
if itemType == 'required' then
currencyInfo = C_QuestOffer.GetQuestRequiredCurrencyInfo(index)
else
currencyInfo = C_QuestOffer.GetQuestRewardCurrencyInfo(itemType, index)
end
if currencyInfo then
currencyInfo.displayedAmount = (itemType == 'required') and currencyInfo.requiredAmount or currencyInfo.totalRewardAmount
return currencyInfo
end
elseif GetQuestCurrencyInfo then
local name, texture, amount, quality = GetQuestCurrencyInfo(itemType, index)
local currencyID = GetQuestCurrencyID(itemType, index)
if name and currencyID then
return {
texture = texture,
name = name,
currencyID = currencyID,
quality = quality or 0,
baseRewardAmount = amount,
bonusRewardAmount = 0,
totalRewardAmount = amount,
questRewardContextFlags = nil,
displayedAmount = amount
}
end
end
end
function API:GetRewardMoney(...)
return GetRewardMoney and GetRewardMoney(...) or 0
end
function API:GetRewardSkillPoints(...)
if GetRewardSkillPoints then
return GetRewardSkillPoints(...)
end
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:GetQuestRewardSpells(...)
return C_QuestInfoSystem and C_QuestInfoSystem.GetQuestRewardSpells(...) or {}
end
function API:GetQuestRewardSpellInfo(...)
return C_QuestInfoSystem and C_QuestInfoSystem.GetQuestRewardSpellInfo(...) or {}
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(onGossipClosed, ...)
if onGossipClosed and IS_WOW10 then return end;
return C_GossipInfo and C_GossipInfo.CloseGossip(...)
end
function API:ForceGossip(...)
return C_GossipInfo and C_GossipInfo.ForceGossip(...)
end
function API:CanAutoSelectGossip(dontAutoSelect)
local gossip, option = self:GetGossipOptions()
if ( #gossip > 0 ) then
local firstOption = gossip[1];
option = firstOption.selectOptionWhenOnlyOption and (firstOption.orderIndex or firstOption.gossipOptionID);
option = option or (firstOption.type and firstOption.type:lower() ~= 'gossip' and 1)
end
if option then
if not dontAutoSelect then
self:SelectGossipOption(option)
end
return true
end
end
function API:GetGossipText(...)
return C_GossipInfo and C_GossipInfo.GetText(...)
end
function API:GetNumGossipAvailableQuests(...)
return C_GossipInfo and C_GossipInfo.GetNumAvailableQuests(...)
end
function API:GetNumGossipActiveQuests(...)
return C_GossipInfo and C_GossipInfo.GetNumActiveQuests(...)
end
function API:GetNumGossipOptions(...)
return #(C_GossipInfo and C_GossipInfo.GetOptions(...) or {})
end
function API:GetGossipAvailableQuests(...)
return C_GossipInfo and C_GossipInfo.GetAvailableQuests(...)
end
function API:GetGossipActiveQuests(...)
return C_GossipInfo and C_GossipInfo.GetActiveQuests(...)
end
function API:GetGossipOptions(...)
assert(C_GossipInfo.GetOptions, 'C_GossipInfo.GetOptions does not exist.')
if GossipOptionSort then
local gossipOptions = C_GossipInfo.GetOptions(...)
table.sort(gossipOptions, GossipOptionSort)
return gossipOptions
end
return C_GossipInfo.GetOptions(...)
end
function API:GetGossipOptionID(option)
return option.orderIndex;
end
-- Quest greeting API
function API:GetNumActiveQuests(...)
return GetNumActiveQuests and GetNumActiveQuests(...) or 0
end
function API:GetNumAvailableQuests(...)
return GetNumAvailableQuests and GetNumAvailableQuests(...) or 0
end
function API:GetActiveQuestID(...)
return GetActiveQuestID and GetActiveQuestID(...)
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(...)
return (C_GossipInfo and (C_GossipInfo.SelectOptionByIndex or C_GossipInfo.SelectOption) or SelectGossipOption)(...)
end
function API:SelectGossipActiveQuest(...)
return C_GossipInfo and C_GossipInfo.SelectActiveQuest(...)
end
function API:SelectGossipAvailableQuest(...)
return C_GossipInfo and C_GossipInfo.SelectAvailableQuest(...)
end
-- Misc
function API:IsSecretValue(value)
if issecretvalue then
return issecretvalue(value)
end
return false;
end
function API:GetUnitName(...)
return GetUnitName and GetUnitName(...)
end
function API:GetPortraitAtlas()
if C_Texture and C_Texture.GetAtlasInfo and C_Texture.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(6, strsplit('-', guid))
end
function API:CloseItemText(...)
if CloseItemText then return CloseItemText(...) end
end
function API:GetQuestDetailsTheme(...)
if C_QuestLog and C_QuestLog.GetQuestDetailsTheme then
return C_QuestLog.GetQuestDetailsTheme(...)
end
end
function API:GetQuestItemInfoLootType(...)
if GetQuestItemInfoLootType then
return GetQuestItemInfoLootType(...)
end
end
-- Interaction manager, events from PlayerInteractionManagerConstantsDocumentation.lua
local StayOpenOnInteractionTypes = Enum and Enum.PlayerInteractionType and {
[Enum.PlayerInteractionType.Gossip] = true;
[Enum.PlayerInteractionType.Item] = true;
[Enum.PlayerInteractionType.QuestGiver] = true;
} or {};
function API:ShouldCloseOnInteraction(type)
return not StayOpenOnInteractionTypes[type];
end