annotate ClassPlanMissions.lua @ 113:03e4a8b93012 v7.3.0-2

7.3 Updates - Added some map frame adjustments to keep the filter bar from obstructing edge of zone clicks KNOWN ISSUES: - Argus quests can only be filtered when viewing Argus maps - Main Argus map in the WorldMapFrame has misaligned pins; this is due to it using a different map texture from what is used in the teleporter map, so all the POI coordinates are based on that map in the client info
author Nenue
date Tue, 05 Sep 2017 03:14:34 -0400
parents b29b35cb8539
children
rev   line source
Nenue@40 1 local _, db= ...
Nenue@35 2 local ORDERHALL_TYPE = LE_GARRISON_TYPE_7_0
Nenue@40 3 local UnitClass = UnitClass
Nenue@40 4 local time, max, min = time, max, min
Nenue@40 5 local print = DEVIAN_WORKSPACE and function(...) print('ClassPlan', ...) end or nop
Nenue@35 6 local GetPrimaryGarrisonFollowerType = GetPrimaryGarrisonFollowerType
Nenue@35 7 local C_Garrison = C_Garrison
Nenue@35 8
Nenue@35 9 local wipe, tinsert, date, ipairs = table.wipe, table.insert, date, ipairs
Nenue@35 10 local GetItemIcon = GetItemIcon
Nenue@35 11
Nenue@40 12
Nenue@40 13 local MissionList = {
Nenue@40 14 templateName = 'ClassPlanMissionEntry',
Nenue@40 15 listKey = {'missions', 'available'},
Nenue@40 16 listTitle = {'In Progress', 'Available'},
Nenue@40 17
Nenue@40 18 point = 'TOPLEFT',
Nenue@40 19 relativePoint ='TOPLEFT',
Nenue@40 20 events = {
Nenue@40 21 'GARRISON_MISSION_LIST_UPDATE'},
Nenue@40 22 }
Nenue@40 23 local ListEntry = {}
Nenue@40 24
Nenue@40 25 function MissionList:Reanchor()
Nenue@40 26 self:SetPoint('TOPRIGHT', ClassOrderPlan.BackgroundInset, 'TOPRIGHT', 0, 0)
Nenue@40 27 self:SetPoint('BOTTOMLEFT', ClassOrderPlan:GetWidth()/2, 0)
Nenue@40 28 end
Nenue@40 29
Nenue@40 30
Nenue@40 31
Nenue@40 32
Nenue@40 33 function MissionList:GetPlayerData ()
Nenue@40 34 local profile = self:GetParent().profile
Nenue@35 35 local items = C_Garrison.GetAvailableMissions(GetPrimaryGarrisonFollowerType(ORDERHALL_TYPE));
Nenue@35 36 if not items then
Nenue@35 37 return
Nenue@35 38 end
Nenue@35 39 wipe(profile.missions)
Nenue@35 40 wipe(profile.available)
Nenue@35 41
Nenue@35 42
Nenue@95 43 for _, data in ipairs(items) do
Nenue@35 44
Nenue@95 45 --print(' -',data.name, '|cFF00FF00'.. data.offerEndTime .. '|r', date("%A %I:%m %p", data.offerEndTime))
Nenue@95 46 if data.offerEndTime then
Nenue@95 47 data.offerEndTime = time() + (data.offerEndTime - GetTime())
Nenue@35 48 end
Nenue@95 49 tinsert(profile.available, data)
Nenue@95 50
Nenue@35 51 end
Nenue@35 52
Nenue@35 53 local items = C_Garrison.GetLandingPageItems(ORDERHALL_TYPE)
Nenue@35 54 for index, data in ipairs(items) do
Nenue@35 55 print(' -',data.name, '|cFF00FF00'.. data.timeLeft .. '|r', date("%A %I:%m %p", data.missionEndTime))
Nenue@35 56 tinsert(profile.missions, data)
Nenue@35 57 end
Nenue@35 58 return true
Nenue@35 59 end
Nenue@35 60
Nenue@40 61 function MissionList:OnGetItem (data)
Nenue@40 62 if data.missionEndTime then
Nenue@40 63 if (data.missionEndTime < self.currentTime) then
Nenue@40 64 data.isComplete = true
Nenue@40 65 else
Nenue@40 66 self:ScheduleUpdate(data.missionEndTime)
Nenue@40 67 end
Nenue@35 68 end
Nenue@40 69
Nenue@40 70 if data.offerEndTime then
Nenue@40 71 if (data.offerEndTime < self.currentTime) then
Nenue@40 72 data.isExpired = true
Nenue@40 73 data.timeToKeep = self.currentTime + 300
Nenue@40 74 else
Nenue@40 75 self:ScheduleUpdate(data.offerEndTime)
Nenue@40 76 end
Nenue@35 77 end
Nenue@40 78
Nenue@35 79 end
Nenue@35 80
Nenue@35 81 MissionList.SortHandler = function (a,b)
Nenue@35 82 local result = false
Nenue@35 83 if b.isComplete ~= a.isComplete then
Nenue@35 84 return a.isComplete
Nenue@35 85 else
Nenue@40 86 if b.isMine ~= a.isMine then
Nenue@40 87 return a.isMine
Nenue@40 88 else
Nenue@40 89 if a.isComplete then
Nenue@40 90 if a.profileKey ~= b.profileKey then
Nenue@40 91 return (a.profileKey < b.profileKey)
Nenue@40 92 else
Nenue@40 93 return (a.name < b.name)
Nenue@40 94 end
Nenue@40 95 else
Nenue@40 96 if b.missionEndTime then
Nenue@40 97 return ( b.missionEndTime > a.missionEndTime)
Nenue@40 98 else
Nenue@40 99 return ((b.offerEndTime or 0) > (a.offerEndTime or 0))
Nenue@40 100 end
Nenue@40 101 end
Nenue@40 102 end
Nenue@40 103 end
Nenue@40 104 end
Nenue@40 105
Nenue@40 106 function MissionList:OnEvent(event, ...)
Nenue@40 107 self:RefreshData()
Nenue@40 108 if event == 'GARRISON_MISSION_FINISHED' then
Nenue@40 109 local followerTypeID, missionID = ...;
Nenue@40 110 elseif event == 'GARRISON_TALENT_COMPLETE' then
Nenue@40 111 local garrisonType = ...;
Nenue@40 112 elseif event == '' then
Nenue@35 113 end
Nenue@35 114
Nenue@35 115 end
Nenue@35 116
Nenue@35 117 function MissionList:OnShow()
Nenue@35 118 print('|cFF00FF88'..self:GetName()..':OnShow()|r')
Nenue@35 119 end
Nenue@35 120
Nenue@40 121 function ListEntry:OnComplete()
Nenue@35 122 print('flagging complete', self.name)
Nenue@35 123 self:Update()
Nenue@35 124 end
Nenue@35 125
Nenue@40 126 function ListEntry:OnUpdate(sinceLast)
Nenue@40 127 if self.doAnimation then
Nenue@40 128 self.doAnimation = nil
Nenue@40 129 self.NewBlockFade:Play()
Nenue@40 130 end
Nenue@35 131 self.throttle = (self.throttle or .5) + sinceLast
Nenue@35 132 if self.throttle < .5 then
Nenue@35 133 return
Nenue@35 134 else
Nenue@35 135 self.throttle = self.throttle - .5
Nenue@35 136 end
Nenue@40 137
Nenue@35 138 if self.offerEndTime then
Nenue@35 139 self:SetTimeLeft(self.offerEndTime)
Nenue@35 140 elseif self.missionEndTime then
Nenue@35 141 self:SetTimeLeft(self.missionEndTime, self.durationSeconds)
Nenue@35 142 end
Nenue@35 143 end
Nenue@35 144
Nenue@40 145 function ListEntry:OnHide(...)
Nenue@40 146 print(self:GetName().. ':Hide()', ...)
Nenue@40 147 end
Nenue@40 148
Nenue@40 149 function ListEntry:OnLoad()
Nenue@40 150 print('|cFFFF4400'..self:GetName()..':OnLoad()')
Nenue@35 151 self.Count = self.Overlay.Count
Nenue@35 152 self.Name = self.Overlay.Name
Nenue@35 153 self.TimeLeft = self.Overlay.TimeLeft
Nenue@35 154 self.Owner = self.Overlay.Owner
Nenue@35 155 self.maxDisplayed = 10
Nenue@35 156
Nenue@35 157 self.Icon:SetDesaturated(false)
Nenue@35 158 self.Done:Hide()
Nenue@40 159 --[[
Nenue@40 160 hooksecurefunc(self.Background, 'SetColorTexture', function(self, ...)
Nenue@40 161 print(self:GetName(), ...)
Nenue@40 162 end)
Nenue@40 163 hooksecurefunc(self.Background, 'SetTexture', function(self, ...)
Nenue@40 164 --print(self:GetName(), ...)
Nenue@40 165 end)
Nenue@40 166 --]]
Nenue@35 167 end
Nenue@35 168
Nenue@40 169 function ListEntry:Update()
Nenue@35 170 local r,g,b = 1, 1, 1
Nenue@35 171 if self.isRare then
Nenue@35 172 r,g,b = 0.1, 0.4, 1
Nenue@35 173 self.IconBorder:SetVertexColor(r, g, b, 1)
Nenue@35 174 end
Nenue@35 175
Nenue@35 176 --self.missionData = data
Nenue@35 177 self.Name:SetText(self.name)
Nenue@35 178 if #self.rewards >= 1 then
Nenue@35 179 self.Icon:SetTexture(self.rewards[1].icon or GetItemIcon(self.rewards[1].itemID))
Nenue@35 180 self.rewardInfo = self.rewards[1]
Nenue@35 181 else
Nenue@35 182 self.Icon:SetAtlas(self.typeAtlas, false)
Nenue@35 183 end
Nenue@35 184
Nenue@40 185 local itemType = db.ClassPlanTypes.inProgress
Nenue@40 186 if self.isComplete then
Nenue@40 187 itemType = db.ClassPlanTypes.complete
Nenue@40 188 end
Nenue@35 189
Nenue@40 190 self.Background:SetColorTexture(unpack(itemType.backgroundColor))
Nenue@35 191 end
Nenue@35 192
Nenue@35 193 function ListEntry:OnEnter()
Nenue@40 194 WorldMap_HijackTooltip(self)
Nenue@35 195 if self.rewardInfo and self.rewardInfo.itemID then
Nenue@40 196 WorldMapTooltip:SetOwner(self, 'ANCHOR_LEFT')
Nenue@40 197 WorldMapTooltip:AddLine(self.name)
Nenue@40 198 EmbeddedItemTooltip_SetItemByID(WorldMapTooltip.ItemTooltip, self.rewardInfo.itemID)
Nenue@40 199 WorldMapTooltip:Show()
Nenue@35 200 end
Nenue@35 201 end
Nenue@35 202
Nenue@35 203 function ListEntry:OnLeave()
Nenue@40 204 WorldMap_RestoreTooltip()
Nenue@40 205 if WorldMapTooltip:IsOwned(self) then
Nenue@40 206 WorldMapTooltip:Hide()
Nenue@35 207 end
Nenue@40 208 end
Nenue@40 209
Nenue@40 210
Nenue@40 211 ClassPlanMissionHandler = CreateFromMixins(ClassPlanHandlerBase, MissionList)
Nenue@40 212 ClassPlanMissionEntryMixin = CreateFromMixins(ClassPlanEntryBase, ListEntry)