diff --git a/media/textures/bar_subtle_diagonal_bottom.tga b/media/textures/bar_subtle_diagonal_bottom.tga new file mode 100644 index 0000000..910382a Binary files /dev/null and b/media/textures/bar_subtle_diagonal_bottom.tga differ diff --git a/media/textures/bar_subtle_diagonal_top.tga b/media/textures/bar_subtle_diagonal_top.tga new file mode 100644 index 0000000..778c98c Binary files /dev/null and b/media/textures/bar_subtle_diagonal_top.tga differ diff --git a/src/types/statusbar.lua b/src/types/statusbar.lua index e9f15e2..a18a18f 100644 --- a/src/types/statusbar.lua +++ b/src/types/statusbar.lua @@ -20,7 +20,7 @@ local types = omi.GetModule("types") types.StatusBar = types.CreateClass("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 level = level or 0 -- parent: the parent frame @@ -38,15 +38,17 @@ function StatusBar:Init(parent, width, height, level, top) end bar:SetSize(width, height) - bar:SetStatusBarTexture("Interface\\Addons\\OmicronFrames\\media\\textures\\bar_subtle_diagonal") + bar:SetStatusBarTexture(texture) bar:GetStatusBarTexture():SetHorizTile(false) bar:GetStatusBarTexture():SetVertTile(false) self.bar = bar - local bg = bar:CreateTexture(nil, "BACKGROUND") - bg:SetTexture("Interface\\Addons\\OmicronFrames\\media\\textures\\bar_subtle_diagonal") - bg:SetAllPoints(true) - self.bg = bg + if bgtexture ~= nil then + local bg = bar:CreateTexture(nil, "BACKGROUND") + bg:SetTexture(bgtexture) + bg:SetAllPoints(true) + self.bg = bg + end self:SetRange(0, 1) self:SetValue(1) @@ -61,6 +63,10 @@ function StatusBar:SetValue(value) self.bar:SetValue(value) end +function StatusBar:SetFillStyle(style) + self.bar:SetFillStyle(style) +end + function StatusBar:Show() self.bar:Show() end @@ -78,5 +84,7 @@ end function StatusBar:SetColor(r, g, b) self.bar:SetStatusBarColor(r, g, b) - self.bg:SetVertexColor(0.2 * r, 0.2 * g, 0.2 * b) + if self.bg ~= nil then + self.bg:SetVertexColor(0.2 * r, 0.2 * g, 0.2 * b) + end end diff --git a/src/types/unitframe.lua b/src/types/unitframe.lua index 9c388b6..b1f40e1 100644 --- a/src/types/unitframe.lua +++ b/src/types/unitframe.lua @@ -50,7 +50,9 @@ local colors = { immune = { 0.0, 0.2, 0.4 }, bomb = { 1.0, 0.7, 0.7 }, 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 @@ -86,11 +88,28 @@ function UnitFrame:Init(unit, config) self:SetMouseBinds(config.mouse) - self.hp = StatusBar:new(self, width, height, 0, true) - self.power = StatusBar:new(self, width, 6, 2, false) + local texture = "Interface\\Addons\\OmicronFrames\\media\\textures\\bar_subtle_diagonal" + 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.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) + local overlays = CreateFrame("Frame", nil, secure) overlays:SetFrameStrata("MEDIUM") overlays:SetFrameLevel(100) @@ -410,6 +429,8 @@ function UnitFrame:RegisterEvents() secure:RegisterUnitEvent("UNIT_HEALTH", unit) secure:RegisterUnitEvent("UNIT_MAXHEALTH", unit) secure:RegisterUnitEvent("UNIT_NAME_UPDATE", unit) + secure:RegisterUnitEvent("UNIT_ABSORB_AMOUNT_CHANGED", unit) + secure:RegisterUnitEvent("UNIT_HEAL_ABSORB_AMOUNT_CHANGED", unit) end -- returns whether or not the unit guid has changed since the last call to this @@ -430,6 +451,22 @@ function UnitFrame:HasUnitChanged() 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) if self:HasUnitChanged() then self:UpdateAll(true) @@ -536,6 +573,8 @@ function UnitFrame:UpdateAll(unitChanged) end self:UpdateHealth() self:UpdateHealthColor() + self:UpdateAbsorb() + self:UpdateShield() self:UpdateRange() self:UpdateName() self:UpdateRole() -- Also calls UpdatePower if power is visible @@ -550,6 +589,32 @@ function UnitFrame:UpdateHealth() self.hp:SetValue(val) 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() local unit = self.unit local val = UnitHealth(unit)