local _, cfg = ... --import config
local addon, ns = ... --get addon namespace
-----------------------------
-- Add custom functions (overrides)
function CreateBackdrop(frame)
frame:SetBackdrop({bgFile = "Interface\\Buttons\\WHITE8x8", edgeFile = "Interface\\Buttons\\WHITE8x8", edgeSize = 2,
insets = {top = 2, left = 2, bottom = 2, right = 2}})
frame:SetBackdropColor(0,0,0,.5)
frame:SetBackdropBorderColor(0,0,0,1)
frame:CreateBorder(12,1,1,1)
frame:SetBorderPadding(1)
end
------------------------------------------------------------------------
-- UnitSpecific settings
------------------------------------------------------------------------
local UnitSpecific = {
player = function(self)
-- player specific stuff
self:SetSize(cfg.width,cfg.height)
-- 3D Portrait
-- Position and size
local Portrait = CreateFrame('PlayerModel', nil, self)
Portrait:SetSize(cfg.height, cfg.height)
Portrait:SetPoint('RIGHT', self, 'LEFT', -2,0)
CreateBackdrop(Portrait)
-- Register it with oUF
self.Portrait = Portrait
-----------------------------
-- Runes
local Runes = {}
for index = 1, 6 do
-- Position and size of the rune bar indicators
local Rune = CreateFrame('StatusBar', nil, Power)
Rune:SetSize(120 / 6, 20)
Rune:SetPoint('TOPLEFT', Power, 'BOTTOMLEFT', index * 120 / 6 - 20, 0)
Rune:CreateBorder(10,1,1,1)
Rune:SetBorderPadding(1)
Rune:SetStatusBarTexture(cfg.statusbar_texture)
CreateBackdrop(Rune)
Runes[index] = Rune
end
-- Register with oUF
self.Runes = Runes
-----------------------------
-- Eclipse Bar
local EclipseBar = CreateFrame("Frame", nil, self)
EclipseBar:SetPoint("TOP", Power, "BOTTOM", 0, -2) -- are you sure you want this overlapping your power bar by 2px?
EclipseBar:SetSize(cfg.width, 15)
self.EclipseBar = EclipseBar
local LunarBar = CreateFrame("StatusBar", nil, EclipseBar)
LunarBar:SetPoint("LEFT")
LunarBar:SetSize(cfg.width, 15)
LunarBar:SetStatusBarTexture(cfg.statusbar_texture)
LunarBar:CreateBorder(12,1,1,1)
LunarBar:SetBorderPadding(1)
EclipseBar.LunarBar = LunarBar
local SolarBar = CreateFrame("StatusBar", nil, EclipseBar)
SolarBar:SetPoint("LEFT", LunarBar:GetStatusBarTexture(), "RIGHT")
SolarBar:SetSize(cfg.width, 15)
EclipseBar.SolarBar = SolarBar
-----------------------------
-- Druid Mana
-- Position and size
local DruidMana = CreateFrame('StatusBar', nil, Power)
DruidMana:SetSize(20, 20)
DruidMana:SetPoint('TOP',Power,'BOTTOM',0,-2)
DruidMana:SetPoint('LEFT')
DruidMana:SetPoint('RIGHT')
DruidMana:CreateBorder(8,1,1,1)
DruidMana:SetBorderPadding(1)
-- Add a background
local Background = DruidMana:CreateTexture(nil, 'BACKGROUND')
Background:SetAllPoints(DruidMana)
Background:SetTexture(0, 0, 0, .5)
-- Register it with oUF
self.DruidMana = DruidMana
self.DruidMana.bg = Background
-----------------------------
-- Totems
local Totems = {}
for index = 1, MAX_TOTEMS do
-- Position and size of the totem indicator
local Totem = CreateFrame('Button', nil, self)
Totem:SetSize(40, 40)
Totem:SetPoint('TOPLEFT', Power, 'BOTTOMLEFT', index * Totem:GetWidth(), 0)
local Icon = Totem:CreateTexture(nil, "OVERLAY")
Icon:SetAllPoints()
local Cooldown = CreateFrame("Cooldown", nil, Totem)
Cooldown:SetAllPoints()
Totem.Icon = Icon
Totem.Cooldown = Cooldown
Totems[index] = Totem
end
-- Register with oUF
self.Totems = Totems
-----------------------------
-- Castbar
-- Position and size
local Castbar = CreateFrame("StatusBar", nil, self)
Castbar:SetSize(200, 20)
Castbar:SetStatusBarTexture(cfg.statusbar_texture)
Castbar:SetPoint('CENTER',UIParent,0,-140)
Castbar:CreateBorder(12,1,1,1)
Castbar:SetBorderPadding(1)
-- Add a background
local Background = Castbar:CreateTexture(nil, 'BACKGROUND')
Background:SetTexture(TEXTURE)
Background:SetAllPoints(Castbar)
Background:SetTexture(0, 0, 0, .5)
-- Add a spark
local Spark = Castbar:CreateTexture(nil, "OVERLAY")
Spark:SetSize(20, 10)
Spark:SetBlendMode("ADD")
-- Add a timer
local Time = Castbar:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
Time:SetPoint("RIGHT", Castbar, -3, 1)
-- Add spell text
local Text = Castbar:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
Text:SetPoint("LEFT", Castbar, 3, 1)
-- Add Shield
local Shield = Castbar:CreateTexture(nil, "OVERLAY")
Shield:SetSize(20, 10)
Shield:SetPoint("CENTER", Castbar)
-- Add safezone
local SafeZone = Castbar:CreateTexture(nil, "OVERLAY")
-- Register it with oUF
self.Castbar = Castbar
self.Castbar.bg = Background
self.Castbar.Spark = Spark
self.Castbar.Time = Time
self.Castbar.Text = Text
self.Castbar.SafeZone = SafeZone
end,
target = function(self)
-- target specific stuff
self:SetSize(cfg.width,cfg.height)
-- 3D Portrait
-- Position and size
local Portrait = CreateFrame('PlayerModel', nil, self)
Portrait:SetSize(cfg.height, cfg.height)
Portrait:SetPoint('LEFT', self, 'RIGHT', 2,0)
CreateBackdrop(Portrait)
-- Register it with oUF
self.Portrait = Portrait
-----------------------------
-- Castbar
-- Position and size
local Castbar = CreateFrame("StatusBar", nil, self)
Castbar:SetSize(200, 20)
Castbar:SetStatusBarTexture(cfg.statusbar_texture)
Castbar:SetPoint('CENTER',UIParent,0,-115)
Castbar:CreateBorder(12,1,1,1)
Castbar:SetBorderPadding(1)
-- Add a background
local Background = Castbar:CreateTexture(nil, 'BACKGROUND')
Background:SetTexture(cfg.statusbar_texture)
Background:SetAllPoints(Castbar)
Background:SetTexture(0, 0, 0, .5)
-- Add a spark
local Spark = Castbar:CreateTexture(nil, "OVERLAY")
Spark:SetSize(20, 10)
Spark:SetBlendMode("ADD")
-- Add a timer
local Time = Castbar:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
Time:SetPoint("RIGHT", Castbar, -3, 1)
-- Add spell text
local Text = Castbar:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
Text:SetPoint("LEFT", Castbar, 3, 1)
-- Add Shield
local Shield = Castbar:CreateTexture(nil, "OVERLAY")
Shield:SetSize(20, 10)
Shield:SetPoint("CENTER", Castbar)
-- Add safezone
local SafeZone = Castbar:CreateTexture(nil, "OVERLAY")
-- Register it with oUF
self.Castbar = Castbar
self.Castbar.bg = Background
self.Castbar.Spark = Spark
self.Castbar.Time = Time
self.Castbar.Text = Text
self.Castbar.SafeZone = SafeZone
end,
focus = function(self)
-- target specific stuff
self:SetSize(cfg.width,cfg.height)
-- 3D Portrait
-- Position and size
local Portrait = CreateFrame('PlayerModel', nil, self)
Portrait:SetSize(cfg.height, cfg.height)
Portrait:SetPoint('RIGHT', self, 'LEFT', -2,0)
CreateBackdrop(Portrait)
-- Register it with oUF
self.Portrait = Portrait
-----------------------------
-- Castbar
-- Position and size
local Castbar = CreateFrame("StatusBar", nil, self)
Castbar:SetSize(200, 20)
Castbar:SetStatusBarTexture(cfg.statusbar_texture)
Castbar:SetPoint('CENTER',UIParent,0,-165)
Castbar:CreateBorder(12,1,1,1)
Castbar:SetBorderPadding(1)
-- Add a background
local Background = Castbar:CreateTexture(nil, 'BACKGROUND')
Background:SetTexture(cfg.statusbar_texture)
Background:SetAllPoints(Castbar)
Background:SetTexture(0, 0, 0, .5)
-- Add a spark
local Spark = Castbar:CreateTexture(nil, "OVERLAY")
Spark:SetSize(20, 10)
Spark:SetBlendMode("ADD")
-- Add a timer
local Time = Castbar:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
Time:SetPoint("RIGHT", Castbar, -3, 1)
-- Add spell text
local Text = Castbar:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
Text:SetPoint("LEFT", Castbar, 3, 1)
-- Add Shield
local Shield = Castbar:CreateTexture(nil, "OVERLAY")
Shield:SetSize(20, 10)
Shield:SetPoint("CENTER", Castbar)
-- Add safezone
local SafeZone = Castbar:CreateTexture(nil, "OVERLAY")
-- Register it with oUF
self.Castbar = Castbar
self.Castbar.bg = Background
self.Castbar.Spark = Spark
self.Castbar.Time = Time
self.Castbar.Text = Text
self.Castbar.SafeZone = SafeZone
end,
boss = function(self)
-- boss frames
end,
arena = function(self)
-- arena frames
end,
party = function(self)
--party stuff
end
}
UnitSpecific.raid = UnitSpecific.party -- raid is equal to party
------------------------------------------------------------------------
-- Shared settings
------------------------------------------------------------------------
local function Shared(self, unit)
self:SetScript("OnEnter", UnitFrame_OnEnter)
self:SetScript("OnLeave", UnitFrame_OnLeave)
self:RegisterForClicks"AnyUp"
-- shared functions
-----------------------------
-- Health
-- Your Health Statusbar
local Health = CreateFrame("StatusBar", nil, self)
Health:SetHeight(cfg.height/2)
Health:SetStatusBarTexture(cfg.statusbar_texture)
Health:SetPoint('TOP')
Health:SetPoint('LEFT')
Health:SetPoint('RIGHT')
Health:CreateBorder(12,1,1,1)
Health:SetBorderPadding(1)
CreateBackdrop(Health)
-- Options
Health.frequentUpdates = true
Health.colorTapping = true
Health.colorDisconnected = true
Health.colorClass = true
Health.colorReaction = true
Health.colorHealth = true
-- Register it with oUF
self.Health = Health
self.Health.bg = Healthbg
--Text
--Percent
local HealthText = Health:CreateFontString(nil, "OVERLAY", "TextStatusBarText") -- parent to last child to make sure it's on top
HealthText:SetPoint("RIGHT", Health, -5,0) -- but anchor to the base element so it doesn't wiggle
self:Tag(HealthText, "[perhp]") -- oUF will automagically update it!
Health.text = HealthText
--Value
local HealthText2 = Health:CreateFontString(nil, "OVERLAY", "TextStatusBarText") -- parent to last child to make sure it's on top
HealthText2:SetPoint("LEFT", Health, 5,0) -- but anchor to the base element so it doesn't wiggle
self:Tag(HealthText2, "[curhp]") -- oUF will automagically update it!
Health.text = HealthText2
-----------------------------
-- Power
-- Your Power Statusbar
local Power = CreateFrame("StatusBar", nil, Health)
Power:SetHeight(cfg.height/2-11)
Power:SetStatusBarTexture(cfg.statusbar_texture)
Power:SetPoint('TOP',Health,'BOTTOM',0,-2)
Power:SetPoint('LEFT')
Power:SetPoint('RIGHT')
Power:CreateBorder(12,1,1,1)
Power:SetBorderPadding(1)
CreateBackdrop(Power)
-- Options
Power.frequentUpdates = true
Power.colorPower = true -- powertype colored bar
Power.colorClassNPC = false -- color power based on NPC
Power.colorClassPet = false -- color power based on pet type
-- Register it with oUF
self.Power = Power
self.Power.bg = Powerbg
--Text
--Percent
local PowerText = Power:CreateFontString(nil, "OVERLAY", "TextStatusBarText") -- parent to last child to make sure it's on top
PowerText:SetPoint("RIGHT", Power, -5,0) -- but anchor to the base element so it doesn't wiggle
self:Tag(PowerText, "[perpp]") -- oUF will automagically update it!
Power.text = PowerText
--Value
local PowerText2 = Power:CreateFontString(nil, "OVERLAY", "TextStatusBarText") -- parent to last child to make sure it's on top
PowerText2:SetPoint("LEFT", Power, 5,0) -- but anchor to the base element so it doesn't wiggle
self:Tag(PowerText2, "[curpp]") -- oUF will automagically update it!
Power.text = PowerText2
-----------------------------
-- Buffs
local Buffs = CreateFrame("Frame", nil, self)
Buffs:SetPoint("BOTTOM", self, "TOPLEFT", -cfg.height,0)
Buffs:SetPoint'LEFT'
Buffs:SetPoint'RIGHT'
Buffs:SetHeight(17)
Buffs.size = 17
self.Buffs = Buffs
-----------------------------
-- Debuffs
local Debuffs = CreateFrame("Frame", nil, self)
Debuffs:SetPoint("TOP", self, "BOTTOMLEFT", -cfg.height,-30)
Debuffs:SetPoint'LEFT'
Debuffs:SetPoint'RIGHT'
Debuffs:SetHeight(20)
Debuffs.initialAnchor = "TOPLEFT"
Debuffs.size = 20
Debuffs.showDebuffType = true
self.Debuffs = Debuffs
-----------------------------
-- Rez Icon
-- Position and size
local ResurrectIcon = self:CreateTexture(nil, 'OVERLAY')
ResurrectIcon:SetSize(16, 16)
ResurrectIcon:SetPoint('TOPRIGHT', self)
-- Register it with oUF
self.ResurrectIcon = ResurrectIcon
-----------------------------
-- Raid icons
-- Position and size
local RaidIcon = self:CreateTexture(nil, 'OVERLAY')
RaidIcon:SetSize(16, 16)
RaidIcon:SetPoint('TOPRIGHT', self)
-- Register it with oUF
self.RaidIcon = RaidIcon
-----------------------------
-- Raid Roles
-- Position and size
local RaidRole = self:CreateTexture(nil, 'OVERLAY')
RaidRole:SetSize(16, 16)
RaidRole:SetPoint('TOPLEFT')
-- Register it with oUF
self.RaidRole = RaidRole
-----------------------------
-- LFD Role
-- Position and size
local LFDRole = self:CreateTexture(nil, "OVERLAY")
LFDRole:SetSize(16, 16)
LFDRole:SetPoint("LEFT", self)
-- Register it with oUF
self.LFDRole = LFDRole
-----------------------------
-- Quest Icon
-- Position and size
local QuestIcon = self:CreateTexture(nil, 'OVERLAY')
QuestIcon:SetSize(16, 16)
QuestIcon:SetPoint('TOPRIGHT', self)
-- Register it with oUF
self.QuestIcon = QuestIcon
-----------------------------
-- Leader Icon
-- Position and size
local Leader = self:CreateTexture(nil, "OVERLAY")
Leader:SetSize(16, 16)
Leader:SetPoint("BOTTOM", self, "TOP")
-- Register it with oUF
self.Leader = Leadera
-----------------------------
-- Master looter
-- Position and size
local MasterLooter = self:CreateTexture(nil, 'OVERLAY')
MasterLooter:SetSize(16, 16)
MasterLooter:SetPoint('TOPRIGHT', self)
-- Register it with oUF
self.MasterLooter = MasterLooter
-----------------------------
-- Class Icons
local ClassIcons = {}
for index = 1, 5 do
local Icon = self:CreateTexture(nil, 'BACKGROUND')
-- Position and size.
Icon:SetSize(16, 16)
Icon:SetPoint('TOPLEFT', self, 'BOTTOMLEFT', index * Icon:GetWidth(), 0)
ClassIcons[index] = Icon
end
-----------------------------
-- Combat
-- Position and size
local Combat = self:CreateTexture(nil, "OVERLAY")
Combat:SetSize(16, 16)
Combat:SetPoint('TOP', self)
-- Register it with oUF
self.Combat = Combat
-- leave this in!!
if(UnitSpecific[unit]) then
return UnitSpecific[unit](self)
end
end
oUF:RegisterStyle('Bob', Shared)
oUF:Factory(function(self)
self:SetActiveStyle('Bob')
self:Spawn('player'):SetPoint(unpack(cfg.player_position))
self:Spawn('target'):SetPoint(unpack(cfg.target_position))
self:Spawn('focus'):SetPoint(unpack(cfg.focus_position))
end)