Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
ls- committed Jun 29, 2021
2 parents 49a767b + a1e132e commit dd80fb3
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 62 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CHANGELOG

## Version 90100.01

- Added 9.1.0 support;
- Further fading optimisation.

## Version 90005.05

- Optimised fading a bit more;
Expand Down
2 changes: 1 addition & 1 deletion core/border.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion core/cooldown.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ local defaults = {
},
}

local updater = CreateFrame("Frame")
local updater = CreateFrame("Frame", "LSCooldownUpdater")
local updateTime = 0
local time1, time2, format, color

Expand Down
18 changes: 1 addition & 17 deletions core/core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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(...)
Expand Down Expand Up @@ -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

------------
Expand Down
92 changes: 54 additions & 38 deletions core/fading.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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 = {}

Expand Down Expand Up @@ -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 = {},
Expand Down
2 changes: 1 addition & 1 deletion core/mover.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion core/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions ls_UI.toc
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion modules/bars/petbar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit dd80fb3

Please sign in to comment.