Skip to content

Commit

Permalink
pixel perfect fixes for castbar spark effect
Browse files Browse the repository at this point in the history
  • Loading branch information
wardz committed Apr 5, 2024
1 parent b082793 commit 5a62ba8
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions ClassicCastbars/core/Frames.lua
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,10 @@ function ClassicCastbars:SetCastbarStyle(castbar, db, unitID)
castbar.Icon:SetTexCoord(0, 1, 0, 1)
end

castbar.Spark:SetHeight(db.height * 2.1)
castbar.Spark:SetHeight(db.height * 2.39)
castbar.Icon:SetShown(db.showIcon)
castbar.Icon:SetSize(db.iconSize, db.iconSize)
castbar.Border:SetVertexColor(unpack(db.borderColor))
castbar.Border:SetVertexColor(unpack(db.borderColor, 1, 3))

castbar.Flash:ClearAllPoints()
if castbar.isUninterruptible then
Expand Down Expand Up @@ -273,7 +273,7 @@ function ClassicCastbars:SetLSMBorders(castbar, db)
castbar.Border:SetAlpha(0) -- hide default border
castbar.BorderFrameLSM:SetAlpha(db.borderColor[4])
castbar.BorderFrameLSM:SetFrameLevel(textureFrameLevels[db.castBorder] or castbar:GetFrameLevel() + 1)
castbar.BorderFrameLSM:SetBackdropBorderColor(unpack(db.borderColor))
castbar.BorderFrameLSM:SetBackdropBorderColor(unpack(db.borderColor, 1, 3))
end

function ClassicCastbars:SetCastbarFonts(castbar, db)
Expand Down Expand Up @@ -422,7 +422,7 @@ function ClassicCastbars:DisplayCastbar(castbar, unitID)
end

local sparkPosition = (castbar.value / castbar.maxValue) * (castbar.currWidth or castbar:GetWidth())
castbar.Spark:SetPoint("CENTER", castbar, "LEFT", sparkPosition, 0)
castbar.Spark:SetPoint("CENTER", castbar, "LEFT", sparkPosition, castbar.BorderShield:IsShown() and 3 or 0)
castbar:SetMinMaxValues(0, castbar.maxValue)
castbar:SetValue(castbar.value)
castbar:SetParent(parentFrame)
Expand Down Expand Up @@ -562,6 +562,15 @@ function ClassicCastbars:SkinPlayerCastbar()
CastingBarFrame:SetPoint(db.position[1], UIParent, db.position[2], db.position[3])
end
end)

-- Temp fix for pixel perfect spark position
hooksecurefunc(CastingBarFrame.Spark, "SetPoint", function(_, point, _, relativePoint, _, ofsY)
if point == "CENTER" and relativePoint == "LEFT" and ofsY == 2 then
local sparkPosition = (CastingBarFrame.value / CastingBarFrame.maxValue) * CastingBarFrame:GetWidth()
CastingBarFrame.Spark:SetPoint("CENTER", CastingBarFrame, "LEFT", sparkPosition, 0)
end
end)

CastingBarFrame.CC_isHooked = true
end

Expand All @@ -578,6 +587,7 @@ function ClassicCastbars:SkinPlayerCastbar()
CastingBarFrame.Text:SetJustifyH(db.textPoint)
CastingBarFrame.Icon:ClearAllPoints()
CastingBarFrame.Icon:SetShown(db.showIcon)
CastingBarFrame.Spark:ClearAllPoints()

if not db.autoPosition then
CastingBarFrame.ignoreFramePositionManager = true
Expand Down

0 comments on commit 5a62ba8

Please sign in to comment.