Mercurial > wow > worldplan
changeset 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 | 594692f36b5b |
children | 6016ec3c8adf |
files | ClassPlan.lua ClassPlan.xml WorldPlan.lua |
diffstat | 3 files changed, 96 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/ClassPlan.lua Mon Oct 24 06:00:21 2016 -0400 +++ b/ClassPlan.lua Mon Oct 24 18:23:06 2016 -0400 @@ -24,7 +24,8 @@ timers = {}, shipments = {}, playerFirst = false, - prototypes = {} + prototypes = {}, + Queued = {} } ClassPlanMissionMixin = { @@ -313,6 +314,7 @@ end end +local last_invoc = {} function core:OnEvent (event, ...) print(event) if event == 'PLAYER_REGEN_DISABLED' then @@ -331,16 +333,19 @@ self:Setup() end elseif self.initialized and self.events[event] then - local numCalls = 0 - for ptype, eventFunc in pairs(self.events[event]) do - numCalls = numCalls + 1 - print('|cFF88FF00' .. tostring(ptype) .. '|r:GetPlayerData() --', numCalls) - eventFunc(self, event) - end + self.isStale = true + if self:IsVisible() then - - if self:IsVisible() then - self:Refresh() + else + for handler, func in pairs(self.events[event]) do + if not self.Queued[handler] then + print('scheduling update for handler', handler) + self.Queued[handler] = C_Timer.NewTimer(0.25, function() + func(handler) + self.Queued[handler] = nil + end) + end + end end end end @@ -358,12 +363,6 @@ self.Owner:SetText(ownerText) self.Name:SetTextColor(data.classColor.r, data.classColor.g, data.classColor.b) - if self.isComplete then - self.TimeLeft:SetText('Complete!') - self.Background:SetColorTexture(.25,.25,.25,1) - else - self.Background:SetColorTexture(0,0,0,0.5) - end end @@ -450,6 +449,12 @@ if self.fadeTimer and self.fadeTimer < GetTime() then self:Hide() end + + if self.isStale then + print('updating items on show') + self:Refresh() + end + end function core:OnShow() @@ -541,12 +546,23 @@ end if not self.isComplete then - local progress = (self.missionEndTime - time()) / self.durationSeconds + local progress = (time() - (self.missionEndTime - self.durationSeconds)) / self.durationSeconds local w = self.ProgressBG:GetWidth() if progress >= 1 then self.ProgressBar:SetWidth(w) else - self.ProgressBar:SetWidth(w - (progress * w)) + self.ProgressBar:SetWidth(progress * w) + + local r, g = 1, 0 + if progress >= 0.5 then + g = 1 + r = 1-((progress-0.5)*2) + else + g = min(progress * 2, 1) + r = 1 + end + self.ProgressBar:SetColorTexture(r,g,0,1) + self.ProgressBG:SetColorTexture(r,g,0,0.125) end self.ProgressBG:Show() @@ -587,6 +603,14 @@ self.Done:Hide() end + + if self.isComplete then + self.TimeLeft:SetText('Complete!') + self.Background:SetColorTexture(.25,.25,.25,1) + else + self.Background:SetColorTexture(0,0,0,0.5) + end + end @@ -646,11 +670,24 @@ self.Swipe:SetCooldownUNIX(self.creationTime or 0 , self.duration or 0); end - local hasPickups = (self.isComplete or (self.shipmentsTotal and (self.shipmentsReady > 0))) - self.Background:SetAlpha(hasPickups and 1 or 0.1) + if self.isComplete then + self.TimeLeft:SetText('Complete!') + self.Background:SetColorTexture(0.5,0.5,0.5) + elseif (self.shipmentsReady and (self.shipmentsReady > 0)) then + self.Background:SetColorTexture(0.5,0.5,0.5,.5) + else + self.Background:SetColorTexture(0,0,0,0.5) + end + end local time = time -function ShipmentsHandler:OnUpdate() +function ShipmentsHandler:OnUpdate(sinceLast) + self.throttle = (self.throttle or 1) + sinceLast + if self.throttle >= 1 then + self.throttle = self.throttle - 1 + else + return + end if (self.shipmentsReady and self.shipmentsTotal) and (self.shipmentsReady < self.shipmentsTotal) then local timeLeft = self.creationTime + self.duration - time() @@ -677,6 +714,34 @@ self.TimeLeft:SetTextColor(0,1,0) end + + if not self.isComplete then + local progress = ((time() - self.creationTime) / self.duration) + local w = self.ProgressBG:GetWidth() + if progress >= 1 then + self.ProgressBar:SetWidth(w) + else + self.ProgressBar:SetWidth(progress * w) + end + + local r, g = 1, 0 + if progress >= 0.5 then + g = 1 + r = 1-((progress-0.5)*2) + else + g = min(progress * 2, 1) + r = 1 + end + + self.ProgressBar:SetColorTexture(r, g, 0, 1) + self.ProgressBG:SetColorTexture(r, g, 0, .125) + self.ProgressBG:Show() + self.ProgressBar:Show() + else + self.ProgressBG:Hide() + self.ProgressBar:Hide() + end + end function ShipmentsHandler:OnEnter()
--- a/ClassPlan.xml Mon Oct 24 06:00:21 2016 -0400 +++ b/ClassPlan.xml Mon Oct 24 18:23:06 2016 -0400 @@ -58,6 +58,7 @@ <OnEvent method="OnEvent" /> <OnShow method="OnShow" /> <OnHide method="OnHide" /> + <OnUpdate method="OnUpdate" /> </Scripts> <Layers> <Layer level="BACKGROUND"> @@ -123,7 +124,7 @@ </Anchors> </Texture> <Texture parentKey="ProgressBar" hidden="true"> - <Size y="1" /> + <Size y="2" /> <Anchors> <Anchor point="BOTTOMLEFT" relativeKey="$parent.ProgressBG" /> </Anchors>
--- a/WorldPlan.lua Mon Oct 24 06:00:21 2016 -0400 +++ b/WorldPlan.lua Mon Oct 24 18:23:06 2016 -0400 @@ -378,7 +378,15 @@ self.db.WorldQuests = self.db.WorldQuests or {} db = self.db for k,v in pairs(defaults) do + --[===[@non-debug@ + if not db[k] then + db[k] = v + end + + --@end-non-debug@]===] + --@debug@ db[k] = v + --@end-debug@ end self.currentMapID = GetCurrentMapAreaID()