Add bar overlays for absorb and heal absorb
This commit is contained in:
BIN
media/textures/bar_subtle_diagonal_bottom.tga
Normal file
BIN
media/textures/bar_subtle_diagonal_bottom.tga
Normal file
Binary file not shown.
BIN
media/textures/bar_subtle_diagonal_top.tga
Normal file
BIN
media/textures/bar_subtle_diagonal_top.tga
Normal file
Binary file not shown.
@@ -20,7 +20,7 @@ local types = omi.GetModule("types")
|
|||||||
types.StatusBar = types.CreateClass("StatusBar")
|
types.StatusBar = types.CreateClass("StatusBar")
|
||||||
local StatusBar = types.StatusBar
|
local StatusBar = types.StatusBar
|
||||||
|
|
||||||
function StatusBar:Init(parent, width, height, level, top)
|
function StatusBar:Init(parent, width, height, level, top, texture, bgtexture)
|
||||||
if top == nil then top = true end
|
if top == nil then top = true end
|
||||||
level = level or 0
|
level = level or 0
|
||||||
-- parent: the parent frame
|
-- parent: the parent frame
|
||||||
@@ -38,15 +38,17 @@ function StatusBar:Init(parent, width, height, level, top)
|
|||||||
end
|
end
|
||||||
|
|
||||||
bar:SetSize(width, height)
|
bar:SetSize(width, height)
|
||||||
bar:SetStatusBarTexture("Interface\\Addons\\OmicronFrames\\media\\textures\\bar_subtle_diagonal")
|
bar:SetStatusBarTexture(texture)
|
||||||
bar:GetStatusBarTexture():SetHorizTile(false)
|
bar:GetStatusBarTexture():SetHorizTile(false)
|
||||||
bar:GetStatusBarTexture():SetVertTile(false)
|
bar:GetStatusBarTexture():SetVertTile(false)
|
||||||
self.bar = bar
|
self.bar = bar
|
||||||
|
|
||||||
|
if bgtexture ~= nil then
|
||||||
local bg = bar:CreateTexture(nil, "BACKGROUND")
|
local bg = bar:CreateTexture(nil, "BACKGROUND")
|
||||||
bg:SetTexture("Interface\\Addons\\OmicronFrames\\media\\textures\\bar_subtle_diagonal")
|
bg:SetTexture(bgtexture)
|
||||||
bg:SetAllPoints(true)
|
bg:SetAllPoints(true)
|
||||||
self.bg = bg
|
self.bg = bg
|
||||||
|
end
|
||||||
|
|
||||||
self:SetRange(0, 1)
|
self:SetRange(0, 1)
|
||||||
self:SetValue(1)
|
self:SetValue(1)
|
||||||
@@ -61,6 +63,10 @@ function StatusBar:SetValue(value)
|
|||||||
self.bar:SetValue(value)
|
self.bar:SetValue(value)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function StatusBar:SetFillStyle(style)
|
||||||
|
self.bar:SetFillStyle(style)
|
||||||
|
end
|
||||||
|
|
||||||
function StatusBar:Show()
|
function StatusBar:Show()
|
||||||
self.bar:Show()
|
self.bar:Show()
|
||||||
end
|
end
|
||||||
@@ -78,5 +84,7 @@ end
|
|||||||
|
|
||||||
function StatusBar:SetColor(r, g, b)
|
function StatusBar:SetColor(r, g, b)
|
||||||
self.bar:SetStatusBarColor(r, g, b)
|
self.bar:SetStatusBarColor(r, g, b)
|
||||||
|
if self.bg ~= nil then
|
||||||
self.bg:SetVertexColor(0.2 * r, 0.2 * g, 0.2 * b)
|
self.bg:SetVertexColor(0.2 * r, 0.2 * g, 0.2 * b)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
@@ -50,7 +50,9 @@ local colors = {
|
|||||||
immune = { 0.0, 0.2, 0.4 },
|
immune = { 0.0, 0.2, 0.4 },
|
||||||
bomb = { 1.0, 0.7, 0.7 },
|
bomb = { 1.0, 0.7, 0.7 },
|
||||||
cyan = { 0.0, 0.8, 0.8 },
|
cyan = { 0.0, 0.8, 0.8 },
|
||||||
white = { 1.0, 1.0, 1.0 }
|
white = { 1.0, 1.0, 1.0 },
|
||||||
|
shield = { 0.85, .95, 1.0 },
|
||||||
|
absorb = { 0.5, .4, .75 },
|
||||||
}
|
}
|
||||||
|
|
||||||
-- This trucates _codepoints_ not graphemes. If combination codepoints are
|
-- This trucates _codepoints_ not graphemes. If combination codepoints are
|
||||||
@@ -86,11 +88,28 @@ function UnitFrame:Init(unit, config)
|
|||||||
|
|
||||||
self:SetMouseBinds(config.mouse)
|
self:SetMouseBinds(config.mouse)
|
||||||
|
|
||||||
self.hp = StatusBar:new(self, width, height, 0, true)
|
local texture = "Interface\\Addons\\OmicronFrames\\media\\textures\\bar_subtle_diagonal"
|
||||||
self.power = StatusBar:new(self, width, 6, 2, false)
|
local texture_top = "Interface\\Addons\\OmicronFrames\\media\\textures\\bar_subtle_diagonal_top"
|
||||||
|
local texture_bot = "Interface\\Addons\\OmicronFrames\\media\\textures\\bar_subtle_diagonal_bottom"
|
||||||
|
|
||||||
|
self.hp = StatusBar:new(self, width, height, 0, true, texture, texture)
|
||||||
|
|
||||||
|
self.power = StatusBar:new(self, width, 6, 2, false, texture, texture)
|
||||||
self.power:Hide()
|
self.power:Hide()
|
||||||
|
|
||||||
|
self.absorb = StatusBar:new(self, width, height, 1, true, texture_top)
|
||||||
|
self.absorb:SetColor(unpack(colors.absorb))
|
||||||
|
self.absorb:SetFillStyle("REVERSE")
|
||||||
|
|
||||||
|
self.shield = StatusBar:new(self, width, height, 1, true, texture_bot)
|
||||||
|
self.shield:SetColor(unpack(colors.shield))
|
||||||
|
self.shield:SetRange(0, 1)
|
||||||
|
self.shield:SetValue(0.6)
|
||||||
|
self.shield:SetFillStyle("REVERSE")
|
||||||
|
|
||||||
self.auras = AuraList:new(self)
|
self.auras = AuraList:new(self)
|
||||||
|
|
||||||
|
|
||||||
local overlays = CreateFrame("Frame", nil, secure)
|
local overlays = CreateFrame("Frame", nil, secure)
|
||||||
overlays:SetFrameStrata("MEDIUM")
|
overlays:SetFrameStrata("MEDIUM")
|
||||||
overlays:SetFrameLevel(100)
|
overlays:SetFrameLevel(100)
|
||||||
@@ -410,6 +429,8 @@ function UnitFrame:RegisterEvents()
|
|||||||
secure:RegisterUnitEvent("UNIT_HEALTH", unit)
|
secure:RegisterUnitEvent("UNIT_HEALTH", unit)
|
||||||
secure:RegisterUnitEvent("UNIT_MAXHEALTH", unit)
|
secure:RegisterUnitEvent("UNIT_MAXHEALTH", unit)
|
||||||
secure:RegisterUnitEvent("UNIT_NAME_UPDATE", unit)
|
secure:RegisterUnitEvent("UNIT_NAME_UPDATE", unit)
|
||||||
|
secure:RegisterUnitEvent("UNIT_ABSORB_AMOUNT_CHANGED", unit)
|
||||||
|
secure:RegisterUnitEvent("UNIT_HEAL_ABSORB_AMOUNT_CHANGED", unit)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- returns whether or not the unit guid has changed since the last call to this
|
-- returns whether or not the unit guid has changed since the last call to this
|
||||||
@@ -430,6 +451,22 @@ function UnitFrame:HasUnitChanged()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function UnitFrame:UNIT_HEAL_ABSORB_AMOUNT_CHANGED()
|
||||||
|
if self:HasUnitChanged() then
|
||||||
|
self:UpdateAll(true)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
self:UpdateAbsorb()
|
||||||
|
end
|
||||||
|
|
||||||
|
function UnitFrame:UNIT_ABSORB_AMOUNT_CHANGED()
|
||||||
|
if self:HasUnitChanged() then
|
||||||
|
self:UpdateAll(true)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
self:UpdateShield()
|
||||||
|
end
|
||||||
|
|
||||||
function UnitFrame:UNIT_AURA(unit, info)
|
function UnitFrame:UNIT_AURA(unit, info)
|
||||||
if self:HasUnitChanged() then
|
if self:HasUnitChanged() then
|
||||||
self:UpdateAll(true)
|
self:UpdateAll(true)
|
||||||
@@ -536,6 +573,8 @@ function UnitFrame:UpdateAll(unitChanged)
|
|||||||
end
|
end
|
||||||
self:UpdateHealth()
|
self:UpdateHealth()
|
||||||
self:UpdateHealthColor()
|
self:UpdateHealthColor()
|
||||||
|
self:UpdateAbsorb()
|
||||||
|
self:UpdateShield()
|
||||||
self:UpdateRange()
|
self:UpdateRange()
|
||||||
self:UpdateName()
|
self:UpdateName()
|
||||||
self:UpdateRole() -- Also calls UpdatePower if power is visible
|
self:UpdateRole() -- Also calls UpdatePower if power is visible
|
||||||
@@ -550,6 +589,32 @@ function UnitFrame:UpdateHealth()
|
|||||||
self.hp:SetValue(val)
|
self.hp:SetValue(val)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function UnitFrame:UpdateShield()
|
||||||
|
local unit = self.unit
|
||||||
|
local val = UnitGetTotalAbsorbs(unit)
|
||||||
|
local max = UnitHealthMax(unit)
|
||||||
|
if val <= 0 then
|
||||||
|
self.shield:Hide()
|
||||||
|
else
|
||||||
|
self.shield:SetRange(0, max)
|
||||||
|
self.shield:SetValue(val)
|
||||||
|
self.shield:Show()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function UnitFrame:UpdateAbsorb()
|
||||||
|
local unit = self.unit
|
||||||
|
local val = UnitGetTotalHealAbsorbs(unit)
|
||||||
|
local max = UnitHealthMax(unit)
|
||||||
|
if val <= 0 then
|
||||||
|
self.absorb:Hide()
|
||||||
|
else
|
||||||
|
self.absorb:SetRange(0, max)
|
||||||
|
self.absorb:SetValue(val)
|
||||||
|
self.absorb:Show()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function UnitFrame:UpdateHealthColor()
|
function UnitFrame:UpdateHealthColor()
|
||||||
local unit = self.unit
|
local unit = self.unit
|
||||||
local val = UnitHealth(unit)
|
local val = UnitHealth(unit)
|
||||||
|
Reference in New Issue
Block a user