annotate ClassPlanMissions.lua @ 36:21bcff08b0f4

WorldPlan: - Quest pins are now placed on the flight map. Their visibility rules will mirror the filter options from the world map. - Filter controls polish: - First click negates other reward type filters. Subsequent clicks will then toggle individual reward types until the filters are reset via Right-click. - Adheres to the Blizzard CVars added in patch 7.1 - Numerous optimizations to how data and visual updates are handled; should see an even better load time, and snappier world map interaction. ClassPlan: - The 'Available Missions' list is now recorded. It can be reviewed by clicking on the mission list heading. - Information filtering by character and realm.
author Nenue
date Fri, 04 Nov 2016 01:40:39 -0400
parents 26dfa661daa7
children 589c444d4837
rev   line source
Nenue@35 1 local MissionList = ClassPlanMissionHandler
Nenue@35 2 local ListEntry = ClassPlanMissionEntryMixin
Nenue@35 3 local ORDERHALL_TYPE = LE_GARRISON_TYPE_7_0
Nenue@35 4 function ClassPlanMissionHandler:Reanchor()
Nenue@35 5 self:SetPoint('TOPRIGHT', 0, -24)
Nenue@35 6 self:SetPoint('BOTTOMLEFT', ClassOrderPlan:GetWidth()/2, 0)
Nenue@35 7
Nenue@35 8 end
Nenue@35 9 local GetPrimaryGarrisonFollowerType = GetPrimaryGarrisonFollowerType
Nenue@35 10 local C_Garrison = C_Garrison
Nenue@35 11
Nenue@35 12 local wipe, tinsert, date, ipairs = table.wipe, table.insert, date, ipairs
Nenue@35 13 local GetItemIcon = GetItemIcon
Nenue@35 14 local print = DEVIAN_WORKSPACE and function(...) print('ClassPlan', ...) end or nop
Nenue@35 15
Nenue@35 16 function ClassPlanMissionHandler:GetPlayerData (profile)
Nenue@35 17 local items = C_Garrison.GetAvailableMissions(GetPrimaryGarrisonFollowerType(ORDERHALL_TYPE));
Nenue@35 18 if not items then
Nenue@35 19 return
Nenue@35 20 end
Nenue@35 21 wipe(profile.missions)
Nenue@35 22 wipe(profile.available)
Nenue@35 23
Nenue@35 24
Nenue@35 25 for i = 1, #items do
Nenue@35 26 if (not items[i].isBuilding and items[i].isZoneSupport) then
Nenue@35 27 else
Nenue@35 28
Nenue@35 29 tinsert(profile.available, items[i])
Nenue@35 30 end
Nenue@35 31 end
Nenue@35 32
Nenue@35 33 local items = C_Garrison.GetLandingPageItems(ORDERHALL_TYPE)
Nenue@35 34 for index, data in ipairs(items) do
Nenue@35 35 print(' -',data.name, '|cFF00FF00'.. data.timeLeft .. '|r', date("%A %I:%m %p", data.missionEndTime))
Nenue@35 36 tinsert(profile.missions, data)
Nenue@35 37 end
Nenue@35 38 return true
Nenue@35 39 end
Nenue@35 40
Nenue@35 41 function ClassPlanMissionHandler:OnGetItem (data)
Nenue@35 42 if data.missionEndTime and (data.missionEndTime < self.currentTime) then
Nenue@35 43 data.isComplete = true
Nenue@35 44 end
Nenue@35 45 if data.offerEndTime and (data.offerEndTime < self.currentTime) then
Nenue@35 46 data.isExpired = true
Nenue@35 47 data.timeToKeep = self.currentTime + 300
Nenue@35 48 end
Nenue@35 49 end
Nenue@35 50
Nenue@35 51 MissionList.SortHandler = function (a,b)
Nenue@35 52 local result = false
Nenue@35 53 --if not a or not b then
Nenue@35 54 -- return true
Nenue@35 55 --else
Nenue@35 56 --if (a.isMine ~= b.isMine) then
Nenue@35 57 -- result = a.isMine
Nenue@35 58 --else
Nenue@35 59 --if (not b.missionEndTime) or (not a.missionEndTime) then
Nenue@35 60 -- print('missing article', b.missionEndTime, a.missionEndTime)
Nenue@35 61 --end
Nenue@35 62 if b.isComplete ~= a.isComplete then
Nenue@35 63 return a.isComplete
Nenue@35 64 elseif b.isMine ~= a.isMine then
Nenue@35 65 return a.isMine
Nenue@35 66 elseif b.missionEndTime then
Nenue@35 67 return ( b.missionEndTime > a.missionEndTime)
Nenue@35 68 else
Nenue@35 69 return ((b.offerEndTime or 0) > (a.offerEndTime or 0))
Nenue@35 70 end
Nenue@35 71
Nenue@35 72 --end
Nenue@35 73 --end
Nenue@35 74 end
Nenue@35 75
Nenue@35 76
Nenue@35 77 function MissionList:OnShow()
Nenue@35 78 print('|cFF00FF88'..self:GetName()..':OnShow()|r')
Nenue@35 79 end
Nenue@35 80
Nenue@35 81
Nenue@35 82
Nenue@35 83 function ClassPlanMissionEntryMixin:OnComplete()
Nenue@35 84 print('flagging complete', self.name)
Nenue@35 85 self:Update()
Nenue@35 86 end
Nenue@35 87
Nenue@35 88 function ClassPlanMissionEntryMixin:OnUpdate(sinceLast)
Nenue@35 89 self.throttle = (self.throttle or .5) + sinceLast
Nenue@35 90 if self.throttle < .5 then
Nenue@35 91 return
Nenue@35 92 else
Nenue@35 93 self.throttle = self.throttle - .5
Nenue@35 94 end
Nenue@35 95 if self.offerEndTime then
Nenue@35 96 self:SetTimeLeft(self.offerEndTime)
Nenue@35 97 elseif self.missionEndTime then
Nenue@35 98 self:SetTimeLeft(self.missionEndTime, self.durationSeconds)
Nenue@35 99 end
Nenue@35 100 end
Nenue@35 101
Nenue@35 102 function ClassPlanMissionEntryMixin:OnLoad()
Nenue@35 103 print('|cFFFF4400',self:GetName() or tostring(self), 'onload')
Nenue@35 104 self.Count = self.Overlay.Count
Nenue@35 105 self.Name = self.Overlay.Name
Nenue@35 106 self.TimeLeft = self.Overlay.TimeLeft
Nenue@35 107 self.Owner = self.Overlay.Owner
Nenue@35 108 self.maxDisplayed = 10
Nenue@35 109
Nenue@35 110 self.Icon:SetDesaturated(false)
Nenue@35 111 self.Done:Hide()
Nenue@35 112 end
Nenue@35 113
Nenue@35 114 function ClassPlanMissionEntryMixin:Update()
Nenue@35 115 local r,g,b = 1, 1, 1
Nenue@35 116 if self.isRare then
Nenue@35 117 r,g,b = 0.1, 0.4, 1
Nenue@35 118 self.IconBorder:SetVertexColor(r, g, b, 1)
Nenue@35 119 end
Nenue@35 120
Nenue@35 121 --self.missionData = data
Nenue@35 122 self.Name:SetText(self.name)
Nenue@35 123 if #self.rewards >= 1 then
Nenue@35 124 self.Icon:SetTexture(self.rewards[1].icon or GetItemIcon(self.rewards[1].itemID))
Nenue@35 125 self.rewardInfo = self.rewards[1]
Nenue@35 126 else
Nenue@35 127 self.Icon:SetAtlas(self.typeAtlas, false)
Nenue@35 128 end
Nenue@35 129
Nenue@35 130
Nenue@35 131
Nenue@35 132 if self.isComplete then
Nenue@35 133 self.TimeLeft:SetText('Complete!')
Nenue@35 134 self.Background:SetColorTexture(.25,.25,.25,1)
Nenue@35 135 else
Nenue@35 136 self.Background:SetColorTexture(0,0,0,0.5)
Nenue@35 137 end
Nenue@35 138 end
Nenue@35 139
Nenue@35 140 function ListEntry:OnEnter()
Nenue@35 141 if self.rewardInfo and self.rewardInfo.itemID then
Nenue@35 142 GameTooltip:SetOwner(self, 'ANCHOR_LEFT')
Nenue@35 143 GameTooltip:SetItemByID(self.rewardInfo.itemID)
Nenue@35 144 GameTooltip:Show()
Nenue@35 145 end
Nenue@35 146 end
Nenue@35 147
Nenue@35 148 function ListEntry:OnLeave()
Nenue@35 149 if GameTooltip:IsOwned(self) then
Nenue@35 150 GameTooltip:Hide()
Nenue@35 151 end
Nenue@35 152 end