View Single Post
11-14-10, 07:22 PM   #10
kawe
A Cyclonian
 
kawe's Avatar
Join Date: Sep 2009
Posts: 40
Originally Posted by gratzner View Post
If you'r successful with those castbars let me know please

hehe, simple castbar added successfully

full code (green text = code from ouf_lilly and don't forget to create texture file or just copy texture map from lily)

Code:
local FONT = [=[Interface\AddOns\oUF_Senomar\calibri.ttf]=]
local FONTSIZE = 13
local HEIGHT = 26
local HEALTHHEIGHT = 21
local TEXTURE = [=[Interface\AddOns\oUF_Senomar\minimalist]=]
local BACKDROP = {
	bgFile = TEXTURE, insets = {top = -1, bottom = -1, left = -1, right = -1}
}
local _, playerclass = UnitClass("player")

local function ShortenValue(value)
	if(value >= 1e6) then
		return ('%.2fm'):format(value / 1e6):gsub('%.?0+([km])$', '%1')
	elseif(value >= 1e4) then
		return ('%.1fk'):format(value / 1e3):gsub('%.?0+([km])$', '%1')
	else
		return value
	end
end

oUF.Tags['seno:health'] = function(u)
	local min, max = UnitHealth(u), UnitHealthMax(u)
	local status = not UnitIsConnected(u) and 'Offline' or UnitIsGhost(u) and 'Ghost' or UnitIsDead(u) and 'Dead'

	if(status) then
		return status
	elseif(u == 'target' and UnitCanAttack('player', u)) then
		return ('%s || %d|cff0090ff%%|r'):format(ShortenValue(min), min / max * 100)
	elseif(u == 'target') then
		local power = UnitPower(u)
		local pmin = ""
		if(power > 0 and not UnitIsDeadOrGhost(u)) then
			local _, type = UnitPowerType(u)
			local colors = _COLORS.power
			pmin = ('%s%s|r'):format(Hex(colors[type] or colors['RUNES']), ShortenValue(power)) .. ' | '
		end
		return pmin .. ('%s'):format(ShortenValue(min), ShortenValue(min))
	elseif(u == 'player' and min ~= max) then
		return ('|cffff8080-%s|r || %s'):format(ShortenValue((min - max)*-1), ShortenValue(min))
	elseif(u == 'player') then
		return max
	elseif(min ~= max) then
		return ShortenValue(min)
	else
		return ShortenValue(max)
	end
end

oUF.Tags['seno:power'] = function(u)
	local power = UnitPower(u)
	if(power > 0 and not UnitIsDeadOrGhost(u)) then
		local _, type = UnitPowerType(u)
		local colors = _COLORS.power
		return ('%s%d|r'):format(Hex(colors[type] or colors['RUNES']), power)
	end
end

oUF.Tags['seno:druid'] = function(u)
	local min, max = UnitPower(u, 0), UnitPowerMax(u, 0)
	if(UnitPowerType(u) ~= 0 and min ~= max) then
		return ('|cff0090ff%d%%|r'):format(min / max * 100)
	end
end

oUF.TagEvents['seno:shards'] = 'UNIT_POWER'
oUF.Tags['seno:shards'] = function(u) return UnitPower(u, SPELL_POWER_SOUL_SHARDS) end

oUF.Tags['pvp'] = function(u)
local running = IsPVPTimerRunning()
	if(UnitIsPVP(u) and not running) then
		return '|cffff0000+|r'
	elseif(running) then
		local timer = GetPVPTimer() / 1e3
		return ('|cffff0000%d:%02d|r'):format(timer / 60, timer % 60)
	end	
end

oUF.TagEvents['seno:name'] = 'UNIT_NAME_UPDATE UNIT_REACTION UNIT_FACTION'
oUF.Tags['seno:name'] = function(u)
	local reaction = UnitReaction(u, 'player')

	local r, g, b = 1, 1, 1
	if((UnitIsTapped(u) and not UnitIsTappedByPlayer(u)) or not UnitIsConnected(u)) then
		r, g, b = 3/5, 3/5, 3/5
	elseif(not UnitIsPlayer(u) and reaction) then
		r, g, b = unpack(_COLORS.reaction[reaction])
	elseif(UnitFactionGroup(u) and UnitIsEnemy(u, 'player') and UnitIsPVP(u)) then
		r, g, b = 1, 0, 0
	end

	return ('%s%s|r'):format(Hex(r, g, b), UnitName(u))
end

local f = CreateFrame"Frame"
f.peticon = nil
f:RegisterEvent('PET_ATTACK_START')
f:RegisterEvent('PET_ATTACK_STOP')
f:SetScript('OnEvent', function(self, e) if e == 'PET_ATTACK_START' then self.peticon:Show() else self.peticon:Hide() end end)

local function SpawnMenu(self)
	ToggleDropDownMenu(1, nil, _G[string.gsub(self.unit, '^.', string.upper)..'FrameDropDown'], 'cursor')
end

local PostCastStart = function(Castbar, unit, spell, spellrank)
	Castbar:GetParent().Name:SetText('×' .. spell)
end

local PostCastStop = function(Castbar, unit)
	local self = Castbar:GetParent()
	self.Name:SetText(UnitName(self.realUnit or unit))
end

local PostCastStopUpdate = function(self, event, unit)
	if(unit ~= self.unit) then return end
	return PostCastStop(self.Castbar, unit)
end


local function PostUpdatePower(element, unit, min, max)
	element:GetParent().Health:SetHeight(max ~= 0 and HEALTHHEIGHT or HEIGHT)
end

local function PostCreateAura(element, button)
	button:SetBackdrop(BACKDROP)
	button:SetBackdropColor(0, 0, 0)
	button.cd:SetReverse()
	button.icon:SetTexCoord(0.08, 0.92, 0.08, 0.92)
	button.icon:SetDrawLayer('ARTWORK')
end

local function PostUpdateDebuff(element, unit, button, index)
	if(UnitIsFriend('player', unit) or button.isPlayer) then
		local _, _, _, _, type = UnitAura(unit, index, button.filter)
		local color = DebuffTypeColor[type] or DebuffTypeColor.none

		button:SetBackdropColor(color.r * 3/5, color.g * 3/5, color.b * 3/5)
		button.icon:SetDesaturated(false)
	else
		button:SetBackdropColor(0, 0, 0)
		button.icon:SetDesaturated(true)
	end
end

local buffFilter = {
	[GetSpellInfo(13159)] = true, -- AotP
	[GetSpellInfo(13165)] = true, -- AotH
	[GetSpellInfo(3045)] = true, -- Rapid Fire
	[GetSpellInfo(34477)] = true, -- Misdirection
	[GetSpellInfo(53760)] = true, -- Flask of Endless Rage
	[GetSpellInfo(57325)] = true, -- Well Fed
	[GetSpellInfo(57399)] = true, -- Well Fed (fish meal)
	[GetSpellInfo(2565)] = true, -- Shield Block
	[GetSpellInfo(23920)] = true, -- Spell Reflection
	[GetSpellInfo(6673)] = true, -- Battle shout
	[GetSpellInfo(469)] = true, -- Commanding shout
	[GetSpellInfo(12975)] = true, -- Last stand
	[GetSpellInfo(871)] = true, -- Shield Wall
	[GetSpellInfo(55694)] = true, -- Enraged Regeneration
	[GetSpellInfo(5171)] = true, -- SnD
	[GetSpellInfo(13750)] = true, -- Adrenaline Rush
	[GetSpellInfo(13877)] = true, -- Blade Fury
	[GetSpellInfo(1126)] = true, -- Mark of the Wild
	[GetSpellInfo(29166)] = true, -- Innervate
	[GetSpellInfo(50334)] = true, -- Berserk
	[GetSpellInfo(61336)] = true, -- Survival Instincts
	[GetSpellInfo(22842)] = true, -- Frenzied Regeneration
	[GetSpellInfo(22812)] = true, -- Barkskin
	[GetSpellInfo(71586)] = true, -- Hardened Skin


}

local function customFilter(icons, unit, icon, name)
	if(buffFilter[name] and (playerclass == 'HUNTER' or playerclass == 'WARRIOR' or playerclass == 'DRUID' or playerclass == 'ROGUE')) then return true end
end

local UnitSpecific = {
	player = function(self)
		local buffs = CreateFrame('Frame', nil, self)
		buffs:SetPoint('TOPLEFT', self, 'TOPLEFT', 0, 20)
		buffs:SetSize(110, 44)
		buffs.num = 10
		buffs.size = 19
		buffs.spacing = 3
		buffs.initialAnchor = 'TOPLEFT'
		buffs['growth-y'] = 'UP'
		buffs.PostCreateIcon = PostCreateAura
		self.Buffs = buffs
		buffs.CustomFilter = customFilter
				     
	      BuffFrame:Hide() 

		
		local leader = self.Health:CreateTexture(nil, 'OVERLAY')
		leader:SetPoint('TOPRIGHT', self, 0, 8)
		leader:SetSize(16, 16)
		self.Leader = leader

		local assistant = self.Health:CreateTexture(nil, 'OVERLAY')
		assistant:SetPoint('TOPRIGHT', self, 0, 8)
		assistant:SetSize(16, 16)
		self.Assistant = assistant

		local info = self.Health:CreateFontString(nil, 'OVERLAY')
		info:SetFont(FONT, FONTSIZE)
		info:SetShadowColor(0, 0, 0)
		info:SetShadowOffset(1, -1)
		info:SetPoint('CENTER')
		self:Tag(info, '[pvp]')
		
		
		local debuffs = CreateFrame('Frame', nil, self)
		debuffs.spacing = 10
		debuffs:SetSize(180, 200)
		debuffs.initialAnchor = 'BOTTOMLEFT'
		debuffs.PostCreateIcon = PostCreateAura
		debuffs:SetPoint('BOTTOMLEFT', self, 'TOPLEFT', -100, 350)
		debuffs.num = 18
		debuffs.size = 48
		debuffs['growth-y'] = 'UP'
		debuffs['growth-x'] = 'RIGHT'
		debuffs.PostUpdateIcon = PostUpdateDebuff
		self.Debuffs = debuffs
		
		
		--self:SetAttribute('initial-width', 170)
		self:SetWidth(203)
	end,
	target = function(self)
		local cpoints = self:CreateFontString(nil, 'OVERLAY', 'SubZoneTextFont')
		cpoints:SetPoint('RIGHT', self, 'LEFT', -9, 0)
		cpoints:SetJustifyH('RIGHT')
		self:Tag(cpoints, '|cffffffff[cpoints]|r')

		self.Power.PostUpdate = PostUpdatePower
		self:SetWidth(190)
	end,
			
		focus = function(self)
		self:SetWidth(175)
	end,
}

local function Shared(self, unit)
	self.colors.power.MANA = {0, 144/255, 1}

	self:RegisterForClicks('AnyDown')
	self:SetScript('OnEnter', UnitFrame_OnEnter)
	self:SetScript('OnLeave', UnitFrame_OnLeave)

	self:SetBackdrop(BACKDROP)
	self:SetBackdropColor(0, 0, 0)

	self:SetHeight(HEIGHT)

	local health = CreateFrame('StatusBar', nil, self)
	health:SetStatusBarTexture(TEXTURE)
	health:SetStatusBarColor(0.1, 0.1, 0.1)
	health.frequentUpdates = true
	self.Health = health

	local healthBG = health:CreateTexture(nil, 'BORDER')
	healthBG:SetAllPoints()
	
	if(unit == 'player' or unit == 'pet') then
		healthBG:SetTexture(0.75, 0.1, 0.1)
	else
		healthBG:SetTexture(1/3, 1/3, 1/3)
	end

	local healthValue = health:CreateFontString(nil, 'OVERLAY')
	healthValue:SetFont(FONT, FONTSIZE)
	healthValue:SetShadowColor(0, 0, 0)
	healthValue:SetShadowOffset(1, -1)
	healthValue:SetPoint('RIGHT', health, -2, 0)
	healthValue:SetJustifyH('RIGHT')
	healthValue.frequentUpdates = 1/4
	self:Tag(healthValue, '[seno:health]')

	local Castbar = CreateFrame("StatusBar", nil, self)
	Castbar:SetStatusBarTexture(TEXTURE)
	Castbar:SetStatusBarColor(1, .1, .1, .5)
	Castbar:SetAllPoints(healthBG)
	Castbar:SetToplevel(true)
	Castbar:GetStatusBarTexture():SetHorizTile(false)

	self.Castbar = Castbar


	if(unit == 'player' or unit == 'target' or unit == 'pet') then
		local power = CreateFrame('StatusBar', nil, self)
		power:SetPoint('BOTTOMRIGHT')
		power:SetPoint('BOTTOMLEFT')
		power:SetPoint('TOP', health, 'BOTTOM', 0, -1)
		power:SetStatusBarTexture(TEXTURE)
		power.frequentUpdates = true
		self.Power = power

		power.colorClass = true
		power.colorTapping = true
		power.colorDisconnected = true
		power.colorReaction = unit ~= 'pet'
		power.colorHappiness = unit == 'pet'
		power.colorPower = unit == 'pet'

		local powerBG = power:CreateTexture(nil, 'BORDER')
		powerBG:SetAllPoints()
		powerBG:SetTexture(TEXTURE)
		powerBG.multiplier = 1/3
		power.bg = powerBG

		if(unit ~= 'target') then
			local powerValue = health:CreateFontString(nil, 'OVERLAY')
			powerValue:SetFont(FONT, FONTSIZE)
			powerValue:SetShadowColor(0, 0, 0)
			powerValue:SetShadowOffset(1, -1)
			powerValue:SetPoint('LEFT', health, 2, 0)
			powerValue:SetJustifyH('LEFT')
			powerValue.frequentUpdates = 0.1
			if (unit == 'player' and playerclass == 'WARLOCK') then
				self:Tag(powerValue, '[seno:power< ][seno:shards][seno:druid]')
			else
				self:Tag(powerValue, '[seno:power< ][seno:druid]')
			end
		end

		local raidicon = health:CreateTexture(nil, 'OVERLAY')
		raidicon:SetPoint('TOP', self, 0, 8)
		raidicon:SetSize(16, 16)
		self.RaidIcon = raidicon

		health:SetHeight(HEALTHHEIGHT)
		health:SetPoint('TOPRIGHT')
		health:SetPoint('TOPLEFT')

		self.menu = SpawnMenu
	end

	if(unit == 'focus' or unit:find('target')) then
		local name = health:CreateFontString(nil, 'OVERLAY')
		name:SetFont(FONT, FONTSIZE)
		name:SetShadowColor(0, 0, 0)
		name:SetShadowOffset(1, -1)
		name:SetPoint('LEFT', health, 2, 0)
		name:SetPoint('RIGHT', healthValue, 'LEFT')
		name:SetJustifyH('LEFT')
		if unit == 'target' then
			self:Tag(name, '[difficulty][plus][level] [seno:name< ][|cff0090ff>rare<|r]')
		else
			self:Tag(name, '[seno:name< ][|cff0090ff>rare<|r]')
		end

		local debuffs = CreateFrame('Frame', nil, self)
		debuffs.spacing = 3
		debuffs:SetSize(110, 44)
		debuffs.initialAnchor = 'BOTTOMLEFT'
		debuffs.PostCreateIcon = PostCreateAura
		debuffs:SetPoint('LEFT', self, 'BOTTOMLEFT', 0, -5)
		debuffs.num = 10
		debuffs.size = 24
		debuffs['growth-y'] = 'DOWN'
		debuffs['growth-x'] = 'RIGHT'
		debuffs.PostUpdateIcon = PostUpdateDebuff
		self.Debuffs = debuffs

		if(unit ~= 'target') then
			debuffs.num = 10
			debuffs:SetPoint('TOPRIGHT', self, 'RIGHT', 0, 5)
			debuffs['growth-y'] = 'DOWN'
			debuffs['growth-x'] = 'RIGHT'
			health:SetAllPoints()
		end

		if(unit == 'target') then
			debuffs.onlyShowPlayer = true
			debuffs.size = 24
		end

	end

	if(UnitSpecific[unit]) then
		return UnitSpecific[unit](self)
	end
end

oUF.colors.power.MANA = {0, 144/255, 1}

oUF:RegisterStyle('seno', Shared)

oUF:Factory(function(self)
	self:SetActiveStyle('seno')
	self:Spawn('player'):SetPoint('CENTER', -220, -300)
	self:Spawn('pet'):SetPoint('CENTER', -370, -300)
	self:Spawn('focus'):SetPoint('CENTER', 500, -300)
	self:Spawn('target'):SetPoint('CENTER', 0, -300)
	self:Spawn('targettarget'):SetPoint('CENTER', 220, -300)
end)

Last edited by kawe : 11-14-10 at 07:27 PM.
  Reply With Quote