Moved version 0.11 to SVN

This commit is contained in:
iceroth
2006-07-17 13:47:18 +00:00
parent 80a88cfdb1
commit 772fe5a179
19 changed files with 1839 additions and 0 deletions

219
IceBarElement.lua Normal file
View File

@ -0,0 +1,219 @@
local AceOO = AceLibrary("AceOO-2.0")
IceBarElement = AceOO.Class(IceElement)
IceBarElement.virtual = true
IceBarElement.BackgroundAlpha = 0.25
IceBarElement.BarTexture = IceHUD.Location .. "\\textures\\HiBar"
IceBarElement.BackgroundTexture = IceHUD.Location .. "\\textures\\HiBarBG"
IceBarElement.BarProportion = 0.25 -- 0.18
IceBarElement.prototype.barFrame = nil
IceBarElement.prototype.side = nil
IceBarElement.prototype.offset = nil --offsets less than 0 should be reserved for pets etc
IceBarElement.prototype.width = nil
IceBarElement.prototype.height = nil
IceBarElement.prototype.backgroundAlpha = nil
-- Constructor --
function IceBarElement.prototype:init(name)
IceBarElement.super.prototype.init(self, name)
self.width = 77
self.height = 154
self.backgroundAlpha = IceBarElement.BackgroundAlpha
end
-- 'Public' methods -----------------------------------------------------------
function IceBarElement.prototype:SetPosition(side, offset)
IceBarElement.prototype.side = side
IceBarElement.prototype.offset = offset
end
-- 'Protected' methods --------------------------------------------------------
-- OVERRIDE
function IceBarElement.prototype:CreateFrame()
-- don't call overridden method
self:CreateBackground()
self:CreateBar()
self:CreateTexts()
end
-- Creates background for the bar
function IceBarElement.prototype:CreateBackground()
self.frame = CreateFrame("StatusBar", nil, self.parent)
self.frame:SetFrameStrata("BACKGROUND")
self.frame:SetWidth(self.width)
self.frame:SetHeight(self.height)
local bg = self.frame:CreateTexture(nil, "BACKGROUND")
bg:SetTexture(IceBarElement.BackgroundTexture)
bg:SetAllPoints(self.frame)
if (self.side == IceCore.Side.Left) then
bg:SetTexCoord(1, 0, 0, 1)
end
self.frame:SetStatusBarTexture(bg)
self.frame:SetStatusBarColor(self:GetColor("undef", self.backgroundAlpha))
local ownPoint = "LEFT"
if (self.side == ownPoint) then
ownPoint = "RIGHT"
end
-- ofxx = (bar width) + (extra space in between the bars)
local offx = (IceBarElement.BarProportion * self.width * self.offset) + (self.offset * 10)
if (self.side == IceCore.Side.Left) then
offx = offx * -1
end
self.frame:SetPoint("BOTTOM"..ownPoint, self.parent, "BOTTOM"..self.side, offx, 0)
end
-- Creates the actual bar
function IceBarElement.prototype:CreateBar()
self.barFrame = CreateFrame("StatusBar", nil, self.frame)
self.barFrame:SetFrameStrata("BACKGROUND")
self.barFrame:SetWidth(self.width)
self.barFrame:SetHeight(self.height)
local bar = self.frame:CreateTexture(nil, "BACKGROUND")
self.barFrame.texture = bar
bar:SetTexture(IceBarElement.BarTexture)
bar:SetAllPoints(self.frame)
self.barFrame:SetStatusBarTexture(bar)
self:UpdateBar(1, "undef")
local point = "LEFT"
if (self.side == point) then
point = "RIGHT"
end
self.barFrame:SetPoint("BOTTOM"..point, self.frame, "BOTTOM"..self.side, 0, 0)
end
function IceBarElement.prototype:CreateTexts()
self.frame.bottomUpperText = self:FontFactory(nil, 13)
self.frame.bottomLowerText = self:FontFactory(nil, 13)
self.frame.bottomUpperText:SetWidth(80)
self.frame.bottomLowerText:SetWidth(120)
local justify = "RIGHT"
if ((self.side == "LEFT" and self.offset <= 1) or
(self.side == "RIGHT" and self.offset > 1))
then
justify = "LEFT"
end
self.frame.bottomUpperText:SetJustifyH(justify)
self.frame.bottomLowerText:SetJustifyH(justify)
local ownPoint = self.side
if (self.offset > 1) then
ownPoint = self:Flip(ownPoint)
end
local parentPoint = self:Flip(self.side)
local offx = 2
-- adjust offset for bars where text is aligned to the outer side
if (self.offset <= 1) then
offx = IceBarElement.BarProportion * self.width + 6
end
if (self.side == IceCore.Side.Left) then
offx = offx * -1
end
self.frame.bottomUpperText:SetPoint("TOP"..ownPoint , self.frame, "BOTTOM"..parentPoint, offx, -1)
self.frame.bottomLowerText:SetPoint("TOP"..ownPoint , self.frame, "BOTTOM"..parentPoint, offx, -15)
end
function IceBarElement.prototype:Flip(side)
if (side == IceCore.Side.Left) then
return IceCore.Side.Right
else
return IceCore.Side.Left
end
end
function IceBarElement.prototype:SetScale(texture, scale)
if (self.side == IceCore.Side.Left) then
texture:SetTexCoord(1, 0, 1-scale, 1)
else
texture:SetTexCoord(0, 1, 1-scale, 1)
end
end
function IceBarElement.prototype:UpdateBar(scale, color, alpha)
alpha = alpha or 1
self.frame:SetAlpha(alpha)
self.frame:SetStatusBarColor(self:GetColor(color, self.backgroundAlpha))
self.barFrame:SetStatusBarColor(self:GetColor(color))
self:SetScale(self.barFrame.texture, scale)
end
-- Bottom line 1
function IceBarElement.prototype:SetBottomText1(text, color)
if not (color) then
color = "text"
end
self.frame.bottomUpperText:SetTextColor(self:GetColor(color, 1))
self.frame.bottomUpperText:SetText(text)
end
-- Bottom line 2
function IceBarElement.prototype:SetBottomText2(text, color, alpha)
if not (color) then
color = "text"
end
if not (alpha) then
alpha = self.alpha + 0.1
end
self.frame.bottomLowerText:SetTextColor(self:GetColor(color, alpha))
self.frame.bottomLowerText:SetText(text)
end
function IceBarElement.prototype:GetFormattedText(value1, value2)
local color = "ffcccccc"
if not (value2) then
return string.format("|c%s[|r%s|c%s]|r", color, value1, color)
end
return string.format("|c%s[|r%s|c%s/|r%s|c%s]|r", color, value1, color, value2, color)
end

76
IceCore.lua Normal file
View File

@ -0,0 +1,76 @@
local AceOO = AceLibrary("AceOO-2.0")
IceCore = AceOO.Class("AceEvent-2.0")
IceCore.Side = { Left = "LEFT", Right = "RIGHT" }
IceCore.Width = 150
-- Events modules should register/trigger during load
IceCore.Loaded = "IceCore_Loaded"
IceCore.RegisterModule = "IceCore_RegisterModule"
-- 'Private' variables
IceCore.prototype.IceHUDFrame = nil
IceCore.prototype.elements = {}
function IceCore.prototype:init()
IceCore.super.prototype.init(self)
IceHUD:Debug("IceCore.prototype:init()")
self:DrawFrame()
-- We are ready to load modules
self:RegisterEvent(IceCore.RegisterModule, "Register")
self:TriggerEvent(IceCore.Loaded)
end
function IceCore.prototype:Enable()
for i = 1, table.getn(self.elements) do
self.elements[i]:Create(self.IceHUDFrame)
self.elements[i]:Enable()
end
end
function IceCore.prototype:DrawFrame()
self.IceHUDFrame = CreateFrame("Frame","IceHUDFrame", UIParent)
self.IceHUDFrame:SetFrameStrata("BACKGROUND")
self.IceHUDFrame:SetWidth(IceCore.Width)
self.IceHUDFrame:SetHeight(20)
-- For debug purposes
--[[
self.IceHUDFrame:SetBackdrop(
{
bgFile = "Interface/Tooltips/UI-Tooltip-Background",
edgeFile = "Interface/Tooltips/UI-ToolTip-Border",
tile = false,
tileSize = 32,
edgeSize = 14,
insets = { left = 4, right = 4, top = 4, bottom = 4 }
} )
self.IceHUDFrame:SetBackdropColor(0.5, 0.5, 0.5, 0.1)
self.IceHUDFrame:SetBackdropBorderColor(0.4, 0.4, 0.4, 0.1)
--]]
self.IceHUDFrame:SetPoint("CENTER", 0, -150)
self.IceHUDFrame:Show()
end
-- Method to handle module registration
function IceCore.prototype:Register(element)
assert(element, "Trying to register a nil module")
IceHUD:Debug("Registering: " .. element:ToString())
table.insert(self.elements, element)
end

148
IceElement.lua Normal file
View File

@ -0,0 +1,148 @@
local AceOO = AceLibrary("AceOO-2.0")
IceElement = AceOO.Class("AceEvent-2.0")
IceElement.virtual = true
IceElement.Alpha = 0.3 -- default alpha for hud elements
-- Private variables --
IceElement.prototype.name = nil
IceElement.prototype.parent = nil
IceElement.prototype.frame = nil
IceElement.prototype.colors = {} -- Shared table for all child classes to save some memory
IceElement.prototype.alpha = nil
-- Constructor --
-- IceElements are to be instantiated before IceCore is loaded.
-- Therefore we can wait for IceCore to load and then register our
-- module to the core with another event.
function IceElement.prototype:init(name)
IceElement.super.prototype.init(self)
assert(name, "IceElement must have a name")
self.name = name
self.alpha = IceElement.Alpha
-- Some common colors
self:SetColor("text", 1, 1, 1)
self:SetColor("undef", 0.7, 0.7, 0.7)
self:RegisterEvent(IceCore.Loaded, "OnCoreLoad")
end
-- 'Public' methods -----------------------------------------------------------
function IceElement.prototype:ToString()
return "IceElement('" .. self.name .. "')"
end
function IceElement.prototype:GetName()
return self.name
end
function IceElement.prototype:Create(parent)
assert(parent, "IceElement 'parent' can't be nil")
self.parent = parent
self:CreateFrame()
end
function IceElement.prototype:Enable()
self.frame:Show()
end
function IceElement.prototype:Disable()
self.frame:Hide()
self:UnregisterAllEvents()
end
-- 'Protected' methods --------------------------------------------------------
-- This should be overwritten by inheriting classes
function IceElement.prototype:CreateFrame()
self.frame = CreateFrame("Frame", nil, self.parent)
end
function IceElement.prototype:GetColor(color, alpha)
if not (color) then
return 1, 1, 1, 1
end
if not (alpha) then
alpha = self.alpha
end
if not (self.colors[color]) then
local r, g, b = self:GetClassColor(color)
return r, g, b, alpha
end
return self.colors[color].r, self.colors[color].g, self.colors[color].b, alpha
end
function IceElement.prototype:GetHexColor(color, alpha)
local r, g, b, a = self:GetColor(color)
return string.format("%02x%02x%02x%02x", a * 255, r * 255, g * 255, b * 255)
end
function IceElement.prototype:SetColor(color, red, green, blue)
if (red > 1) then
red = red / 255
end
if (green > 1) then
green = green / 255
end
if (blue > 1) then
blue = blue / 255
end
self.colors[color] = {r = red, g = green, b = blue}
end
function IceElement.prototype:GetClassColor(class)
class = string.upper(class)
return RAID_CLASS_COLORS[class].r, RAID_CLASS_COLORS[class].g, RAID_CLASS_COLORS[class].b
end
function IceElement.prototype:FontFactory(weight, size, frame)
weight = weight or ""
local fontFile = IceHUD.Location .. "\\fonts\\Calibri" .. weight ..".ttf"
if not (frame) then
frame = self.frame
end
local font = frame:CreateFontString()
font:SetFont(fontFile, size)
font:SetShadowColor(0, 0, 0, 1)
font:SetShadowOffset(1, -1)
return font
end
-- Event Handlers -------------------------------------------------------------
-- Register ourself to the core
function IceElement.prototype:OnCoreLoad()
self:TriggerEvent(IceCore.RegisterModule, self)
end
-- Inherited classes should just instantiate themselves and let
-- superclass to handle registration to the core
-- IceInheritedClass:new()

20
IceHUD.lua Normal file
View File

@ -0,0 +1,20 @@
IceHUD = AceLibrary("AceAddon-2.0"):new("AceDebug-2.0")
local AceOO = AceLibrary("AceOO-2.0")
IceHUD.Location = "Interface\\AddOns\\IceHUD"
function IceHUD:OnInitialize()
self:SetDebugging(false)
self:Debug("IceHUD:OnInitialize()")
self.IceCore = IceCore:new()
end
function IceHUD:OnEnable()
self:Debug("IceHUD:OnEnable()")
self.IceCore:Enable()
end

31
IceHUD.toc Normal file
View File

@ -0,0 +1,31 @@
## Interface: 11100
## Author: Iceroth
## Title: IceHUD |cff7fff7f -Ace2-|r
## Notes: Another HUD mod
## Version: 0.11
## X-Category: UnitFrames
libs\AceLibrary\AceLibrary.lua
libs\AceOO-2.0\AceOO-2.0.lua
libs\AceEvent-2.0\AceEvent-2.0.lua
libs\AceDebug-2.0\AceDebug-2.0.lua
libs\AceLocale-2.0\AceLocale-2.0.lua
libs\AceAddon-2.0\AceAddon-2.0.lua
libs\Metrognome-2.0\Metrognome-2.0.lua
IceCore.lua
IceHUD.lua
IceElement.lua
IceBarElement.lua
IceUnitBar.lua
modules\PlayerHealth.lua
modules\PlayerMana.lua
modules\TargetHealth.lua
modules\TargetMana.lua
modules\DruidMana.lua
modules\TargetInfo.lua
modules\TargetOfTarget.lua
modules\CastBar.lua
modules\MirrorBar.lua

100
IceUnitBar.lua Normal file
View File

@ -0,0 +1,100 @@
local AceOO = AceLibrary("AceOO-2.0")
IceUnitBar = AceOO.Class(IceBarElement)
IceUnitBar.virtual = true
IceUnitBar.prototype.unit = nil
IceUnitBar.prototype.alive = nil
IceUnitBar.prototype.combat = nil
IceUnitBar.prototype.tapped = nil
IceUnitBar.prototype.health = nil
IceUnitBar.prototype.maxHealth = nil
IceUnitBar.prototype.healthPercentage = nil
IceUnitBar.prototype.mana = nil
IceUnitBar.prototype.maxMana = nil
IceUnitBar.prototype.manaPercentage = nil
IceUnitBar.prototype.unitClass = nil
-- Constructor --
function IceUnitBar.prototype:init(name, unit)
IceUnitBar.super.prototype.init(self, name)
assert(unit, "IceUnitBar 'unit' is nil")
self.unit = unit
_, self.unitClass = UnitClass(self.unit)
self:SetColor("dead", 0.5, 0.5, 0.5)
self:SetColor("tapped", 0.8, 0.8, 0.8)
end
-- 'Public' methods -----------------------------------------------------------
function IceUnitBar.prototype:Enable()
IceUnitBar.super.prototype.Enable(self)
self:RegisterEvent("PLAYER_UNGHOST", "Alive")
self:RegisterEvent("PLAYER_ALIVE", "Alive")
self:RegisterEvent("PLAYER_DEAD", "Dead")
self:RegisterEvent("PLAYER_REGEN_DISABLED", "InCombat")
self:RegisterEvent("PLAYER_REGEN_ENABLED", "OutCombat")
self.alive = not UnitIsDeadOrGhost(self.unit)
self.combat = UnitAffectingCombat(self.unit)
end
-- 'Protected' methods --------------------------------------------------------
-- To be overridden
function IceUnitBar.prototype:Update(unit)
if (self.combat) then
self.alpha = IceElement.Alpha + 0.2
self.backgroundAlpha = IceBarElement.BackgroundAlpha
else
self.alpha = IceElement.Alpha
self.backgroundAlpha = IceBarElement.BackgroundAlpha
end
self.tapped = UnitIsTapped(self.unit) and (not UnitIsTappedByPlayer(self.unit))
self.health = UnitHealth(self.unit)
self.maxHealth = UnitHealthMax(self.unit)
self.healthPercentage = math.floor( (self.health/self.maxHealth)*100 )
self.mana = UnitMana(self.unit)
self.maxMana = UnitManaMax(self.unit)
self.manaPercentage = math.floor( (self.mana/self.maxMana)*100 )
end
function IceUnitBar.prototype:Alive()
-- instead of maintaining a state for 3 different things
-- (dead, dead/ghost, alive) just afford the extra function call here
self.alive = not UnitIsDeadOrGhost(self.unit)
self:Update(self.unit)
end
function IceUnitBar.prototype:Dead()
self.alive = false
self:Update(self.unit)
end
function IceUnitBar.prototype:InCombat()
self.combat = true
self:Update(self.unit)
end
function IceUnitBar.prototype:OutCombat()
self.combat = false
self:Update(self.unit)
end

BIN
fonts/Calibri.ttf Normal file

Binary file not shown.

BIN
fonts/CalibriBold.ttf Normal file

Binary file not shown.

233
modules/CastBar.lua Normal file
View File

@ -0,0 +1,233 @@
local AceOO = AceLibrary("AceOO-2.0")
local CastBar = AceOO.Class(IceBarElement)
CastBar.prototype.casting = nil
CastBar.prototype.channeling = nil
CastBar.prototype.failing = nil
CastBar.prototype.succeeding = nil
CastBar.prototype.spellName = nil
CastBar.prototype.startTime = nil
CastBar.prototype.castTime = nil
CastBar.prototype.delay = nil
CastBar.prototype.debug = 0
-- Constructor --
function CastBar.prototype:init()
CastBar.super.prototype.init(self, "CastBar")
self.side = IceCore.Side.Left
self.offset = 0
self:SetColor("castCasting", 242, 242, 10)
self:SetColor("castChanneling", 117, 113, 161)
self:SetColor("castSuccess", 242, 242, 10)
self:SetColor("castFail", 1, 0, 0)
end
-- 'Public' methods -----------------------------------------------------------
function CastBar.prototype:Enable()
CastBar.super.prototype.Enable(self)
self.frame.bottomUpperText:SetWidth(200)
self:RegisterEvent("SPELLCAST_START", "CastStart")
self:RegisterEvent("SPELLCAST_STOP", "CastStop")
self:RegisterEvent("SPELLCAST_FAILED", "CastFailed")
self:RegisterEvent("SPELLCAST_INTERRUPTED", "CastInterrupted")
self:RegisterEvent("SPELLCAST_DELAYED", "CastDelayed")
self:RegisterEvent("SPELLCAST_CHANNEL_START", "ChannelingStart")
self:RegisterEvent("SPELLCAST_CHANNEL_STOP", "ChannelingStop")
self:RegisterEvent("SPELLCAST_CHANNEL_UPDATE", "ChannelingUpdate")
self.frame:Hide()
-- remove blizz cast bar
CastingBarFrame:UnregisterAllEvents()
end
function CastBar.prototype:Disable()
CastBar.super.prototype.Disable(self)
CastingBarFrame:RegisterEvent("SPELLCAST_START");
CastingBarFrame:RegisterEvent("SPELLCAST_STOP");
CastingBarFrame:RegisterEvent("SPELLCAST_FAILED");
CastingBarFrame:RegisterEvent("SPELLCAST_INTERRUPTED");
CastingBarFrame:RegisterEvent("SPELLCAST_DELAYED");
CastingBarFrame:RegisterEvent("SPELLCAST_CHANNEL_START");
CastingBarFrame:RegisterEvent("SPELLCAST_CHANNEL_UPDATE");
CastingBarFrame:RegisterEvent("SPELLCAST_CHANNEL_STOP");
end
-- 'Protected' methods --------------------------------------------------------
function CastBar.prototype:OnUpdate()
local taken = GetTime() - self.startTime
local scale = taken / (self.castTime + self.delay)
if (self.casting or self.channeling) then
if (scale > 1) then -- lag compensation
scale = 1
end
local timeRemaining = self.castTime - taken
local remaining = string.format("%.1f", timeRemaining)
if (timeRemaining < 0 and timeRemaining > -1.5) then -- lag compensation
remaining = 0
end
if (self.channeling) then
scale = 1 - scale
end
self:UpdateBar(scale, "castCasting")
self:SetBottomText1(remaining .. "s " .. self:GetFormattedText(self.spellName))
elseif (self.failing) then
self.alpha = 0.7
self:UpdateBar(1, "castFail", 1-scale)
self:SetBottomText1(self.spellName, "castFail")
if (scale >= 1) then
self:CleanUp()
self.frame:Hide()
self.frame:SetScript("OnUpdate", nil)
end
elseif (self.succeeding) then
if (scale < 0.1) then -- "wait" for possible fail event before showing success animation
return
end
self.alpha = 0.5
self:UpdateBar(1, "castSuccess", 1.1-scale)
if (scale >= 1) then
self:CleanUp()
self.frame:Hide()
self.frame:SetScript("OnUpdate", nil)
end
else -- shouldn't be needed
self:CleanUp()
self.frame:Hide()
self.frame:SetScript("OnUpdate", nil)
end
end
function CastBar.prototype:CastStart(name, castTime)
self.spellName = name
self.castTime = castTime / 1000
self.startTime = GetTime()
self.delay = 0
self.casting = true
self.frame:Show()
self.frame:SetScript("OnUpdate", function() self:OnUpdate() end)
end
function CastBar.prototype:CastStop()
if not (self.casting) then
return
end
self:CleanUp()
self.spellName = nil
self.castTime = 1
self.startTime = GetTime()
self.succeeding = true
self.frame:Show()
end
function CastBar.prototype:CastFailed()
self:CastTerminated("Failed")
end
function CastBar.prototype:CastInterrupted()
self:CastTerminated("Interrupted")
end
function CastBar.prototype:CastTerminated(reason)
if not (self.casting or self.channeling or self.succeeding) then
return
end
self:CleanUp()
self.spellName = reason
self.castTime = 1
self.startTime = GetTime()
self.failing = true
self.frame:Show()
end
function CastBar.prototype:CastDelayed(delay)
self.delay = self.delay + (delay / 1000)
end
function CastBar.prototype:ChannelingStart(duration, spell)
self.spellName = spell
self.castTime = duration / 1000
self.startTime = GetTime()
self.delay = 0
self.channeling = true
self.frame:Show()
self.frame:SetScript("OnUpdate", function() self:OnUpdate() end)
end
function CastBar.prototype:ChannelingStop()
self:CleanUp()
self.frame:Hide()
end
function CastBar.prototype:ChannelingUpdate(duration)
self.castTime = duration / 1000
end
function CastBar.prototype:CleanUp()
self.spellName = nil
self.castTime = nil
self.startTime = nil
self.delay = 0
self.casting = false
self.channeling = false
self.failing = false
self.succeeding = false
self:SetBottomText1()
self.alpha = IceElement.Alpha
end
-- Load us up
CastBar:new()

65
modules/DruidMana.lua Normal file
View File

@ -0,0 +1,65 @@
local AceOO = AceLibrary("AceOO-2.0")
local Metrognome = AceLibrary("Metrognome-2.0")
local DruidMana = AceOO.Class(IceUnitBar)
DruidMana.prototype.inForms = nil
-- Constructor --
function DruidMana.prototype:init()
DruidMana.super.prototype.init(self, "DruidMana", "player")
self.side = IceCore.Side.Right
self.offset = 0
self:SetColor("druidMana", 87, 82, 141)
end
function DruidMana.prototype:Enable()
DruidMana.super.prototype.Enable(self)
if (DruidBar_OnLoad) then
Metrognome:Register("DruidMana", self.Update, 0.1, self)
Metrognome:Start("DruidMana")
end
self:RegisterEvent("UNIT_DISPLAYPOWER", "FormsChanged")
self:Update()
end
function DruidMana.prototype:FormsChanged(unit)
if (unit ~= self.unit) then
return
end
self.inForms = (UnitPowerType(self.unit) ~= 0)
end
function DruidMana.prototype:Update(unit)
if ((not self.alive) or (not self.inForms)) then
self.frame:Hide()
return
else
self.frame:Show()
end
--IceHUD:Debug(self.alive, self.inForms)
local color = "druidMana"
self:UpdateBar(DruidBarKey.keepthemana / DruidBarKey.maxmana, color)
local percentage = DruidBarKey.keepthemana / DruidBarKey.maxmana * 100
self:SetBottomText1(math.floor(percentage))
--self:SetBottomText2(self:GetFormattedText(DruidBarKey.keepthemana, DruidBarKey.maxmana), color)
end
-- Load us up (if we are a druid)
local _, unitClass = UnitClass("player")
if (unitClass == "DRUID") then
DruidMana:new()
end

223
modules/MirrorBar.lua Normal file
View File

@ -0,0 +1,223 @@
local AceOO = AceLibrary("AceOO-2.0")
-- 2 classes in the same file.. ugly but keeps the idea of
-- "1 module, 1 file" intact
-------------------------------------------------------------------------------
-- MirrorBar --
-------------------------------------------------------------------------------
local MirrorBar = AceOO.Class(IceBarElement)
MirrorBar.prototype.timer = nil
MirrorBar.prototype.value = nil
MirrorBar.prototype.maxValue = nil
MirrorBar.prototype.scale = nil
MirrorBar.prototype.paused = nil
MirrorBar.prototype.label = nil
-- Constructor --
function MirrorBar.prototype:init(side, offset, name)
MirrorBar.super.prototype.init(self, name)
self.side = side
self.offset = offset
-- unregister the event superclass registered, we don't want to register
-- this to the core
self:UnregisterEvent(IceCore.Loaded)
end
function MirrorBar.prototype:Enable()
MirrorBar.super.prototype.Enable(self)
self.frame.bottomUpperText:SetWidth(200)
self.frame.bottomLowerText:SetWidth(200)
self.frame:Hide()
end
function MirrorBar.prototype:OnUpdate(elapsed)
if (self.paused) then
return
end
self.value = self.value + (self.scale * elapsed * 1000)
scale = self.value / self.maxValue
if (scale < 0) then -- lag compensation
scale = 0
end
if (scale > 1) then -- lag compensation
scale = 1
end
local timeRemaining = (self.maxValue - self.value) / 1000
local remaining = string.format("%.1f", timeRemaining)
if (timeRemaining < 0) then -- lag compensation
remaining = 0
end
self:UpdateBar(scale, self.timer)
local text = self.label .. " " .. remaining .. "s"
if (math.mod(self.offset, 2) == 1) then
self:SetBottomText1(text)
else
self:SetBottomText2(text, "text", 1)
end
end
function MirrorBar.prototype:MirrorStart(timer, value, maxValue, scale, paused, label)
self.timer = timer
self.value = value
self.maxValue = maxValue
self.scale = scale
self.paused = (paused > 0)
self.label = label
self.startTime = GetTime()
self.frame:Show()
self.frame:SetScript("OnUpdate", function() self:OnUpdate(arg1) end)
end
function MirrorBar.prototype:MirrorStop()
self:CleanUp()
self.frame:Hide()
self.frame:SetScript("OnUpdate", nil)
end
function MirrorBar.prototype:MirrorPause(paused)
if (paused > 0) then
self.paused = true
else
self.paused = false
end
end
function MirrorBar.prototype:CleanUp()
self.timer = nil
self.value = nil
self.maxValue = nil
self.scale = nil
self.paused = nil
self.label = nil
self.startTime = nil
self:SetBottomText1()
self:SetBottomText2()
end
-------------------------------------------------------------------------------
-- MirrorBarHandler --
-------------------------------------------------------------------------------
local MirrorBarHandler = AceOO.Class(IceElement)
MirrorBarHandler.prototype.bars = nil
-- Constructor --
function MirrorBarHandler.prototype:init()
MirrorBarHandler.super.prototype.init(self, "MirrorBarHandler")
self.side = IceCore.Side.Left
self.offset = 3
self.bars = {}
self:SetColor("EXHAUSTION", 1, 0.9, 0)
self:SetColor("BREATH", 0, 0.5, 1)
self:SetColor("DEATH", 1, 0.7, 0)
self:SetColor("FEIGNDEATH", 1, 0.9, 0)
end
function MirrorBarHandler.prototype:Enable()
MirrorBarHandler.super.prototype.Enable(self)
self:RegisterEvent("MIRROR_TIMER_START", "MirrorStart")
self:RegisterEvent("MIRROR_TIMER_STOP", "MirrorStop")
self:RegisterEvent("MIRROR_TIMER_PAUSE", "MirrorPause")
-- hide blizz mirror bar
UIParent:UnregisterEvent("MIRROR_TIMER_START");
end
function MirrorBarHandler.prototype:Disable()
MirrorBarHandler.super.prototype.Disable(self)
UIParent:RegisterEvent("MIRROR_TIMER_START");
end
function MirrorBarHandler.prototype:MirrorStart(timer, value, maxValue, scale, paused, label)
local done = nil
-- check if we can find an already running timer to reverse it
for i = 1, table.getn(self.bars) do
if (self.bars[i].timer == timer) then
done = true
self.bars[i]:MirrorStart(timer, value, maxValue, scale, paused, label)
end
end
-- check if there's a free instance in case we didn't find an already running bar
if not (done) then
for i = 1, table.getn(self.bars) do
if not (self.bars[i].timer) and not (done) then
done = true
self.bars[i]:MirrorStart(timer, value, maxValue, scale, paused, label)
end
end
end
-- finally create a new instance if no available ones were found
if not (done) then
local count = table.getn(self.bars)
self.bars[count + 1] = MirrorBar:new(self.side, self.offset + count, "MirrorBar" .. tostring(count+1))
self.bars[count + 1]:Create(self.parent)
self.bars[count + 1]:Enable()
self.bars[count + 1]:MirrorStart(timer, value, maxValue, scale, paused, label)
end
end
function MirrorBarHandler.prototype:MirrorStop(timer)
for i = 1, table.getn(self.bars) do
if (self.bars[i].timer == timer) then
self.bars[i]:MirrorStop()
end
end
end
function MirrorBarHandler.prototype:MirrorPause(paused)
for i = 1, table.getn(self.bars) do
if (self.bars[i].timer ~= nil) then
self.bars[i]:MirrorPause(paused > 0)
end
end
end
-- Load us up
MirrorBarHandler:new()

47
modules/PlayerHealth.lua Normal file
View File

@ -0,0 +1,47 @@
local AceOO = AceLibrary("AceOO-2.0")
local PlayerHealth = AceOO.Class(IceUnitBar)
-- Constructor --
function PlayerHealth.prototype:init()
PlayerHealth.super.prototype.init(self, "PlayerHealth", "player")
self.side = IceCore.Side.Left
self.offset = 1
self:SetColor("playerHealth", 37, 164, 30)
end
function PlayerHealth.prototype:Enable()
PlayerHealth.super.prototype.Enable(self)
self:RegisterEvent("UNIT_HEALTH", "Update")
self:RegisterEvent("UNIT_MAXHEALTH", "Update")
self:Update(self.unit)
end
function PlayerHealth.prototype:Update(unit)
PlayerHealth.super.prototype.Update(self)
if (unit and (unit ~= self.unit)) then
return
end
local color = "playerHealth"
if not (self.alive) then
color = "dead"
end
self:UpdateBar(self.health/self.maxHealth, color)
self:SetBottomText1(self.healthPercentage)
self:SetBottomText2(self:GetFormattedText(self.health, self.maxHealth), color)
end
-- Load us up
PlayerHealth:new()

78
modules/PlayerMana.lua Normal file
View File

@ -0,0 +1,78 @@
local AceOO = AceLibrary("AceOO-2.0")
local PlayerMana = AceOO.Class(IceUnitBar)
PlayerMana.prototype.manaType = nil
-- Constructor --
function PlayerMana.prototype:init()
PlayerMana.super.prototype.init(self, "PlayerMana", "player")
self.side = IceCore.Side.Right
self.offset = 1
self:SetColor("playerMana", 62, 54, 152)
self:SetColor("playerRage", 171, 59, 59)
self:SetColor("playerEnergy", 218, 231, 31)
end
function PlayerMana.prototype:Enable()
PlayerMana.super.prototype.Enable(self)
self:RegisterEvent("UNIT_MANA", "Update")
self:RegisterEvent("UNIT_MAXMANA", "Update")
self:RegisterEvent("UNIT_RAGE", "Update")
self:RegisterEvent("UNIT_MAXRAGE", "Update")
self:RegisterEvent("UNIT_ENERGY", "Update")
self:RegisterEvent("UNIT_MAXENERGY", "Update")
self:RegisterEvent("UNIT_DISPLAYPOWER", "ManaType")
self:ManaType(self.unit)
self:Update("player")
end
function PlayerMana.prototype:ManaType(unit)
if (unit ~= self.unit) then
return
end
self.manaType = UnitPowerType(self.unit)
self:Update(self.unit)
end
function PlayerMana.prototype:Update(unit)
PlayerMana.super.prototype.Update(self)
if (unit and (unit ~= "player")) then
return
end
local color = "playerMana"
if not (self.alive) then
color = "dead"
else
if (self.manaType == 1) then
color = "playerRage"
elseif (self.manaType == 3) then
color = "playerEnergy"
end
end
self:UpdateBar(self.mana/self.maxMana, color)
self:SetBottomText1(self.manaPercentage)
local amount = self:GetFormattedText(self.mana, self.maxMana)
-- druids get a little shorted string to make room for druid mana in forms
if (self.unitClass == "DRUID" and self.manaType ~= 0) then
amount = self:GetFormattedText(self.mana)
end
self:SetBottomText2(amount, color)
end
-- Load us up
PlayerMana:new()

74
modules/TargetHealth.lua Normal file
View File

@ -0,0 +1,74 @@
local AceOO = AceLibrary("AceOO-2.0")
local TargetHealth = AceOO.Class(IceUnitBar)
-- Constructor --
function TargetHealth.prototype:init()
TargetHealth.super.prototype.init(self, "TargetHealth", "target")
self.side = IceCore.Side.Left
self.offset = 2
self:SetColor("targetHealthHostile", 231, 31, 36)
self:SetColor("targetHealthFriendly", 46, 223, 37)
self:SetColor("targetHealthNeutral", 210, 219, 87)
end
function TargetHealth.prototype:Enable()
TargetHealth.super.prototype.Enable(self)
self:RegisterEvent("UNIT_HEALTH", "Update")
self:RegisterEvent("UNIT_MAXHEALTH", "Update")
self:RegisterEvent("PLAYER_TARGET_CHANGED", "TargetChanged")
self:Update("target")
end
function TargetHealth.prototype:TargetChanged()
self:Update("target")
end
function TargetHealth.prototype:Update(unit)
TargetHealth.super.prototype.Update(self)
if (unit and (unit ~= self.unit)) then
return
end
if not (UnitExists(unit)) then
self.frame:Hide()
return
else
self.frame:Show()
end
local color = "targetHealthFriendly" -- friendly > 4
local reaction = UnitReaction("target", "player")
if (reaction and (reaction == 4)) then
color = "targetHealthNeutral"
elseif (reaction and (reaction < 4)) then
color = "targetHealthHostile"
end
if (self.tapped) then
color = "tapped"
end
self:UpdateBar(self.health/self.maxHealth, color)
self:SetBottomText1(self.healthPercentage)
-- assumption that if a unit's max health is 100, it's not actual amount
-- but rather a percentage - this obviously has one caveat though
if (self.maxHealth ~= 100) then
self:SetBottomText2(self:GetFormattedText(self.health, self.maxHealth), color)
else
self:SetBottomText2(nil, color)
end
end
-- Load us up
TargetHealth:new()

342
modules/TargetInfo.lua Normal file
View File

@ -0,0 +1,342 @@
local AceOO = AceLibrary("AceOO-2.0")
local TargetInfo = AceOO.Class(IceElement)
TargetInfo.Width = 260
TargetInfo.prototype.buffSize = nil
-- Constructor --
function TargetInfo.prototype:init()
TargetInfo.super.prototype.init(self, "TargetInfo")
self:SetColor("combo", 1, 1, 0)
self.buffSize = math.floor((TargetInfo.Width - 15) / 16)
end
-- 'Public' methods -----------------------------------------------------------
function TargetInfo.prototype:Enable()
TargetInfo.super.prototype.Enable(self)
self:RegisterEvent("PLAYER_TARGET_CHANGED", "TargetChanged")
self:RegisterEvent("UNIT_AURA", "AuraChanged")
self:RegisterEvent("UNIT_FACTION", "InfoTextChanged")
self:RegisterEvent("UNIT_LEVEL", "InfoTextChanged");
self:RegisterEvent("UNIT_CLASSIFICATION_CHANGED", "InfoTextChanged");
self:RegisterEvent("PLAYER_FLAGS_CHANGED", "InfoTextChanged");
self:RegisterEvent("RAID_TARGET_UPDATE", "RaidIconChanged");
self:RegisterEvent("PLAYER_COMBO_POINTS", "ComboPointsChanged");
end
-- 'Protected' methods --------------------------------------------------------
-- OVERRIDE
function TargetInfo.prototype:CreateFrame()
TargetInfo.super.prototype.CreateFrame(self)
self.frame:SetFrameStrata("BACKGROUND")
self.frame:SetWidth(TargetInfo.Width)
self.frame:SetHeight(42)
self.frame:SetPoint("TOP", self.parent, "BOTTOM", 0, -50)
--[[
self.frame:SetBackdrop(
{
bgFile = "Interface/Tooltips/UI-Tooltip-Background",
edgeFile = "Interface/Tooltips/UI-ToolTip-Border",
tile = false,
tileSize = 32,
edgeSize = 5,
insets = { left = 1, right = 1, top = 1, bottom = 1 }
} )
self.frame:SetBackdropColor(0.5, 0.5, 0.5, 0.2)
self.frame:SetBackdropBorderColor(0.4, 0.4, 0.4, 0.4)
--]]
self.frame:Show()
self:CreateTextFrame()
self:CreateInfoTextFrame()
self:CreateBuffFrame()
self:CreateDebuffFrame()
self:CreateRaidIconFrame()
self:CreateComboFrame()
end
function TargetInfo.prototype:CreateTextFrame()
self.frame.targetName = self:FontFactory("Bold", 15)
self.frame.targetName:SetWidth(TargetInfo.Width)
self.frame.targetName:SetHeight(14)
self.frame.targetName:SetJustifyH("LEFT")
self.frame.targetName:SetJustifyV("BOTTOM")
self.frame.targetName:SetPoint("TOPLEFT", self.frame, "TOPLEFT", 2, -2)
self.frame.targetName:Show()
end
function TargetInfo.prototype:CreateInfoTextFrame()
self.frame.targetInfo = self:FontFactory(nil, 13)
self.frame.targetInfo:SetWidth(TargetInfo.Width)
self.frame.targetInfo:SetHeight(14)
self.frame.targetInfo:SetJustifyH("LEFT")
self.frame.targetInfo:SetJustifyV("TOP")
self.frame.targetInfo:SetPoint("TOPLEFT", self.frame, "TOPLEFT", 2, -16)
self.frame.targetInfo:Show()
end
function TargetInfo.prototype:CreateComboFrame()
self.frame.comboPoints = self:FontFactory("Bold", 18)
self.frame.comboPoints:SetWidth(TargetInfo.Width)
self.frame.comboPoints:SetJustifyH("CENTER")
self.frame.comboPoints:SetPoint("BOTTOM", self.frame, "TOP", 0, 5)
self.frame.comboPoints:Show()
end
function TargetInfo.prototype:CreateRaidIconFrame()
self.frame.raidIcon = self.frame:CreateTexture(nil, "BACKGROUND")
self.frame.raidIcon:SetTexture("Interface\\TargetingFrame\\UI-RaidTargetingIcons")
self.frame.raidIcon:SetPoint("TOPRIGHT", self.frame, "TOPLEFT", -5, -5)
self.frame.raidIcon:SetWidth(16)
self.frame.raidIcon:SetHeight(16)
SetRaidTargetIconTexture(self.frame.raidIcon, 0)
self.frame:Hide()
end
function TargetInfo.prototype:CreateBuffFrame()
self.frame.buffFrame = CreateFrame("Frame", nil, self.frame)
self.frame.buffFrame:SetFrameStrata("BACKGROUND")
self.frame.buffFrame:SetWidth(TargetInfo.Width)
self.frame.buffFrame:SetHeight(20)
self.frame.buffFrame:SetPoint("TOPLEFT", self.frame, "TOPLEFT", 2, -32)
self.frame.buffFrame:Show()
self.frame.buffFrame.buffs = self:CreateIconFrames(self.frame.buffFrame)
end
function TargetInfo.prototype:CreateDebuffFrame()
self.frame.debuffFrame = CreateFrame("Frame", nil, self.frame)
self.frame.debuffFrame:SetFrameStrata("BACKGROUND")
self.frame.debuffFrame:SetWidth(TargetInfo.Width)
self.frame.debuffFrame:SetHeight(20)
self.frame.debuffFrame:SetPoint("TOPLEFT", self.frame, "TOPLEFT", 2, -34 - self.buffSize)
self.frame.debuffFrame:Show()
self.frame.debuffFrame.buffs = self:CreateIconFrames(self.frame.debuffFrame)
end
function TargetInfo.prototype:CreateIconFrames(parent)
local buffs = {}
for i = 1, 16 do
buffs[i] = CreateFrame("Frame", nil, parent)
buffs[i]:SetFrameStrata("BACKGROUND")
buffs[i]:SetWidth(self.buffSize)
buffs[i]:SetHeight(self.buffSize)
buffs[i]:SetPoint("LEFT", (i-1) * self.buffSize + (i-1), 0)
buffs[i]:Show()
buffs[i].texture = buffs[i]:CreateTexture()
buffs[i].texture:SetTexture(nil)
buffs[i].texture:SetAllPoints(buffs[i])
buffs[i].stack = self:FontFactory("Bold", 15, buffs[i])
buffs[i].stack:SetPoint("BOTTOMRIGHT" , buffs[i], "BOTTOMRIGHT", 0, -1)
end
return buffs
end
function TargetInfo.prototype:UpdateBuffs()
for i = 1, 16 do
local buffTexture, buffApplications = UnitBuff("target", i)
self.frame.buffFrame.buffs[i].texture:SetTexture(buffTexture)
if (buffApplications and (buffApplications > 1)) then
self.frame.buffFrame.buffs[i].stack:SetText(buffApplications)
else
self.frame.buffFrame.buffs[i].stack:SetText(nil)
end
end
for i = 1, 16 do
local buffTexture, buffApplications = UnitDebuff("target", i)
self.frame.debuffFrame.buffs[i].texture:SetTexture(buffTexture)
if (buffApplications and (buffApplications > 1)) then
self.frame.debuffFrame.buffs[i].stack:SetText(buffApplications)
else
self.frame.debuffFrame.buffs[i].stack:SetText(nil)
end
end
end
function TargetInfo.prototype:InfoTextChanged(unit)
if (unit == "target") then
self.frame.targetInfo:SetText(self:GetInfoString())
end
end
function TargetInfo.prototype:AuraChanged(unit)
if (unit == "target") then
self:UpdateBuffs()
end
end
function TargetInfo.prototype:ComboPointsChanged()
self:UpdateComboPoints()
end
function TargetInfo.prototype:RaidIconChanged(unit)
if (unit == "target") then
self:UpdateRaidTargetIcon()
end
end
function TargetInfo.prototype:UpdateRaidTargetIcon()
if not (UnitExists("target")) then
self.frame.raidIcon:Hide()
return
end
local index = GetRaidTargetIndex("target");
if (index and (index > 0)) then
SetRaidTargetIconTexture(self.frame.raidIcon, index)
self.frame.raidIcon:Show()
else
self.frame.raidIcon:Hide()
end
end
function TargetInfo.prototype:UpdateComboPoints()
local points = GetComboPoints("target")
self.frame.comboPoints:SetTextColor(self:GetColor("combo", 0.7))
if (points == 0) then
points = nil
end
self.frame.comboPoints:SetText(points)
end
function TargetInfo.prototype:TargetChanged()
local name = UnitName("target")
local _, unitClass = UnitClass("target")
self.frame.targetName:SetTextColor(self:GetColor(unitClass, 1))
self.frame.targetName:SetText(name)
self.frame.targetInfo:SetText(self:GetInfoString())
self:UpdateBuffs()
self:UpdateRaidTargetIcon()
self:UpdateComboPoints()
end
function TargetInfo.prototype:GetInfoString()
local u = "target"
if not (UnitExists(u)) then
return ""
end
local class, _ = UnitClass(u)
local creatureType = UnitCreatureType(u)
local classification = UnitClassification(u)
local level = UnitLevel(u)
local isPlayer = UnitIsPlayer(u)
local classColor = self:GetHexColor(class)
local sLevel = "[??] "
if (level > 0) then
sLevel = "[L" .. level
if (UnitIsPlusMob(u)) then
sLevel = sLevel .. "+"
end
sLevel = sLevel .. "] "
end
local sClass = ""
if (class and isPlayer) then
sClass = "|c" .. classColor .. class .. "|r "
elseif (creatureType) then
sClass = creatureType .. " "
end
local sPVP = ""
if (isPlayer) then
if (UnitIsPVP(u)) then
local color = "ff10ff10" -- friendly
if (UnitFactionGroup("target") ~= UnitFactionGroup("player")) then
color = "ffff1010"
end
sPVP = "|c" .. color .. "[PvP]|r "
else
sPVP = "|cff1010ff[PvE]|r "
end
end
local sClassification = ""
if (classification == "rare" or classification == "rareelite") then
sClassification = "[Rare] "
end
if (classification == "worldboss") then
sClassification = "[World Boss] "
end
local sLeader = ""
if (UnitIsPartyLeader(u)) then
sLeader = "[Leader] "
end
local guildName, guildRankName, guildRankIndex = GetGuildInfo("target")
local sGuild = ""
if (guildName) then
--sGuild = " <" .. guildName .. ">"
end
return string.format("%s%s%s%s%s%s",
sLevel, sClass, sPVP, sClassification, sLeader, sGuild)
end
-- Load us up
TargetInfo:new()

77
modules/TargetMana.lua Normal file
View File

@ -0,0 +1,77 @@
local AceOO = AceLibrary("AceOO-2.0")
local TargetMana = AceOO.Class(IceUnitBar)
-- Constructor --
function TargetMana.prototype:init()
TargetMana.super.prototype.init(self, "TargetMana", "target")
self.side = IceCore.Side.Right
self.offset = 2
self:SetColor("targetMana", 52, 64, 221)
self:SetColor("targetRage", 235, 44, 26)
self:SetColor("targetEnergy", 228, 242, 31)
self:SetColor("targetFocus", 242, 149, 98)
end
function TargetMana.prototype:Enable()
TargetMana.super.prototype.Enable(self)
self:RegisterEvent("UNIT_MANA", "Update")
self:RegisterEvent("UNIT_MAXMANA", "Update")
self:RegisterEvent("UNIT_RAGE", "Update")
self:RegisterEvent("UNIT_MAXRAGE", "Update")
self:RegisterEvent("UNIT_ENERGY", "Update")
self:RegisterEvent("UNIT_MAXENERGY", "Update")
self:RegisterEvent("UNIT_AURA", "Update")
self:RegisterEvent("PLAYER_TARGET_CHANGED", "TargetChanged")
self:Update("target")
end
function TargetMana.prototype:TargetChanged()
self:Update("target")
end
function TargetMana.prototype:Update(unit)
TargetMana.super.prototype.Update(self)
if (unit and (unit ~= self.unit)) then
return
end
if ((not UnitExists(unit)) or (self.maxMana == 0)) then
self.frame:Hide()
return
else
self.frame:Show()
end
local manaType = UnitPowerType(self.unit)
local color = "targetMana"
if (manaType == 1) then
color = "targetRage"
elseif (manaType == 2) then
color = "targetFocus"
elseif (manaType == 3) then
color = "targetEnergy"
end
if (self.tapped) then
color = "tapped"
end
self:UpdateBar(self.mana/self.maxMana, color)
self:SetBottomText1(self.manaPercentage)
self:SetBottomText2(self:GetFormattedText(self.mana, self.maxMana), color)
end
-- Load us up
TargetMana:new()

106
modules/TargetOfTarget.lua Normal file
View File

@ -0,0 +1,106 @@
local AceOO = AceLibrary("AceOO-2.0")
local Metrognome = AceLibrary("Metrognome-2.0")
local TargetOfTarget = AceOO.Class(IceElement)
-- Constructor --
function TargetOfTarget.prototype:init()
TargetOfTarget.super.prototype.init(self, "TargetOfTarget")
self:SetColor("totHostile", 0.8, 0.1, 0.1)
self:SetColor("totFriendly", 0.2, 1, 0.2)
self:SetColor("totNeutral", 0.9, 0.9, 0)
end
function TargetOfTarget.prototype:Enable()
TargetOfTarget.super.prototype.Enable(self)
Metrognome:Register("TargetOfTarget", self.Update, 0.2, self)
Metrognome:Start("TargetOfTarget")
self:RegisterEvent("PLAYER_TARGET_CHANGED", "Update")
self:Update()
end
-- 'Protected' methods --------------------------------------------------------
-- OVERRIDE
function TargetOfTarget.prototype:CreateFrame()
TargetOfTarget.super.prototype.CreateFrame(self)
self.frame:SetFrameStrata("BACKGROUND")
self.frame:SetWidth(260)
self.frame:SetHeight(50)
self.frame:SetPoint("TOP", self.parent, "BOTTOM", 0, -50)
self.frame:Show()
self:CreateToTFrame()
self:CreateToTHPFrame()
end
function TargetOfTarget.prototype:CreateToTFrame()
self.frame.totName = self:FontFactory("Bold", 14)
self.frame.totName:SetWidth(120)
self.frame.totName:SetHeight(14)
self.frame.totName:SetJustifyH("RIGHT")
self.frame.totName:SetJustifyV("BOTTOM")
self.frame.totName:SetPoint("TOPRIGHT", self.frame, "TOPRIGHT", -2, -2)
self.frame.totName:Show()
end
function TargetOfTarget.prototype:CreateToTHPFrame()
self.frame.totHealth = self:FontFactory(nil, 12)
self.frame.totHealth:SetWidth(120)
self.frame.totHealth:SetHeight(14)
self.frame.totHealth:SetJustifyH("RIGHT")
self.frame.totHealth:SetJustifyV("TOP")
self.frame.totHealth:SetPoint("TOPRIGHT", self.frame, "TOPRIGHT", -2, -16)
self.frame.totHealth:Show()
end
function TargetOfTarget.prototype:Update()
if not (UnitExists("targettarget")) then
self.frame.totName:SetText()
self.frame.totHealth:SetText()
return
end
local _, unitClass = UnitClass("targettarget")
local name = UnitName("targettarget")
self.frame.totName:SetTextColor(self:GetColor(unitClass, 1))
self.frame.totName:SetText(name)
local color = "totFriendly" -- friendly > 4
local reaction = UnitReaction("targettarget", "player")
if (reaction and (reaction == 4)) then
color = "totNeutral"
elseif (reaction and (reaction < 4)) then
color = "totHostile"
end
local health = UnitHealth("targettarget")
local maxHealth = UnitHealthMax("targettarget")
local healthPercentage = math.floor( (health/maxHealth)*100 )
self.frame.totHealth:SetTextColor(self:GetColor(color, 1))
self.frame.totHealth:SetText(healthPercentage .. "%")
end
-- load us up
TargetOfTarget:new()

BIN
textures/HiBar.blp Normal file

Binary file not shown.

BIN
textures/HiBarBG.blp Normal file

Binary file not shown.