# HG changeset patch # User Nenue # Date 1477087853 14400 # Node ID 48001b6a94966db67b1edf9b2e20d23ebff6bcfd # Parent 4e1883842abf68fd9332c2dcc0b521adca2be9ea shipment/missions list refresh should commit all result sets diff -r 4e1883842abf -r 48001b6a9496 ClassPlan.lua --- a/ClassPlan.lua Tue Oct 18 01:50:06 2016 -0400 +++ b/ClassPlan.lua Fri Oct 21 18:10:53 2016 -0400 @@ -26,18 +26,18 @@ playerFirst = false, prototypes = {} } -ClassPlanBlockMixin = { - templateName = 'ClassPlanBlock', +ClassPlanMissionMixin = { + templateName = 'ClassPlanMissionEntry', events = {'GARRISON_MISSION_LIST_UPDATE', 'GARRISON_MISSION_STARTED', 'GARRISON_MISSION_FINISHED'},} ClassPlanShipmentMixin = { - templateName = 'ClassPlanShipment', + templateName = 'ClassPlanShipmentEntry', parent = false, point = 'TOPRIGHT', relativePoint ='TOPRIGHT', events = {'GARRISON_LANDINGPAGE_SHIPMENTS', 'GARRISON_TALENT_UPDATE', "GARRISON_TALENT_COMPLETE", "GARRISON_SHIPMENT_RECEIVED"}, } -setmetatable(ClassPlanShipmentMixin, {__index = ClassPlanBlockMixin}) -local core, MissionsHandler, ShipmentsHandler = ClassOrderPlanCore, ClassPlanBlockMixin, ClassPlanShipmentMixin +setmetatable(ClassPlanShipmentMixin, {__index = ClassPlanMissionMixin}) +local core, MissionsHandler, ShipmentsHandler = ClassOrderPlanCore, ClassPlanMissionMixin, ClassPlanShipmentMixin local print = DEVIAN_WORKSPACE and function(...) print('ClassPlan', ...) end or nop local GetTimeLeftString = function(timeLeft) @@ -46,9 +46,9 @@ local minutes = floor(mod(timeLeft, 3600) / 60) local seconds = mod(timeLeft, 60) if days >= 1 then - return (days .. 'd' .. ' ') .. ((hours > 0) and (hours .. 'h ') or '') + return (days .. 'd' .. ' ') .. ((hours > 0) and (hours .. 'h') or '') else - return ((hours > 0) and (hours .. 'h ') or '') .. ((minutes > 0) and (minutes .. ' min') or '') + return ((hours > 0) and (hours .. 'h') or '') .. ((minutes > 0) and (' ' ..minutes .. ' min') or '') end end @@ -101,10 +101,12 @@ if data.shipmentsTotal then local timeLeft = data.creationTime + data.duration - GI_currentTime if (timeLeft <= 0) and (data.shipmentsReady < data.shipmentsTotal) then - local numOrders = -1*floor(timeLeft/data.duration) + local numOrders = min(-1*floor(timeLeft/data.duration), (data.shipmentsTotal - data.shipmentsReady)) - data.originalCreationTime = data.creationTime - data.originalShipmentsReady = data.shipmentsReady + if not data.originalCreationTime then + data.originalCreationTime = data.creationTime + data.originalShipmentsReady = data.shipmentsReady + end data.creationTime = data.creationTime + numOrders*data.duration data.shipmentsReady = data.shipmentsReady + numOrders @@ -123,13 +125,14 @@ end end -local AddShipmentInfo = function(self, shipmentType, name, texture, shipmentCapacity, shipmentsReady, shipmentsTotal, creationTime, duration, timeleftString, itemName, itemIcon, itemQuality, itemID, followerID) +local ShipmentsInfo = {} +local AddShipmentInfo = function(shipmentType, name, texture, shipmentCapacity, shipmentsReady, shipmentsTotal, creationTime, duration, timeleftString, itemName, itemIcon, itemQuality, itemID, followerID) -- early login queries may return empty tables, causing the sorter to compare nil if not creationTime then return end print(shipmentType, name, shipmentCapacity, shipmentsReady, shipmentsTotal, creationTime, duration, timeleftString) - tinsert(self.shipments, + tinsert(ShipmentsInfo, { shipmentType = shipmentType, name = name, @@ -151,7 +154,7 @@ if not self.profile then return end - wipe(self.shipments) + wipe(ShipmentsInfo) local garrisonType = LE_GARRISON_TYPE_7_0 @@ -160,21 +163,21 @@ --print('Buildings:') for i = 1, #buildings do local name, texture, shipmentCapacity, shipmentsReady, shipmentsTotal, creationTime, duration, timeleftString, itemName, itemIcon, itemQuality, itemID = C_Garrison.GetLandingPageShipmentInfo(buildingID); - AddShipmentInfo(self, 'Building', name, texture, shipmentCapacity, shipmentsReady, shipmentsTotal, creationTime, duration, timeleftString, itemName, itemIcon, itemQuality, itemID) + AddShipmentInfo('Building', name, texture, shipmentCapacity, shipmentsReady, shipmentsTotal, creationTime, duration, timeleftString, itemName, itemIcon, itemQuality, itemID) end --print('Follower:') local followerShipments = C_Garrison.GetFollowerShipments(garrisonType); for i = 1, #followerShipments do local name, texture, shipmentCapacity, shipmentsReady, shipmentsTotal, creationTime, duration, timeleftString, _, _, _, _, followerID = C_Garrison.GetLandingPageShipmentInfoByContainerID(followerShipments[i]); - AddShipmentInfo(self, 'Follower', name, texture, shipmentCapacity, shipmentsReady, shipmentsTotal, creationTime, duration, timeleftString, nil, nil, nil, nil, followerID) + AddShipmentInfo('Follower', name, texture, shipmentCapacity, shipmentsReady, shipmentsTotal, creationTime, duration, timeleftString, nil, nil, nil, nil, followerID) end --print('Loose:') local looseShipments = C_Garrison.GetLooseShipments(garrisonType) for i = 1, #looseShipments do local name, texture, shipmentCapacity, shipmentsReady, shipmentsTotal, creationTime, duration, timeleftString = C_Garrison.GetLandingPageShipmentInfoByContainerID(looseShipments[i]); - AddShipmentInfo(self, 'Follower', name, texture, shipmentCapacity, shipmentsReady, shipmentsTotal, creationTime, duration, timeleftString) + AddShipmentInfo('Misc', name, texture, shipmentCapacity, shipmentsReady, shipmentsTotal, creationTime, duration, timeleftString) end local talentTrees = C_Garrison.GetTalentTrees(garrisonType, select(3, UnitClass("player"))); @@ -186,22 +189,19 @@ for talentIndex, talent in ipairs(tree) do local showTalent = false; if (talent.isBeingResearched) or (talent.id == completeTalentID) then - AddShipmentInfo(self, 'Talent', talent.name, talent.icon, 1, (talent.isBeingResearched and 0 or 1), 1, talent.researchStartTime, talent.researchDuration, talent.timeleftString) + AddShipmentInfo('Talent', talent.name, talent.icon, 1, (talent.isBeingResearched and 0 or 1), 1, talent.researchStartTime, talent.researchDuration, talent.timeleftString) end end end end self.profile.shipments = self.profile.shipments or {} - if #self.shipments >= 1 then - wipe(self.profile.shipments) - for index, data in ipairs(self.shipments) do - - --DEFAULT_CHAT_FRAME:AddMessage(data.shipmentType ..' '.. tostring(data.name) ..' '.. tostring(data.creationTime) ..' '.. tostring(data.duration)) - tinsert(self.profile.shipments, data) - end - self.isStale = true + wipe(self.profile.shipments) + for index, data in ipairs(ShipmentsInfo) do + --DEFAULT_CHAT_FRAME:AddMessage(data.shipmentType ..' '.. tostring(data.name) ..' '.. tostring(data.creationTime) ..' '.. tostring(data.duration)) + tinsert(self.profile.shipments, data) end + self.isStale = true if self:IsVisible() then self:Refresh() @@ -322,9 +322,16 @@ function core:OnEvent (event, ...) print(event) if event == 'PLAYER_REGEN_DISABLED' then - self:SetShown(false) + if self:IsVisible() then + self.combatHide = true + self:SetShown(false) + end + elseif event == 'PLAYER_REGEN_ENABLED' then - self:SetShown(true) + if self.combatHide == true then + self.combatHide = nil + self:SetShown(true) + end elseif event == 'PLAYER_LOGIN' then if not self.initialized then self:Setup() @@ -508,10 +515,17 @@ self:Refresh() end -function MissionsHandler:OnUpdate() +function MissionsHandler:OnUpdate(sinceLast) if self.isComplete then return end + self.throttle = (self.throttle or .5) + sinceLast + if self.throttle >= .5 then + self.throttle = self.throttle - .5 + else + return + end + if self.missionEndTime then local timeLeft = self.missionEndTime - time() @@ -525,8 +539,24 @@ else self.TimeLeft:SetTextColor(1,1,0) end + end + if not self.isComplete then + local progress = (self.missionEndTime - time()) / self.durationSeconds + local w = self.ProgressBG:GetWidth() + if progress >= 1 then + self.ProgressBar:SetWidth(w) + else + self.ProgressBar:SetWidth(w - (progress * w)) + end + + self.ProgressBG:Show() + self.ProgressBar:Show() + else + self.ProgressBG:Hide() + self.ProgressBar:Hide() end + else self.TimeLeft:SetText(self.missionEndTime) end @@ -551,6 +581,8 @@ else self.Icon:SetAtlas(self.typeAtlas, false) end + + end @@ -602,7 +634,7 @@ -- flag as complete - if ( self.shipmentsReady == self.shipmentsTotal ) and (not self.isBeingResearched) then + if ( self.shipmentsReady >= self.shipmentsTotal ) and (not self.isBeingResearched) then self.Swipe:SetCooldownUNIX(0, 0); self.Done:Show(); self.isComplete = true @@ -616,15 +648,29 @@ local time = time function ShipmentsHandler:OnUpdate() - if (self.shipmentsReady and self.shipmentsTotal) and (self.shipmentsReady ~= self.shipmentsTotal) then + if (self.shipmentsReady and self.shipmentsTotal) and (self.shipmentsReady < self.shipmentsTotal) then local timeLeft = self.creationTime + self.duration - time() - self.TimeLeft:SetText('Next: '.. GetTimeLeftString(timeLeft) .. ' |cFFFFFF00'..self.shipmentsTotal..' orders|r') - elseif self.isStale then - self.TimeLeft:SetText('|cFFFF0000Needs refresh|r') + if self.shipmentsReady >= 1 then + self.TimeLeft:SetText(GetTimeLeftString(timeLeft)) + self.TimeLeft:SetTextColor(0,1,0) + else + self.TimeLeft:SetText(GetTimeLeftString(timeLeft)) + self.TimeLeft:SetTextColor(1,1,1) + end + if (timeLeft < 0) then + if self.shipmentsReady < self.shipmentsTotal then + self.shipmentsReady = self.shipmentsReady + 1 + self.creationTime = self.creationTime + self.duration + -- text will be set on next update + end + end + elseif self.isBeingResearched then self.TimeLeft:SetText(GetTimeLeftString(self.researchStartTime + self.researchDuration - time())) + self.TimeLeft:SetTextColor(1,1,0) else self.TimeLeft:SetText('Complete!') + self.TimeLeft:SetTextColor(0,1,0) end end diff -r 4e1883842abf -r 48001b6a9496 ClassPlan.xml --- a/ClassPlan.xml Tue Oct 18 01:50:06 2016 -0400 +++ b/ClassPlan.xml Fri Oct 21 18:10:53 2016 -0400 @@ -21,7 +21,7 @@ - +