Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Settings
- -- Possible values:
- -- "LTR" - Left to Right,
- -- "RTL" - Right to Left,
- -- "TTB" - Top to Bottom,
- -- "BTT" - Bottom to top
- local FILL_DIRECTION = "BTT"
- local ATTENUATE_DEAD_BARS = true
- local function reanchorOutlets(P, outlet, healthBar)
- P.ClearPoints(outlet)
- P.Point(outlet, "TOPLEFT", healthBar:GetStatusBarTexture(), "TOPRIGHT")
- P.Point(outlet, "BOTTOMLEFT", healthBar:GetStatusBarTexture(), "BOTTOMRIGHT")
- end
- local function reanchorInlets(P, inlet, healthBar)
- P.ClearPoints(inlet)
- P.Point(inlet, "TOPLEFT", healthBar:GetStatusBarTexture())
- P.Point(inlet, "BOTTOMLEFT", healthBar:GetStatusBarTexture())
- end
- local function reanchorVerticalOutlets(P, outlet, healthBar)
- P.ClearPoints(outlet)
- P.Point(outlet, "TOPLEFT", healthBar:GetStatusBarTexture(), "BOTTOMLEFT")
- P.Point(outlet, "TOPRIGHT", healthBar:GetStatusBarTexture(), "BOTTOMRIGHT")
- end
- local function reanchorVerticalInlets(P, inlet, healthBar)
- P.ClearPoints(inlet)
- P.Point(inlet, "TOPLEFT", healthBar:GetStatusBarTexture())
- P.Point(inlet, "TOPRIGHT", healthBar:GetStatusBarTexture())
- end
- local function applyFillDirection()
- Cell.funcs.IterateAllUnitButtons(function(b)
- local P = Cell.pixelPerfectFuncs
- local healthBar = b.widgets.healthBar
- local healthBarLoss = b.widgets.healthBarLoss
- if FILL_DIRECTION == "LTR" then
- healthBar:SetOrientation("HORIZONTAL")
- healthBar:SetReverseFill(true)
- P.ClearPoints(healthBarLoss)
- P.Point(healthBarLoss, "TOPLEFT", healthBar:GetStatusBarTexture(), "TOPRIGHT")
- P.Point(healthBarLoss, "BOTTOMRIGHT", healthBar, "BOTTOMRIGHT")
- reanchorOutlets(P, b.widgets.damageFlashTex, healthBar)
- reanchorOutlets(P, b.widgets.incomingHeal, healthBar)
- reanchorOutlets(P, b.widgets.shieldBar, healthBar)
- reanchorInlets(P, b.widgets.shieldBarR, healthBar)
- reanchorInlets(P, b.widgets.absorbsBar, healthBar)
- elseif FILL_DIRECTION == "RTL" then
- healthBar:SetOrientation("HORIZONTAL")
- healthBar:SetReverseFill(false)
- P.ClearPoints(healthBarLoss)
- P.Point(healthBarLoss, "TOPLEFT", healthBar, "TOPLEFT")
- P.Point(healthBarLoss, "BOTTOMRIGHT", healthBar:GetStatusBarTexture(), "BOTTOMLEFT")
- reanchorOutlets(P, b.widgets.damageFlashTex, healthBar)
- reanchorOutlets(P, b.widgets.incomingHeal, healthBar)
- reanchorOutlets(P, b.widgets.shieldBar, healthBar)
- reanchorInlets(P, b.widgets.shieldBarR, healthBar)
- reanchorInlets(P, b.widgets.absorbsBar, healthBar)
- elseif FILL_DIRECTION == "TTB" then
- healthBar:SetOrientation("VERTICAL")
- healthBar:SetReverseFill(false)
- P.ClearPoints(healthBarLoss)
- P.Point(healthBarLoss, "TOPLEFT", healthBar, "TOPLEFT")
- P.Point(healthBarLoss, "BOTTOMRIGHT", healthBar:GetStatusBarTexture(), "TOPRIGHT")
- reanchorVerticalOutlets(P, b.widgets.damageFlashTex, healthBar)
- reanchorVerticalOutlets(P, b.widgets.incomingHeal, healthBar)
- reanchorVerticalOutlets(P, b.widgets.shieldBar, healthBar)
- reanchorVerticalInlets(P, b.widgets.shieldBarR, healthBar)
- reanchorVerticalInlets(P, b.widgets.absorbsBar, healthBar)
- elseif FILL_DIRECTION == "BTT" then
- healthBar:SetOrientation("VERTICAL")
- healthBar:SetReverseFill(true)
- P.ClearPoints(healthBarLoss)
- P.Point(healthBarLoss, "TOPLEFT", healthBar:GetStatusBarTexture(), "BOTTOMLEFT")
- P.Point(healthBarLoss, "BOTTOMRIGHT", healthBar, "BOTTOMRIGHT")
- reanchorVerticalOutlets(P, b.widgets.damageFlashTex, healthBar)
- reanchorVerticalOutlets(P, b.widgets.incomingHeal, healthBar)
- reanchorVerticalOutlets(P, b.widgets.shieldBar, healthBar)
- reanchorVerticalInlets(P, b.widgets.shieldBarR, healthBar)
- reanchorVerticalInlets(P, b.widgets.absorbsBar, healthBar)
- end
- -- Special cases
- local overAbsorbGlow = b.widgets.overAbsorbGlow
- local overShieldGlow = b.widgets.overShieldGlow
- P.ClearPoints(overAbsorbGlow)
- P.ClearPoints(overShieldGlow)
- if FILL_DIRECTION == "LEFT_TO_RIGHT" or FILL_DIRECTION == "RIGHT_TO_LEFT" then
- P.Point(overAbsorbGlow, "TOPRIGHT")
- P.Point(overAbsorbGlow, "BOTTOMRIGHT")
- P.Point(overShieldGlow, "TOPLEFT")
- P.Point(overShieldGlow, "BOTTOMLEFT")
- else
- P.Point(overAbsorbGlow, "TOP")
- P.Point(overShieldGlow, "TOP")
- end
- end)
- end
- function hookCell()
- if Cell.__fill_direction_hook_installed then return end
- if ATTENUATE_DEAD_BARS then
- local F = Cell.funcs
- local oldGetHealthBarColor = F.GetHealthBarColor
- F.GetHealthBarColor = function(...)
- local colors = {oldGetHealthBarColor(...)}
- if not isDeadOrGhost then
- return unpack(colors)
- end
- return colors[4], colors[5], colors[6], colors[1], colors[2], colors[3]
- end
- Cell.funcs.IterateAllUnitButtons(function(button)
- local originalSetVertexColor = button.widgets.healthBarLoss.SetVertexColor
- button.widgets.healthBarLoss.SetVertexColor = function(self, r, g, b, a)
- local dead = button.states.isDeadOrGhost or button.states.isDead
- if dead then
- r, g, b, a = button.widgets.healthBar:GetStatusBarColor()
- end
- originalSetVertexColor(self, r, g, b, a)
- end
- end)
- end
- local B = Cell.bFuncs
- hooksecurefunc(B, "SetOrientation", function()
- applyFillDirection()
- end)
- applyFillDirection()
- Cell.__fill_direction_hook_installed = true
- end
- hookCell()
- Cell.RegisterCallback("AddonLoaded", "FillDirectionHook", hookCell)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement