diff --git a/CHANGELOG.md b/CHANGELOG.md index 7535d1ac..5b9b5353 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # CHANGELOG +## Version 90100.01 + +- Added 9.1.0 support; +- Further fading optimisation. + ## Version 90005.05 - Optimised fading a bit more; diff --git a/core/border.lua b/core/border.lua index 4ad905a2..8d5d2c7d 100644 --- a/core/border.lua +++ b/core/border.lua @@ -97,7 +97,7 @@ function border_proto:SetAlpha(a) end end -function border_proto:IsObjectType(_, t) +function border_proto:IsObjectType(t) return t == "Border" end diff --git a/core/cooldown.lua b/core/cooldown.lua index 86e06d14..c0e9ea6e 100644 --- a/core/cooldown.lua +++ b/core/cooldown.lua @@ -31,7 +31,7 @@ local defaults = { }, } -local updater = CreateFrame("Frame") +local updater = CreateFrame("Frame", "LSCooldownUpdater") local updateTime = 0 local time1, time2, format, color diff --git a/core/core.lua b/core/core.lua index dfdd33d1..af09f634 100644 --- a/core/core.lua +++ b/core/core.lua @@ -33,7 +33,7 @@ do local oneTimeEvents = {ADDON_LOADED = false, PLAYER_LOGIN = false} local registeredEvents = {} - local dispatcher = CreateFrame("Frame") + local dispatcher = CreateFrame("Frame", "LSEventFrame") dispatcher:SetScript("OnEvent", function(_, event, ...) for func in pairs(registeredEvents[event]) do func(...) @@ -76,32 +76,16 @@ end ------------ do - -- not sure about this implementation just yet, but I'll try using it for - -- profiling later on - local registry = { - -- [obj] = {["method"] = func,}, - } - function P:Mixin(obj, ...) - registry[obj] = {} - for i = 1, select("#", ...) do local mixin = select(i, ...) for k, v in next, mixin do - if type(v) == "function" then - registry[obj][k] = v - end - obj[k] = v end end return obj end - - function P:GetMixedInRegistry() - return registry - end end ------------ diff --git a/core/fading.lua b/core/fading.lua index 11e1e805..50b2c6a4 100644 --- a/core/fading.lua +++ b/core/fading.lua @@ -12,35 +12,6 @@ local FADE_OUT = -1 local widgets = {} local miscWidgets = {} -local activeWidgets = {} - -local function addActiveWidget(object, widget, mode) - widget.mode = mode - widget.fadeTimer = mode == FADE_OUT and -widget.config.out_delay or 0 - widget.initAlpha = nil - activeWidgets[object] = widget -end - -local function removeActiveWidget(object, widget, atMinAlpha, atMaxAlpha) - widget.mode = nil - widget.atMaxAlpha = atMaxAlpha - widget.atMinAlpha = atMinAlpha - widget.isFading = nil - activeWidgets[object] = nil -end - -local hoverWidgets = {} - -local function addHoverWidget(object, widget) - widget.canHover = true - hoverWidgets[object] = widget -end - -local function removeHoverWidget(object, widget) - widget.canHover = false - hoverWidgets[object] = nil -end - local targetWidgets = {} local function addTargetWidget(object, widget) @@ -65,9 +36,12 @@ local function removeCombatWidget(object, widget) combatWidgets[object] = nil end -local updater = CreateFrame("Frame") +local activeWidgets = {} +local addActiveWidget, removeActiveWidget + +local updater = CreateFrame("Frame", "LSFadingUpdater") -updater:SetScript("OnUpdate", function(_, elapsed) +local function updater_OnUpdate(_, elapsed) for object, widget in next, activeWidgets do widget.fadeTimer = widget.fadeTimer + elapsed widget.initAlpha = widget.initAlpha or object:GetAlpha() @@ -118,7 +92,30 @@ updater:SetScript("OnUpdate", function(_, elapsed) end end end -end) +end + +function addActiveWidget(object, widget, mode) + widget.mode = mode + widget.fadeTimer = mode == FADE_OUT and -widget.config.out_delay or 0 + widget.initAlpha = nil + activeWidgets[object] = widget + + if not updater:GetScript("OnUpdate") then + updater:SetScript("OnUpdate", updater_OnUpdate) + end +end + +function removeActiveWidget(object, widget, atMinAlpha, atMaxAlpha) + widget.mode = nil + widget.atMaxAlpha = atMaxAlpha + widget.atMinAlpha = atMinAlpha + widget.isFading = nil + activeWidgets[object] = nil + + if not next(activeWidgets) then + updater:SetScript("OnUpdate", nil) + end +end updater:SetScript("OnEvent", function(self, event) if event == "PLAYER_REGEN_DISABLED" then @@ -169,11 +166,14 @@ local function isMouseOver(frame) or (SpellFlyout:IsShown() and SpellFlyout:GetParent() and SpellFlyout:GetParent():GetParent() == frame and SpellFlyout:IsMouseOver(4, -4, -4, 4)) end -local hoverUpdater = CreateFrame("Frame") +local hoverWidgets = {} +local addHoverWidget, removeHoverWidget -hoverUpdater:SetScript("OnUpdate", function(self, elapsed) +local hoverUpdater = CreateFrame("Frame", "LSHoverFadingUpdater") + +local function hoverUpdater_OnUpdate(self, elapsed) self.elapsed = (self.elapsed or 0) + elapsed - if self.elapsed > elapsed * 1.5 then -- run it at half the refresh rate + if self.elapsed > 0.016 then -- limit to 60 fps for object, widget in next, hoverWidgets do if object:IsShown() then if isMouseOver(object) then @@ -188,7 +188,25 @@ hoverUpdater:SetScript("OnUpdate", function(self, elapsed) self.elapsed = 0 end -end) +end + +function addHoverWidget(object, widget) + widget.canHover = true + hoverWidgets[object] = widget + + if not hoverUpdater:GetScript("OnUpdate") then + hoverUpdater:SetScript("OnUpdate", hoverUpdater_OnUpdate) + end +end + +function removeHoverWidget(object, widget) + widget.canHover = false + hoverWidgets[object] = nil + + if not next(hoverWidgets) then + hoverUpdater:SetScript("OnUpdate", nil) + end +end local object_proto = {} @@ -251,8 +269,6 @@ function E:SetUpFading(object) fader:SetPoint("TOPLEFT", -4, 4) fader:SetPoint("BOTTOMRIGHT", 4, -4) fader:SetMouseClickEnabled(false) - fader.object = object - fader.threshold = 0.05 widgets[object] = { config = {}, diff --git a/core/mover.lua b/core/mover.lua index 7a7607f3..cfd29879 100644 --- a/core/mover.lua +++ b/core/mover.lua @@ -191,7 +191,7 @@ local function tracker_OnUpdate(self, elapsed) end end -local tracker = CreateFrame("Frame", nil, UIParent) +local tracker = CreateFrame("Frame", "LSMoverTracker", UIParent) local function calculatePosition(self) local moverCenterX, moverCenterY = self:GetCenter() diff --git a/core/utils.lua b/core/utils.lua index 194da06b..1ea5934a 100644 --- a/core/utils.lua +++ b/core/utils.lua @@ -257,7 +257,7 @@ do end do - local updater = CreateFrame("Frame") + local updater = CreateFrame("Frame", "LSColorSmoother") local objects = {} local function isCloseEnough(r, g, b, tR, tG, tB) diff --git a/ls_UI.toc b/ls_UI.toc index 2ae50273..3d866021 100644 --- a/ls_UI.toc +++ b/ls_UI.toc @@ -1,6 +1,6 @@ -## Interface: 90005 +## Interface: 90100 ## Author: lightspark -## Version: 90005.05 +## Version: 90100.01 ## Title: LS: |cff1a9fc0UI|r ## Notes: Yet another UI, but this one is a bit special... ## SavedVariablesPerCharacter: LS_UI_CHAR_CONFIG diff --git a/modules/bars/petbar.lua b/modules/bars/petbar.lua index 5700c183..d4801e78 100644 --- a/modules/bars/petbar.lua +++ b/modules/bars/petbar.lua @@ -313,7 +313,7 @@ function MODULE.CreatePetActionBar() local flashTime = 0 local rangeTimer = -1 - local updater = CreateFrame("Frame") + local updater = CreateFrame("Frame", "LSPetActionBarUpdater") updater:SetScript("OnUpdate", function(_, elapsed) flashTime = flashTime - elapsed rangeTimer = rangeTimer - elapsed