Mercurial > wow > worldplan
diff ClassPlanMissions.lua @ 40:589c444d4837
WowAce/Curseforge migration push
author | Nenue |
---|---|
date | Sun, 25 Dec 2016 13:04:57 -0500 |
parents | 26dfa661daa7 |
children | b29b35cb8539 |
line wrap: on
line diff
--- a/ClassPlanMissions.lua Fri Nov 04 02:54:32 2016 -0400 +++ b/ClassPlanMissions.lua Sun Dec 25 13:04:57 2016 -0500 @@ -1,19 +1,37 @@ -local MissionList = ClassPlanMissionHandler -local ListEntry = ClassPlanMissionEntryMixin +local _, db= ... local ORDERHALL_TYPE = LE_GARRISON_TYPE_7_0 -function ClassPlanMissionHandler:Reanchor() - self:SetPoint('TOPRIGHT', 0, -24) - self:SetPoint('BOTTOMLEFT', ClassOrderPlan:GetWidth()/2, 0) - -end +local UnitClass = UnitClass +local time, max, min = time, max, min +local print = DEVIAN_WORKSPACE and function(...) print('ClassPlan', ...) end or nop local GetPrimaryGarrisonFollowerType = GetPrimaryGarrisonFollowerType local C_Garrison = C_Garrison local wipe, tinsert, date, ipairs = table.wipe, table.insert, date, ipairs local GetItemIcon = GetItemIcon -local print = DEVIAN_WORKSPACE and function(...) print('ClassPlan', ...) end or nop -function ClassPlanMissionHandler:GetPlayerData (profile) + +local MissionList = { + templateName = 'ClassPlanMissionEntry', + listKey = {'missions', 'available'}, + listTitle = {'In Progress', 'Available'}, + + point = 'TOPLEFT', + relativePoint ='TOPLEFT', + events = { + 'GARRISON_MISSION_LIST_UPDATE'}, +} +local ListEntry = {} + +function MissionList:Reanchor() + self:SetPoint('TOPRIGHT', ClassOrderPlan.BackgroundInset, 'TOPRIGHT', 0, 0) + self:SetPoint('BOTTOMLEFT', ClassOrderPlan:GetWidth()/2, 0) +end + + + + +function MissionList:GetPlayerData () + local profile = self:GetParent().profile local items = C_Garrison.GetAvailableMissions(GetPrimaryGarrisonFollowerType(ORDERHALL_TYPE)); if not items then return @@ -38,60 +56,83 @@ return true end -function ClassPlanMissionHandler:OnGetItem (data) - if data.missionEndTime and (data.missionEndTime < self.currentTime) then - data.isComplete = true +function MissionList:OnGetItem (data) + if data.missionEndTime then + if (data.missionEndTime < self.currentTime) then + data.isComplete = true + else + self:ScheduleUpdate(data.missionEndTime) + end end - if data.offerEndTime and (data.offerEndTime < self.currentTime) then - data.isExpired = true - data.timeToKeep = self.currentTime + 300 + + if data.offerEndTime then + if (data.offerEndTime < self.currentTime) then + data.isExpired = true + data.timeToKeep = self.currentTime + 300 + else + self:ScheduleUpdate(data.offerEndTime) + end end + end MissionList.SortHandler = function (a,b) local result = false - --if not a or not b then - -- return true - --else - --if (a.isMine ~= b.isMine) then - -- result = a.isMine - --else - --if (not b.missionEndTime) or (not a.missionEndTime) then - -- print('missing article', b.missionEndTime, a.missionEndTime) - --end if b.isComplete ~= a.isComplete then return a.isComplete - elseif b.isMine ~= a.isMine then - return a.isMine - elseif b.missionEndTime then - return ( b.missionEndTime > a.missionEndTime) else - return ((b.offerEndTime or 0) > (a.offerEndTime or 0)) + if b.isMine ~= a.isMine then + return a.isMine + else + if a.isComplete then + if a.profileKey ~= b.profileKey then + return (a.profileKey < b.profileKey) + else + return (a.name < b.name) + end + else + if b.missionEndTime then + return ( b.missionEndTime > a.missionEndTime) + else + return ((b.offerEndTime or 0) > (a.offerEndTime or 0)) + end + end + end + end +end + +function MissionList:OnEvent(event, ...) + self:RefreshData() + if event == 'GARRISON_MISSION_FINISHED' then + local followerTypeID, missionID = ...; + elseif event == 'GARRISON_TALENT_COMPLETE' then + local garrisonType = ...; + elseif event == '' then end - --end - --end end - function MissionList:OnShow() print('|cFF00FF88'..self:GetName()..':OnShow()|r') end - - -function ClassPlanMissionEntryMixin:OnComplete() +function ListEntry:OnComplete() print('flagging complete', self.name) self:Update() end -function ClassPlanMissionEntryMixin:OnUpdate(sinceLast) +function ListEntry:OnUpdate(sinceLast) + if self.doAnimation then + self.doAnimation = nil + self.NewBlockFade:Play() + end self.throttle = (self.throttle or .5) + sinceLast if self.throttle < .5 then return else self.throttle = self.throttle - .5 end + if self.offerEndTime then self:SetTimeLeft(self.offerEndTime) elseif self.missionEndTime then @@ -99,8 +140,12 @@ end end -function ClassPlanMissionEntryMixin:OnLoad() - print('|cFFFF4400',self:GetName() or tostring(self), 'onload') +function ListEntry:OnHide(...) + print(self:GetName().. ':Hide()', ...) +end + +function ListEntry:OnLoad() + print('|cFFFF4400'..self:GetName()..':OnLoad()') self.Count = self.Overlay.Count self.Name = self.Overlay.Name self.TimeLeft = self.Overlay.TimeLeft @@ -109,9 +154,17 @@ self.Icon:SetDesaturated(false) self.Done:Hide() + --[[ + hooksecurefunc(self.Background, 'SetColorTexture', function(self, ...) + print(self:GetName(), ...) + end) + hooksecurefunc(self.Background, 'SetTexture', function(self, ...) + --print(self:GetName(), ...) + end) + --]] end -function ClassPlanMissionEntryMixin:Update() +function ListEntry:Update() local r,g,b = 1, 1, 1 if self.isRare then r,g,b = 0.1, 0.4, 1 @@ -127,26 +180,31 @@ self.Icon:SetAtlas(self.typeAtlas, false) end + local itemType = db.ClassPlanTypes.inProgress + if self.isComplete then + itemType = db.ClassPlanTypes.complete + end - - if self.isComplete then - self.TimeLeft:SetText('Complete!') - self.Background:SetColorTexture(.25,.25,.25,1) - else - self.Background:SetColorTexture(0,0,0,0.5) - end + self.Background:SetColorTexture(unpack(itemType.backgroundColor)) end function ListEntry:OnEnter() + WorldMap_HijackTooltip(self) if self.rewardInfo and self.rewardInfo.itemID then - GameTooltip:SetOwner(self, 'ANCHOR_LEFT') - GameTooltip:SetItemByID(self.rewardInfo.itemID) - GameTooltip:Show() + WorldMapTooltip:SetOwner(self, 'ANCHOR_LEFT') + WorldMapTooltip:AddLine(self.name) + EmbeddedItemTooltip_SetItemByID(WorldMapTooltip.ItemTooltip, self.rewardInfo.itemID) + WorldMapTooltip:Show() end end function ListEntry:OnLeave() - if GameTooltip:IsOwned(self) then - GameTooltip:Hide() + WorldMap_RestoreTooltip() + if WorldMapTooltip:IsOwned(self) then + WorldMapTooltip:Hide() end -end \ No newline at end of file +end + + +ClassPlanMissionHandler = CreateFromMixins(ClassPlanHandlerBase, MissionList) +ClassPlanMissionEntryMixin = CreateFromMixins(ClassPlanEntryBase, ListEntry) \ No newline at end of file