Skip to content

Commit

Permalink
Merge pull request #6 from Cortes-Jeremy/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Cortes-Jeremy authored Mar 2, 2021
2 parents 36fb01a + de7c7ff commit b2f5c99
Show file tree
Hide file tree
Showing 4 changed files with 188 additions and 75 deletions.
61 changes: 54 additions & 7 deletions Gladius/Gladius.lua
Original file line number Diff line number Diff line change
Expand Up @@ -270,21 +270,67 @@ function Gladius:LeftArena()
self.frame:Hide()
end

-- Health bar Loss Animation
function Gladius:UpdateCutaway(button, curH, maxH)

local curHealthNorm = curH / maxH -- normalized (0->1)

-- First time it run there is no previous value so we pretend max
if not button.cutaway.previousValue then button.cutaway.previousValue = 1 end
-- Not animating for Health Gain
if(button.cutaway.previousValue and button.cutaway.previousValue < curHealthNorm) then
-- Check if old animation is already playing and stop it
if(button.cutaway.anim:IsPlaying()) then
button.cutaway.anim:Stop()
button.cutaway.bar:Hide()
end
button.cutaway.previousValue = curHealthNorm
return
end

-- RED Health Loss
if(button.cutaway.previousValue and math.abs(curHealthNorm - button.cutaway.previousValue) > 0.001) then
-- Check if old animation is already playing and stop it
if(button.cutaway.anim:IsPlaying()) then
button.cutaway.anim:Stop()
button.cutaway.bar:Hide()
end
--
local padding = 2
local low = curHealthNorm > button.cutaway.previousValue and button.cutaway.previousValue or curHealthNorm
local diff = math.abs(button.cutaway.previousValue - curHealthNorm)
button.cutaway.bar:ClearAllPoints()
button.cutaway.bar:SetPoint("TOPLEFT", button.health, low*button.health:GetWidth() - padding, 0)
button.cutaway.bar:SetWidth(diff*button.health:GetWidth())
button.cutaway.bar:Show()
button.cutaway.anim:Play()
button.cutaway.anim:SetScript("OnFinished", function() button.cutaway.bar:Hide() end)
end
button.cutaway.previousValue = curHealthNorm

end

--Update units health
function Gladius:UNIT_HEALTH(event, unit)
if (arenaUnits[unit]) then
local button = self.buttons[unit]
if(not button) then return 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 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
-- update cutaway
if ( db.cutawayBar and unit == 'arena1' or unit == 'arena2' or unit == 'arena3') then
local _currentHealth, _maxHealth = UnitHealth(unit), UnitHealthMax(unit)
Gladius:UpdateCutaway(button, _currentHealth, _maxHealth)
end

if(not UnitIsDeadOrGhost(unit)) then
Expand Down Expand Up @@ -906,7 +952,7 @@ function Gladius:StartCooldownGlow(unit, spellId, auraType)
if (db.cooldownList[spellId] == false and auraType == 'DEBUFF') then return end

for i=1,(button.lastCooldownSpell or 14) do -- button.lastCooldownSpell return a number that match max number of detected talent cooldown
if (button.spellCooldownFrame["icon" .. i] == nil) then return end
if (button.spellCooldownFrame == nil) then return end
if (button.spellCooldownFrame["icon" .. i].spellId == spellId) then
local frame = button.spellCooldownFrame["icon" .. i]
frame.glowActive = true
Expand All @@ -929,6 +975,7 @@ function Gladius:StopCooldownGlow(unit, spellId, auraType)
if (db.cooldownList[spellId] == false and auraType == 'BUFF') then return end

for i=1,(button.lastCooldownSpell or 14) do
if (button.spellCooldownFrame == nil) then return end
if (button.spellCooldownFrame["icon" .. i].spellId == spellId) then
local frame = button.spellCooldownFrame["icon" .. i]
frame.glowActive = false
Expand Down Expand Up @@ -1716,11 +1763,11 @@ function Gladius:UpdateAbsorb(event, unit, button)
--

if ( myCurrentHealAbsorb > 0 and health < maxHealth ) then
CompactUnitFrameUtil_UpdateFillBar(button.absorb.totalAbsorbOverlay, button, button.health, health, myCurrentHealAbsorb)
CompactUnitFrameUtil_UpdateFillBar(button.absorb.totalAbsorb, button, button.health, health, myCurrentHealAbsorb)
CompactUnitFrameUtil_UpdateFillBar(button.absorb.totalAbsorbOverlay, button, button.health, health, myCurrentHealAbsorb)
else
button.absorb.totalAbsorbOverlay:Hide()
button.absorb.totalAbsorb:Hide()
button.absorb.totalAbsorbOverlay:Hide()
end

local overAbsorb = false;
Expand Down
83 changes: 62 additions & 21 deletions Gladius/frame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ local function CastUpdate(self, elapsed)
end
end

local function StyleActionButton(f)
local function StyleActionButton(f, hideBorder, iconPadding)
local name = f:GetName()
local button = _G[name]
local icon = _G[name.."Icon"]
Expand All @@ -56,9 +56,21 @@ local function StyleActionButton(f)

button:SetNormalTexture("Interface\\AddOns\\Gladius\\images\\clean")

if hideBorder then
normalTex:SetAlpha(0)
else
normalTex:SetAlpha(1)
end

icon:SetTexCoord(0.1,0.9,0.1,0.9)
icon:SetPoint("TOPLEFT", button, "TOPLEFT", 2, -2)
icon:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", -2, 2)

if iconPadding then
icon:SetPoint("TOPLEFT", button, "TOPLEFT", iconPadding, -iconPadding)
icon:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", -iconPadding, iconPadding)
else
icon:SetPoint("TOPLEFT", button, "TOPLEFT", 2, -2)
icon:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", -2, 2)
end

--normalTex:SetVertexColor(1,1,1,1)
end
Expand Down Expand Up @@ -224,6 +236,22 @@ function Gladius:CreateButton(i)
healthBar.highlight:SetAllPoints(healthBar)
healthBar.highlight:Hide()

-- Health bar loss animation
local cutaway = CreateFrame("Frame", "GladiusCutawayBar"..i, button)
--cutaway:SetFrameLevel(healthBar:GetFrameLevel() + 1)
cutaway.bar = cutaway:CreateTexture(nil, "ARTWORK") -- b.BS
cutaway.bar:SetAlpha(1) -- set from alpha
cutaway.bar:Hide()
--
cutaway.anim = cutaway.bar:CreateAnimationGroup()
cutaway.anim.s1 = cutaway.anim:CreateAnimation("Scale")
cutaway.anim.s1:SetScale(0,1)
cutaway.anim.s1:SetOrigin("LEFT", 0, 0)
cutaway.anim.s1:SetDuration(0.475)
cutaway.anim.s1:SetSmoothing("OUT")
--
cutaway.previousValue = 1 -- init at max

-- AbsorbBar
local absorbBar = CreateFrame("Frame", "GladiusAbsorbBar"..i, button)
local overAbsorbFrame = CreateFrame("Frame", "GladiusOverAbsorbGlow"..i, healthBar) -- hack to get the glow spark over everything
Expand All @@ -233,13 +261,10 @@ function Gladius:CreateButton(i)
absorbBar.overAbsorbGlow:SetBlendMode("ADD");
absorbBar.overAbsorbGlow:Hide()
-- Total absorb
absorbBar.totalAbsorb = absorbBar:CreateTexture(nil, "BORDER", nil, 0)
absorbBar.totalAbsorb:SetTexture([[Interface\AddOns\Gladius\media\RaidFrame\Shield-Fill]])
absorbBar.totalAbsorb = absorbBar:CreateTexture(nil, "BACKGROUND")
absorbBar.totalAbsorb:Hide()
-- Total absorb overlay
absorbBar.totalAbsorbOverlay = absorbBar:CreateTexture(nil, "BORDER", nil, 1)
absorbBar.totalAbsorbOverlay:SetHorizTile(true)
absorbBar.totalAbsorbOverlay:SetTexture([[Interface\AddOns\Gladius\media\RaidFrame\Shield-Overlay]], "MIRROR")
absorbBar.totalAbsorbOverlay = absorbBar:CreateTexture(nil, "BORDER")
absorbBar.totalAbsorbOverlay:Hide()

--Mana bar
Expand Down Expand Up @@ -320,9 +345,6 @@ function Gladius:CreateButton(i)
for x=1, 14 do
local icon = CreateFrame("CheckButton", "Gladius"..i.."SpellCooldownFrame"..x, spellCooldownFrame, "ActionButtonTemplate")
icon:EnableMouse(false)
if( db.hideCooldownBorder ) then
icon:GetNormalTexture():SetTexCoord(1,1,1,1) -- force removal of ugly black square
end
icon.texture = _G[icon:GetName().."Icon"]
icon.cooldown = _G[icon:GetName().."Cooldown"]
icon.cooldown:SetReverse(false)
Expand Down Expand Up @@ -452,6 +474,7 @@ function Gladius:CreateButton(i)

button.mana = manaBar
button.health = healthBar
button.cutaway = cutaway
button.absorb = absorbBar
button.castBar = castBar
button.castBar.timeText = castBarTextTime
Expand Down Expand Up @@ -783,19 +806,27 @@ function Gladius:UpdateFrame()
DisableTexTiling(button.health:GetStatusBarTexture())
DisableTexTiling(button.health.bg)

-- Health bar loss animation (textures, size, position)
button.cutaway.bar:SetTexture(LSM:Fetch(LSM.MediaType.STATUSBAR, db.barTexture)) -- same bar as health bar
button.cutaway.bar:SetVertexColor(255/255, 0/255, 0/255, 1) -- texture color
button.cutaway.bar:SetSize(0, button.health:GetHeight())

-- absorb bar location and size
-- OverAbsorb
button.absorb.overAbsorbGlow:ClearAllPoints()
button.absorb.overAbsorbGlow:SetPoint("RIGHT", button.health, "RIGHT", 7, 0)
button.absorb.overAbsorbGlow:SetSize(12, button.health:GetHeight() + 4)
button.absorb.overAbsorbGlow:SetPoint("RIGHT", button.health, "RIGHT", 6, 0)
button.absorb.overAbsorbGlow:SetSize(12, button.health:GetHeight())
-- Total absorb
button.absorb.totalAbsorb:ClearAllPoints()
button.absorb.totalAbsorb:SetTexture(LSM:Fetch(LSM.MediaType.STATUSBAR, db.barTexture)) -- same bar as health bar
button.absorb.totalAbsorb:SetPoint("RIGHT", button.health, "RIGHT")
button.absorb.totalAbsorb:SetSize(15, button.health:GetHeight())
button.absorb.totalAbsorb:SetSize(button.health:GetSize()*0.5, button.health:GetHeight())
-- Total absorb overlay
button.absorb.totalAbsorbOverlay:ClearAllPoints()
button.absorb.totalAbsorbOverlay:SetHorizTile(true)
button.absorb.totalAbsorbOverlay:SetTexture([[Interface\AddOns\Gladius\media\RaidFrame\Shield-Overlay]], "MIRROR")
button.absorb.totalAbsorbOverlay:SetPoint("RIGHT", button.health, "RIGHT")
button.absorb.totalAbsorbOverlay:SetSize(15, button.health:GetHeight()) -- -15
button.absorb.totalAbsorbOverlay:SetSize(button.health:GetSize()*0.5, button.health:GetHeight())

--mana bar location, size and texture
button.mana:ClearAllPoints()
Expand Down Expand Up @@ -1205,7 +1236,13 @@ function Gladius:UpdateFrame()
button.spellCooldownFrame:SetHeight(db.barHeight+extraBarHeight)
button.spellCooldownFrame:SetWidth(db.barHeight+extraBarHeight)

-- Update each cooldown icon
-- Update each cooldown icon
local iconPadding = 0
if db.cooldownIconPadding then
iconPadding = db.cooldownIconPadding
else
iconPadding = 2 -- default
end
for i=1,14 do
local icon = button.spellCooldownFrame["icon"..i]
icon:SetHeight(button.spellCooldownFrame:GetHeight()/2)
Expand All @@ -1216,17 +1253,17 @@ function Gladius:UpdateFrame()
if(i==1) then
icon:SetPoint("TOPLEFT",button.spellCooldownFrame)
elseif(i==2) then
icon:SetPoint("TOP",button.spellCooldownFrame["icon"..i-1],"BOTTOM",0,-1)
icon:SetPoint("TOP",button.spellCooldownFrame["icon"..i-1],"BOTTOM",0,-iconPadding)
elseif(i>=3) then
icon:SetPoint("LEFT",button.spellCooldownFrame["icon"..i-2],"RIGHT",1,0)
icon:SetPoint("LEFT",button.spellCooldownFrame["icon"..i-2],"RIGHT",iconPadding,0)
end
else
if(i==1) then
icon:SetPoint("TOPRIGHT",button.spellCooldownFrame)
elseif(i==2) then
icon:SetPoint("TOP",button.spellCooldownFrame["icon"..i-1],"BOTTOM",0,-1)
icon:SetPoint("TOP",button.spellCooldownFrame["icon"..i-1],"BOTTOM",0,-iconPadding)
elseif(i>=3) then
icon:SetPoint("RIGHT",button.spellCooldownFrame["icon"..i-2],"LEFT",-1,0)
icon:SetPoint("RIGHT",button.spellCooldownFrame["icon"..i-2],"LEFT",-iconPadding,0)
end
end

Expand All @@ -1239,7 +1276,11 @@ function Gladius:UpdateFrame()
icon.spellId = nil
icon:SetAlpha(1)
icon.texture:SetTexture("Interface\\Icons\\Spell_Holy_PainSupression")
StyleActionButton(icon)
if db.hideCooldownBorder then
StyleActionButton(icon, true, iconPadding)
else
StyleActionButton(icon, false, iconPadding)
end

if (not self.frame.testing) then
icon:Hide()
Expand Down
2 changes: 2 additions & 0 deletions Gladius/localization/enUS.lua
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ L["Font of the aura text"] = "Font of the aura text"
L["Cast bar position"] = "Cast bar position"
L["Position of the cast bar"] = "Position of the cast bar"
L["Show absorb bars"] = "Show absorb bars"
L["Show cutaway bars"] = "Show cutaway bars"
L["Show power bars"] = "Show power bars"
L["Show class icon"] = "Show class icon"
L["Show class icon\nIMPORTANT:\nToggling this off will disable showing auras even if it is enabled"] = "Show class icon\nIMPORTANT:\nToggling this off will disable showing auras even if it is enabled"
Expand Down Expand Up @@ -366,6 +367,7 @@ L["Show cooldown icons"] = "Show cooldown icons"
L["Cooldown list"] = "Cooldown list"
L["Show cooldown"] = "Show cooldown"
L["Hide Cooldown border"] = "Hide Cooldown border"
L["Cooldown icon padding"] = "Cooldown icon padding"
L["Glow when cooldown is active"] = "Glow when cooldown is active"
L["Desaturate used cooldown"] = "Desature used cooldown"
L["Used cooldown opacity"] = "Used cooldown opacity"
Expand Down
Loading

0 comments on commit b2f5c99

Please sign in to comment.