Nenue@35: local MissionList = ClassPlanMissionHandler Nenue@35: local ListEntry = ClassPlanMissionEntryMixin Nenue@35: local ORDERHALL_TYPE = LE_GARRISON_TYPE_7_0 Nenue@35: function ClassPlanMissionHandler:Reanchor() Nenue@35: self:SetPoint('TOPRIGHT', 0, -24) Nenue@35: self:SetPoint('BOTTOMLEFT', ClassOrderPlan:GetWidth()/2, 0) Nenue@35: Nenue@35: end Nenue@35: local GetPrimaryGarrisonFollowerType = GetPrimaryGarrisonFollowerType Nenue@35: local C_Garrison = C_Garrison Nenue@35: Nenue@35: local wipe, tinsert, date, ipairs = table.wipe, table.insert, date, ipairs Nenue@35: local GetItemIcon = GetItemIcon Nenue@35: local print = DEVIAN_WORKSPACE and function(...) print('ClassPlan', ...) end or nop Nenue@35: Nenue@35: function ClassPlanMissionHandler:GetPlayerData (profile) Nenue@35: local items = C_Garrison.GetAvailableMissions(GetPrimaryGarrisonFollowerType(ORDERHALL_TYPE)); Nenue@35: if not items then Nenue@35: return Nenue@35: end Nenue@35: wipe(profile.missions) Nenue@35: wipe(profile.available) Nenue@35: Nenue@35: Nenue@35: for i = 1, #items do Nenue@35: if (not items[i].isBuilding and items[i].isZoneSupport) then Nenue@35: else Nenue@35: Nenue@35: tinsert(profile.available, items[i]) Nenue@35: end Nenue@35: end Nenue@35: Nenue@35: local items = C_Garrison.GetLandingPageItems(ORDERHALL_TYPE) Nenue@35: for index, data in ipairs(items) do Nenue@35: print(' -',data.name, '|cFF00FF00'.. data.timeLeft .. '|r', date("%A %I:%m %p", data.missionEndTime)) Nenue@35: tinsert(profile.missions, data) Nenue@35: end Nenue@35: return true Nenue@35: end Nenue@35: Nenue@35: function ClassPlanMissionHandler:OnGetItem (data) Nenue@35: if data.missionEndTime and (data.missionEndTime < self.currentTime) then Nenue@35: data.isComplete = true Nenue@35: end Nenue@35: if data.offerEndTime and (data.offerEndTime < self.currentTime) then Nenue@35: data.isExpired = true Nenue@35: data.timeToKeep = self.currentTime + 300 Nenue@35: end Nenue@35: end Nenue@35: Nenue@35: MissionList.SortHandler = function (a,b) Nenue@35: local result = false Nenue@35: --if not a or not b then Nenue@35: -- return true Nenue@35: --else Nenue@35: --if (a.isMine ~= b.isMine) then Nenue@35: -- result = a.isMine Nenue@35: --else Nenue@35: --if (not b.missionEndTime) or (not a.missionEndTime) then Nenue@35: -- print('missing article', b.missionEndTime, a.missionEndTime) Nenue@35: --end Nenue@35: if b.isComplete ~= a.isComplete then Nenue@35: return a.isComplete Nenue@35: elseif b.isMine ~= a.isMine then Nenue@35: return a.isMine Nenue@35: elseif b.missionEndTime then Nenue@35: return ( b.missionEndTime > a.missionEndTime) Nenue@35: else Nenue@35: return ((b.offerEndTime or 0) > (a.offerEndTime or 0)) Nenue@35: end Nenue@35: Nenue@35: --end Nenue@35: --end Nenue@35: end Nenue@35: Nenue@35: Nenue@35: function MissionList:OnShow() Nenue@35: print('|cFF00FF88'..self:GetName()..':OnShow()|r') Nenue@35: end Nenue@35: Nenue@35: Nenue@35: Nenue@35: function ClassPlanMissionEntryMixin:OnComplete() Nenue@35: print('flagging complete', self.name) Nenue@35: self:Update() Nenue@35: end Nenue@35: Nenue@35: function ClassPlanMissionEntryMixin:OnUpdate(sinceLast) Nenue@35: self.throttle = (self.throttle or .5) + sinceLast Nenue@35: if self.throttle < .5 then Nenue@35: return Nenue@35: else Nenue@35: self.throttle = self.throttle - .5 Nenue@35: end Nenue@35: if self.offerEndTime then Nenue@35: self:SetTimeLeft(self.offerEndTime) Nenue@35: elseif self.missionEndTime then Nenue@35: self:SetTimeLeft(self.missionEndTime, self.durationSeconds) Nenue@35: end Nenue@35: end Nenue@35: Nenue@35: function ClassPlanMissionEntryMixin:OnLoad() Nenue@35: print('|cFFFF4400',self:GetName() or tostring(self), 'onload') Nenue@35: self.Count = self.Overlay.Count Nenue@35: self.Name = self.Overlay.Name Nenue@35: self.TimeLeft = self.Overlay.TimeLeft Nenue@35: self.Owner = self.Overlay.Owner Nenue@35: self.maxDisplayed = 10 Nenue@35: Nenue@35: self.Icon:SetDesaturated(false) Nenue@35: self.Done:Hide() Nenue@35: end Nenue@35: Nenue@35: function ClassPlanMissionEntryMixin:Update() Nenue@35: local r,g,b = 1, 1, 1 Nenue@35: if self.isRare then Nenue@35: r,g,b = 0.1, 0.4, 1 Nenue@35: self.IconBorder:SetVertexColor(r, g, b, 1) Nenue@35: end Nenue@35: Nenue@35: --self.missionData = data Nenue@35: self.Name:SetText(self.name) Nenue@35: if #self.rewards >= 1 then Nenue@35: self.Icon:SetTexture(self.rewards[1].icon or GetItemIcon(self.rewards[1].itemID)) Nenue@35: self.rewardInfo = self.rewards[1] Nenue@35: else Nenue@35: self.Icon:SetAtlas(self.typeAtlas, false) Nenue@35: end Nenue@35: Nenue@35: Nenue@35: Nenue@35: if self.isComplete then Nenue@35: self.TimeLeft:SetText('Complete!') Nenue@35: self.Background:SetColorTexture(.25,.25,.25,1) Nenue@35: else Nenue@35: self.Background:SetColorTexture(0,0,0,0.5) Nenue@35: end Nenue@35: end Nenue@35: Nenue@35: function ListEntry:OnEnter() Nenue@35: if self.rewardInfo and self.rewardInfo.itemID then Nenue@35: GameTooltip:SetOwner(self, 'ANCHOR_LEFT') Nenue@35: GameTooltip:SetItemByID(self.rewardInfo.itemID) Nenue@35: GameTooltip:Show() Nenue@35: end Nenue@35: end Nenue@35: Nenue@35: function ListEntry:OnLeave() Nenue@35: if GameTooltip:IsOwned(self) then Nenue@35: GameTooltip:Hide() Nenue@35: end Nenue@35: end