Mercurial > wow > worldplan
comparison ClassPlan.lua @ 18:08b03bcdfeac
ClassPlan:
- 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:23:06 -0400 |
parents | a2b623043970 |
children | 6016ec3c8adf |
comparison
equal
deleted
inserted
replaced
17:594692f36b5b | 18:08b03bcdfeac |
---|---|
22 blocks = {}, | 22 blocks = {}, |
23 sortedItems = {}, | 23 sortedItems = {}, |
24 timers = {}, | 24 timers = {}, |
25 shipments = {}, | 25 shipments = {}, |
26 playerFirst = false, | 26 playerFirst = false, |
27 prototypes = {} | 27 prototypes = {}, |
28 Queued = {} | |
28 } | 29 } |
29 | 30 |
30 ClassPlanMissionMixin = { | 31 ClassPlanMissionMixin = { |
31 templateName = 'ClassPlanMissionEntry', | 32 templateName = 'ClassPlanMissionEntry', |
32 events = {'GARRISON_MISSION_LIST_UPDATE', 'GARRISON_MISSION_STARTED', 'GARRISON_MISSION_FINISHED', 'GARRISON_LANDINGPAGE_SHIPMENTS'},} | 33 events = {'GARRISON_MISSION_LIST_UPDATE', 'GARRISON_MISSION_STARTED', 'GARRISON_MISSION_FINISHED', 'GARRISON_LANDINGPAGE_SHIPMENTS'},} |
311 end | 312 end |
312 self.initialized = true | 313 self.initialized = true |
313 end | 314 end |
314 end | 315 end |
315 | 316 |
317 local last_invoc = {} | |
316 function core:OnEvent (event, ...) | 318 function core:OnEvent (event, ...) |
317 print(event) | 319 print(event) |
318 if event == 'PLAYER_REGEN_DISABLED' then | 320 if event == 'PLAYER_REGEN_DISABLED' then |
319 if self:IsVisible() then | 321 if self:IsVisible() then |
320 self.combatHide = true | 322 self.combatHide = true |
329 elseif event == 'PLAYER_LOGIN' then | 331 elseif event == 'PLAYER_LOGIN' then |
330 if not self.initialized then | 332 if not self.initialized then |
331 self:Setup() | 333 self:Setup() |
332 end | 334 end |
333 elseif self.initialized and self.events[event] then | 335 elseif self.initialized and self.events[event] then |
334 local numCalls = 0 | 336 self.isStale = true |
335 for ptype, eventFunc in pairs(self.events[event]) do | |
336 numCalls = numCalls + 1 | |
337 print('|cFF88FF00' .. tostring(ptype) .. '|r:GetPlayerData() --', numCalls) | |
338 eventFunc(self, event) | |
339 end | |
340 | |
341 | |
342 if self:IsVisible() then | 337 if self:IsVisible() then |
343 self:Refresh() | 338 |
339 else | |
340 for handler, func in pairs(self.events[event]) do | |
341 if not self.Queued[handler] then | |
342 print('scheduling update for handler', handler) | |
343 self.Queued[handler] = C_Timer.NewTimer(0.25, function() | |
344 func(handler) | |
345 self.Queued[handler] = nil | |
346 end) | |
347 end | |
348 end | |
344 end | 349 end |
345 end | 350 end |
346 end | 351 end |
347 | 352 |
348 function core:UpdateNotifications() | 353 function core:UpdateNotifications() |
356 --ownerText = ownerText .. ' (' .. realm .. ')' | 361 --ownerText = ownerText .. ' (' .. realm .. ')' |
357 --end | 362 --end |
358 self.Owner:SetText(ownerText) | 363 self.Owner:SetText(ownerText) |
359 self.Name:SetTextColor(data.classColor.r, data.classColor.g, data.classColor.b) | 364 self.Name:SetTextColor(data.classColor.r, data.classColor.g, data.classColor.b) |
360 | 365 |
361 if self.isComplete then | |
362 self.TimeLeft:SetText('Complete!') | |
363 self.Background:SetColorTexture(.25,.25,.25,1) | |
364 else | |
365 self.Background:SetColorTexture(0,0,0,0.5) | |
366 end | |
367 | 366 |
368 end | 367 end |
369 | 368 |
370 function core:RefreshItems(configKey, prototype) | 369 function core:RefreshItems(configKey, prototype) |
371 local sortedItems = self.sortedItems[configKey] | 370 local sortedItems = self.sortedItems[configKey] |
448 | 447 |
449 function core:OnUpdate() | 448 function core:OnUpdate() |
450 if self.fadeTimer and self.fadeTimer < GetTime() then | 449 if self.fadeTimer and self.fadeTimer < GetTime() then |
451 self:Hide() | 450 self:Hide() |
452 end | 451 end |
452 | |
453 if self.isStale then | |
454 print('updating items on show') | |
455 self:Refresh() | |
456 end | |
457 | |
453 end | 458 end |
454 | 459 |
455 function core:OnShow() | 460 function core:OnShow() |
456 if self.isStale then | 461 if self.isStale then |
457 print('updating items on show') | 462 print('updating items on show') |
539 self.TimeLeft:SetTextColor(1,1,0) | 544 self.TimeLeft:SetTextColor(1,1,0) |
540 end | 545 end |
541 end | 546 end |
542 | 547 |
543 if not self.isComplete then | 548 if not self.isComplete then |
544 local progress = (self.missionEndTime - time()) / self.durationSeconds | 549 local progress = (time() - (self.missionEndTime - self.durationSeconds)) / self.durationSeconds |
545 local w = self.ProgressBG:GetWidth() | 550 local w = self.ProgressBG:GetWidth() |
546 if progress >= 1 then | 551 if progress >= 1 then |
547 self.ProgressBar:SetWidth(w) | 552 self.ProgressBar:SetWidth(w) |
548 else | 553 else |
549 self.ProgressBar:SetWidth(w - (progress * w)) | 554 self.ProgressBar:SetWidth(progress * w) |
555 | |
556 local r, g = 1, 0 | |
557 if progress >= 0.5 then | |
558 g = 1 | |
559 r = 1-((progress-0.5)*2) | |
560 else | |
561 g = min(progress * 2, 1) | |
562 r = 1 | |
563 end | |
564 self.ProgressBar:SetColorTexture(r,g,0,1) | |
565 self.ProgressBG:SetColorTexture(r,g,0,0.125) | |
550 end | 566 end |
551 | 567 |
552 self.ProgressBG:Show() | 568 self.ProgressBG:Show() |
553 self.ProgressBar:Show() | 569 self.ProgressBar:Show() |
554 else | 570 else |
583 | 599 |
584 if self.isComplete then | 600 if self.isComplete then |
585 self.Done:Show() | 601 self.Done:Show() |
586 else | 602 else |
587 self.Done:Hide() | 603 self.Done:Hide() |
604 end | |
605 | |
606 | |
607 if self.isComplete then | |
608 self.TimeLeft:SetText('Complete!') | |
609 self.Background:SetColorTexture(.25,.25,.25,1) | |
610 else | |
611 self.Background:SetColorTexture(0,0,0,0.5) | |
588 end | 612 end |
589 | 613 |
590 end | 614 end |
591 | 615 |
592 | 616 |
644 self.isComplete = true | 668 self.isComplete = true |
645 else | 669 else |
646 self.Swipe:SetCooldownUNIX(self.creationTime or 0 , self.duration or 0); | 670 self.Swipe:SetCooldownUNIX(self.creationTime or 0 , self.duration or 0); |
647 end | 671 end |
648 | 672 |
649 local hasPickups = (self.isComplete or (self.shipmentsTotal and (self.shipmentsReady > 0))) | 673 if self.isComplete then |
650 self.Background:SetAlpha(hasPickups and 1 or 0.1) | 674 self.TimeLeft:SetText('Complete!') |
675 self.Background:SetColorTexture(0.5,0.5,0.5) | |
676 elseif (self.shipmentsReady and (self.shipmentsReady > 0)) then | |
677 self.Background:SetColorTexture(0.5,0.5,0.5,.5) | |
678 else | |
679 self.Background:SetColorTexture(0,0,0,0.5) | |
680 end | |
681 | |
651 end | 682 end |
652 local time = time | 683 local time = time |
653 function ShipmentsHandler:OnUpdate() | 684 function ShipmentsHandler:OnUpdate(sinceLast) |
685 self.throttle = (self.throttle or 1) + sinceLast | |
686 if self.throttle >= 1 then | |
687 self.throttle = self.throttle - 1 | |
688 else | |
689 return | |
690 end | |
654 | 691 |
655 if (self.shipmentsReady and self.shipmentsTotal) and (self.shipmentsReady < self.shipmentsTotal) then | 692 if (self.shipmentsReady and self.shipmentsTotal) and (self.shipmentsReady < self.shipmentsTotal) then |
656 local timeLeft = self.creationTime + self.duration - time() | 693 local timeLeft = self.creationTime + self.duration - time() |
657 if self.shipmentsReady >= 1 then | 694 if self.shipmentsReady >= 1 then |
658 self.TimeLeft:SetText(GetTimeLeftString(timeLeft)) | 695 self.TimeLeft:SetText(GetTimeLeftString(timeLeft)) |
675 else | 712 else |
676 self.TimeLeft:SetText('Complete!') | 713 self.TimeLeft:SetText('Complete!') |
677 self.TimeLeft:SetTextColor(0,1,0) | 714 self.TimeLeft:SetTextColor(0,1,0) |
678 end | 715 end |
679 | 716 |
717 | |
718 if not self.isComplete then | |
719 local progress = ((time() - self.creationTime) / self.duration) | |
720 local w = self.ProgressBG:GetWidth() | |
721 if progress >= 1 then | |
722 self.ProgressBar:SetWidth(w) | |
723 else | |
724 self.ProgressBar:SetWidth(progress * w) | |
725 end | |
726 | |
727 local r, g = 1, 0 | |
728 if progress >= 0.5 then | |
729 g = 1 | |
730 r = 1-((progress-0.5)*2) | |
731 else | |
732 g = min(progress * 2, 1) | |
733 r = 1 | |
734 end | |
735 | |
736 self.ProgressBar:SetColorTexture(r, g, 0, 1) | |
737 self.ProgressBG:SetColorTexture(r, g, 0, .125) | |
738 self.ProgressBG:Show() | |
739 self.ProgressBar:Show() | |
740 else | |
741 self.ProgressBG:Hide() | |
742 self.ProgressBar:Hide() | |
743 end | |
744 | |
680 end | 745 end |
681 | 746 |
682 function ShipmentsHandler:OnEnter() | 747 function ShipmentsHandler:OnEnter() |
683 | 748 |
684 if ( self.shipmentsReady and self.shipmentsTotal ) then | 749 if ( self.shipmentsReady and self.shipmentsTotal ) then |