-
Notifications
You must be signed in to change notification settings - Fork 4
/
followerpage.lua
458 lines (448 loc) · 14.6 KB
/
followerpage.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
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
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
local __FILE__=tostring(debugstack(1,2,0):match("(.*):1:")) -- Always check line number in regexp and file, must be 1
--@debug@
print('Loaded',__FILE__)
--@end-debug@
local function pp(...) print(GetTime(),"|cff009900",__FILE__:sub(-15),strjoin(",",tostringall(...)),"|r") end
--*TYPE module
--*CONFIG noswitch=false,profile=true,enhancedProfile=true
--*MIXINS "AceHook-3.0","AceEvent-3.0","AceTimer-3.0"
--*MINOR 35
-- Auto Generated
local me,ns=...
if ns.die then return end
local addon=ns --#Addon (to keep eclipse happy)
ns=nil
local module=addon:NewSubModule('Followerpage',"AceHook-3.0","AceEvent-3.0","AceTimer-3.0") --#Module
function addon:GetFollowerpageModule() return module end
-- Template
local G=C_Garrison
local _
local AceGUI=LibStub("AceGUI-3.0")
local C=addon:GetColorTable()
local L=addon:GetLocale()
local new=addon:Wrap("NewTable")
local del=addon:Wrap("DelTable")
local kpairs=addon:Wrap("Kpairs")
local empty=addon:Wrap("Empty")
local todefault=addon:Wrap("todefault")
local tonumber=tonumber
local type=type
local OHF=OrderHallMissionFrame
local OHFMissionTab=OrderHallMissionFrame.MissionTab --Container for mission list and single mission
local OHFMissions=OrderHallMissionFrame.MissionTab.MissionList -- same as OrderHallMissionFrameMissions Call Update on this to refresh Mission Listing
local OHFFollowerTab=OrderHallMissionFrame.FollowerTab -- Contains model view
local OHFFollowerList=OrderHallMissionFrame.FollowerList -- Contains follower list (visible in both follower and mission mode)
local OHFFollowers=OrderHallMissionFrameFollowers -- Contains scroll list
local OHFMissionPage=OrderHallMissionFrame.MissionTab.MissionPage -- Contains mission description and party setup
local OHFMapTab=OrderHallMissionFrame.MapTab -- Contains quest map
local OHFCompleteDialog=OrderHallMissionFrameMissions.CompleteDialog
local OHFMissionScroll=OrderHallMissionFrameMissionsListScrollFrame
local OHFMissionScrollChild=OrderHallMissionFrameMissionsListScrollFrameScrollChild
local LE_FOLLOWER_TYPE_GARRISON_6_0=Enum.GarrisonFollowerType.FollowerType_6_0_GarrisonFollower
local LE_FOLLOWER_TYPE_SHIPYARD_6_2=Enum.GarrisonFollowerType.FollowerType_6_0_Boat
local LE_FOLLOWER_TYPE_GARRISON_7_0=Enum.GarrisonFollowerType.FollowerType_7_0_GarrisonFollower
local LE_FOLLOWER_TYPE_GARRISON_8_0=Enum.GarrisonFollowerType.FollowerType_8_0_GarrisonFollower
local LE_GARRISON_TYPE_6_0=Enum.GarrisonType.Type_6_0_Garrison
local LE_GARRISON_TYPE_6_2=Enum.GarrisonType.Type_6_2_Garrison
local LE_GARRISON_TYPE_7_0=Enum.GarrisonType.Type_7_0_Garrison
local LE_GARRISON_TYPE_8_0=Enum.GarrisonType.Type_8_0_Garrison
local followerType=Enum.GarrisonFollowerType.FollowerType_7_0_GarrisonFollower
local garrisonType=Enum.GarrisonType.Type_7_0_Garrison
local FAKE_FOLLOWERID="0x0000000000000000"
local MAX_LEVEL=110
local ShowTT=OrderHallCommanderMixin.ShowTT
local HideTT=OrderHallCommanderMixin.HideTT
local dprint=print
local ddump
--@debug@
C_AddOns.LoadAddOn("Blizzard_DebugTools")
ddump=DevTools_Dump
C_AddOns.LoadAddOn("LibDebug")
if LibDebug then LibDebug() dprint=print end
local safeG=addon.safeG
--@end-debug@
--[===[@non-debug@
dprint=function() end
ddump=function() end
local print=function() end
--@end-non-debug@]===]
local GARRISON_FOLLOWER_COMBAT_ALLY=GARRISON_FOLLOWER_COMBAT_ALLY
local GARRISON_FOLLOWER_ON_MISSION=GARRISON_FOLLOWER_ON_MISSION
local GARRISON_FOLLOWER_INACTIVE=GARRISON_FOLLOWER_INACTIVE
local GARRISON_FOLLOWER_IN_PARTY=GARRISON_FOLLOWER_IN_PARTY
local GARRISON_FOLLOWER_AVAILABLE=AVAILABLE
local ViragDevTool_AddData=_G.ViragDevTool_AddData
if not ViragDevTool_AddData then ViragDevTool_AddData=function() end end
local KEY_BUTTON1 = "\124TInterface\\TutorialFrame\\UI-Tutorial-Frame:12:12:0:0:512:512:10:65:228:283\124t" -- left mouse button
local KEY_BUTTON2 = "\124TInterface\\TutorialFrame\\UI-Tutorial-Frame:12:12:0:0:512:512:10:65:330:385\124t" -- right mouse button
local CTRL_KEY_TEXT,SHIFT_KEY_TEXT=CTRL_KEY_TEXT,SHIFT_KEY_TEXT
local CTRL_KEY_TEXT,SHIFT_KEY_TEXT=CTRL_KEY_TEXT,SHIFT_KEY_TEXT
local CTRL_SHIFT_KEY_TEXT=CTRL_KEY_TEXT .. '-' ..SHIFT_KEY_TEXT
local format,pcall=format,pcall
local function safeformat(mask,...)
local rc,result=pcall(format,mask,...)
if not rc then
for k,v in pairs(L) do
if v==mask then
mask=k
break
end
end
end
rc,result=pcall(format,mask,...)
return rc and result or mask
end
-- End Template - DO NOT MODIFY ANYTHING BEFORE THIS LINE
--*BEGIN
local GetItemCount=GetItemCount
local GetItemInfo=GetItemInfo
local GarrisonMissionFrame_SetItemRewardDetails=GarrisonMissionFrame_SetItemRewardDetails
local GetItemInfoInstant=GetItemInfoInstant
local select=select
local function GetItemName(id) return (GetItemInfo(id)) end
local UpgradeFrame
local UpgradeButtons={}
--@debug@
local debugInfo
--@end-debug@
function module:CheckSpell()
end
function module:OnInitialized()
UpgradeFrame=CreateFrame("Frame",nil,OHFFollowerTab)
local u=UpgradeFrame
u:SetPoint("TOPLEFT",OHFFollowerTab,"TOPLEFT",5,-72)
u:SetPoint("BOTTOMLEFT",OHFFollowerTab,"BOTTOMLEFT",5,7)
u:SetWidth(70)
u:Show()
--@debug@
--addon:SetBackdrop(u,C:Green())
--@end-debug@
self:SecureHook("GarrisonMission_SetFollowerModel","RefreshUpgrades")
UpgradeFrame:EnableMouse(true)
--@debug@
self:RawHookScript(UpgradeFrame,"OnEnter","ShowFollowerData")
self:SecureHook(OHFFollowerTab,"ShowEquipment","CheckEquipment")
self:RawHookScript(UpgradeFrame,"OnLeave",function() GameTooltip:Hide() end)
debugInfo=u:CreateFontString(nil, "OVERLAY", "GameFontNormal")
debugInfo:SetPoint("TOPLEFT",70,20)
--@end-debug@
end
function module:Events()
self:RegisterEvent("GARRISON_FOLLOWER_UPGRADED")
self:RegisterEvent("GARRISON_FOLLOWER_LIST_UPDATE","GARRISON_FOLLOWER_UPGRADED")
self:RegisterEvent("GARRISON_FOLLOWER_XP_CHANGED","GARRISON_FOLLOWER_UPGRADED")
end
function module:ShowFollowerData(this)
local tip=GameTooltip
tip:SetOwner(this,"CURSOR_ANCHOR")
tip:AddLine(this:GetName())
OrderHallCommanderMixin.DumpData(tip,addon:GetFollowerData(OHFFollowerTab.followerID))
tip:Show()
end
function module:GARRISON_FOLLOWER_UPGRADED(event,followerType,followerId)
if followerType ~= LE_FOLLOWER_TYPE_GARRISON_7_0 then
return
end
if OHFFollowerTab:IsVisible() then
self:ScheduleTimer("RefreshUpgrades",0.3)
end
end
do
local left=0
local i=0
local previous=nil
local rendered=false
function module:RenderEquipmentButton(id)
if not(id) then
left=-15
i=0
previous=nil
else
if i > 13 then
i=0
left=left + 50
previous=nil
end
previous,rendered=self:RenderButton(id,left,previous)
if rendered then i=i+1 end
end
end
end
do
local left=360
local i=0
local previous=nil
local rendered=false
function module:RenderUpgradeButton(id)
if not(id) then
left=360
i=0
previous=nil
return
else
if i > 12 then
i=0
left=left - 50
previous=nil
end
previous,rendered=self:RenderButton(id,left,previous)
if rendered then i=i+1 end
end
end
end
local originalcolor
function module:CheckEquipment(this,followerInfo)
local equipmentFrames=this.AbilitiesFrame.Equipment
for _,f in pairs(equipmentFrames) do
local iconid=f.Icon:GetTexture()
local colored=false
if type(iconid)=="number" then
local itemid=addon:GetItemIdByIcon(iconid)
if type(iconid)=="number" then
local quality=addon:GetItemQuality(itemid)
if type(quality)=="number" then
colored=true
f.Border:SetVertexColor(GetItemQualityColor(quality))
end
end
end
if not colored then f.Border:SetVertexColor(1,1,1,1) end
end
end
local eqCount={}
function addon:RefreshEquipments()
wipe(eqCount)
for followerID,followerInfo in pairs(addon:GetFollowerData()) do
if pcall(GarrisonFollowerTabMixin.SetupAbilities,GarrisonFollowerTabMixin,followerInfo) then
for i=1,#followerInfo.equipment do
local eq=followerInfo.equipment[i]
if eq.icon then
if not eqCount[eq.icon] then eqCount[eq.icon]={} end
tinsert(eqCount[eq.icon],followerInfo.followerID)
end
end
end
end
end
function module:RefreshUpgrades(model,followerID,displayID,showWeapon)
if not OHFFollowerTab:IsVisible() then return end
if model then
UpgradeFrame:SetFrameStrata(model:GetFrameStrata())
UpgradeFrame:SetFrameLevel(model:GetFrameLevel()+5)
end
if not followerID then followerID=OHFFollowerTab.followerID end
local follower=addon:GetFollowerData(followerID)
--@debug@
if followerID then
debugInfo:SetText(followerID .. " " .. (displayID or "no display id") .. " " .. (follower.status or ""))
end
--@end-debug@
for i=1,#UpgradeButtons do
self:ReleaseButton(UpgradeButtons[i])
end
wipe(UpgradeButtons)
self:RenderUpgradeButton()
self:RenderEquipmentButton()
if not follower then return end
if not follower.isCollected then return end
--if follower.status==GARRISON_FOLLOWER_ON_MISSION then return end
--if follower.status==GARRISON_FOLLOWER_COMBAT_ALLY then return end
--if follower.status==GARRISON_FOLLOWER_INACTIVE then return end
local data=addon:GetData("Buffs")
--@debug@
print("Buffs",#data)
--@end-debug@
for i=1,#data do
local id=data[i]
self:RenderUpgradeButton(id)
end
if follower.isTroop then return end
if follower.iLevel <850 then
local data=addon:GetData("U850")
--@debug@
print("U850",#data)
--@end-debug@
for i=1,#data do
local id=data[i]
self:RenderUpgradeButton(id)
end
end
if follower.iLevel <880 then
local data=addon:GetData("U880")
--@debug@
print("U880",#data)
--@end-debug@
for i=1,#data do
local id=data[i]
self:RenderUpgradeButton(id)
end
end
if follower.iLevel <900 then
local data=addon:GetData("U900")
--@debug@
print("U900",#data)
--@end-debug@
for i=1,#data do
local id=data[i]
self:RenderUpgradeButton(id)
end
end
if follower.iLevel <925 then
local data=addon:GetData("U925")
--@debug@
print("U925",#data)
--@end-debug@
for i=1,#data do
local id=data[i]
self:RenderUpgradeButton(id)
end
end
if follower.iLevel <950 then
local data=addon:GetData("U950")
--@debug@
print("U950",#data)
--@end-debug@
for i=1,#data do
local id=data[i]
self:RenderUpgradeButton(id)
end
end
if not follower.isMaxLevel or follower.quality < 5 then
local data=addon:GetData("Xp")
--@debug@
print("Xp",#data)
--@end-debug@
for i=1,#data do
local id=data[i]
self:RenderUpgradeButton(id)
end
end
if follower.quality >=Enum.ItemQuality.Rare then
local data=addon:GetData("Equipments")
--@debug@
print("Equipments",#data)
--@end-debug@
for i=1,#data do
local id=data[i]
self:RenderEquipmentButton(id)
end
end
end
function module:UpgradeTooltip(this)
local t=this.Icon:GetTexture()
local tip=GameTooltip
local followers=eqCount[t]
if followers and #followers > 0 then
tip:AddLine(L["Equipped by following champions:"])
for i=1,#followers do
tip:AddLine(G.GetFollowerLink(followers[i]))
end
end
tip:Show()
end
local UpgradeFollower
do local pool={}
function addon:AcquireButton(frame)
local b=tremove(pool)
frame=frame or UpgradeFrame
if not b then
b=CreateFrame("Button",nil,frame,"OHCUpgradeButton,SecureActionbuttonTemplate")
b:EnableMouse(true)
b:RegisterForClicks("LeftButtonDown")
b:SetAttribute("type","item")
--b.Quantity:SetFontObject("NumberFont_Outline_Huge")
b.Quantity:SetFontObject("GameFontNormalShadowHuge2")
--b:SetScript("PostClick",UpgradeFollower)
--b:SetSize(35,35)
--b.Icon:SetSize(35,35)
--b.IconBorder:SetSize(36,36)
b:SetScale(0.7)
addon.SecureHookScript(module,b,"OnEnter","UpgradeTooltip")
else
b:SetParent(frame)
end
tinsert(UpgradeButtons,b)
return b
end
function addon:ReleaseButton(u)
u:Hide()
u:ClearAllPoints()
u:SetParent(nil)
tinsert(pool,u)
end
function addon:RenderButton(id,left,previous)
local qt=GetItemCount(id)
if qt == 0 then return previous end --Not rendering empty buttons
if type(id) ~= "number" then return previous end
local b=module:AcquireButton()
if previous then
b:SetPoint("TOPLEFT",previous,"BOTTOMLEFT",0,0)
else
b:SetPoint("TOPLEFT",left,-5)
end
--b.IconBorder:SetVertexColor(1,0,0)
self:DrawButton(b,id,qt)
return b,true
end
function addon:DrawButton(b,id,qt)
qt=qt or GetItemCount(id)
b.itemID=id
b:SetAttribute("item",select(2,GetItemInfo(id)))
GarrisonMissionFrame_SetItemRewardDetails(b)
local t=b.Icon:GetTexture()
if not t and GetItemInfoInstant then
b.Icon:SetTexture(select(5,GetItemInfoInstant(id)))
t=b.Icon:GetTexture()
end
if not t then
b.Icon:SetTexture("Interface/ICONS/INV_Misc_QuestionMark")
end
b.Quantity:SetFormattedText("%d",qt)
b.Quantity:Show()
if qt>0 then
b.Icon:SetDesaturated(false)
b.Quantity:SetTextColor(b.IconBorder:GetVertexColor())
else
b.Icon:SetDesaturated(true)
b.Quantity:SetTextColor(C.Grey())
end
b:Show()
end
module.ReleaseButton=addon.ReleaseButton
module.AcquireButton=addon.AcquireButton
module.RenderButton=addon.RenderButton
module.DrawButton=addon.DrawButton
end
local CONFIRM1=L["Upgrading to |cff00ff00%d|r"].."\n" .. CONFIRM_GARRISON_FOLLOWER_UPGRADE
local CONFIRM2=L["Upgrading to |cff00ff00%d|r"].."\n|cffffd200 "..L["You are wasting |cffff0000%d|cffffd200 point(s)!!!"].."|r\n" .. CONFIRM_GARRISON_FOLLOWER_UPGRADE
local function DoUpgradeFollower(this)
G.CastSpellOnFollower(this.data);
end
function UpgradeFollower(this)
local follower=this:GetParent()
local followerID=follower.followerID
local upgradelevel=this.rawlevel
local genere=this.tipo:sub(1,1)
local currentlevel=genere=="w" and follower.ItemWeapon.itemLevel or follower.ItemArmor.itemLevel
local name = ITEM_QUALITY_COLORS[G.GetFollowerQuality(followerID)].hex..G.GetFollowerName(followerID)..FONT_COLOR_CODE_CLOSE;
local losing=false
local upgrade=math.min(upgradelevel>600 and upgradelevel or upgradelevel+currentlevel,GARRISON_FOLLOWER_MAX_ITEM_LEVEL)
if upgradelevel > 600 and currentlevel>600 then
if (currentlevel > upgradelevel) then
losing=upgradelevel - 600
else
losing=currentlevel -600
end
elseif upgrade > GARRISON_FOLLOWER_MAX_ITEM_LEVEL then
losing=(upgrade)-GARRISON_FOLLOWER_MAX_ITEM_LEVEL
end
if losing then
return module:Popup(format(CONFIRM2,upgrade,losing,name),0,DoUpgradeFollower,true,followerID,true)
else
if addon:GetToggle("NOCONFIRM") then
return G.CastSpellOnFollower(followerID);
else
return module:Popup(format(CONFIRM1,upgrade,name),0,DoUpgradeFollower,true,followerID,true)
end
end
end