annotate ClassPlanFollowers.lua @ 121:1fcc4fe645dc tip

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