Skip to content

Instantly share code, notes, and snippets.

@airtonix
Created June 11, 2009 06:08
Show Gist options
  • Save airtonix/127733 to your computer and use it in GitHub Desktop.
Save airtonix/127733 to your computer and use it in GitHub Desktop.
local auraWhiteList = {
["Power Word: Fortitude"] = true,
["Prayer of Fortitude"] = true,
["Shadow Protection"] = true,
["Prayer of Shadow Protection"] = true,
["Heroic Presence"] = nil,
["Gift of the Naaru"] = true,
["Gift of the Wild"] = true,
["Mark of the Wild"] = true,
["Well Fed"] = true,
["Drink"] = true,
["Food"] = true,
}
local colors = setmetatable({
power = setmetatable({
['MANA'] = {0, 144/255, 1},
}, {__index = oUF.colors.power}),
}, {__index = oUF.colors})
local function menu(self)
if(self.unit:match('party')) then
ToggleDropDownMenu(1, nil, _G['PartyMemberFrame'..self.id..'DropDown'], 'cursor')
else
FriendsDropDown.unit = self.unit
FriendsDropDown.id = self.id
FriendsDropDown.initialize = RaidFrameDropDown_Initialize
ToggleDropDownMenu(1, nil, FriendsDropDown, 'cursor')
end
end
oUF.Tags['[smarthp]'] = function(u)
local min, max = UnitHealth(u), UnitHealthMax(u)
return UnitIsDeadOrGhost(u) and oUF.Tags['[dead]'](u) or (min~=max) and format('|cffff8080%d|r|cff0090ff %.0f|r%%', min-max, min/max*100) or max
end
oUF.Tags['[smartpp]'] = function(u)
local min, max = UnitPower(u), UnitPowerMax(u)
return (UnitPowerType(u) == 0 and min > 0) and format('|cff%02x%02x%02x%.0f|r%%', 0, 144, 255, min/max*100)
end
oUF.Tags['[afk]'] = function(u) return UnitIsAFK(u) and '<AFK>' end
oUF.Tags['[assisticon]'] = function(u) local i = GetRaidTargetIndex(u..'target') return i and ICON_LIST[i]..'22|t' end
oUF.Tags['[assistname]'] = function(u) return UnitName(u..'target') end
oUF.TagEvents['[smarthp]'] = 'UNIT_HEALTH'
oUF.TagEvents['[smartpp]'] = 'UNIT_MANA UNIT_DISPLAYPOWER'
oUF.TagEvents['[afk]'] = 'PLAYER_FLAGS_CHANGED'
oUF.TagEvents['[assisticon]'] = 'UNIT_TARGET RAID_TARGET_UPDATE'
oUF.TagEvents['[assistname]'] = 'UNIT_TARGET UNIT_NAME_UPDATE'
local function ShowAuraTooltip(self,motion)
GameTooltip:SetOwner(self, "ANCHOR_TOP");
if(self.debuff)then
GameTooltip:SetUnitDebuff(self.frame.unit,self.index,nil)
else
GameTooltip:SetUnitBuff(self.frame.unit,self.index,nil)
end
GameTooltip:AddLine("Aura Owner : "..(self.owner and UnitName(self.owner) or "Unknown Unit"), 1, 1, 1);
GameTooltip:Show();
end
local function HideAuraTooltip(self,motion)
GameTooltip:Hide()
end
local function PostCreateAuraIcon(self, button, icons, index, debuff)
button.cd:SetReverse()
if (not debuff and UnitIsUnit(self.unit,"player") ) then
button:SetScript('OnMouseUp', function(self, mouseButton)
if mouseButton == 'RightButton' then
CancelUnitBuff('player', index)
end
end)
end
button:SetScript('OnEnter', ShowAuraTooltip)
button:SetScript('OnLeave', HideAuraTooltip)
end
local function customFilter(icons, unit, icon, name, rank, texture, count, dtype, duration, timeLeft, caster)
icon.duration, icon.timeLeft,icon.owner = duration,timeLeft,caster
local filtered = (icons.whitelist~=nil) and icons.whitelist[name]
return name and filtered
end
local function tableSize(table)
local i = 0
for index,_ in pairs(table)do
i = i + 1
end
return i
end
local function updatePower(self, event, unit, bar, min, max)
if(min<max) then
self.Health:SetHeight(18)
bar:Show()
else
self.Health:SetHeight(20)
bar:Hide()
end
end
local function CreateStyle(self, unit)
self.menu = menu
self.colors = colors
self:RegisterForClicks('AnyUp')
self:SetScript('OnEnter', UnitFrame_OnEnter)
self:SetScript('OnLeave', UnitFrame_OnLeave)
self:SetAttribute('*type2', 'menu')
self:SetAttribute('initial-height', 20)
self:SetAttribute('initial-width', 180)
self:SetBackdrop({bgFile = [=[Interface\ChatFrame\ChatFrameBackground]=], insets = {top = -1, left = -1, bottom = -1, right = -1}})
self:SetBackdropColor(0, 0, 0)
self.Health = CreateFrame('StatusBar', nil, self)
self.Health:SetPoint('TOPLEFT', self,"TOPLEFT")
self.Health:SetPoint('TOPRIGHT', self,"TOPRIGHT")
self.Health:SetHeight(20)
self.Health:SetStatusBarTexture([=[Interface\AddOns\oUF_Perfect\minimalist]=])
self.Health.colorDisconnected = true
self.Health.colorClass = true
self.Health.bg = self.Health:CreateTexture(nil, 'BORDER')
self.Health.bg:SetAllPoints(self.Health)
self.Health.bg:SetTexture([=[Interface\ChatFrame\ChatFrameBackground]=])
self.Health.bg.multiplier = 0.3
self.Power = CreateFrame('StatusBar', nil, self)
self.Power:SetPoint('TOPRIGHT', self.Health,"BOTTOMRIGHT")
self.Power:SetPoint('TOPLEFT', self.Health,"BOTTOMLEFT")
self.Power:SetStatusBarTexture([=[Interface\AddOns\oUF_Perfect\minimalist]=])
self.Power:SetHeight(2)
-- self.Power.frequentUpdates = true
self.Power.bg = self.Power:CreateTexture(nil, 'BORDER')
self.Power.bg:SetAllPoints(self.Power)
self.Power.bg:SetTexture([=[Interface\ChatFrame\ChatFrameBackground]=])
self.Power.colorDisconnected = true
self.Power.colorPower = true
self.PostUpdatePower = updatePower
local health = self.Health:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmallRight')
health:SetPoint('RIGHT', -3, 0)
self:Tag(health, '[smarthp]')
local power = self.Health:CreateFontString(nil, 'OVERLAY', 'GameFontHighlightSmallLeft')
power:SetPoint('LEFT', 3, 0)
self:Tag(power, '[smartpp]')
-- changed name font object template to a smaller one
local name = self.Health:CreateFontString(nil, 'OVERLAY', 'GameTooltipTextSmall')
name:SetPoint('TOPLEFT', self, 'TOPRIGHT', 5, 2)
self:Tag(name, '[name( )][leader( )][offline( )][afk( )]|cff00ffff[(- )assistname( )][assisticon]')
self.ReadyCheck = self.Health:CreateTexture(nil, 'OVERLAY')
self.ReadyCheck:SetPoint('LEFT', self, -18, 0)
self.ReadyCheck:SetHeight(20)
self.ReadyCheck:SetWidth(20)
self.MasterLooter = self.Health:CreateTexture(nil, 'OVERLAY')
self.MasterLooter:SetPoint('TOPLEFT', self, 5, 0)
self.MasterLooter:SetHeight(12)
self.MasterLooter:SetWidth(12)
-- BEGIN BUFF FRAME
--------------------------
self.Buffs = CreateFrame('Frame', nil, self)
--points to the table at the top
self.Buffs.whitelist = auraWhiteList
--position it from the BottomLeft corner of the buffFrame to the BottomRight corner of the unitframe(self),
-- offset it to the right by 5pixels and down by 1 pixel
self.Buffs:SetPoint('BOTTOMLEFT', self, 'BOTTOMRIGHT', 5, -1)
-- set the number of buffs to display to be equal to the amount of entries in out whitelist.
self.Buffs.num = tableSize(self.Buffs.whitelist)
-- the width and height of our buff icons
self.Buffs.size = 12
-- spacing between the icons
self.Buffs.spacing = 2
-- where our first icon is anchored to within the buffframe.
self.Buffs.initialAnchor = 'BOTTOMLEFT'
-- set the height of our buffframe to the same hieght as our icons size
self.Buffs:SetHeight(self.Buffs.size)
-- set the width of the buffframe -equal to- the icon size -plus- icon spacing -times- the amount of entries in our whitelist
self.Buffs:SetWidth( (self.Buffs.size+self.Buffs.spacing) * self.Buffs.num )
-- new icon rows grow down. we wont have any here because our row length always equals our whitelist size.
self.Buffs['growth-y'] = 'DOWN'
-- new icons appear to the right of old ones.
self.Buffs['growth-x'] = 'RIGHT'
-- this hooks the whitelist filter
self.CustomAuraFilter = customFilter
-- this hooks tooltip text and buff canceling of your own buffs on your own frames. *not others*
self.PostCreateAuraIcon = PostCreateAuraIcon
--END BUFF FRAME
-----------------------
self.DebuffHighlightBackdrop = true
self.DebuffHighlightFilter = true
self.outsideRangeAlpha = 0.4
self.inRangeAlpha = 1.0
self.Range = true
self:SetScale(0.8)
end
oUF:RegisterStyle('Perfect', CreateStyle)
oUF:SetActiveStyle('Perfect')
--[[
List of the various configuration attributes
======================================================
showRaid = [BOOLEAN] -- true if the header should be shown while in a raid
showParty = [BOOLEAN] -- true if the header should be shown while in a party and not in a raid
showPlayer = [BOOLEAN] -- true if the header should show the player when not in a raid
showSolo = [BOOLEAN] -- true if the header should be shown while not in a group (implies showPlayer)
nameList = [STRING] -- a comma separated list of player names (not used if 'groupFilter' is set)
groupFilter = [1-8, STRING] -- a comma seperated list of raid group numbers and/or uppercase class names and/or uppercase roles
strictFiltering = [BOOLEAN] - if true, then characters must match both a group and a class from the groupFilter list
point = [STRING] -- a valid XML anchoring point (Default: "TOP")
xOffset = [NUMBER] -- the x-Offset to use when anchoring the unit buttons (Default: 0)
yOffset = [NUMBER] -- the y-Offset to use when anchoring the unit buttons (Default: 0)
sortMethod = ["INDEX", "NAME"] -- defines how the group is sorted (Default: "INDEX")
sortDir = ["ASC", "DESC"] -- defines the sort order (Default: "ASC")
template = [STRING] -- the XML template to use for the unit buttons
templateType = [STRING] - specifies the frame type of the managed subframes (Default: "Button")
groupBy = [nil, "GROUP", "CLASS", "ROLE"] - specifies a "grouping" type to apply before regular sorting (Default: nil)
groupingOrder = [STRING] - specifies the order of the groupings (ie. "1,2,3,4,5,6,7,8")
maxColumns = [NUMBER] - maximum number of columns the header will create (Default: 1)
unitsPerColumn = [NUMBER or nil] - maximum units that will be displayed in a singe column, nil is infinate (Default: nil)
startingIndex = [NUMBER] - the index in the final sorted unit list at which to start displaying units (Default: 1)
columnSpacing = [NUMBER] - the ammount of space between the rows/columns (Default: 0)
columnAnchorPoint = [STRING] - the anchor point of each new column (ie. use LEFT for the columns to grow to the right)
--]]
local raid = {}
for i = 1, 5 do
local group = oUF:Spawn('header', 'oUF_Group'..i)
group:SetManyAttributes('groupFilter', tostring(i), 'showRaid', true, 'yOffset', -5)
group:SetFrameStrata('BACKGROUND')
table.insert(raid, group)
if(i == 1) then
group:SetManyAttributes('showParty', true, 'showPlayer', true,'showSolo',true)
group:SetPoint('TOPLEFT', UIParent, 15, -35)
else
group:SetPoint('TOP', raid[i-1], 'BOTTOM', 0, -20)
end
group:Show()
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment