Mercurial > wow > worldplan
comparison ClassPlan.lua @ 19:6016ec3c8adf v1.0-rc5
ClassPlan:
- Colored progress bars accompany the mission and shipment journal entries.
- Significant load time improvements in the order hall.
* Data events are spammed gratuitously at load-in, so any sort of operation that results should be done from a delayed enclosure. In this case: using a self-destructing C_Timer identified by the function handle, and setting a flag that frame scripts can respond to.
author | Nenue |
---|---|
date | Mon, 24 Oct 2016 18:32:00 -0400 |
parents | 08b03bcdfeac |
children | e49efad51698 |
comparison
equal
deleted
inserted
replaced
18:08b03bcdfeac | 19:6016ec3c8adf |
---|---|
92 --end | 92 --end |
93 return ( b.missionEndTime > a.missionEndTime) | 93 return ( b.missionEndTime > a.missionEndTime) |
94 --end | 94 --end |
95 --end | 95 --end |
96 end | 96 end |
97 | |
98 | 97 |
99 ShipmentsHandler.OnGetItem = function(data) | 98 ShipmentsHandler.OnGetItem = function(data) |
100 if data.shipmentsTotal then | 99 if data.shipmentsTotal then |
101 local timeLeft = data.creationTime + data.duration - GI_currentTime | 100 local timeLeft = data.creationTime + data.duration - GI_currentTime |
102 if (timeLeft <= 0) and (data.shipmentsReady < data.shipmentsTotal) then | 101 if (timeLeft <= 0) and (data.shipmentsReady < data.shipmentsTotal) then |
153 if not self.profile then | 152 if not self.profile then |
154 return | 153 return |
155 end | 154 end |
156 wipe(ShipmentsInfo) | 155 wipe(ShipmentsInfo) |
157 | 156 |
158 | |
159 local garrisonType = LE_GARRISON_TYPE_7_0 | 157 local garrisonType = LE_GARRISON_TYPE_7_0 |
160 local buildings = C_Garrison.GetBuildings(garrisonType); | 158 local buildings = C_Garrison.GetBuildings(garrisonType); |
161 local shipmentIndex = 0 | 159 local shipmentIndex = 0 |
162 --print('Buildings:') | 160 --print('Buildings:') |
163 for i = 1, #buildings do | 161 for i = 1, #buildings do |
199 for index, data in ipairs(ShipmentsInfo) do | 197 for index, data in ipairs(ShipmentsInfo) do |
200 --DEFAULT_CHAT_FRAME:AddMessage(data.shipmentType ..' '.. tostring(data.name) ..' '.. tostring(data.creationTime) ..' '.. tostring(data.duration)) | 198 --DEFAULT_CHAT_FRAME:AddMessage(data.shipmentType ..' '.. tostring(data.name) ..' '.. tostring(data.creationTime) ..' '.. tostring(data.duration)) |
201 tinsert(self.profile.shipments, data) | 199 tinsert(self.profile.shipments, data) |
202 end | 200 end |
203 self.isStale = true | 201 self.isStale = true |
204 | |
205 end | 202 end |
206 | 203 |
207 function core:OnLoad () | 204 function core:OnLoad () |
208 self:RegisterEvent('PLAYER_LOGIN') | 205 self:RegisterEvent('PLAYER_LOGIN') |
209 self:RegisterEvent('ADDON_LOADED') | 206 self:RegisterEvent('ADDON_LOADED') |
210 self:RegisterEvent('PLAYER_REGEN_ENABLED') | 207 self:RegisterEvent('PLAYER_REGEN_ENABLED') |
211 self:RegisterEvent('PLAYER_REGEN_DISABLED') | 208 self:RegisterEvent('PLAYER_REGEN_DISABLED') |
212 -- Blizzard_GarrisonUI already fires a shipment data request for GARRISON_SHIPMENT_RECEIVED; this is unlikely to | 209 -- Blizzard_GarrisonUI already fires a shipment data request for GARRISON_SHIPMENT_RECEIVED; this is unlikely to |
213 | |
214 | |
215 self:AddHandler('missions', MissionsHandler) | 210 self:AddHandler('missions', MissionsHandler) |
216 self:AddHandler('shipments', ShipmentsHandler) | 211 self:AddHandler('shipments', ShipmentsHandler) |
217 | |
218 | |
219 self:Reanchor() | 212 self:Reanchor() |
220 end | 213 end |
214 | |
221 local parentFrames = {'VeneerWorldState', 'OrderHallCommandBar'} | 215 local parentFrames = {'VeneerWorldState', 'OrderHallCommandBar'} |
222 function core:Reanchor() | 216 function core:Reanchor() |
223 | |
224 | |
225 self:ClearAllPoints() | 217 self:ClearAllPoints() |
226 | 218 self.anchorParent = UIParent |
227 local anchorTo = 'TOP' | 219 local anchorTo = 'TOP' |
228 self.anchorParent = UIParent | |
229 for i, name in ipairs(parentFrames) do | 220 for i, name in ipairs(parentFrames) do |
230 local frame = _G[name] | 221 local frame = _G[name] |
231 if frame then | 222 if frame then |
232 if not BOUND_FRAMES[frame] then | 223 if not BOUND_FRAMES[frame] then |
233 BOUND_FRAMES[frame] = {visible = (frame:IsVisible() and frame:IsShown())} | 224 BOUND_FRAMES[frame] = {visible = (frame:IsVisible() and frame:IsShown())} |
360 --if realm ~= GI_currentRealm then | 351 --if realm ~= GI_currentRealm then |
361 --ownerText = ownerText .. ' (' .. realm .. ')' | 352 --ownerText = ownerText .. ' (' .. realm .. ')' |
362 --end | 353 --end |
363 self.Owner:SetText(ownerText) | 354 self.Owner:SetText(ownerText) |
364 self.Name:SetTextColor(data.classColor.r, data.classColor.g, data.classColor.b) | 355 self.Name:SetTextColor(data.classColor.r, data.classColor.g, data.classColor.b) |
365 | |
366 | |
367 end | 356 end |
368 | 357 |
369 function core:RefreshItems(configKey, prototype) | 358 function core:RefreshItems(configKey, prototype) |
370 local sortedItems = self.sortedItems[configKey] | 359 local sortedItems = self.sortedItems[configKey] |
371 | 360 |
452 | 441 |
453 if self.isStale then | 442 if self.isStale then |
454 print('updating items on show') | 443 print('updating items on show') |
455 self:Refresh() | 444 self:Refresh() |
456 end | 445 end |
457 | |
458 end | 446 end |
459 | 447 |
460 function core:OnShow() | 448 function core:OnShow() |
461 if self.isStale then | 449 if self.isStale then |
462 print('updating items on show') | 450 print('updating items on show') |
528 self.throttle = self.throttle - .5 | 516 self.throttle = self.throttle - .5 |
529 else | 517 else |
530 return | 518 return |
531 end | 519 end |
532 | 520 |
533 | |
534 if self.missionEndTime then | 521 if self.missionEndTime then |
535 local timeLeft = self.missionEndTime - time() | 522 local timeLeft = self.missionEndTime - time() |
536 if timeLeft < 0 then | 523 if timeLeft < 0 then |
537 self:OnComplete() | 524 self:OnComplete() |
538 else | 525 else |
539 self.TimeLeft:SetText(GetTimeLeftString(timeLeft)) | 526 self.TimeLeft:SetText(GetTimeLeftString(timeLeft)) |
540 | |
541 if timeLeft > 3600 then | 527 if timeLeft > 3600 then |
542 self.TimeLeft:SetTextColor(1,1,1) | 528 self.TimeLeft:SetTextColor(1,1,1) |
543 else | 529 else |
544 self.TimeLeft:SetTextColor(1,1,0) | 530 self.TimeLeft:SetTextColor(1,1,0) |
545 end | 531 end |
550 local w = self.ProgressBG:GetWidth() | 536 local w = self.ProgressBG:GetWidth() |
551 if progress >= 1 then | 537 if progress >= 1 then |
552 self.ProgressBar:SetWidth(w) | 538 self.ProgressBar:SetWidth(w) |
553 else | 539 else |
554 self.ProgressBar:SetWidth(progress * w) | 540 self.ProgressBar:SetWidth(progress * w) |
555 | |
556 local r, g = 1, 0 | 541 local r, g = 1, 0 |
557 if progress >= 0.5 then | 542 if progress >= 0.5 then |
558 g = 1 | 543 g = 1 |
559 r = 1-((progress-0.5)*2) | 544 r = 1-((progress-0.5)*2) |
560 else | 545 else |
562 r = 1 | 547 r = 1 |
563 end | 548 end |
564 self.ProgressBar:SetColorTexture(r,g,0,1) | 549 self.ProgressBar:SetColorTexture(r,g,0,1) |
565 self.ProgressBG:SetColorTexture(r,g,0,0.125) | 550 self.ProgressBG:SetColorTexture(r,g,0,0.125) |
566 end | 551 end |
567 | |
568 self.ProgressBG:Show() | 552 self.ProgressBG:Show() |
569 self.ProgressBar:Show() | 553 self.ProgressBar:Show() |
570 else | 554 else |
571 self.ProgressBG:Hide() | 555 self.ProgressBG:Hide() |
572 self.ProgressBar:Hide() | 556 self.ProgressBar:Hide() |
573 end | 557 end |
574 | |
575 else | 558 else |
576 self.TimeLeft:SetText(self.missionEndTime) | 559 self.TimeLeft:SetText(self.missionEndTime) |
577 end | 560 end |
578 end | 561 end |
579 | 562 |
580 function MissionsHandler:Refresh() | 563 function MissionsHandler:Refresh() |
581 | |
582 | |
583 local r,g,b = 1, 1, 1 | 564 local r,g,b = 1, 1, 1 |
584 if self.isRare then | 565 if self.isRare then |
585 r,g,b = 0.1, 0.4, 1 | 566 r,g,b = 0.1, 0.4, 1 |
586 self.IconBorder:SetVertexColor(r, g, b, 1) | 567 self.IconBorder:SetVertexColor(r, g, b, 1) |
587 end | 568 end |
588 | 569 |
589 | |
590 --self.missionData = data | 570 --self.missionData = data |
591 self.Name:SetText(self.name) | 571 self.Name:SetText(self.name) |
592 | |
593 if #self.rewards >= 1 then | 572 if #self.rewards >= 1 then |
594 self.Icon:SetTexture(self.rewards[1].icon or GetItemIcon(self.rewards[1].itemID)) | 573 self.Icon:SetTexture(self.rewards[1].icon or GetItemIcon(self.rewards[1].itemID)) |
595 self.rewardInfo = self.rewards[1] | 574 self.rewardInfo = self.rewards[1] |
596 else | 575 else |
597 self.Icon:SetAtlas(self.typeAtlas, false) | 576 self.Icon:SetAtlas(self.typeAtlas, false) |
601 self.Done:Show() | 580 self.Done:Show() |
602 else | 581 else |
603 self.Done:Hide() | 582 self.Done:Hide() |
604 end | 583 end |
605 | 584 |
606 | |
607 if self.isComplete then | 585 if self.isComplete then |
608 self.TimeLeft:SetText('Complete!') | 586 self.TimeLeft:SetText('Complete!') |
609 self.Background:SetColorTexture(.25,.25,.25,1) | 587 self.Background:SetColorTexture(.25,.25,.25,1) |
610 else | 588 else |
611 self.Background:SetColorTexture(0,0,0,0.5) | 589 self.Background:SetColorTexture(0,0,0,0.5) |
612 end | 590 end |
613 | 591 end |
614 end | |
615 | |
616 | 592 |
617 function MissionsHandler:OnEnter() | 593 function MissionsHandler:OnEnter() |
618 if self.rewardInfo and self.rewardInfo.itemID then | 594 if self.rewardInfo and self.rewardInfo.itemID then |
619 GameTooltip:SetOwner(self, 'ANCHOR_LEFT') | 595 GameTooltip:SetOwner(self, 'ANCHOR_LEFT') |
620 GameTooltip:SetItemByID(self.rewardInfo.itemID) | 596 GameTooltip:SetItemByID(self.rewardInfo.itemID) |
621 GameTooltip:Show() | 597 GameTooltip:Show() |
622 end | 598 end |
623 end | 599 end |
600 | |
624 function MissionsHandler:OnLeave() | 601 function MissionsHandler:OnLeave() |
625 if GameTooltip:IsOwned(self) then | 602 if GameTooltip:IsOwned(self) then |
626 GameTooltip:Hide() | 603 GameTooltip:Hide() |
627 end | 604 end |
628 end | 605 end |
629 | 606 |
630 | |
631 | |
632 function ShipmentsHandler:Refresh() | 607 function ShipmentsHandler:Refresh() |
633 | |
634 --[[ | 608 --[[ |
635 self.icon = data.icon | 609 self.icon = data.icon |
636 self.shipmentCapacity = data.shipmentCapacity | 610 self.shipmentCapacity = data.shipmentCapacity |
637 self.shipmentsReady = data.shipmentsReady | 611 self.shipmentsReady = data.shipmentsReady |
638 self.shipmentsTotal = data.shipmentsTotal | 612 self.shipmentsTotal = data.shipmentsTotal |
651 itemIcon = itemIcon, | 625 itemIcon = itemIcon, |
652 itemQuality = itemQuality, | 626 itemQuality = itemQuality, |
653 itemID = itemID | 627 itemID = itemID |
654 | 628 |
655 --]] | 629 --]] |
656 | |
657 self.Icon:SetTexture(self.icon) | 630 self.Icon:SetTexture(self.icon) |
658 | |
659 self.Name:SetText(self.name) | 631 self.Name:SetText(self.name) |
660 self.Count:SetText(self.shipmentsReady) | 632 self.Count:SetText(self.shipmentsReady) |
661 self.Done:SetShown(self.shipmentsReady and (self.shipmentsReady >= 1)) | 633 self.Done:SetShown(self.shipmentsReady and (self.shipmentsReady >= 1)) |
662 | |
663 | 634 |
664 -- flag as complete | 635 -- flag as complete |
665 if ( self.shipmentsReady >= self.shipmentsTotal ) and (not self.isBeingResearched) then | 636 if ( self.shipmentsReady >= self.shipmentsTotal ) and (not self.isBeingResearched) then |
666 self.Swipe:SetCooldownUNIX(0, 0); | 637 self.Swipe:SetCooldownUNIX(0, 0); |
667 self.Done:Show(); | 638 self.Done:Show(); |
676 elseif (self.shipmentsReady and (self.shipmentsReady > 0)) then | 647 elseif (self.shipmentsReady and (self.shipmentsReady > 0)) then |
677 self.Background:SetColorTexture(0.5,0.5,0.5,.5) | 648 self.Background:SetColorTexture(0.5,0.5,0.5,.5) |
678 else | 649 else |
679 self.Background:SetColorTexture(0,0,0,0.5) | 650 self.Background:SetColorTexture(0,0,0,0.5) |
680 end | 651 end |
681 | 652 end |
682 end | 653 |
683 local time = time | 654 local time = time |
684 function ShipmentsHandler:OnUpdate(sinceLast) | 655 function ShipmentsHandler:OnUpdate(sinceLast) |
685 self.throttle = (self.throttle or 1) + sinceLast | 656 self.throttle = (self.throttle or 1) + sinceLast |
686 if self.throttle >= 1 then | 657 if self.throttle >= 1 then |
687 self.throttle = self.throttle - 1 | 658 self.throttle = self.throttle - 1 |
703 self.shipmentsReady = self.shipmentsReady + 1 | 674 self.shipmentsReady = self.shipmentsReady + 1 |
704 self.creationTime = self.creationTime + self.duration | 675 self.creationTime = self.creationTime + self.duration |
705 -- text will be set on next update | 676 -- text will be set on next update |
706 end | 677 end |
707 end | 678 end |
708 | |
709 elseif self.isBeingResearched then | 679 elseif self.isBeingResearched then |
710 self.TimeLeft:SetText(GetTimeLeftString(self.researchStartTime + self.researchDuration - time())) | 680 self.TimeLeft:SetText(GetTimeLeftString(self.researchStartTime + self.researchDuration - time())) |
711 self.TimeLeft:SetTextColor(1,1,0) | 681 self.TimeLeft:SetTextColor(1,1,0) |
712 else | 682 else |
713 self.TimeLeft:SetText('Complete!') | 683 self.TimeLeft:SetText('Complete!') |
714 self.TimeLeft:SetTextColor(0,1,0) | 684 self.TimeLeft:SetTextColor(0,1,0) |
715 end | 685 end |
716 | |
717 | 686 |
718 if not self.isComplete then | 687 if not self.isComplete then |
719 local progress = ((time() - self.creationTime) / self.duration) | 688 local progress = ((time() - self.creationTime) / self.duration) |
720 local w = self.ProgressBG:GetWidth() | 689 local w = self.ProgressBG:GetWidth() |
721 if progress >= 1 then | 690 if progress >= 1 then |
730 r = 1-((progress-0.5)*2) | 699 r = 1-((progress-0.5)*2) |
731 else | 700 else |
732 g = min(progress * 2, 1) | 701 g = min(progress * 2, 1) |
733 r = 1 | 702 r = 1 |
734 end | 703 end |
735 | |
736 self.ProgressBar:SetColorTexture(r, g, 0, 1) | 704 self.ProgressBar:SetColorTexture(r, g, 0, 1) |
737 self.ProgressBG:SetColorTexture(r, g, 0, .125) | 705 self.ProgressBG:SetColorTexture(r, g, 0, .125) |
738 self.ProgressBG:Show() | 706 self.ProgressBG:Show() |
739 self.ProgressBar:Show() | 707 self.ProgressBar:Show() |
740 else | 708 else |
741 self.ProgressBG:Hide() | 709 self.ProgressBG:Hide() |
742 self.ProgressBar:Hide() | 710 self.ProgressBar:Hide() |
743 end | 711 end |
744 | |
745 end | 712 end |
746 | 713 |
747 function ShipmentsHandler:OnEnter() | 714 function ShipmentsHandler:OnEnter() |
748 | |
749 if ( self.shipmentsReady and self.shipmentsTotal ) then | 715 if ( self.shipmentsReady and self.shipmentsTotal ) then |
750 GameTooltip:SetOwner(self, 'ANCHOR_LEFT') | 716 GameTooltip:SetOwner(self, 'ANCHOR_LEFT') |
751 | |
752 GameTooltip:AddLine(self.Owner:GetText(), self.Owner:GetTextColor()) | 717 GameTooltip:AddLine(self.Owner:GetText(), self.Owner:GetTextColor()) |
753 GameTooltip:AddLine(self.shipmentType) | 718 GameTooltip:AddLine(self.shipmentType) |
754 GameTooltip:AddLine(self.shipmentsReady .. ' of '.. self.shipmentsTotal) | 719 GameTooltip:AddLine(self.shipmentsReady .. ' of '.. self.shipmentsTotal) |
755 GameTooltip:Show() | 720 GameTooltip:Show() |
756 end | 721 end |