comparison ClassPlanMissions.lua @ 40:589c444d4837

WowAce/Curseforge migration push
author Nenue
date Sun, 25 Dec 2016 13:04:57 -0500
parents 26dfa661daa7
children b29b35cb8539
comparison
equal deleted inserted replaced
39:89ddef0594bc 40:589c444d4837
1 local MissionList = ClassPlanMissionHandler 1 local _, db= ...
2 local ListEntry = ClassPlanMissionEntryMixin
3 local ORDERHALL_TYPE = LE_GARRISON_TYPE_7_0 2 local ORDERHALL_TYPE = LE_GARRISON_TYPE_7_0
4 function ClassPlanMissionHandler:Reanchor() 3 local UnitClass = UnitClass
5 self:SetPoint('TOPRIGHT', 0, -24) 4 local time, max, min = time, max, min
6 self:SetPoint('BOTTOMLEFT', ClassOrderPlan:GetWidth()/2, 0) 5 local print = DEVIAN_WORKSPACE and function(...) print('ClassPlan', ...) end or nop
7
8 end
9 local GetPrimaryGarrisonFollowerType = GetPrimaryGarrisonFollowerType 6 local GetPrimaryGarrisonFollowerType = GetPrimaryGarrisonFollowerType
10 local C_Garrison = C_Garrison 7 local C_Garrison = C_Garrison
11 8
12 local wipe, tinsert, date, ipairs = table.wipe, table.insert, date, ipairs 9 local wipe, tinsert, date, ipairs = table.wipe, table.insert, date, ipairs
13 local GetItemIcon = GetItemIcon 10 local GetItemIcon = GetItemIcon
14 local print = DEVIAN_WORKSPACE and function(...) print('ClassPlan', ...) end or nop 11
15 12
16 function ClassPlanMissionHandler:GetPlayerData (profile) 13 local MissionList = {
14 templateName = 'ClassPlanMissionEntry',
15 listKey = {'missions', 'available'},
16 listTitle = {'In Progress', 'Available'},
17
18 point = 'TOPLEFT',
19 relativePoint ='TOPLEFT',
20 events = {
21 'GARRISON_MISSION_LIST_UPDATE'},
22 }
23 local ListEntry = {}
24
25 function MissionList:Reanchor()
26 self:SetPoint('TOPRIGHT', ClassOrderPlan.BackgroundInset, 'TOPRIGHT', 0, 0)
27 self:SetPoint('BOTTOMLEFT', ClassOrderPlan:GetWidth()/2, 0)
28 end
29
30
31
32
33 function MissionList:GetPlayerData ()
34 local profile = self:GetParent().profile
17 local items = C_Garrison.GetAvailableMissions(GetPrimaryGarrisonFollowerType(ORDERHALL_TYPE)); 35 local items = C_Garrison.GetAvailableMissions(GetPrimaryGarrisonFollowerType(ORDERHALL_TYPE));
18 if not items then 36 if not items then
19 return 37 return
20 end 38 end
21 wipe(profile.missions) 39 wipe(profile.missions)
36 tinsert(profile.missions, data) 54 tinsert(profile.missions, data)
37 end 55 end
38 return true 56 return true
39 end 57 end
40 58
41 function ClassPlanMissionHandler:OnGetItem (data) 59 function MissionList:OnGetItem (data)
42 if data.missionEndTime and (data.missionEndTime < self.currentTime) then 60 if data.missionEndTime then
43 data.isComplete = true 61 if (data.missionEndTime < self.currentTime) then
44 end 62 data.isComplete = true
45 if data.offerEndTime and (data.offerEndTime < self.currentTime) then 63 else
46 data.isExpired = true 64 self:ScheduleUpdate(data.missionEndTime)
47 data.timeToKeep = self.currentTime + 300 65 end
48 end 66 end
67
68 if data.offerEndTime then
69 if (data.offerEndTime < self.currentTime) then
70 data.isExpired = true
71 data.timeToKeep = self.currentTime + 300
72 else
73 self:ScheduleUpdate(data.offerEndTime)
74 end
75 end
76
49 end 77 end
50 78
51 MissionList.SortHandler = function (a,b) 79 MissionList.SortHandler = function (a,b)
52 local result = false 80 local result = false
53 --if not a or not b then
54 -- return true
55 --else
56 --if (a.isMine ~= b.isMine) then
57 -- result = a.isMine
58 --else
59 --if (not b.missionEndTime) or (not a.missionEndTime) then
60 -- print('missing article', b.missionEndTime, a.missionEndTime)
61 --end
62 if b.isComplete ~= a.isComplete then 81 if b.isComplete ~= a.isComplete then
63 return a.isComplete 82 return a.isComplete
64 elseif b.isMine ~= a.isMine then
65 return a.isMine
66 elseif b.missionEndTime then
67 return ( b.missionEndTime > a.missionEndTime)
68 else 83 else
69 return ((b.offerEndTime or 0) > (a.offerEndTime or 0)) 84 if b.isMine ~= a.isMine then
70 end 85 return a.isMine
71 86 else
72 --end 87 if a.isComplete then
73 --end 88 if a.profileKey ~= b.profileKey then
74 end 89 return (a.profileKey < b.profileKey)
75 90 else
91 return (a.name < b.name)
92 end
93 else
94 if b.missionEndTime then
95 return ( b.missionEndTime > a.missionEndTime)
96 else
97 return ((b.offerEndTime or 0) > (a.offerEndTime or 0))
98 end
99 end
100 end
101 end
102 end
103
104 function MissionList:OnEvent(event, ...)
105 self:RefreshData()
106 if event == 'GARRISON_MISSION_FINISHED' then
107 local followerTypeID, missionID = ...;
108 elseif event == 'GARRISON_TALENT_COMPLETE' then
109 local garrisonType = ...;
110 elseif event == '' then
111 end
112
113 end
76 114
77 function MissionList:OnShow() 115 function MissionList:OnShow()
78 print('|cFF00FF88'..self:GetName()..':OnShow()|r') 116 print('|cFF00FF88'..self:GetName()..':OnShow()|r')
79 end 117 end
80 118
81 119 function ListEntry:OnComplete()
82
83 function ClassPlanMissionEntryMixin:OnComplete()
84 print('flagging complete', self.name) 120 print('flagging complete', self.name)
85 self:Update() 121 self:Update()
86 end 122 end
87 123
88 function ClassPlanMissionEntryMixin:OnUpdate(sinceLast) 124 function ListEntry:OnUpdate(sinceLast)
125 if self.doAnimation then
126 self.doAnimation = nil
127 self.NewBlockFade:Play()
128 end
89 self.throttle = (self.throttle or .5) + sinceLast 129 self.throttle = (self.throttle or .5) + sinceLast
90 if self.throttle < .5 then 130 if self.throttle < .5 then
91 return 131 return
92 else 132 else
93 self.throttle = self.throttle - .5 133 self.throttle = self.throttle - .5
94 end 134 end
135
95 if self.offerEndTime then 136 if self.offerEndTime then
96 self:SetTimeLeft(self.offerEndTime) 137 self:SetTimeLeft(self.offerEndTime)
97 elseif self.missionEndTime then 138 elseif self.missionEndTime then
98 self:SetTimeLeft(self.missionEndTime, self.durationSeconds) 139 self:SetTimeLeft(self.missionEndTime, self.durationSeconds)
99 end 140 end
100 end 141 end
101 142
102 function ClassPlanMissionEntryMixin:OnLoad() 143 function ListEntry:OnHide(...)
103 print('|cFFFF4400',self:GetName() or tostring(self), 'onload') 144 print(self:GetName().. ':Hide()', ...)
145 end
146
147 function ListEntry:OnLoad()
148 print('|cFFFF4400'..self:GetName()..':OnLoad()')
104 self.Count = self.Overlay.Count 149 self.Count = self.Overlay.Count
105 self.Name = self.Overlay.Name 150 self.Name = self.Overlay.Name
106 self.TimeLeft = self.Overlay.TimeLeft 151 self.TimeLeft = self.Overlay.TimeLeft
107 self.Owner = self.Overlay.Owner 152 self.Owner = self.Overlay.Owner
108 self.maxDisplayed = 10 153 self.maxDisplayed = 10
109 154
110 self.Icon:SetDesaturated(false) 155 self.Icon:SetDesaturated(false)
111 self.Done:Hide() 156 self.Done:Hide()
112 end 157 --[[
113 158 hooksecurefunc(self.Background, 'SetColorTexture', function(self, ...)
114 function ClassPlanMissionEntryMixin:Update() 159 print(self:GetName(), ...)
160 end)
161 hooksecurefunc(self.Background, 'SetTexture', function(self, ...)
162 --print(self:GetName(), ...)
163 end)
164 --]]
165 end
166
167 function ListEntry:Update()
115 local r,g,b = 1, 1, 1 168 local r,g,b = 1, 1, 1
116 if self.isRare then 169 if self.isRare then
117 r,g,b = 0.1, 0.4, 1 170 r,g,b = 0.1, 0.4, 1
118 self.IconBorder:SetVertexColor(r, g, b, 1) 171 self.IconBorder:SetVertexColor(r, g, b, 1)
119 end 172 end
125 self.rewardInfo = self.rewards[1] 178 self.rewardInfo = self.rewards[1]
126 else 179 else
127 self.Icon:SetAtlas(self.typeAtlas, false) 180 self.Icon:SetAtlas(self.typeAtlas, false)
128 end 181 end
129 182
130 183 local itemType = db.ClassPlanTypes.inProgress
131
132 if self.isComplete then 184 if self.isComplete then
133 self.TimeLeft:SetText('Complete!') 185 itemType = db.ClassPlanTypes.complete
134 self.Background:SetColorTexture(.25,.25,.25,1) 186 end
135 else 187
136 self.Background:SetColorTexture(0,0,0,0.5) 188 self.Background:SetColorTexture(unpack(itemType.backgroundColor))
137 end
138 end 189 end
139 190
140 function ListEntry:OnEnter() 191 function ListEntry:OnEnter()
192 WorldMap_HijackTooltip(self)
141 if self.rewardInfo and self.rewardInfo.itemID then 193 if self.rewardInfo and self.rewardInfo.itemID then
142 GameTooltip:SetOwner(self, 'ANCHOR_LEFT') 194 WorldMapTooltip:SetOwner(self, 'ANCHOR_LEFT')
143 GameTooltip:SetItemByID(self.rewardInfo.itemID) 195 WorldMapTooltip:AddLine(self.name)
144 GameTooltip:Show() 196 EmbeddedItemTooltip_SetItemByID(WorldMapTooltip.ItemTooltip, self.rewardInfo.itemID)
197 WorldMapTooltip:Show()
145 end 198 end
146 end 199 end
147 200
148 function ListEntry:OnLeave() 201 function ListEntry:OnLeave()
149 if GameTooltip:IsOwned(self) then 202 WorldMap_RestoreTooltip()
150 GameTooltip:Hide() 203 if WorldMapTooltip:IsOwned(self) then
151 end 204 WorldMapTooltip:Hide()
152 end 205 end
206 end
207
208
209 ClassPlanMissionHandler = CreateFromMixins(ClassPlanHandlerBase, MissionList)
210 ClassPlanMissionEntryMixin = CreateFromMixins(ClassPlanEntryBase, ListEntry)