comparison ClassPlan.lua @ 35:26dfa661daa7

WorldPlan: - Quest pins will appear in the flight map. They follow the filter settings applied from the world map. - Reward filter toggle changed to clear out other reward filters. The assumption being that one is most often looking only for that particular type of quest when they go to use it. - Fixed filter bar info falling out of sync after player-triggered world map updates. - Code stuff: -- Quest pin shown-state management makes better use of OnShow OnHide handlers, SetShown is toggled and it all goes from there -- WorldQuests module re-factored outside of the top level frame script. ClassPlan: - Available missions are now recorded; the mission list can be toggled between in-progress and available by clicking the heading.
author Nenue
date Thu, 03 Nov 2016 17:29:15 -0400
parents e8679ecb48d8
children 589c444d4837
comparison
equal deleted inserted replaced
34:0100d923d8c3 35:26dfa661daa7
36 36
37 37
38 ClassOrderPlanCore = { 38 ClassOrderPlanCore = {
39 events = {}, 39 events = {},
40 freeBlocks = {}, 40 freeBlocks = {},
41 characterButtons = {},
41 blocks = {}, 42 blocks = {},
42 sortedItems = {}, 43 sortedItems = {},
43 timers = {}, 44 timers = {},
44 shipments = {}, 45 shipments = {},
45 playerFirst = false, 46 playerFirst = false,
71 'GARRISON_SHOW_LANDING_PAGE'}, 72 'GARRISON_SHOW_LANDING_PAGE'},
72 } 73 }
73 local SharedHandlers = { 74 local SharedHandlers = {
74 numBlocks = 0, 75 numBlocks = 0,
75 isStale = true, 76 isStale = true,
77 maxItems = 10
76 } 78 }
77 local SharedEntry = {} 79 local SharedEntry = {}
78 local ShipmentEntry = {} 80 local ShipmentEntry = {}
79 local MissionEntry = {} 81 local MissionEntry = {}
80 82
120 122
121 print('|cFFFFFF00Loaded:|r', classColor.hex, className, profileName) 123 print('|cFFFFFF00Loaded:|r', classColor.hex, className, profileName)
122 self.Background:SetColorTexture(classColor.r, classColor.g, classColor.b, 0.5) 124 self.Background:SetColorTexture(classColor.r, classColor.g, classColor.b, 0.5)
123 self.profile.classColor = classColor 125 self.profile.classColor = classColor
124 self.profile.className = className 126 self.profile.className = className
127 self.profile.characterName = name
128 self.profile.characterRealm = realm
125 return self.profile 129 return self.profile
126 end 130 end
127 131
128 function ClassPlan:SetupHandler(handler) 132 function ClassPlan:SetupHandler(handler)
129 print('|cFF00FF00'..handler:GetName()..' loaded') 133 print('|cFF00FF00'..handler:GetName()..' loaded')
187 for index, handler in pairs(self.Handlers) do 191 for index, handler in pairs(self.Handlers) do
188 if handler.isStale then 192 if handler.isStale then
189 print(' |cFF00FF00'..index..' '..handler:GetName()..'|r') 193 print(' |cFF00FF00'..index..' '..handler:GetName()..'|r')
190 local sortedItems = handler.sortedItems 194 local sortedItems = handler.sortedItems
191 local activeKey = handler.activeKey 195 local activeKey = handler.activeKey
196
192 handler.profile = self.profile[handler.activeKey] 197 handler.profile = self.profile[handler.activeKey]
193 198 handler.currentTime = GI_currentTime
199 handler:GetPlayerData(self.profile)
194 wipe(sortedItems) 200 wipe(sortedItems)
195 handler:GetPlayerData(self.profile)
196 for key, profile in pairs(self.data.characters) do 201 for key, profile in pairs(self.data.characters) do
197 print('profile', key, activeKey) 202 print('profile', key, activeKey)
198 local profileList = profile[activeKey] 203 local profileList = profile[activeKey]
199 if profileList and #profileList >= 1 then 204 if profileList and #profileList >= 1 then
200 local classColor = profile.classColor or defaultClassColor 205 local classColor = profile.classColor or RAID_CLASS_COLORS['HUNTER']
201 local isMine = (profile == self.profile) 206 local isMine = (profile == self.profile)
202 for index, data in ipairs(profileList) do 207 for index, data in ipairs(profileList) do
203 data.classColor = classColor 208 data.classColor = classColor
204 data.profileKey = key 209 data.profileKey = key
205 data.isMine = isMine 210 data.isMine = isMine
206 if handler.OnGetItem then 211 if handler.OnGetItem then
207 handler.OnGetItem(data) 212 handler:OnGetItem(data)
208 end 213 end
209 tinsert(sortedItems, data) 214 tinsert(sortedItems, data)
210 end 215 end
211 end 216 end
212 end 217 end
220 local itemsHeight = handler:UpdateItems() 225 local itemsHeight = handler:UpdateItems()
221 self.currentHeight = max(itemsHeight, self.currentHeight) 226 self.currentHeight = max(itemsHeight, self.currentHeight)
222 227
223 end 228 end
224 229
230 local index = 1
231 for id, profile in pairs(self.data.characters) do
232 local button = self.characterButtons[index]
233 if not button then
234 button = CreateFrame('Button', nil, self, 'ClassOrderPlanCharacterButton')
235 button:SetID(index)
236 self.characterButtons[index] = button
237
238 if not self.lastButton then
239 button:SetPoint('BOTTOMLEFT', self, 'TOPLEFT', 0, 0)
240 else
241 button:SetPoint('BOTTOMLEFT', self.lastButton, 'BOTTOMRIGHT', 2, 0)
242 end
243 self.lastButton = button
244 end
245 if not profile.characterName then
246 profile.characterName, profile.characterRealm = id:match("%(.+)%-(.+)^")
247 end
248
249 button.className = profile.className
250 button.classColor = profile.classColor
251 button.characterName = profile.characterName
252 button.characterRealm = profile.characterRealm
253 button.hideItems = (profile.showItems == false) and (profile ~= self.profile)
254 button.isMine = (profile == self.profile)
255 button:Update()
256 button:Show()
257 index = index + 1
258 end
259
260
225 self.isStale = nil 261 self.isStale = nil
226 self:Reanchor() 262 self:Reanchor()
227 self:SetHeight(self.currentHeight + CP_HEADER_SIZE) 263 self:SetHeight(self.currentHeight + CP_HEADER_SIZE)
228 end 264 end
229 265
263 self:ClearAllPoints() 299 self:ClearAllPoints()
264 self:SetPoint('CENTER', self.data.positionX, self.data.positionY) 300 self:SetPoint('CENTER', self.data.positionX, self.data.positionY)
265 301
266 for index, frame in ipairs(self.Handlers) do 302 for index, frame in ipairs(self.Handlers) do
267 frame:Reanchor() 303 frame:Reanchor()
304
305 local ListTab = frame.ListTab
306 if ListTab then
307 ListTab:ClearAllPoints()
308 ListTab:SetPoint('TOPLEFT', frame, 'TOPLEFT', 0, CP_HEADER_SIZE)
309 ListTab:SetPoint('BOTTOMRIGHT', frame, 'TOPRIGHT', 0, 0)
310 ListTab.Label:SetText(frame.listTitle[frame.currentListIndex])
311 ListTab:Show()
312 print(ListTab:GetSize())
313 end
314
268 end 315 end
269 end 316 end
270 317
271 function ClassPlan:OnDragStart() 318 function ClassPlan:OnDragStart()
272 self:StartMoving() 319 self:StartMoving()
296 self.currentListIndex = index 343 self.currentListIndex = index
297 self.activeKey = self.listKey[index] 344 self.activeKey = self.listKey[index]
298 self.activeTitle = self.listTitle[index] 345 self.activeTitle = self.listTitle[index]
299 346
300 self.isStale = true 347 self.isStale = true
348 end
349
350 function SharedHandlers:OnMouseWheel(delta)
351 self.scrollOffset = (self.scrollOffset or 0) - ((delta > 0) and 1 or -1)
352 self:UpdateItems()
301 end 353 end
302 354
303 function SharedHandlers:RequestData() 355 function SharedHandlers:RequestData()
304 print('|cFF0088FF'..self:GetName()..':RequestData()') 356 print('|cFF0088FF'..self:GetName()..':RequestData()')
305 self.isStale = true 357 self.isStale = true
343 self.Owner:SetText(ownerText) 395 self.Owner:SetText(ownerText)
344 self.Name:SetText(self.name) 396 self.Name:SetText(self.name)
345 self.Name:SetTextColor(data.classColor.r, data.classColor.g, data.classColor.b) 397 self.Name:SetTextColor(data.classColor.r, data.classColor.g, data.classColor.b)
346 end 398 end
347 399
400 function SharedHandlers:Acquire(id)
401 end
402 function SharedHandlers:FreeBlock (block)
403 end
404
348 function SharedHandlers:UpdateItems() 405 function SharedHandlers:UpdateItems()
406
407 self.MoreItemsUp:Hide()
408 self.MoreItemsDown:Hide()
409
349 local sortedItems = self.sortedItems 410 local sortedItems = self.sortedItems
411 local scrollOffset = self.scrollOffset or 0
412 local numItems = #sortedItems
413 if (not sortedItems[scrollOffset+1]) or (numItems <= self.maxItems) then
414 scrollOffset = 0
415 elseif (numItems > self.maxItems) and (scrollOffset > (numItems - self.maxItems)) then
416 scrollOffset = (numItems - self.maxItems)
417 end
418
350 419
351 self.blocks = self.blocks or {} 420 self.blocks = self.blocks or {}
352 local blocks = self.blocks 421 local blocks = self.blocks
353 422
354 local lastProfile 423 local lastProfile
355 local numItems = #sortedItems
356 local totalHeight = 0 424 local totalHeight = 0
357 self.lastBlock = nil 425 self.lastBlock = nil
358 self.numActive = 0 426 self.numActive = 0
359 for i, data in ipairs(sortedItems) do 427 for i = 1, self.maxItems do
428 local index = scrollOffset + i
429 local data = sortedItems[index]
430 if not data then
431 break
432 end
433
434
360 local block = blocks[i] 435 local block = blocks[i]
361 if not block then 436 if not block then
362 block = CreateFrame('Button', nil, self, self.templateName) 437 block = CreateFrame('Button', nil, self, self.templateName)
363 block:SetID(i)
364 block.listType = self.activeKey 438 block.listType = self.activeKey
365 block.handler = self 439 block.handler = self
366 self.numBlocks = self.numBlocks + 1 440 self.numBlocks = self.numBlocks + 1
367 blocks[i] = block 441 blocks[i] = block
368 end 442 end
443 block:SetID(index)
369 444
370 print('RefreshItem', block) 445 print('RefreshItem', block)
371 self.numActive = self.numActive + 1 446 self.numActive = self.numActive + 1
372 447
373 if self.lastBlock then 448 if self.lastBlock then
374 block:SetPoint('TOPLEFT', self.lastBlock, 'BOTTOMLEFT', 0, 0) 449 block:SetPoint('TOPLEFT', self.lastBlock, 'BOTTOMLEFT', 0, 0)
375 print('--', i, data.isComplete, data.missionEndTime, data.name) 450 print('--', index, data.isComplete, data.missionEndTime, data.name)
376 else 451 else
377 block:SetPoint('TOPLEFT', 0, 0) 452 block:SetPoint('TOPLEFT', 0, 0)
378 print('--top') 453 print('--top')
379 end 454 end
380 self.lastBlock = block 455 self.lastBlock = block
399 474
400 block:Show() 475 block:Show()
401 lastProfile = data.profileKey 476 lastProfile = data.profileKey
402 end 477 end
403 478
404 for i = numItems + 1, self.numBlocks do 479 if self.numActive < numItems then
480 if scrollOffset < (numItems - self.maxItems) then
481 self.MoreItemsDown:Show()
482 end
483 if scrollOffset > 0 then
484 self.MoreItemsUp:Show()
485 end
486 end
487
488 for i = self.numActive + 1, self.numBlocks do
405 if blocks[i] then 489 if blocks[i] then
406 blocks[i]:Hide() 490 blocks[i]:Hide()
407 end 491 end
408 end 492 end
409 493
494 self.scrollOffset = scrollOffset
410 self:Reanchor() 495 self:Reanchor()
411 496
412 return totalHeight 497 return totalHeight
413 end 498 end
414 499
417 print('|cFF00FFFF'..self:GetName()..':Reanchor|r') 502 print('|cFF00FFFF'..self:GetName()..':Reanchor|r')
418 self:SetPoint('TOPLEFT', 0, -24) 503 self:SetPoint('TOPLEFT', 0, -24)
419 self:SetPoint('BOTTOMRIGHT', -ClassOrderPlan:GetWidth()/2, 0) 504 self:SetPoint('BOTTOMRIGHT', -ClassOrderPlan:GetWidth()/2, 0)
420 end 505 end
421 506
422 function MissionList:Reanchor() 507
423 self:SetPoint('TOPRIGHT', 0, -24)
424 self:SetPoint('BOTTOMLEFT', ClassOrderPlan:GetWidth()/2, 0)
425
426 self.ListTab:ClearAllPoints()
427 self.ListTab:SetPoint('TOPLEFT', self, 'TOPLEFT', 0, CP_HEADER_SIZE)
428 self.ListTab:SetPoint('BOTTOMRIGHT', self, 'TOPRIGHT', 0, 0)
429 self.ListTab.Label:SetText(self.listTitle[self.currentListIndex])
430 self.ListTab:Show()
431 print(self.ListTab:GetSize())
432 end
433
434 function MissionList:GetPlayerData (profile)
435 wipe(profile.missions)
436 wipe(profile.available)
437
438 local items = C_Garrison.GetAvailableMissions(GetPrimaryGarrisonFollowerType(LE_GARRISON_TYPE_7_0));
439 for i = 1, #items do
440 if (not items[i].isBuilding and items[i].isZoneSupport) then
441 else
442
443 tinsert(profile.available, items[i])
444 end
445 end
446
447 local items = C_Garrison.GetLandingPageItems(LE_GARRISON_TYPE_7_0)
448 for index, data in ipairs(items) do
449 print(' -',data.name, '|cFF00FF00'.. data.timeLeft .. '|r', date("%A %I:%m %p", data.missionEndTime))
450 tinsert(profile.missions, data)
451 end
452 return true
453 end
454 508
455 do 509 do
456 local ShipmentsInfo = {} 510 local ShipmentsInfo = {}
457 local AddShipmentInfo = function(shipmentType, name, texture, shipmentCapacity, shipmentsReady, shipmentsTotal, creationTime, duration, timeleftString, itemName, itemIcon, itemQuality, itemID, followerID) 511 local AddShipmentInfo = function(shipmentType, name, texture, shipmentCapacity, shipmentsReady, shipmentsTotal, creationTime, duration, timeleftString, itemName, itemIcon, itemQuality, itemID, followerID)
458 -- early login queries may return empty tables, causing the sorter to compare nil 512 -- early login queries may return empty tables, causing the sorter to compare nil
530 end 584 end
531 self.isStale = true 585 self.isStale = true
532 return true 586 return true
533 end 587 end
534 end 588 end
535 MissionList.OnGetItem = function(data) 589
536 if data.missionEndTime and (data.missionEndTime < GI_currentTime) then 590
537 data.isComplete = true 591 function SharedEntry:SetTimeLeft(expires, duration)
538 end 592 self.ProgressBG:Hide()
539 end 593 self.ProgressBar:Hide()
540 594 if not expires then
541 MissionList.FreeBlock = function(self, block) 595 return
542 end 596 end
543 597
544 MissionList.SortHandler = function (a,b) 598 -- calculate here since time isn't available
545 local result = false 599 local timeLeft = expires - GI_currentTime
546 --if not a or not b then 600 if timeLeft < 0 then
547 -- return true 601 -- handle being complete
548 --else 602
549 --if (a.isMine ~= b.isMine) then 603 else
550 -- result = a.isMine 604 self.TimeLeft:SetText(GetTimeLeftString(timeLeft))
551 --else 605 end
552 --if (not b.missionEndTime) or (not a.missionEndTime) then 606
553 -- print('missing article', b.missionEndTime, a.missionEndTime) 607 if (timeLeft > 0) and duration then
554 --end 608 local progress = (duration - timeLeft) / duration
555 if b.isComplete ~= a.isComplete then 609 local r = ((progress >= .5) and (progress/2)) or 1
556 return a.isComplete 610 local g = ((progress <= .5) and (progress*2)) or 1
557 elseif b.isMine ~= a.isMine then 611 self.ProgressBG:Show()
558 return a.isMine 612 self.ProgressBar:Show()
559 elseif b.missionEndTime then 613
560 return ( b.missionEndTime > a.missionEndTime) 614 self.ProgressBG:SetColorTexture(r,g,0,0.25)
561 else 615 self.ProgressBar:SetColorTexture(r,g,0,0.5)
562 return ( b.offerEndTime > a.offerEndTime) 616 self.ProgressBar:SetWidth(self:GetWidth() * progress)
563 end 617 end
564
565 --end
566 --end
567 end
568
569
570 function MissionList:OnShow()
571 print('|cFF00FF88'..self:GetName()..':OnShow()|r')
572 end
573
574 function ShipmentList:OnLoad()
575 C_Garrison.RequestLandingPageShipmentInfo();
576 end
577 function ShipmentList:OnShow()
578 print('|cFF00FF88'..self:GetName()..':OnShow()|r')
579 C_Garrison.RequestLandingPageShipmentInfo()
580 end 618 end
581 619
582 -- Update shipment flags data 620 -- Update shipment flags data
583 local SetActualShipmentTime = function(self) 621 local SetActualShipmentTime = function(self)
584 622
585 if self.isComplete then 623 if self.isComplete then
586 print('|cFF00FF88isComplete '..self.name..'|r') 624 return nil, nil
587 return true
588 end 625 end
589 626
590 local timestamp = time() 627 local timestamp = time()
591 local timeLeft = self.creationTime + self.duration - timestamp 628 local timeLeft = self.creationTime + self.duration - timestamp
629 local duration = self.duration * self.shipmentsTotal
592 local justFinished = false 630 local justFinished = false
593 while (self.shipmentsReady < self.shipmentsTotal) and (timeLeft <= 0) do 631 while (self.shipmentsReady < self.shipmentsTotal) and (timeLeft <= 0) do
594 if not self.originalReady then 632 if not self.originalReady then
595 self.originalReady = self.shipmentsReady 633 self.originalReady = self.shipmentsReady
596 self.originalCreationTime = self.creationTime 634 self.originalCreationTime = self.creationTime
606 if (timeLeft <= 0) and (not self.isBeingResearched) then 644 if (timeLeft <= 0) and (not self.isBeingResearched) then
607 self.isComplete = true 645 self.isComplete = true
608 self.isStale = true 646 self.isStale = true
609 end 647 end
610 648
611 return timeLeft 649
612 end 650 local expires = (self.originalCreationTime or self.creationTime) + duration
613 651
614 ShipmentList.OnGetItem = function(data) 652 return expires, duration
653 end
654
655 function ShipmentList:OnGetItem (data)
615 print('OnGetItem()') 656 print('OnGetItem()')
616 if data.shipmentsTotal then 657 if data.shipmentsTotal then
617 SetActualShipmentTime(data) 658 SetActualShipmentTime(data)
618 end 659 end
619 end 660 end
626 else 667 else
627 return (a.creationTime) < (b.creationTime) 668 return (a.creationTime) < (b.creationTime)
628 end 669 end
629 end 670 end
630 671
631 672 function ShipmentList:OnLoad()
632 function MissionEntry:OnComplete() 673 C_Garrison.RequestLandingPageShipmentInfo();
633 print('flagging complete', self.name) 674 end
634 self:Update() 675 function ShipmentList:OnShow()
635 end 676 print('|cFF00FF88'..self:GetName()..':OnShow()|r')
636 677 C_Garrison.RequestLandingPageShipmentInfo()
637 function MissionEntry:OnUpdate(sinceLast)
638 self.throttle = (self.throttle or .5) + sinceLast
639 if self.throttle < .5 then
640 return
641 else
642 self.throttle = self.throttle - .5
643 end
644 if self.offerEndTime then
645 local timeLeft = self.offerEndTime
646 self.TimeLeft:SetText(GetTimeLeftString(timeLeft))
647 self.TimeLeft:SetTextColor(1,1,1)
648 elseif self.missionEndTime then
649
650 if self.isComplete then
651 return
652 end
653 local timeLeft = self.missionEndTime - time()
654 if timeLeft < 0 then
655 self:OnComplete()
656 else
657 self.TimeLeft:SetText(GetTimeLeftString(timeLeft))
658 if timeLeft > 3600 then
659 self.TimeLeft:SetTextColor(1,1,1)
660 else
661 self.TimeLeft:SetTextColor(1,1,0)
662 end
663 end
664
665 if not self.isComplete then
666 local progress = (time() - (self.missionEndTime - self.durationSeconds)) / self.durationSeconds
667 local w = self.ProgressBG:GetWidth()
668 if progress >= 1 then
669 self.ProgressBar:SetWidth(w)
670 else
671 self.ProgressBar:SetWidth(progress * w)
672 local r, g = 1, 0
673 if progress >= 0.5 then
674 g = 1
675 r = 1-((progress-0.5)*2)
676 else
677 g = min(progress * 2, 1)
678 r = 1
679 end
680 self.ProgressBar:SetColorTexture(r,g,0,.4)
681 self.ProgressBG:SetColorTexture(r,g,0,0.125)
682 end
683 self.ProgressBG:Show()
684 self.ProgressBar:Show()
685 else
686 self.ProgressBG:Hide()
687 self.ProgressBar:Hide()
688 end
689 else
690 self.TimeLeft:SetText(self.missionEndTime)
691 end
692 end
693
694 function MissionEntry:OnLoad()
695 print('|cFFFF4400',self:GetName() or tostring(self), 'onload')
696 self.Count = self.Overlay.Count
697 self.Name = self.Overlay.Name
698 self.TimeLeft = self.Overlay.TimeLeft
699 self.Owner = self.Overlay.Owner
700
701 self.Icon:SetDesaturated(false)
702 self.Done:Hide()
703 end
704
705 function MissionEntry:Update()
706 local r,g,b = 1, 1, 1
707 if self.isRare then
708 r,g,b = 0.1, 0.4, 1
709 self.IconBorder:SetVertexColor(r, g, b, 1)
710 end
711
712 --self.missionData = data
713 self.Name:SetText(self.name)
714 if #self.rewards >= 1 then
715 self.Icon:SetTexture(self.rewards[1].icon or GetItemIcon(self.rewards[1].itemID))
716 self.rewardInfo = self.rewards[1]
717 else
718 self.Icon:SetAtlas(self.typeAtlas, false)
719 end
720
721
722
723 if self.isComplete then
724 self.TimeLeft:SetText('Complete!')
725 self.Background:SetColorTexture(.25,.25,.25,1)
726 else
727 self.Background:SetColorTexture(0,0,0,0.5)
728 end
729 end
730
731 function MissionEntry:OnEnter()
732 if self.rewardInfo and self.rewardInfo.itemID then
733 GameTooltip:SetOwner(self, 'ANCHOR_LEFT')
734 GameTooltip:SetItemByID(self.rewardInfo.itemID)
735 GameTooltip:Show()
736 end
737 end
738
739 function MissionEntry:OnLeave()
740 if GameTooltip:IsOwned(self) then
741 GameTooltip:Hide()
742 end
743 end 678 end
744 679
745 function ShipmentEntry:OnLoad() 680 function ShipmentEntry:OnLoad()
746 MissionEntry.OnLoad(self) 681 MissionEntry.OnLoad(self)
747 end 682 end
783 return 718 return
784 end 719 end
785 720
786 721
787 if (self.shipmentsReady and self.shipmentsTotal) and (self.shipmentsReady < self.shipmentsTotal) then 722 if (self.shipmentsReady and self.shipmentsTotal) and (self.shipmentsReady < self.shipmentsTotal) then
788 local timeLeft = SetActualShipmentTime(self) 723 local expires, duration = SetActualShipmentTime(self)
789 724
790 if self.isComplete then 725 if self.isComplete then
791 self.TimeLeft:SetText('Complete!') 726 self.TimeLeft:SetText('Complete!')
792 self.TimeLeft:SetTextColor(0,0.5,1) 727 self.TimeLeft:SetTextColor(0,1,1)
793 elseif self.shipmentsReady >= 1 then 728 elseif self.shipmentsReady >= 1 then
794 self.TimeLeft:SetText(GetTimeLeftString(timeLeft)) 729 self:SetTimeLeft(expires, duration)
795 self.TimeLeft:SetTextColor(0,1,0) 730 self.TimeLeft:SetTextColor(0,1,0)
796 else 731 else
797 self.TimeLeft:SetText(GetTimeLeftString(timeLeft)) 732 self:SetTimeLeft(expires, duration)
798 self.TimeLeft:SetTextColor(1,1,1) 733 self.TimeLeft:SetTextColor(1,1,1)
799 end 734 end
800 735
801 elseif self.isBeingResearched then 736 elseif self.isBeingResearched then
802 self.TimeLeft:SetText(GetTimeLeftString(self.researchStartTime + self.researchDuration - time())) 737 self:SetTimeLeft(self.researchStartTime + self.researchDuration - time(), self.researchDuration)
803 self.TimeLeft:SetTextColor(1,1,0) 738 self.TimeLeft:SetTextColor(1,1,1)
804 else 739 else
805 self.TimeLeft:SetText('Complete!') 740 self.TimeLeft:SetText('Complete!')
806 self.TimeLeft:SetTextColor(0,1,0) 741 self.TimeLeft:SetTextColor(0,1,0)
807 end 742 end
808 743
809 if not self.isComplete then
810 local progress = ((time() - self.creationTime) / self.duration)
811 local w = self.ProgressBG:GetWidth()
812 if progress >= 1 then
813 self.ProgressBar:SetWidth(w)
814 else
815 self.ProgressBar:SetWidth(progress * w)
816 end
817
818 local r, g = 1, 0
819 if progress >= 0.5 then
820 g = 1
821 r = 1-((progress-0.5)*2)
822 else
823 g = min(progress * 2, 1)
824 r = 1
825 end
826 self.ProgressBar:SetColorTexture(r, g, 0, .4)
827 self.ProgressBG:SetColorTexture(r, g, 0, .125)
828 self.ProgressBG:Show()
829 self.ProgressBar:Show()
830 else
831 self.ProgressBG:Hide()
832 self.ProgressBar:Hide()
833 end
834 end 744 end
835 745
836 function ShipmentEntry:OnEnter() 746 function ShipmentEntry:OnEnter()
837 if ( self.shipmentsReady and self.shipmentsTotal ) then 747 if ( self.shipmentsReady and self.shipmentsTotal ) then
838 GameTooltip:SetOwner(self, 'ANCHOR_LEFT') 748 GameTooltip:SetOwner(self, 'ANCHOR_LEFT')
853 if button == 'RightButton' then 763 if button == 'RightButton' then
854 self.handler:FreeBlock(self) 764 self.handler:FreeBlock(self)
855 end 765 end
856 end 766 end
857 767
768
769
770
858 ClassPlanMissionHandler = Mixin(MissionList, SharedHandlers) 771 ClassPlanMissionHandler = Mixin(MissionList, SharedHandlers)
772 ClassPlanMissionEntryMixin = Mixin(MissionEntry, SharedEntry)
859 ClassPlanShipmentHandler = Mixin(ShipmentList, SharedHandlers) 773 ClassPlanShipmentHandler = Mixin(ShipmentList, SharedHandlers)
860 ClassPlanMissionEntryMixin = Mixin(MissionEntry, SharedEntry)
861 ClassPlanShipmentEntryMixin = Mixin(ShipmentEntry,SharedEntry) 774 ClassPlanShipmentEntryMixin = Mixin(ShipmentEntry,SharedEntry)
862 775
863 ClassPlanHeaderMixin = { 776 ClassPlanHeaderMixin = {
864 OnClick = function(self) 777 OnClick = function(self)
865 self:GetParent():SetList() 778 self:GetParent():SetList()
866 self:GetParent().isStale = true 779 self:GetParent().isStale = true
867 ClassOrderPlan:Update() 780 ClassOrderPlan:Update()
868 end 781 end
869 } 782 }
783
784 ClassPlanCharacterButtonMixin = {
785 Update = function(self)
786 print(CLASS_ICON_TCOORDS[self.className:upper()])
787 if self.className and CLASS_ICON_TCOORDS[self.className:upper()] then
788 self.Icon:SetTexCoord(unpack(CLASS_ICON_TCOORDS[self.className:upper()]))
789 end
790 self.Icon:SetDesaturated(self.showItems)
791 self.SelectGlow:SetShown(self.isMine)
792 end
793 }
794
795 function ClassPlanCharacterButtonMixin:OnEnter() end
796 function ClassPlanCharacterButtonMixin:OnLeave() end
797 function ClassPlanCharacterButtonMixin:OnClick() end