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 16, 2021
2 parents de5a949 + ef906e4 commit 49a767b
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 32 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 90005.05

- Optimised fading a bit more;
- Misc bug fixes and tweaks.

## Version 90005.04

- Reworked fading. It's way more fluid and responsive now:
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright © 2013-2019 Val Voronov <[email protected]>.
Copyright © 2013-2021 Val Voronov <[email protected]>.

The contents of this addon, excluding third-party resources, are copyrighted to its authors with all rights reserved.

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# ls: UI
# LS: UI

Yet another UI, but this one is a bit special.

"Orbs" Layout:
[![Imgur](https://i.imgur.com/PkQXt5v.png)](https://i.imgur.com/HgdaDa4.png "4K Glory")
[![Imgur](https://i.imgur.com/8K40Ei3.png)](https://i.imgur.com/7Joaewr.png "4K Glory")

"Classic" Layout:
[![Imgur](https://i.imgur.com/tNosWct.png)](https://i.imgur.com/nww6H8B.png "4K Glory")
[![Imgur](https://i.imgur.com/SJGDgla.png)](https://i.imgur.com/q2T8U9H.png "4K Glory")

## Download

Expand Down
Binary file modified assets/unit-frame-sep-horiz.TGA
Binary file not shown.
56 changes: 30 additions & 26 deletions core/fading.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ local activeWidgets = {}

local function addActiveWidget(object, widget, mode)
widget.mode = mode
widget.fadeTimer = 0
widget.fadeTimer = mode == FADE_OUT and -widget.config.out_delay or 0
widget.initAlpha = nil
activeWidgets[object] = widget
end
Expand All @@ -29,6 +29,18 @@ local function removeActiveWidget(object, widget, atMinAlpha, atMaxAlpha)
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 Down Expand Up @@ -63,13 +75,11 @@ updater:SetScript("OnUpdate", function(_, elapsed)
if widget.mode == FADE_IN then
widget.isFading = true

-- add 0.0001 to avoid any "divide by 0" errors in case a user sets both min and max
-- alphas to the same value, I could add a bunch of checks for it to never happen,
-- add 0.0001 to avoid any "divide by 0" errors
-- but precision isn't really necessary here
widget.newAlpha = widget.initAlpha + ((widget.config.max_alpha - widget.initAlpha)
* (widget.fadeTimer / (widget.config.in_duration
* (1 - (widget.initAlpha - widget.config.min_alpha)
/ (widget.config.max_alpha - widget.config.min_alpha + 0.0001)))))
widget.newAlpha = (widget.fadeTimer / widget.config.in_duration)
* (widget.config.max_alpha - widget.initAlpha + 0.0001)
+ widget.initAlpha
-- print("|cff00ffd2IN|r", "|cff00ccff" .. object:GetDebugName() .. "|r", " \n|cffffd200 initAlpha:|r ", widget.initAlpha, " \n|cffffd200 newAlpha:|r ", widget.newAlpha, " \n|cffffd200 delta:|r ", widget.newAlpha - object:GetAlpha())
object:SetAlpha(widget.newAlpha)

Expand All @@ -84,16 +94,14 @@ updater:SetScript("OnUpdate", function(_, elapsed)
object:SetAlpha(widget.config.max_alpha)
end
elseif widget.mode == FADE_OUT then
if widget.fadeTimer >= widget.config.out_delay then
if widget.fadeTimer >= 0 then
widget.isFading = true

-- add 0.0001 to avoid any "divide by 0" errors in case a user sets both min and max
-- alphas to the same value, I could add a bunch of checks for it to never happen,
-- but precision isn't really necessary here
widget.newAlpha = widget.initAlpha - ((widget.initAlpha - widget.config.min_alpha)
* ((widget.fadeTimer - widget.config.out_delay) / (widget.config.out_duration
* (1 - (widget.config.max_alpha - widget.initAlpha)
/ (widget.config.max_alpha - widget.config.min_alpha + 0.0001)))))
-- add 0.0001 to avoid any "divide by 0" errors
-- precision isn't really necessary here
widget.newAlpha = (1 - widget.fadeTimer / widget.config.out_duration)
* (widget.initAlpha - widget.config.min_alpha + 0.0001)
+ widget.config.min_alpha
-- print("|cffffd200OUT|r", "|cff00ccff" .. object:GetDebugName() .. "|r", " \n|cffffd200 initAlpha:|r ", widget.initAlpha, " \n|cffffd200 newAlpha:|r ", widget.newAlpha, " \n|cffffd200delta:|r ", object:GetAlpha() - widget.newAlpha)
object:SetAlpha(widget.newAlpha)

Expand Down Expand Up @@ -166,13 +174,13 @@ local hoverUpdater = CreateFrame("Frame")
hoverUpdater:SetScript("OnUpdate", function(self, elapsed)
self.elapsed = (self.elapsed or 0) + elapsed
if self.elapsed > elapsed * 1.5 then -- run it at half the refresh rate
for object, widget in next, widgets do
if object:IsShown() and widget.canHover then
for object, widget in next, hoverWidgets do
if object:IsShown() then
if isMouseOver(object) then
if (not widget.atMaxAlpha or widget.isFading) and widget.mode ~= FADE_IN then
addActiveWidget(object, widget, FADE_IN)
end
elseif not widget.atMinAlpha and widget.mode ~= FADE_OUT then
elseif (not widget.atMinAlpha and not widget.isFading) and widget.mode ~= FADE_OUT then
addActiveWidget(object, widget, FADE_OUT)
end
end
Expand All @@ -182,17 +190,14 @@ hoverUpdater:SetScript("OnUpdate", function(self, elapsed)
end
end)

local function fader_OnHide(self)
self.object:SetAlpha(1)
end

local object_proto = {}

function object_proto:DisableFading(ignoreFade)
local widget = widgets[self]

if widget.canHover then
widget.canHover = false
-- it's nil on load, but we still want to get in
if widget.canHover ~= false then
removeHoverWidget(self, widget)

if not ignoreFade and (widget.atMinAlpha or widget.mode ~= FADE_IN) then
addActiveWidget(self, widget, FADE_IN)
Expand All @@ -204,7 +209,7 @@ function object_proto:EnableFading()
local widget = widgets[self]

if not (widget.hasTarget or widget.inCombat) then
widget.canHover = true
addHoverWidget(self, widget)
end
end

Expand Down Expand Up @@ -245,7 +250,6 @@ function E:SetUpFading(object)
fader:SetFrameLevel(object:GetFrameLevel())
fader:SetPoint("TOPLEFT", -4, 4)
fader:SetPoint("BOTTOMRIGHT", 4, -4)
fader:SetScript("OnHide", fader_OnHide)
fader:SetMouseClickEnabled(false)
fader.object = object
fader.threshold = 0.05
Expand Down
4 changes: 3 additions & 1 deletion core/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,9 @@ do
local rosterInfo = {}

local function updateUnitInfo(unit)
rosterInfo[UnitGUID(unit)] = UnitGroupRolesAssigned(unit)
if UnitExists(unit) then
rosterInfo[UnitGUID(unit)] = UnitGroupRolesAssigned(unit)
end
end

E:RegisterEvent("UNIT_NAME_UPDATE", updateUnitInfo)
Expand Down
2 changes: 1 addition & 1 deletion ls_UI.toc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Interface: 90005
## Author: lightspark
## Version: 90005.04
## Version: 90005.05
## Title: LS: |cff1a9fc0UI|r
## Notes: Yet another UI, but this one is a bit special...
## SavedVariablesPerCharacter: LS_UI_CHAR_CONFIG
Expand Down

0 comments on commit 49a767b

Please sign in to comment.