Nenue@2: local wipe = table.wipe Nenue@2: local pairs, ipairs = pairs, ipairs Nenue@2: local GetTime = GetTime Nenue@3: local GI_currentTime = time() Nenue@3: Nenue@3: Nenue@2: local blockTemplate = { Nenue@2: point = 'TOPLEFT', Nenue@2: relativePoint ='TOPLEFT', Nenue@2: } Nenue@2: Nenue@1: SLASH_CLASSPLAN1 = "/classplan" Nenue@1: SLASH_CLASSPLAN2 = "/cp" Nenue@1: SlashCmdList.CLASSPLAN = function(args) Nenue@3: ClassOrderPlan:Toggle() Nenue@3: end Nenue@3: Nenue@3: ClassOrderPlanCore = { Nenue@3: events = {}, Nenue@3: freeBlocks = {}, Nenue@3: blocks = {}, Nenue@3: sortedItems = {}, Nenue@3: timers = {}, Nenue@3: shipments = {}, Nenue@3: playerFirst = false, Nenue@3: prototypes = {} Nenue@3: } Nenue@3: ClassPlanBlockMixin = { Nenue@3: templateName = 'ClassPlanBlock', Nenue@3: events = {'GARRISON_MISSION_LIST_UPDATE', 'GARRISON_MISSION_FINISHED', 'GARRISON_MISSION_FINISHED'},} Nenue@3: ClassPlanShipmentMixin = { Nenue@3: templateName = 'ClassPlanShipment', Nenue@3: parent = false, Nenue@3: point = 'TOPRIGHT', Nenue@3: relativePoint ='TOPRIGHT', Nenue@3: events = {'GARRISON_LANDINGPAGE_SHIPMENTS', 'GARRISON_TALENT_UPDATE', "GARRISON_TALENT_COMPLETE", 'GARRISON_TALENT_COMPLETE', 'GARRISON_SHIPMENT_RECEIVED', "GARRISON_SHIPMENT_RECEIVED"}, Nenue@3: } Nenue@3: setmetatable(ClassPlanShipmentMixin, {__index = ClassPlanBlockMixin}) Nenue@3: local core, MissionsHandler, ShipmentsHandler = ClassOrderPlanCore, ClassPlanBlockMixin, ClassPlanShipmentMixin Nenue@3: local print = DEVIAN_WORKSPACE and function(...) print('ClassPlan', ...) end or nop Nenue@3: Nenue@3: Nenue@3: Nenue@3: MissionsHandler.GetPlayerData = function(self) Nenue@3: if not self.profile then Nenue@3: return Nenue@3: end Nenue@3: self.items = C_Garrison.GetLandingPageItems(LE_GARRISON_TYPE_7_0) Nenue@3: Nenue@3: if #self.items >= 1 then Nenue@3: wipe(self.profile.missions) Nenue@3: for index, data in ipairs(self.items) do Nenue@3: print(' ',data.name, '|cFF00FF00'.. data.timeLeft .. '|r', date("%A %I:%m %p", data.missionEndTime)) Nenue@3: tinsert(self.profile.missions, data) Nenue@3: end Nenue@3: print('items update pending') Nenue@3: self.isStale = true Nenue@3: end Nenue@3: Nenue@3: if self:IsVisible() then Nenue@3: self:Refresh() Nenue@1: end Nenue@1: end Nenue@1: Nenue@3: MissionsHandler.SortHandler = function (a,b) Nenue@3: local result = false Nenue@3: if not a or not b then Nenue@3: result = true Nenue@3: else Nenue@3: if (a.isMine ~= b.isMine) then Nenue@3: result = a.isMine Nenue@3: else Nenue@3: if (not b.missionEndTime) or (not a.missionEndTime) then Nenue@3: print('missing article', b.missionEndTime, a.missionEndTime) Nenue@2: end Nenue@3: result = ( b.missionEndTime > a.missionEndTime) Nenue@2: end Nenue@3: end Nenue@3: return result Nenue@1: end Nenue@1: Nenue@2: Nenue@3: ShipmentsHandler.OnGetItem = function(data) Nenue@3: if data.shipmentsTotal then Nenue@3: local timeLeft = data.creationTime + data.duration - GI_currentTime Nenue@3: if (timeLeft <= 0) and (data.shipmentsReady < data.shipmentsTotal) then Nenue@3: local numOrders = -1*floor(timeLeft/data.duration) Nenue@2: Nenue@3: data.originalCreationTime = data.creationTime Nenue@3: data.originalShipmentsReady = data.shipmentsReady Nenue@2: Nenue@3: data.creationTime = data.creationTime + numOrders*data.duration Nenue@3: data.shipmentsReady = data.shipmentsReady + numOrders Nenue@3: print(data.profileKey, 'shipment "'.. data.name..'" reconciling', numOrders, 'lapsed orders. -->', data.creationTime, data.shipmentsReady) Nenue@2: end Nenue@2: end Nenue@2: end Nenue@2: Nenue@3: ShipmentsHandler.SortHandler = function(a, b) Nenue@3: if b.isComplete ~= a.isComplete then Nenue@3: return a.isComplete and true or false Nenue@2: end Nenue@3: return (a.creationTime) < (b.creationTime) Nenue@2: end Nenue@2: Nenue@3: ShipmentsHandler.GetPlayerData = function (self) Nenue@2: if not self.profile then Nenue@2: return Nenue@2: end Nenue@2: wipe(self.shipments) Nenue@2: Nenue@2: Nenue@2: local garrisonType = LE_GARRISON_TYPE_7_0 Nenue@2: local buildings = C_Garrison.GetBuildings(garrisonType); Nenue@2: local shipmentIndex = 0 Nenue@3: --print('Buildings:') Nenue@2: for i = 1, #buildings do Nenue@2: local name, texture, shipmentCapacity, shipmentsReady, shipmentsTotal, creationTime, duration, timeleftString, itemName, itemIcon, itemQuality, itemID = C_Garrison.GetLandingPageShipmentInfo(buildingID); Nenue@2: tinsert(self.shipments, Nenue@2: { Nenue@2: shipmentType = 'Work Order', Nenue@2: name = name, Nenue@2: icon = texture, Nenue@2: shipmentCapacity = shipmentCapacity, Nenue@2: shipmentsReady = shipmentsReady, Nenue@2: shipmentsTotal = shipmentsTotal, Nenue@2: creationTime = creationTime, Nenue@2: duration = duration, Nenue@2: timeleftString = timeleftString, Nenue@2: itemName = itemName, Nenue@2: itemIcon = itemIcon, Nenue@2: itemQuality = itemQuality, Nenue@2: itemID = itemID Nenue@2: }) Nenue@2: end Nenue@2: Nenue@3: --print('Follower:') Nenue@2: local followerShipments = C_Garrison.GetFollowerShipments(garrisonType); Nenue@2: for i = 1, #followerShipments do Nenue@2: local name, texture, shipmentCapacity, shipmentsReady, shipmentsTotal, creationTime, duration, timeleftString, _, _, _, _, followerID = C_Garrison.GetLandingPageShipmentInfoByContainerID(followerShipments[i]); Nenue@2: tinsert(self.shipments, Nenue@2: { Nenue@2: shipmentType = '', Nenue@2: name = name, Nenue@2: icon = texture, Nenue@2: shipmentCapacity = shipmentCapacity, Nenue@2: shipmentsReady = shipmentsReady, Nenue@2: shipmentsTotal = shipmentsTotal, Nenue@2: creationTime = creationTime, Nenue@2: duration = duration, Nenue@2: timeleftString = timeleftString, Nenue@2: followerID = followerID, Nenue@2: }) Nenue@2: end Nenue@2: Nenue@3: --print('Loose:') Nenue@2: local looseShipments = C_Garrison.GetLooseShipments(garrisonType) Nenue@2: for i = 1, #looseShipments do Nenue@2: local name, texture, shipmentCapacity, shipmentsReady, shipmentsTotal, creationTime, duration, timeleftString = C_Garrison.GetLandingPageShipmentInfoByContainerID(looseShipments[i]); Nenue@2: tinsert(self.shipments, Nenue@2: { Nenue@2: shipmentType = '', Nenue@2: name = name, Nenue@2: icon = texture, Nenue@2: shipmentCapacity = shipmentCapacity, Nenue@2: shipmentsReady = shipmentsReady, Nenue@2: shipmentsTotal = shipmentsTotal, Nenue@2: creationTime = creationTime, Nenue@2: duration = duration, Nenue@2: timeleftString = timeleftString, Nenue@2: }) Nenue@2: end Nenue@2: Nenue@2: local talentTrees = C_Garrison.GetTalentTrees(garrisonType, select(3, UnitClass("player"))); Nenue@2: -- this is a talent that has completed, but has not been seen in the talent UI yet. Nenue@2: local completeTalentID = C_Garrison.GetCompleteTalent(garrisonType); Nenue@3: --print('Talents:') Nenue@2: if (talentTrees) then Nenue@2: for treeIndex, tree in ipairs(talentTrees) do Nenue@2: for talentIndex, talent in ipairs(tree) do Nenue@2: local showTalent = false; Nenue@2: if (talent.isBeingResearched) then Nenue@2: showTalent = true; Nenue@2: end Nenue@2: if (talent.id == completeTalentID) then Nenue@2: showTalent = true; Nenue@2: end Nenue@2: if (showTalent) then Nenue@2: print(talent.name) Nenue@2: talent.creationTime = talent.researchStartTime Nenue@2: talent.duration = talent.researchDuration Nenue@2: talent.shipmentType = 'Talent: ' Nenue@2: tinsert(self.shipments, talent) Nenue@2: end Nenue@1: end Nenue@1: end Nenue@2: end Nenue@1: Nenue@2: self.profile.shipments = self.profile.shipments or {} Nenue@2: if #self.shipments >= 1 then Nenue@2: Nenue@3: Nenue@2: wipe(self.profile.shipments) Nenue@3: for index, data in ipairs(self.shipments) do Nenue@3: print(' ', data.shipmentType .. data.name, data.creationTime, data.duration) Nenue@3: tinsert(self.profile.shipments, data) Nenue@1: end Nenue@2: self.isStale = true Nenue@2: end Nenue@1: Nenue@2: if self:IsVisible() then Nenue@2: self:Refresh() Nenue@1: end Nenue@1: end Nenue@1: Nenue@3: function core:OnLoad () Nenue@3: self:RegisterUnitEvent('UNIT_PORTRAIT_UPDATE', 'player') Nenue@3: self:RegisterEvent('PLAYER_LOGIN') Nenue@3: self:RegisterEvent('PLAYER_ENTERING_WORLD') Nenue@3: self:RegisterEvent('ADDON_LOADED') Nenue@3: self:RegisterEvent('PLAYER_REGEN_ENABLED') Nenue@3: Nenue@3: self:AddHandler('missions', MissionsHandler) Nenue@3: self:AddHandler('shipments', ShipmentsHandler) Nenue@3: end Nenue@3: Nenue@3: function core:AddHandler(name, prototype) Nenue@3: self.prototypes[name] = setmetatable(prototype, { Nenue@3: __index = blockTemplate, Nenue@3: __tostring = function() return name end Nenue@3: }) Nenue@3: Nenue@3: for i, event in ipairs(prototype.events) do Nenue@3: if not self.events[event] then Nenue@3: self:RegisterEvent(event) Nenue@3: self.events[event] = {} Nenue@3: print('|cFF00FF00registering', event) Nenue@3: end Nenue@3: Nenue@3: prototype.numBlocks = 0 Nenue@3: if not self.events[event][name] then Nenue@3: print('adding', name, 'to', event) Nenue@3: self.events[event][name] = prototype.GetPlayerData Nenue@3: end Nenue@1: end Nenue@3: self.sortedItems[name] = {} Nenue@3: end Nenue@1: Nenue@3: function core:OnEvent (event, ...) Nenue@3: print(event) Nenue@3: if event == 'UNIT_PORTRAIT_UPDATE' then Nenue@3: SetPortraitTexture(self.portrait, 'player') Nenue@3: elseif event == 'PLAYER_LOGIN' then Nenue@3: if not self.initialized then Nenue@3: if IsLoggedIn() then Nenue@3: WorldPlanData.OrderHall = WorldPlanData.OrderHall or {} Nenue@3: self.data = WorldPlanData.OrderHall Nenue@1: Nenue@1: Nenue@3: local name, realm = UnitName('player') Nenue@3: realm = realm or GetRealmName() Nenue@3: self.profileKey = name .. '-' .. realm Nenue@3: if not self.data[self.profileKey] then Nenue@3: self.data[self.profileKey] = {} Nenue@3: end Nenue@3: self.profile = self.data[self.profileKey] Nenue@1: Nenue@3: self.profile.shipments = self.profile.shipments or {} Nenue@3: self.profile.missions = self.profile.missions or {} Nenue@3: self.profile.classColor = RAID_CLASS_COLORS[select(2, UnitClass('player'))] Nenue@3: Nenue@3: C_Garrison.RequestLandingPageShipmentInfo(); Nenue@3: Nenue@3: if self.data.IsShown then Nenue@3: self:Show() Nenue@3: end Nenue@3: self.initialized = true Nenue@3: end Nenue@1: end Nenue@3: elseif self.events[event] then Nenue@3: for ptype, eventFunc in pairs(self.events[event]) do Nenue@3: print('|cFF88FF00' .. tostring(ptype) .. '|r:GetPlayerData()') Nenue@3: eventFunc(self, event) Nenue@3: end Nenue@2: end Nenue@2: end Nenue@2: Nenue@3: function core:UpdateNotifications() Nenue@3: end Nenue@3: Nenue@3: function core:RefreshItems(configKey, prototype) Nenue@3: local sortedItems = self.sortedItems[configKey] Nenue@3: Nenue@3: self.blocks[configKey] = self.blocks[configKey] or {} Nenue@3: local blocks = self.blocks[configKey] Nenue@3: Nenue@3: local lastProfile Nenue@3: local numItems = #sortedItems Nenue@3: local totalHeight = 0 Nenue@3: for i, data in ipairs(sortedItems) do Nenue@3: local block = blocks[i] Nenue@3: Nenue@3: if not block then Nenue@3: block = CreateFrame('Button', nil, self, prototype.templateName) Nenue@3: block:SetID(i) Nenue@3: prototype.numBlocks = prototype.numBlocks + 1 Nenue@3: Nenue@3: if prototype.lastBlock then Nenue@3: block:SetPoint('TOPLEFT', prototype.lastBlock, 'BOTTOMLEFT', 0, 0) Nenue@3: else Nenue@3: block:SetPoint(prototype.point, self[prototype.parent] or self, prototype.relativePoint, 0, 0) Nenue@3: end Nenue@3: prototype.lastBlock = block Nenue@3: blocks[i] = block Nenue@3: end Nenue@3: Nenue@3: totalHeight = totalHeight + block:GetHeight() Nenue@3: block.lastProfile = lastProfile Nenue@3: block:Refresh(data) Nenue@3: block:Show() Nenue@3: lastProfile = data.profileKey Nenue@3: end Nenue@3: Nenue@3: for i = numItems + 1, prototype.numBlocks do Nenue@3: if blocks[i] then Nenue@3: blocks[i]:Hide() Nenue@3: end Nenue@3: end Nenue@3: Nenue@3: return totalHeight Nenue@3: end Nenue@3: local max = math.max Nenue@3: function core:Refresh() Nenue@3: if self.isStale then Nenue@3: self:SortItems() Nenue@3: end Nenue@3: self.isStale = nil Nenue@3: Nenue@3: self.currentHeight = 0 Nenue@3: for name, info in pairs(self.prototypes) do Nenue@3: local itemsHeight = self:RefreshItems(name, info) Nenue@3: self.currentHeight = max(itemsHeight, self.currentHeight) Nenue@3: end Nenue@3: Nenue@3: if OrderHallCommandBar and OrderHallCommandBar:IsVisible() then Nenue@3: self:ClearAllPoints() Nenue@3: self:SetPoint('TOP', OrderHallCommandBar, 'BOTTOM') Nenue@3: else Nenue@3: Nenue@3: local posX = self.data.posX or 0 Nenue@3: local posY = self.data.posY or -24 Nenue@3: local point = self.point or 'TOP' Nenue@3: local relativePoint = self.point or 'TOP' Nenue@3: self:SetPoint(point, UIParent, relativePoint, posX, posY) Nenue@3: end Nenue@3: Nenue@3: self:SetHeight(self.currentHeight) Nenue@3: end Nenue@3: Nenue@3: function core:Toggle() Nenue@3: if self:IsVisible() then Nenue@3: self:Hide() Nenue@3: else Nenue@3: self:Show() Nenue@3: end Nenue@3: Nenue@3: if self.data then Nenue@3: self.data.IsShown = self:IsVisible() Nenue@3: end Nenue@3: end Nenue@3: Nenue@3: function core:OnUpdate() Nenue@3: if self.fadeTimer and self.fadeTimer < GetTime() then Nenue@3: self:Hide() Nenue@3: end Nenue@3: end Nenue@3: Nenue@3: function core:OnShow() Nenue@3: if self.isStale then Nenue@3: print('updating items on show') Nenue@3: self:Refresh() Nenue@3: end Nenue@3: ClassPlanButton:SetPoint('TOP', self, 'TOP', 0, 0) Nenue@3: end Nenue@3: function core:OnHide() Nenue@3: ClassPlanButton:SetPoint('TOP', UIParent, 'TOP', 0, 0) Nenue@3: end Nenue@3: Nenue@3: local GI_profileKey, GI_profile, GI_isMine Nenue@3: local GetItemList = function (source, dest, onGetItem) Nenue@3: if not source then Nenue@3: return Nenue@3: end Nenue@3: local numItems = 0 Nenue@3: for index, data in ipairs(source) do Nenue@3: data.classColor = GI_profile.classColor or {r = 0.7, g = 0.7, b =0.7} Nenue@3: data.profileKey = GI_profileKey Nenue@3: data.isMine = GI_isMine Nenue@3: if onGetItem then Nenue@3: onGetItem(data) Nenue@3: end Nenue@3: numItems = numItems + 1 Nenue@3: tinsert(dest, data) Nenue@3: end Nenue@3: return numItems Nenue@3: end Nenue@3: Nenue@3: function core:SortItems() Nenue@3: print('|cFF0088FFSortItems()|r') Nenue@3: GI_currentTime = time() Nenue@3: Nenue@3: for key, sortedItems in pairs(self.sortedItems) do Nenue@3: wipe(sortedItems) Nenue@3: local ptype = self.prototypes[key] Nenue@3: print( 'object:', ptype) Nenue@3: for name, profile in pairs(self.data.characters) do Nenue@3: GI_profileKey = name Nenue@3: GI_profile = profile Nenue@3: GI_isMine = (profile == self.profile) Nenue@3: Nenue@3: local results = GetItemList(profile[key], sortedItems, ptype.OnGetItem) Nenue@3: print(' - ', name, results, 'items') Nenue@3: Nenue@3: end Nenue@3: Nenue@3: if ptype.SortHandler then Nenue@3: print(' sorting', key, #sortedItems) Nenue@3: table.sort(sortedItems, ptype.SortHandler) Nenue@3: end Nenue@3: end Nenue@3: end Nenue@3: Nenue@3: Nenue@3: Nenue@3: function core:UpdateItems () Nenue@3: end Nenue@3: Nenue@3: function MissionsHandler:OnComplete() Nenue@3: self.data.isComplete = true Nenue@2: self:Refresh() Nenue@2: end Nenue@2: Nenue@2: local GetTimeLeftString = function(timeLeft) Nenue@2: Nenue@2: local days = floor(timeLeft/(24*3600)) Nenue@2: local hours = floor(mod(timeLeft, (24*3600)) / 3600) Nenue@2: local minutes = floor(mod(timeLeft, 3600) / 60) Nenue@2: local seconds = mod(timeLeft, 60) Nenue@2: if days >= 1 then Nenue@2: return (days .. 'd' .. ' ') .. ((hours > 0) and (hours .. 'h ') or '') Nenue@1: else Nenue@2: return ((hours > 0) and (hours .. 'h ') or '') .. ((minutes > 0) and (minutes .. ' min') or '') Nenue@1: end Nenue@1: end Nenue@1: Nenue@3: function MissionsHandler:OnUpdate() Nenue@3: if self.data.isComplete then Nenue@2: return Nenue@2: end Nenue@2: Nenue@1: if self.missionEndTime then Nenue@1: local timeLeft = self.missionEndTime - time() Nenue@1: if timeLeft < 0 then Nenue@2: self:OnComplete() Nenue@1: else Nenue@2: self.TimeLeft:SetText(GetTimeLeftString(timeLeft)) Nenue@2: Nenue@2: if timeLeft > 3600 then Nenue@2: self.TimeLeft:SetTextColor(1,1,1) Nenue@2: else Nenue@2: self.TimeLeft:SetTextColor(1,1,0) Nenue@2: end Nenue@2: Nenue@1: end Nenue@1: else Nenue@1: self.TimeLeft:SetText(self.missionEndTime) Nenue@1: end Nenue@2: end Nenue@2: Nenue@2: local SetClassColors = function(self, data) Nenue@2: Nenue@2: if self.lastProfile ~= data.profileKey then Nenue@2: self.Owner:SetText(data.profileKey) Nenue@2: self.Owner:SetTextColor(data.classColor.r, data.classColor.g, data.classColor.b) Nenue@2: else Nenue@2: self.Owner:SetText(nil) Nenue@2: end Nenue@2: self.Background:SetColorTexture(data.classColor.r, data.classColor.g, data.classColor.b, Nenue@2: (data.isComplete and 0.5 or 0.1)) Nenue@2: end Nenue@2: Nenue@3: function MissionsHandler:Refresh(data) Nenue@2: data = data or self.data Nenue@2: self.data = data Nenue@2: Nenue@3: self.isComplete = data.isComplete Nenue@3: self.missionEndTime = data.missionEndTime Nenue@3: Nenue@2: local r,g,b = 1, 1, 1 Nenue@2: if data.isRare then Nenue@2: r,g,b = 0.1, 0.4, 1 Nenue@2: end Nenue@2: Nenue@2: Nenue@2: --self.missionData = data Nenue@2: self.Label:SetText(data.name) Nenue@2: self.Label:SetTextColor(r, g, b) Nenue@2: Nenue@2: if #data.rewards >= 1 then Nenue@2: self.Icon:SetTexture(data.rewards[1].icon or GetItemIcon(data.rewards[1].itemID)) Nenue@2: self.rewardInfo = data.rewards[1] Nenue@2: else Nenue@2: self.Icon:SetAtlas(data.typeAtlas, false) Nenue@2: end Nenue@2: if self.isComplete then Nenue@2: self.TimeLeft:SetText('Complete!') Nenue@2: end Nenue@3: SetClassColors(self, data) Nenue@2: end Nenue@2: Nenue@2: Nenue@3: function MissionsHandler:OnEnter() Nenue@2: if self.rewardInfo and self.rewardInfo.itemID then Nenue@2: GameTooltip:SetOwner(self, 'ANCHOR_LEFT') Nenue@2: GameTooltip:SetItemByID(self.rewardInfo.itemID) Nenue@2: GameTooltip:Show() Nenue@2: end Nenue@2: end Nenue@3: function MissionsHandler:OnLeave() Nenue@2: if GameTooltip:IsOwned(self) then Nenue@2: GameTooltip:Hide() Nenue@2: end Nenue@2: end Nenue@2: Nenue@2: Nenue@2: Nenue@3: function ShipmentsHandler:Refresh(data) Nenue@2: data = data or self.data Nenue@3: Nenue@3: --[[ Nenue@3: self.icon = data.icon Nenue@3: self.shipmentCapacity = data.shipmentCapacity Nenue@3: self.shipmentsReady = data.shipmentsReady Nenue@3: self.shipmentsTotal = data.shipmentsTotal Nenue@3: self.creationTime = data.creationTime Nenue@3: self.duration = data.duration Nenue@3: self.itemID = data.itemID Nenue@3: self.itemQuality = data.itemQuality Nenue@3: icon = texture, Nenue@3: shipmentCapacity = shipmentCapacity, Nenue@3: shipmentsReady = shipmentsReady, Nenue@3: shipmentsTotal = shipmentsTotal, Nenue@3: creationTime = creationTime, Nenue@3: duration = duration, Nenue@3: timeleftString = timeleftString, Nenue@3: itemName = itemName, Nenue@3: itemIcon = itemIcon, Nenue@3: itemQuality = itemQuality, Nenue@3: itemID = itemID Nenue@3: Nenue@3: --]] Nenue@3: Nenue@2: self.Icon:SetTexture(data.icon) Nenue@2: self.data = data Nenue@2: Nenue@3: Nenue@3: local isComplete = data.isComplete Nenue@3: Nenue@3: Nenue@3: Nenue@2: self.Name:SetText(data.shipmentType .. data.name) Nenue@2: self.Count:SetText(data.shipmentsReady) Nenue@2: self.Done:SetShown(data.shipmentsReady and (data.shipmentsReady >= 1)) Nenue@2: Nenue@3: Nenue@3: -- flag as complete Nenue@3: if ( data.shipmentsReady == data.shipmentsTotal ) and (not data.isBeingResearched) then Nenue@2: self.Swipe:SetCooldownUNIX(0, 0); Nenue@2: self.Done:Show(); Nenue@3: isComplete = true Nenue@2: else Nenue@2: self.Swipe:SetCooldownUNIX(data.creationTime or 0 , data.duration or 0); Nenue@2: end Nenue@2: Nenue@3: data.isComplete = isComplete Nenue@2: Nenue@2: SetClassColors(self, data) Nenue@2: end Nenue@3: function ShipmentsHandler:OnUpdate() Nenue@2: local data = self.data Nenue@2: if (data.shipmentsReady and data.shipmentsTotal) and (data.shipmentsReady ~= data.shipmentsTotal) then Nenue@2: local timeLeft = data.creationTime + data.duration - time() Nenue@2: self.TimeLeft:SetText('Next: '.. GetTimeLeftString(timeLeft) .. ' |cFFFFFF00'..data.shipmentsTotal..' orders|r') Nenue@3: elseif data.isStale then Nenue@3: self.TimeLeft:SetText('|cFFFF0000Needs refresh|r') Nenue@2: elseif data.isBeingResearched then Nenue@2: self.TimeLeft:SetText(GetTimeLeftString(data.researchStartTime + data.researchDuration - time())) Nenue@2: else Nenue@2: self.TimeLeft:SetText('Complete!') Nenue@2: end Nenue@2: Nenue@2: end Nenue@2: Nenue@3: function ShipmentsHandler:OnEnter() Nenue@2: local data = self.data Nenue@2: if ( data.shipmentsReady and data.shipmentsTotal ) then Nenue@2: GameTooltip:SetOwner(self, 'ANCHOR_LEFT') Nenue@2: GameTooltip:AddLine(data.shipmentsReady .. ' of '.. data.shipmentsTotal) Nenue@2: GameTooltip:Show() Nenue@2: end Nenue@2: end Nenue@2: Nenue@3: function ShipmentsHandler:OnLeave() Nenue@2: if GameTooltip:IsOwned(self) then Nenue@2: GameTooltip:Hide() Nenue@2: end Nenue@2: end Nenue@2: Nenue@3: function ShipmentsHandler:OnClick(button) Nenue@3: if button == 'RightButton' then Nenue@3: for name, profile in pairs(ClassOrderPlan.data) do Nenue@3: for index, shipment in pairs(profile.shipments) do Nenue@3: if shipment == self.data then Nenue@3: profile.shipments[index] = nil Nenue@3: ClassOrderPlan:Refresh() Nenue@3: end Nenue@3: end Nenue@3: end Nenue@3: end Nenue@1: end