comparison ClassPlanFollowers.lua @ 117:a4dfdd4f1cf3 v7.3.2-20171215

- Fixed filter pins not working on Argus maps - More taint counter-measures
author Nenue
date Fri, 15 Dec 2017 16:38:09 -0500
parents b29b35cb8539
children
comparison
equal deleted inserted replaced
116:bf4a36378bb9 117:a4dfdd4f1cf3
1 1
2 local print = DEVIAN_WORKSPACE and function(...) print('ClassPlan', ...) end or nop 2 local print = DEVIAN_WORKSPACE and function(...) print('ClassPlanF', ...) end or nop
3 local c = { 3 local c = {
4 4
5 templateName = 'ClassPlanShipmentEntry', 5 templateName = 'ClassPlanFollowerEntry',
6 listKey = {'followers','troops'}, 6 listKey = {'followers','troops'},
7 listTitle = {'Followers'}, 7 listTitle = {'Followers', 'Troops'},
8 events = { 8 events = {
9 'GARRISON_FOLLOWER_LIST_UPDATE', 9 'GARRISON_FOLLOWER_LIST_UPDATE',
10 'GARRISON_FOLLOWER_XP_CHANGED', 10 'GARRISON_FOLLOWER_XP_CHANGED',
11 'GARRISON_FOLLOWER_DURABILITY_CHANGED', 11 'GARRISON_FOLLOWER_DURABILITY_CHANGED',
12 'GARRISON_FOLLOWER_UPGRADED', 12 'GARRISON_FOLLOWER_UPGRADED',
24 function c:OnEvent(event, ...) 24 function c:OnEvent(event, ...)
25 print('|cFF00FF00'..self:GetName()..':OnEvent()|r', event, ...) 25 print('|cFF00FF00'..self:GetName()..':OnEvent()|r', event, ...)
26 self:GetPlayerData() 26 self:GetPlayerData()
27 end 27 end
28 28
29 function c:OnUpdate() end
30
31 function c:GetPlayerData() 29 function c:GetPlayerData()
32 30
33 print('|cFF0088FF'..self:GetName()..':GetPlayerData()|r') 31 print('|cFF0088FF'..self:GetName()..':GetPlayerData()|r', self.followerType, time())
34 local profileList = self:GetParent().profile.followers 32 local profile = self:GetParent().profile
35 local troopList = self:GetParent().profile.troops
36 33
37 local followerInfo = C_Garrison.GetFollowers(self.followerType) 34 local followerInfo = C_Garrison.GetFollowers(self.followerType)
38 35
39 36
37
40 if followerInfo then 38 if followerInfo then
41 table.wipe(profileList) 39 table.wipe(profile.followers)
40 table.wipe(profile.troops)
42 for followerID, follower in pairs(followerInfo) do 41 for followerID, follower in pairs(followerInfo) do
43 print(FOLLOWER_QUALITY_COLORS[follower.quality].hex, follower.name, follower.isTroop) 42 print(FOLLOWER_QUALITY_COLORS[follower.quality].hex, follower.name, follower.isTroop)
44 if follower.isTroop then 43 if follower.isTroop then
45 troopList[followerID] = follower 44 print('added troop')
45 profile.troops[followerID] = follower
46 else 46 else
47 print(follower.isMaxLevel, follower.xp, follower.levelXP, follower.iLevel) 47 print(follower.isMaxLevel, follower.xp, follower.levelXP, follower.iLevel)
48 48
49 profileList[followerID] = follower 49 profile.followers[followerID] = follower
50 end 50 end
51 51
52 52
53 profileList[followerID] = follower 53 --profileList[followerID] = follower
54 end 54 end
55 end 55 end
56 56
57 return true
57 end 58 end
58 59
59 function c:UpdateItems() 60 function c:UpdateTroops (followers, baseIndex)
61 baseIndex = baseIndex or 1
62 for followerID, follower in pairs(followers) do
63 --local frame = self.
64 end
65
66
67 return baseIndex
68 end
69
70 function c:OnUpdateRequested ()
71 print('OnUpdateRequested()')
72 end
73
74 function c:OnItemsUpdated()
75 print('OnItemsUpdated()')
76 return nil
77 end
78
79 function c:RefreshData()
80
81 print('|cFF0088FF'..self:GetName()..':RefreshData()')
82 local activeKey = self.activeKey
83 self.truncatedItems = 0
84 self.currentTime = time()
85 if self:GetParent().profile then
86 self:GetPlayerData()
87 end
88 local profile = self.profile
89 for _, listKey in ipairs(self.listKey) do
90 local sortedItems = self.sortedItems[listKey]
91 wipe(sortedItems)
92 local isMine = (profile == self.profile)
93 print(listKey, isMine, profile.showItems)
94 local profileList = self.profile[listKey]
95 if profileList and #profileList >= 1 then
96 local classColor = profile.classColor or RAID_CLASS_COLORS['HUNTER']
97 if profile.showItems then
98 for index, data in ipairs(profileList) do
99 data.classColor = classColor
100 data.profileKey = ClassOrderPlan.profileName
101 data.isMine = isMine
102 if self.OnGetItem then
103 self:OnGetItem(data)
104 end
105 tinsert(sortedItems, data)
106 end
107 else
108 self.truncatedItems = self.truncatedItems + 1
109 end
110 end
111
112 if self.SortHandler then
113 sort(sortedItems, self.SortHandler)
114 end
115 end
116
117 for k,v in pairs(self.sortedItems) do
118 print(' ', k)
119 end
120
121 self.isStale = true
122 end
123
124 --[[
125 -- function c:UpdateItems()
60 126
61 local profileList = self:GetParent().profile.followers 127 local profileList = self:GetParent().profile.followers
62 128
63 local troopList = self:GetParent().profile.troops 129 local troopList = self:GetParent().profile.troops
64 130
65 131 print('UpdateItems() ')
132
66 133
67 end 134 end
135 --]]
68 function c:Reanchor() 136 function c:Reanchor()
137 self:SetPoint('TOPLEFT', ClassOrderPlan.BackgroundInset, 'BOTTOMLEFT')
138 self:SetPoint('RIGHT', ClassOrderPlan.BackgroundInset, 'RIGHT')
69 end 139 end
70 140
141 local f = {}
142 function f:Update()
143 self.Icon:SetTexture()
144 end
145 function f:OnLoad()
146 self.Owner = self.Overlay.Owner
71 147
72 ClassPlanFollowerMixin = CreateFromMixins(ClassPlanHandlerBase, c) 148 self.Count = self.Overlay.Count
149 self.Name = self.Overlay.Name
150 end
151
152 function f.SortHandler (a, b)
153 return true
154 end
155
156 ClassPlanFollowersHandler = CreateFromMixins(ClassPlanHandlerBase, c)
157 ClassPlanFollowerEntryMixin = CreateFromMixins(ClassPlanEntryBase, f)