Skip to content

Commit

Permalink
Merge pull request #9 from Cortes-Jeremy/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Cortes-Jeremy authored Apr 12, 2021
2 parents 6814685 + e54236f commit 4aa4d8f
Show file tree
Hide file tree
Showing 7 changed files with 508 additions and 88 deletions.
65 changes: 34 additions & 31 deletions Gladius/Gladius.lua
Original file line number Diff line number Diff line change
Expand Up @@ -323,12 +323,12 @@ function Gladius:UNIT_HEALTH(event, unit)
end

-- update absorb bar
if( db.absorbBar and unit == 'arena1' or unit == 'arena2' or unit == 'arena3') then --hardcode for now to avoid checking pet
if( db.absorbBar and (arenaUnits[unit] == "playerUnit" or (arenaUnits[unit] ~= "playerUnit" and db.showPets)) ) then
Gladius:UpdateAbsorb(event, unit, button)
end

-- update cutaway
if ( db.cutawayBar and unit == 'arena1' or unit == 'arena2' or unit == 'arena3') then
if ( db.cutawayBar and (arenaUnits[unit] == "playerUnit" or (arenaUnits[unit] ~= "playerUnit" and db.showPets)) ) then
local _currentHealth, _maxHealth = UnitHealth(unit), UnitHealthMax(unit)
Gladius:UpdateCutaway(button, _currentHealth, _maxHealth)
end
Expand Down Expand Up @@ -449,17 +449,17 @@ function Gladius:UNIT_AURA(event, unit)
local button = self.buttons[unit]
if(not button) then return end

-- update absorb bar
if( db.absorbBar and unit == 'arena1' or unit == 'arena2' or unit == 'arena3') then --hardcode for now to avoid checking pet
Gladius:UpdateAbsorb(event, unit, button)
end

-- show the button
if (arenaUnits[unit] == "playerUnit" or (arenaUnits[unit] ~= "playerUnit" and db.showPets)) then
if (not button:IsShown()) then button:Show() end
if (button:GetAlpha() < 1) then button:SetAlpha(1) end
end

-- update absorb bar
if( db.absorbBar and (arenaUnits[unit] == "playerUnit" or (arenaUnits[unit] ~= "playerUnit" and db.showPets)) ) then
Gladius:UpdateAbsorb(event, unit, button)
end

local aura = button.auraFrame
local index = 1
local priority = 0
Expand Down Expand Up @@ -730,27 +730,27 @@ function Gladius:DetectSpec(unit, spec)
for k,v in pairs(self.cooldownSpells[class]) do
if (db.cooldownList[k] ~= false and db.cooldownList[class] ~= false) then
if (type(v) == "table" and ((v.spec ~= nil and v.spec == spec) or (v.notSpec ~= nil and v.notSpec ~= spec))) then
local button = self.buttons[unit]

local sharedCD = false
if (type(v) == "table" and v.sharedCD ~= nil and v.sharedCD.cd == nil) then
for spellId, _ in pairs(v.sharedCD) do
for i=1, button.lastCooldownSpell do
local icon = button.spellCooldownFrame["icon" .. i]
if (icon.spellId == spellId) then
sharedCD = true
local button = self.buttons[unit]

local sharedCD = false
if (type(v) == "table" and v.sharedCD ~= nil and v.sharedCD.cd == nil) then
for spellId, _ in pairs(v.sharedCD) do
for i=1, button.lastCooldownSpell do
local icon = button.spellCooldownFrame["icon" .. i]
if (icon.spellId == spellId) then
sharedCD = true
end
end
end
end
end
if sharedCD then return end
if sharedCD then return end

local icon = button.spellCooldownFrame["icon" .. button.lastCooldownSpell]
icon:Show()
icon.texture:SetTexture(self.spellTextures[k])
icon.spellId = k -- Missing spellID to updated talent frame
local icon = button.spellCooldownFrame["icon" .. button.lastCooldownSpell]
icon:Show()
icon.texture:SetTexture(self.spellTextures[k])
icon.spellId = k -- Missing spellID to updated talent frame

button.lastCooldownSpell = button.lastCooldownSpell + 1
button.lastCooldownSpell = button.lastCooldownSpell + 1
end
end
end
Expand Down Expand Up @@ -976,7 +976,7 @@ end
function Gladius:StopCooldownGlow(unit, spellId, auraType)
local button = self.buttons[unit]
if not button then return end
if (db.cooldownList[spellId] == false and auraType == 'BUFF') then return end
if (db.cooldownList[spellId] == false and auraType == 'DEBUFF') then return end

for i=1,(button.lastCooldownSpell or 14) do
if (button.spellCooldownFrame == nil) then return end
Expand Down Expand Up @@ -1703,6 +1703,15 @@ function Gladius:Test()
button.manaText:Hide()
end

--set fake absorb value
if( db.absorbBar ) then
button.absorb.totalAbsorb:SetWidth(100-(i^2))
button.absorb.totalAbsorbOverlay:SetWidth(100-(i^2))
else
button.absorb.totalAbsorb:SetWidth(0)
button.absorb.totalAbsorbOverlay:SetWidth(0)
end

--Check if it's a pet class and in that case update the frame to fit
button.isPetClass = petClasses[class] and true or false

Expand Down Expand Up @@ -1743,13 +1752,9 @@ function Gladius:UpdateAbsorb(event, unit, button)
local _guid = UnitGUID(unit)
local myCurrentHealAbsorb = LAM.Unit_Total(_guid)

--LAM.SetLowValueTolerance(0)
--print("unit: "..unit.." | "..myCurrentHealAbsorb)

--
function CompactUnitFrameUtil_UpdateFillBar(self, frame, previousTexture, health, myCurrentHealAbsorb)
local totalWidth, totalHeight = frame:GetSize();
local prevWidth, prevHeight = previousTexture:GetSize();
local amout = (health + myCurrentHealAbsorb) / maxHealth
local barOffsetX = (health / maxHealth) * totalWidth
local barOffsetXPercent = previousTexture:GetWidth() * amout
Expand All @@ -1759,9 +1764,7 @@ function Gladius:UpdateAbsorb(event, unit, button)
barSize = totalWidth - barOffsetX
end

self:ClearAllPoints()
self:SetPoint("LEFT", previousTexture:GetStatusBarTexture(), "RIGHT")
self:SetSize(barSize, previousTexture:GetHeight())
self:SetWidth(barSize)
self:Show()
end
--
Expand Down
1 change: 1 addition & 0 deletions Gladius/Gladius.toc
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ cooldownlist.lua
drlist.lua
options.lua
frame.lua
Smoothie.lua
140 changes: 140 additions & 0 deletions Gladius/Smoothie.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
-- Credit: ls- (lightspark)
local abs, next = abs, next
local tonumber, assert = tonumber, assert
local activeObjects = {}
local handledObjects = {}
local TARGET_FPS = 60
local AMOUNT = 0.33

local function lerp(startValue, endValue, amount)
return (1 - amount) * startValue + amount * endValue
end

local function clamp(v, min, max)
min = min or 0
max = max or 1

if v > max then
return max
elseif v < min then
return min
end

return v
end

local function isCloseEnough(new, target, range)
if range > 0 then
return abs((new - target) / range) <= 0.001
end

return true
end

local frame = CreateFrame("Frame")
local function onUpdate(_, elapsed)
for object, target in next, activeObjects do
local new = lerp(object._value, target, clamp(AMOUNT * elapsed * TARGET_FPS))
if isCloseEnough(new, target, object._max - object._min) then
new = target
activeObjects[object] = nil
end

object:SetValue_(new)
object._value = new
end
end

local function bar_SetSmoothedValue(self, value)
value = tonumber(value)

assert(value, "bar_SetSmoothedValue requires (value) to be a number.")

self._value = self:GetValue()
activeObjects[self] = clamp(value, self._min, self._max)
end

local function bar_SetSmoothedMinMaxValues(self, min, max)
min, max = tonumber(min), tonumber(max)

assert(min and max, "bar_SetSmoothedMinMaxValues requires (min and max) to be a number.")

self:SetMinMaxValues_(min, max)

if self._max and self._max ~= max then
local ratio = 1
if max ~= 0 and self._max and self._max ~= 0 then
ratio = max / (self._max or max)
end

local target = activeObjects[self]
if target then
activeObjects[self] = target * ratio
end

local cur = self._value
if cur then
self:SetValue_(cur * ratio)
self._value = cur * ratio
end
end

self._min = min
self._max = max
end

local function SmoothBar(bar)
bar._min, bar._max = bar:GetMinMaxValues()
bar._value = bar:GetValue()

if not bar.SetValue_ then
bar.SetValue_ = bar.SetValue
bar.SetValue = bar_SetSmoothedValue
end
if not bar.SetMinMaxValues_ then
bar.SetMinMaxValues_ = bar.SetMinMaxValues
bar.SetMinMaxValues = bar_SetSmoothedMinMaxValues
end

if not frame:GetScript("OnUpdate") then
frame:SetScript("OnUpdate", onUpdate)
end

handledObjects[bar] = true
end

local function DesmoothBar(bar)
if activeObjects[bar] then
bar:SetValue_(activeObjects[bar])
activeObjects[bar] = nil
end

if handledObjects[bar] then
handledObjects[bar] = nil
end

if bar.SetValue_ then
bar.SetValue = bar.SetValue_
bar.SetValue_ = nil
end
if bar.SetMinMaxValues_ then
bar.SetMinMaxValues = bar.SetMinMaxValues_
bar.SetMinMaxValues_ = nil
end

if not next(handledObjects) then
frame:SetScript("OnUpdate", nil)
end
end

function Gladius:SetSmoothingAmount(amount)
AMOUNT = clamp(amount, 0.2, 0.8)
end

function Gladius:SetSmoothing(bar, enable)
if enable then
SmoothBar(bar)
else
DesmoothBar(bar)
end
end
Loading

0 comments on commit 4aa4d8f

Please sign in to comment.