|
发表于 2015-8-13 21:04:22
|
显示全部楼层
〓下面以Dawn 的oUF_Asym 和kyron的oUF_Caellian为实例介绍部分详细代码〓
※实例1、Dawn的oUF_Asym
作者:Dawn
下载地址:http://www.wowinterface.com/downloads/info12614-oUFAsymUI-Widescreen.html

--[[
oUF_Asym
Author: Dawn based on oUF_Lyn by Lyn/Eiszeit
Credits: p3lim for party toggle function and druid mana
Lyn for oUF_Lyn
Neal for a way to get those borders around all frames!
--]]
-- ------------------------------------------------------------------------
-- local horror
-- ------------------------------------------------------------------------
local select = select
local UnitClass = UnitClass
local UnitIsDead = UnitIsDead
local UnitIsPVP = UnitIsPVP
local UnitIsGhost = UnitIsGhost
local UnitIsPlayer = UnitIsPlayer
local UnitReaction = UnitReaction
local UnitIsConnected = UnitIsConnected
local UnitCreatureType = UnitCreatureType
local UnitClassification = UnitClassification
local UnitReactionColor = UnitReactionColor
local RAID_CLASS_COLORS = RAID_CLASS_COLORS
-- ------------------------------------------------------------------------
-- Configuration - font, fontsize and textures --材质和字体大小等设置
-- ------------------------------------------------------------------------
local font = "InterfaceAddOnsoUF_AsymfontsROADWAY.ttf" -- 字体设置,修改成自己喜欢的字体所在路径。或把喜欢的字体重命名替换
local fontsize = 12 -- default 12 --字体大小(除了施法条以外的字号)默认为12
local fontsizeCB = 12 -- castbar fontsize --施法条的字体大小,默认为12
local bartex = "InterfaceAddOnsoUF_Asymtexturesdm" -- change bar texture here --头像的背景框,默认是dm,可以自己去该文件夹查看图片并替换成自己喜欢的
这里附上tga预览插件 tga.rar(186.99 KB, 下载次数: 314),方便电脑没有安装PS的玩家预览图片
缩略图预览即可(如图缩略图显示tga预览图)

local castbartex = "InterfaceAddOnsoUF_Asymtexturesdm" -- change castbar texture here --施法条的背景框材质,默认是dm
local bufftex = "InterfaceAddOnsoUF_Asymtexturesborder1" -- change buff/debuff border texture here --buff和debuff的背景框材质
local playerClass = select(2, UnitClass("player"))
local PorBG = "InterfaceAddOnsoUF_AsymtexturesBorder4.tga" -- change target portait background texture here --头像材质
local frameborder = "InterfaceAddOnsoUF_Asymtexturesframeborder4.tga" --边框材质
local borderDebuffHigh = "InterfaceAddOnsoUF_Asymtexturesframeborder4large.tga" --debuff边框高亮材质
-- color and alpha for frameborders --背景框色调和透明度设置,一般不用改
local color_rb = 0.40 -- default 0.00
local color_gb = 0.40 -- default 0.00
local color_bb = 0.40 -- default 0.00
local alpha_fb = 0.80 -- default 0.35
-- Castbar position for player and target --施法条的位置
local playerCB_x = 0 --自己施法条的横坐标
local playerCB_y = -265 --自己施法条的纵坐标
local targetCB_x = 270 --目标施法条的横坐标
local targetCB_y = -152 --目标施法条的纵坐标
-- Portraits --小队和团队头像开关
-- enable/disable party portrait -- 0 = disable, 1 = enable
local partyport = 1 --是否显示小队头像,1开0闭
-- enable/disable raid portrait -- 0 = disable, 1 = enable
local raidport = 0 -- disabled by default --是否显示团队头像,1开0闭
-- ------------------------------------------------------------------------
-- End of Configuration
-- ------------------------------------------------------------------------
-- local background --头像背景透明度设置
-- ------------------------------------------------------------------------
local backdrop = {
bgFile = "InterfaceChatFrameChatFrameBackground",
insets = {top = -1, left = -1, bottom = -1, right = -1},
}
-- ------------------------------------------------------------------------
-- change some colors 
-- ------------------------------------------------------------------------
oUF.colors.happiness = {
[1] = {182/225, 34/255, 32/255}, -- unhappy --不开心的颜色
[2] = {220/225, 180/225, 52/225}, -- content --普通状态的颜色
[3] = {143/255, 194/255, 32/255}, -- happy --开心的颜色
}
local corb = 1
local cogb = 0
local cobb = 0
-- ------------------------------------------------------------------------
-- right click
-- ------------------------------------------------------------------------
local menu = function(self)
local unit = self.unit:sub(1, -2)
local cunit = self.unit:gsub("(.)", string.upper, 1)
if(unit == "party" or unit == "partypet") then
ToggleDropDownMenu(1, nil, _G[" artyMemberFrame"..self.id.."DropDown"], "cursor", 0, 0)
elseif(_G[cunit.."FrameDropDown"]) then
ToggleDropDownMenu(1, nil, _G[cunit.."FrameDropDown"], "cursor", 0, 0)
end
end
-- ------------------------------------------------------------------------
-- reformat everything above 9999, i.e. 10000 -> 10k --血条数值设置
-- ------------------------------------------------------------------------
local numberize = function(v)
if v <= 99999 then return v end --生命在10万以内,不会科学计数
if v >= 1000000 then
local value = string.format("%.1fm", v/1000000)
return value
elseif v >= 100000 then --生命大于10万时,才会科学计数
local value = string.format("%.1fk", v/1000)
return value
end
end
-- ------------------------------------------------------------------------
-- level update --等级设置
-- ------------------------------------------------------------------------
local updateLevel = function(self, unit, name)
local lvl = UnitLevel(unit)
local typ = UnitClassification(unit)
local color = GetDifficultyColor(lvl)
if lvl <= 0 then lvl = "??" end
if typ=="worldboss" then
self.Level:SetText("|cffff0000"..lvl.."b|r")
elseif typ=="rareelite" then
self.Level:SetText(lvl.."r+")
self.Level:SetTextColor(color.r, color.g, color.b)
elseif typ=="elite" then
self.Level:SetText(lvl.."+")
self.Level:SetTextColor(color.r, color.g, color.b)
elseif typ=="rare" then
self.Level:SetText(lvl.."r")
self.Level:SetTextColor(color.r, color.g, color.b)
else
if UnitIsConnected(unit) == nil then
self.Level:SetText("??")
else
self.Level:SetText(lvl)
end
if(not UnitIsPlayer(unit)) then
self.Level:SetTextColor(color.r, color.g, color.b)
else
local _, class = UnitClass(unit)
color = self.colors.class[class]
self.Level:SetTextColor(color[1], color[2], color[3])
end
end
end
-- ------------------------------------------------------------------------
-- name update --角色名设置
-- ------------------------------------------------------------------------
local updateName = function(self, event, unit)
if(self.unit ~= unit) then return end
local name = UnitName(unit)
self.Name:SetText(string.lower(name):sub(1, 30, nil)) -- only use lower case for names, truncate to 17 for Oksana, 20 for Santana, 30 for Roadway
if unit=="targettarget" then
local totName = UnitName(unit)
local pName = UnitName("player")
if totName==pName then
self.Name:SetTextColor(0.9, 0.5, 0.2) 这里说下颜色,由于BLZ的颜色范围是0-1 ,所以RGB 红绿蓝三通道的数值都除以255就可以了
else
self.Name:SetTextColor(1,1,1)
end
else
self.Name:SetTextColor(1,1,1)
end
if unit=="target" then -- Show level value on targets only 如果鼠标指向为目标时,只在目标上显示等级,玩家头像不显示
updateLevel(self, unit, name)
end
end
-- ------------------------------------------------------------------------
-- health update --生命条的设置
-- ------------------------------------------------------------------------
local updateHealth = function(self, event, unit, bar, min, max)
local cur, maxhp = min, max
local d = floor(cur/maxhp*100)
if(UnitIsDead(unit) or UnitIsGhost(unit)) then
bar:SetValue(0)
bar.value:SetText"dead"
elseif(not UnitIsConnected(unit)) then
bar.value:SetText"D/C"
elseif(unit == "player") then
if(min ~= max) then
bar.value:SetText("|cff33EE44"..numberize(cur) .."|r-".. d.."%")
else
bar.value:SetText("|cff33EE44"..numberize(cur) .."|r") --满血也显示自己生命值
end
elseif(unit == "targettarget") then
bar.value:SetText(d.."%")
elseif(unit == "target") then
if(d < 100) then
bar.value:SetText("|cff33EE44"..numberize(cur).."|r-"..d.."%")
else
bar.value:SetText("|cff33EE44"..numberize(cur) .."|r") --同上,可以满血也显示目标生命值
end
elseif(min == max) then
if unit == "pet" then
bar.value:SetText("|cff33EE44"..numberize(cur) .."|r") -- just here if otherwise wanted --同上,显示BB血量,也可以改为显示BB名字
else
bar.value:SetText("|cff33EE44"..numberize(cur) .."|r")
end
else
if((max-min) < max) then
if unit == "pet" then
bar.value:SetText("|cff33EE44"..numberize(cur) .."|r-".. d.."%") -- just here if otherwise wanted
else
bar.value:SetText("-"..maxhp-cur) -- just here if otherwise wanted
end
end
end
self:UNIT_NAME_UPDATE(event, unit)
end
-- ------------------------------------------------------------------------
-- druid mana (fixed alpha settings) --XD蓝条设置参数
-- ------------------------------------------------------------------------
local function UpdateDruidPower(self)
local ptype = UnitPowerType("player")
if(ptype ~= 0) then
local min = UnitPower("player",0)
local max = UnitPowerMax("player",0)
self.DruidPower:SetMinMaxValues(0, max)
self.DruidPower:SetValue(min)
self.DruidPower:SetStatusBarColor(unpack(self.colors.power["MANA"]))
self.DruidPower.value:SetText(min.." . "..max)
self.DruidPower.percent:SetText(floor(min / max * 100).."%") 文本格式
if(min ~= max) then
self.DruidPower:SetMinMaxValues(0, max)
self.DruidPower:SetValue(min)
self.DruidPower:SetAlpha(0.8)
else
self.DruidPower:SetAlpha(0)
end
else
local min = UnitPower("player",3)
local max = UnitPowerMax("player",3)
self.DruidPower:SetStatusBarColor(unpack(self.colors.power["ENERGY"]))
self.DruidPower.value:SetText()
self.DruidPower.percent:SetText()
self.DruidPower:SetAlpha(0)
end
end
-- ------------------------------------------------------------------------
-- power update --法力,能量、怒气的设置
-- ------------------------------------------------------------------------
local updatePower = function(self, event, unit, bar, min, max)
if UnitIsPlayer(unit)==nil then
bar.value:SetText()
else
local _, ptype = UnitPowerType(unit)
local color = oUF.colors.power[ptype]
if(min==0) then
bar.value:SetText()
elseif(UnitIsDead(unit) or UnitIsGhost(unit)) then
bar:SetValue(0)
elseif(not UnitIsConnected(unit)) then
bar.value:SetText()
elseif unit=="player" then
if((max-min) > 0) then
bar.value:SetText(min)
if color then
bar.value:SetTextColor(color[1], color[2], color[3])
else
bar.value:SetTextColor(0.2, 0.66, 0.93) RGB代码,可自行替换其他颜色
end
elseif(min==max) then
bar.value:SetText(min) --始终显示法力、能量、怒气值
else
bar.value:SetText(min)
if color then
bar.value:SetTextColor(color[1], color[2], color[3])
else
bar.value:SetTextColor(0.2, 0.66, 0.93)
end
end
else
if((max-min) > 0) then
bar.value:SetText(min)
if color then
bar.value:SetTextColor(color[1], color[2], color[3])
else
bar.value:SetTextColor(0.2, 0.66, 0.93)
end
else
bar.value:SetText(min)
if color then
bar.value:SetTextColor(color[1], color[2], color[3])
else
bar.value:SetTextColor(0.2, 0.66, 0.93)
end
end
end
end
end
-- ------------------------------------------------------------------------
-- aura reskin
-- ------------------------------------------------------------------------
local auraIcon = function(self, button, icons)
icons.showDebuffType = true -- show debuff border type color
button.icon:SetTexCoord(.07, .93, .07, .93)
button.icon:SetPoint("TOPLEFT", button, "TOPLEFT", 1, -1)
button.icon:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", -1, 1)
button.overlay:SetTexture(bufftex)
button.overlay:SetTexCoord(0,1,0,1)
button.overlay.Hide = function(self) self:SetVertexColor(0.3, 0.3, 0.3) end
button.cd:SetReverse()
button.cd:SetPoint("TOPLEFT", button, "TOPLEFT", 2, -2)
button.cd:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", -2, 2)
end
-
- ------------------------------------------------------------------------
-- the layout starts here --layout基本参数
-- ------------------------------------------------------------------------
local func = function(self, unit)
self.menu = menu
self:RegisterForClicks('AnyUp')
self:SetAttribute('type2', 'menu')
self:SetScript('OnEnter', UnitFrame_OnEnter)
self:SetScript('OnLeave', UnitFrame_OnLeave)
self.disallowVehicleSwap = true
--
-- background
--
self:SetBackdrop(backdrop)
self:SetBackdropColor(0,0,0,0.6)
--
-- border
--
local TopLeft = self:CreateTexture(nil, "OVERLAY")
TopLeft:SetTexture(frameborder)
TopLeft:SetTexCoord(0, 1/3, 0, 1/3)
TopLeft:SetPoint("TOPLEFT", self, -6, 6)
TopLeft:SetWidth(14) TopLeft:SetHeight(14)
TopLeft:SetVertexColor(color_rb,color_gb,color_bb,alpha_fb)
local TopRight = self:CreateTexture(nil, "OVERLAY")
TopRight:SetTexture(frameborder)
TopRight:SetTexCoord(2/3, 1, 0, 1/3)
TopRight:SetPoint("TOPRIGHT", self, 6, 6)
TopRight:SetWidth(14) TopRight:SetHeight(14)
TopRight:SetVertexColor(color_rb,color_gb,color_bb,alpha_fb)
local BottomLeft = self:CreateTexture(nil, "OVERLAY")
BottomLeft:SetTexture(frameborder)
BottomLeft:SetTexCoord(0, 1/3, 2/3, 1)
BottomLeft:SetPoint("BOTTOMLEFT", self, -6, -6)
BottomLeft:SetWidth(14) BottomLeft:SetHeight(14)
BottomLeft:SetVertexColor(color_rb,color_gb,color_bb,alpha_fb)
local BottomRight = self:CreateTexture(nil, "OVERLAY")
BottomRight:SetTexture(frameborder)
BottomRight:SetTexCoord(2/3, 1, 2/3, 1)
BottomRight:SetPoint("BOTTOMRIGHT", self, 6, -6)
BottomRight:SetWidth(14) BottomRight:SetHeight(14)
BottomRight:SetVertexColor(color_rb,color_gb,color_bb,alpha_fb)
local TopEdge = self:CreateTexture(nil, "OVERLAY")
TopEdge:SetTexture(frameborder)
TopEdge:SetTexCoord(1/3, 2/3, 0, 1/3)
TopEdge:SetPoint("TOPLEFT", TopLeft, "TOPRIGHT")
TopEdge:SetPoint("TOPRIGHT", TopRight, "TOPLEFT")
TopEdge:SetHeight(14)
TopEdge:SetVertexColor(color_rb,color_gb,color_bb,alpha_fb)
local BottomEdge = self:CreateTexture(nil, "OVERLAY")
BottomEdge:SetTexture(frameborder)
BottomEdge:SetTexCoord(1/3, 2/3, 2/3, 1)
BottomEdge:SetPoint("BOTTOMLEFT", BottomLeft, "BOTTOMRIGHT")
BottomEdge:SetPoint("BOTTOMRIGHT", BottomRight, "BOTTOMLEFT")
BottomEdge:SetHeight(14)
BottomEdge:SetVertexColor(color_rb,color_gb,color_bb,alpha_fb)
local LeftEdge = self:CreateTexture(nil, "OVERLAY")
LeftEdge:SetTexture(frameborder)
LeftEdge:SetTexCoord(0, 1/3, 1/3, 2/3)
LeftEdge:SetPoint("TOPLEFT", TopLeft, "BOTTOMLEFT")
LeftEdge:SetPoint("BOTTOMLEFT", BottomLeft, "TOPLEFT")
LeftEdge:SetWidth(14)
LeftEdge:SetVertexColor(color_rb,color_gb,color_bb,alpha_fb)
local RightEdge = self:CreateTexture(nil, "OVERLAY")
RightEdge:SetTexture(frameborder)
RightEdge:SetTexCoord(2/3, 1, 1/3, 2/3)
RightEdge:SetPoint("TOPRIGHT", TopRight, "BOTTOMRIGHT")
RightEdge:SetPoint("BOTTOMRIGHT", BottomRight, "TOPRIGHT")
RightEdge:SetWidth(14)
RightEdge:SetVertexColor(color_rb,color_gb,color_bb,alpha_fb)
--
-- healthbar
--
self.Health = CreateFrame"StatusBar"
self.Health:SetHeight(12) -- custom height used for partytargets/pets
self.Health:SetStatusBarTexture(bartex)
self.Health:SetParent(self)
self.Health:SetPoint"TOP"
self.Health:SetPoint"LEFT"
self.Health:SetPoint"RIGHT"
self.Health.frequentUpdates = true
--
-- healthbar background
--
self.Health.bg = self.Health:CreateTexture(nil, "BORDER")
self.Health.bg:SetAllPoints(self.Health)
self.Health.bg:SetTexture(bartex)
self.Health.bg:SetAlpha(0.30)
--
-- healthbar text
--
self.Health.value = self.Health:CreateFontString(nil, "OVERLAY")
self.Health.value:SetPoint("RIGHT", self.Health, -2, 2)
self.Health.value:SetFont(font, fontsize, "OUTLINE")
self.Health.value:SetTextColor(1,1,1)
self.Health.value:SetShadowOffset(1, -1)
--
-- healthbar functions
--
self.Health.colorClass = true
self.Health.colorReaction = true
self.Health.colorDisconnected = true
self.Health.colorTapping = true
self.PostUpdateHealth = updateHealth -- let the colors be
--
-- powerbar
--
self.Power = CreateFrame"StatusBar"
self.Power:SetHeight(3) -- custom height used for partytargets/pets
self.Power:SetStatusBarTexture(bartex)
self.Power:SetParent(self)
self.Power:SetPoint"LEFT"
self.Power:SetPoint"RIGHT"
self.Power:SetPoint("TOP", self.Health, "BOTTOM", 0, -1.45) -- Little offset to make it pretty
self.Power.frequentUpdates = true
--
-- powerbar background
--
self.Power.bg = self.Power:CreateTexture(nil, "BORDER")
self.Power.bg:SetAllPoints(self.Power)
self.Power.bg:SetTexture(bartex)
self.Power.bg:SetAlpha(0.30)
--
-- powerbar text
--
self.Power.value = self.Power:CreateFontString(nil, "OVERLAY")
self.Power.value:SetPoint("RIGHT", self.Health.value, "BOTTOMRIGHT", 0, -5) -- powerbar text in health box
self.Power.value:SetFont(font, fontsize, "OUTLINE")
self.Power.value:SetTextColor(1,1,1)
self.Power.value:SetShadowOffset(1, -1)
self.Power.value:Hide()
--
-- powerbar functions
--
self.Power.colorTapping = true
self.Power.colorDisconnected = true
self.Power.colorClass = true
self.Power.colorPower = true
self.Power.colorHappiness = false
self.PostUpdatePower = updatePower -- let the colors be
--
-- names
--
self.Name = self.Health:CreateFontString(nil, "OVERLAY")
self.Name:SetPoint("LEFT", self, 0, 9)
self.Name:SetJustifyH"LEFT"
self.Name:SetFont(font, fontsize, "OUTLINE")
self.Name:SetShadowOffset(1, -1)
self.UNIT_NAME_UPDATE = updateName
--
-- level
--
self.Level = self.Health:CreateFontString(nil, "OVERLAY")
self.Level:SetPoint("LEFT", self.Health, 0, 9)
self.Level:SetJustifyH("LEFT")
self.Level:SetFont(font, fontsize, "OUTLINE")
self.Level:SetTextColor(1,1,1)
self.Level:SetShadowOffset(1, -1)
self.UNIT_LEVEL = updateLevel
-- ------------------------------------
-- oUF_SpellRange fading and oUF_Smooth support for all frames
-- ------------------------------------
if(unit) or (self:GetParent():GetName():match"oUF_Raid") or (self:GetParent():GetName():match"oUF_Party") then
self.SpellRange = true; -- fadeout if units are out of range
self.inRangeAlpha = 1.0; -- Frame alpha when in range
self.outsideRangeAlpha = 0.6; -- 超出距离的边框透明度
self.Power.Smooth = true
self.Health.Smooth = true
end
-- ------------------------------------
-- Hide Portrait for units that are disconnected, don't exist or are not visible (out of range)
-- ------------------------------------
local HidePortrait = function(self, unit)
if (self.unit == 'target' or (self:GetParent():GetName():match"oUF_Party")) then
if (not UnitExists(self.unit) or not UnitIsConnected(self.unit) or not UnitIsVisible(self.unit)) then
self.Portrait:SetAlpha(0)
else
self.Portrait:SetAlpha(1)
end
elseif (self.unit == 'player' or (self:GetParent():GetName():match"oUF_Raid")) then
if (not UnitExists(self.unit) or not UnitIsConnected(self.unit) or not UnitIsVisible(self.unit)) then
self.Portrait:SetAlpha(0)
else
self.Portrait:SetAlpha(0.3) -- 小队在团队中的透明度
end
end
end
-- ------------------------------------
-- oUF_DebuffHighlight support - border highlight debuff边框高亮设置
-- ------------------------------------
if unit=="player" or unit=="target" or unit=="pet" or (self:GetParent():GetName():match"oUF_Party") then
self.DebuffHighlight = self:CreateTexture(nil, "OVERLAY")
self.DebuffHighlight:SetPoint("TOPLEFT",self,"TOPLEFT",-6,6)
self.DebuffHighlight:SetPoint("BOTTOMRIGHT",self,"BOTTOMRIGHT",6,-6)
self.DebuffHighlight:SetTexture(borderDebuffHigh)
self.DebuffHighlight:SetVertexColor(0, 0, 0, 0)
self.DebuffHighlight:SetBlendMode("BLEND")
self.DebuffHighlightAlpha = 0.8
self.DebuffHighlightFilter = true
elseif(self:GetParent():GetName():match"oUF_Raid") then
self.DebuffHighlight = self:CreateTexture(nil, "OVERLAY")
self.DebuffHighlight:SetPoint("TOPLEFT",self,"TOPLEFT",-6,6)
self.DebuffHighlight:SetPoint("BOTTOMRIGHT",self,"BOTTOMRIGHT",6,-6)
self.DebuffHighlight:SetTexture(frameborder)
self.DebuffHighlight:SetVertexColor(0, 0, 0, 0)
self.DebuffHighlight:SetBlendMode("BLEND")
self.DebuffHighlightAlpha = 0.8
self.DebuffHighlightFilter = true
end
-- ------------------------------------
-- player --玩家设置
-- ------------------------------------
if unit=="player" then
self:SetWidth(250) --头像长度
self:SetHeight(42) --头像高度
self.Health:SetHeight(15) --血条高度
self.Name:Hide() --姓名显示(隐藏),显示改为Show()
self.Health.value:SetPoint("RIGHT", 0, 9) 生命条位置
self.Power:SetHeight(5) --蓝条高度
self.Power.value:Show()
self.Power.value:SetPoint("LEFT", self.Health, 0, 9)
self.Power.value:SetJustifyH"LEFT"
self.Level:Hide() --等级显示(隐藏),显示改为Show()
self.Power:SetAlpha(1.0) --透明度
self.Health:SetAlpha(1.0) --透明度
self.Power:SetPoint("TOP", self.Health, "BOTTOM", 0, -22) --蓝条位置,如果自己添加2D 或者3D头像,可添加这句,具体数值由添加的头像高度决定
--
-- Portrait --添加的玩家3D头像
--
local portrait = CreateFrame(" layerModel", nil, self)
portrait:SetScript("OnShow", function(self) self:SetCamera(0) end)
portrait:SetWidth(250) --头像宽度
portrait:SetHeight(20) --头像高度
portrait:SetPoint("TOPLEFT", self.Health, "BOTTOMLEFT", 0, -1) --头像位置,TOPLEFT指3d头像左上角,self.Health指自己的血条,BOTTOMLEFT指自己血条底部左下角
portrait.type = "3D" 头像类型
self.Portrait = portrait
portrait:SetFrameLevel(0)
--
-- oUF_Banzai - ignore aggro coloring for player - uncomment this if you want aggro coloring on your player frame
--
self.ignoreBanzai = true
--
-- resting icon --休息标识(zzZ)
--
self.Resting = self.Health:CreateTexture(nil, 'OVERLAY') --素材无
self.Resting:SetHeight(14) --标识的高度
self.Resting:SetWidth(14) --标识的宽度
self.Resting:SetPoint('BOTTOMLEFT', self, 2, 6) --标识的位置
self.Resting:SetTexture('InterfaceCharacterFrameUI-StateIcon')
self.Resting:SetTexCoord(0,0.5,0,0.5)
--
-- Druid Mana --XD蓝条相关设置
--
if playerClass=="DRUID" then
self.DruidPower = CreateFrame"StatusBar"
self.DruidPower:SetStatusBarTexture(bartex)
self.DruidPower:SetPoint("TOPLEFT", self, "BOTTOMLEFT", 0, -14)
self.DruidPower:SetHeight(8)
self.DruidPower:SetWidth(225)
self.DruidPower.Smooth = true
self.DruidPower.bg = self.DruidPower:CreateTexture(nil, "BORDER")
self.DruidPower.bg:SetAllPoints(self.DruidPower)
self.DruidPower.bg:SetTexture(bartex)
self.DruidPower.bg:SetAlpha(0.30)
self.DruidPower.value = self.DruidPower:CreateFontString(nil, "OVERLAY")
self.DruidPower.value:SetPoint("LEFT", self.DruidPower, 2, 0)
self.DruidPower.value:SetFont(font, fontsize-1)
self.DruidPower.value:SetTextColor(1,1,1)
self.DruidPower.value:SetShadowOffset(1, -1)
self.DruidPower.percent = self.DruidPower:CreateFontString(nil, "OVERLAY")
self.DruidPower.percent:SetPoint("RIGHT", self.DruidPower, -1, 0)
self.DruidPower.percent:SetFont(font, fontsize-1)
self.DruidPower.percent:SetTextColor(1,1,1)
self.DruidPower.percent:SetShadowOffset(1, -1)
self.DruidPower:SetBackdrop{
bgFile = "InterfaceChatFrameChatFrameBackground", tile = true, tileSize = 16,
insets = {left = -1, right = -1, top = -1, bottom = -1},
}
self.DruidPower:SetBackdropColor(0,0,0,0.6)
self:RegisterEvent("UNIT_MANA", UpdateDruidPower)
self:RegisterEvent("UNIT_ENERGY", UpdateDruidPower)
self:RegisterEvent(" LAYER_LOGIN", UpdateDruidPower)
-- Druid Mana border
local TopLeft = self.DruidPower:CreateTexture(nil, "OVERLAY")
TopLeft:SetTexture(frameborder)
TopLeft:SetTexCoord(0, 1/3, 0, 1/3)
TopLeft:SetPoint("TOPLEFT", -6, 6)
TopLeft:SetWidth(12) TopLeft:SetHeight(12)
TopLeft:SetVertexColor(color_rb,color_gb,color_bb,alpha_fb)
local TopRight = self.DruidPower:CreateTexture(nil, "OVERLAY")
TopRight:SetTexture(frameborder)
TopRight:SetTexCoord(2/3, 1, 0, 1/3)
TopRight:SetPoint("TOPRIGHT", 6, 6)
TopRight:SetWidth(12) TopRight:SetHeight(12)
TopRight:SetVertexColor(color_rb,color_gb,color_bb,alpha_fb)
local BottomLeft = self.DruidPower:CreateTexture(nil, "OVERLAY")
BottomLeft:SetTexture(frameborder)
BottomLeft:SetTexCoord(0, 1/3, 2/3, 1)
BottomLeft:SetPoint("BOTTOMLEFT", -6, -6)
BottomLeft:SetWidth(12) BottomLeft:SetHeight(12)
BottomLeft:SetVertexColor(color_rb,color_gb,color_bb,alpha_fb)
local BottomRight = self.DruidPower:CreateTexture(nil, "OVERLAY")
BottomRight:SetTexture(frameborder)
BottomRight:SetTexCoord(2/3, 1, 2/3, 1)
BottomRight:SetPoint("BOTTOMRIGHT", 6, -6)
BottomRight:SetWidth(12) BottomRight:SetHeight(12)
BottomRight:SetVertexColor(color_rb,color_gb,color_bb,alpha_fb)
local TopEdge = self.DruidPower:CreateTexture(nil, "OVERLAY")
TopEdge:SetTexture(frameborder)
TopEdge:SetTexCoord(1/3, 2/3, 0, 1/3)
TopEdge:SetPoint("TOPLEFT", TopLeft, "TOPRIGHT")
TopEdge:SetPoint("TOPRIGHT", TopRight, "TOPLEFT")
TopEdge:SetHeight(12)
TopEdge:SetVertexColor(color_rb,color_gb,color_bb,alpha_fb)
local BottomEdge = self.DruidPower:CreateTexture(nil, "OVERLAY")
BottomEdge:SetTexture(frameborder)
BottomEdge:SetTexCoord(1/3, 2/3, 2/3, 1)
BottomEdge:SetPoint("BOTTOMLEFT", BottomLeft, "BOTTOMRIGHT")
BottomEdge:SetPoint("BOTTOMRIGHT", BottomRight, "BOTTOMLEFT")
BottomEdge:SetHeight(12)
BottomEdge:SetVertexColor(color_rb,color_gb,color_bb,alpha_fb)
local LeftEdge = self.DruidPower:CreateTexture(nil, "OVERLAY")
LeftEdge:SetTexture(frameborder)
LeftEdge:SetTexCoord(0, 1/3, 1/3, 2/3)
LeftEdge:SetPoint("TOPLEFT", TopLeft, "BOTTOMLEFT")
LeftEdge:SetPoint("BOTTOMLEFT", BottomLeft, "TOPLEFT")
LeftEdge:SetWidth(12)
LeftEdge:SetVertexColor(color_rb,color_gb,color_bb,alpha_fb)
local RightEdge = self.DruidPower:CreateTexture(nil, "OVERLAY")
RightEdge:SetTexture(frameborder)
RightEdge:SetTexCoord(2/3, 1, 1/3, 2/3)
RightEdge:SetPoint("TOPRIGHT", TopRight, "BOTTOMRIGHT")
RightEdge:SetPoint("BOTTOMRIGHT", BottomRight, "TOPRIGHT")
RightEdge:SetWidth(12)
RightEdge:SetVertexColor(color_rb,color_gb,color_bb,alpha_fb)
end
--
-- leader icon --队长标识
--
self.Leader = self.Health:CreateTexture(nil, "OVERLAY")
self.Leader:SetHeight(12)
self.Leader:SetWidth(12)
self.Leader:SetPoint("BOTTOMRIGHT", self, -2, 6)
self.Leader:SetTexture"InterfaceGroupFrameUI-Group-LeaderIcon"
--
-- Combat icon --战斗状态标志(交叉剑)
--
self.Combat = self.Health:CreateTexture(nil, 'OVERLAY')
self.Combat:SetHeight(14)
self.Combat:SetWidth(14)
self.Combat:SetPoint('BOTTOM', self, 0, -9)
self.Combat:SetTexture('InterfaceCharacterFrameUI-StateIcon')
self.Combat:SetTexCoord(0.58, 0.90, 0.08, 0.41)
--
-- raid target icons -团队标记
--
self.RaidIcon = self.Health:CreateTexture(nil, "OVERLAY")
self.RaidIcon:SetHeight(16)
self.RaidIcon:SetWidth(16)
self.RaidIcon:SetPoint("TOP", self, 0, 9)
self.RaidIcon:SetTexture"InterfaceTargetingFrameUI-RaidTargetingIcons"
--
-- oUF_PowerSpark support --对PowerSpark插件的支持代码,提示战斗回蓝的光标效果
--
self.Spark = self.Power:CreateTexture(nil, "OVERLAY")
self.Spark:SetTexture("InterfaceCastingBarUI-CastingBar-Spark")
self.Spark:SetVertexColor(1, 1, 1, 1)
self.Spark:SetBlendMode("ADD")
self.Spark:SetHeight(self.Power:GetHeight()*2.5)
self.Spark:SetWidth(self.Power:GetHeight()*2)
-- self.Spark.rtl = true -- Make the spark go from Right To Left instead
-- self.Spark.manatick = true -- Show mana regen ticks outside FSR (like the energy ticker)
-- self.Spark.highAlpha = 1 -- What alpha setting to use for the FSR and energy spark
-- self.Spark.lowAlpha = 0.25 -- What alpha setting to use for the mana regen ticker
--
-- oUF_BarFader --对BarFader插件的支持代码,可以在你满血满蓝的时候渐隐或者全隐玩家头像
--
self.BarFade = true
end
-- ------------------------------------
-- pet --bb设置
-- ------------------------------------
if unit=="pet" then
self:SetWidth(120) --头像宽度
self:SetHeight(20) --头像高度
self.Health:SetHeight(14.5) --血条高度
self.Power:SetHeight(4) --蓝条高度
self.Power.value:Hide()
--self.Health.value:Hide() --生命值隐藏,也可在前面添加(去掉注释--即加载)
self.Level:Hide() --BB等级
self.Name:Hide() --BB名字
self.Power:SetAlpha(1.0) --透明度
self.Health:SetAlpha(1.0) --透明度
if playerClass=="HUNTER" then
self.Health.colorReaction = false
self.Health.colorClass = false
self.Health.colorHappiness = true
end
--
-- buffs buff参数设置
--
self.Buffs = CreateFrame("Frame", nil, self) -- buffs
self.Buffs.size = 26 --buff尺寸
self.Buffs:SetHeight(self.Buffs.size)
self.Buffs:SetWidth(self.Buffs.size * 6) --buff栏宽度,以buff的数量计算
self.Buffs:SetPoint("BOTTOMLEFT", self, "RIGHT", 15, -10) --buff位置
self.Buffs.initialAnchor = "BOTTOMLEFT"
self.Buffs["growth-y"] = "TOP"
self.Buffs.num = 4
self.Buffs.spacing = 2 间隔
--
-- debuffs
--
self.Debuffs = CreateFrame("Frame", nil, self)
self.Debuffs.size = 26 --debuff的设置,同buff设置
self.Debuffs:SetHeight(self.Debuffs.size)
self.Debuffs:SetWidth(self.Debuffs.size * 5)
self.Debuffs:SetPoint("TOPLEFT", self, "BOTTOMLEFT", -2, -10)
self.Debuffs.initialAnchor = "TOPLEFT"
self.Debuffs["growth-y"] = "DOWN" 延伸方向
self.Debuffs.filter = false 自身放的debuff突出放大
self.Debuffs.num = 4
self.Debuffs.spacing = 2
--
-- oUF_BarFader
--
self.BarFade = true
end
-- ------------------------------------
-- target --目标的设置
-- ------------------------------------
if unit=="target" then
self:SetWidth(250) --宽度
self:SetHeight(20) --高度
self.Health:SetHeight(14.5) --血条高度
self.Power:SetHeight(4) --蓝条高度
self.Power.value:Hide()
self.Health.value:SetPoint("RIGHT", 0, 9)
self.Name:SetPoint("LEFT", self.Level, "RIGHT", 0, 0)
self.Name:SetHeight(20) --姓名高度
self.Name:SetWidth(154) --姓名长度限制
self.Power:SetAlpha(1.0) --透明度
self.Health:SetAlpha(1.0)
table.insert(self.__elements, HidePortrait)
self.Health.colorClass = true
--
-- PvP Icon --pvp 标识
--
local pvp = self.Health:CreateTexture(nil, "OVERLAY")
pvp:SetPoint("LEFT", self.Health, "LEFT", -22, -7)
pvp:SetHeight(30)
pvp:SetWidth(30)
self.PvP = pvp
--
-- Portrait --中部3D头像 设置
--
local portrait = CreateFrame(" layerModel", nil, self)
portrait:SetScript("OnShow", function(self) self:SetCamera(0) end)
portrait:SetWidth(90) --宽度
portrait:SetHeight(100) --高度
portrait:SetPoint("TOPLEFT", self.Power, "BOTTOMLEFT", 0, -20) --位置
portrait.type = "3D"
self.Portrait = portrait
portrait:SetFrameLevel(0)
--
-- Portrait background --目标头像背景材质
--
local TargetPorBG = CreateFrame("Frame", nil, oUF_Target)
local TPBG = TargetPorBG:CreateTexture(nil,"BACKGROUND")
TargetPorBG:SetPoint("TOPLEFT", self.Power, "BOTTOMLEFT", -6, -14)
TargetPorBG:SetWidth(102) -- default 102
TargetPorBG:SetHeight(111) -- default 111
--TargetPorBG:SetFrameStrata("BACKGROUND") -- move the texture behind the portrait
TPBG:SetTexture(PorBG)
--TPBG:SetTexture(frameborder)
TPBG:SetVertexColor(color_rb,color_gb,color_bb,alpha_fb)
TPBG:SetAllPoints(TargetPorBG)
TargetPorBG.texture = TPBG
TargetPorBG:Show()
--[[
-- alternative (old/default/whatever) background
TargetPorBG = CreateFrame('Frame', 'TargetBG', oUF_Target)
TargetPorBG:SetFrameStrata'BACKGROUND'
TargetPorBG:SetWidth(102)
TargetPorBG:SetHeight(112)
TargetPorBG:SetPoint("TOPLEFT", self.Power, "BOTTOMLEFT", -6, -14)
TargetPorBG:SetBackdrop({bgFile = "InterfaceChatFrameChatFrameBackground",edgeFile = "InterfaceTooltipsChatBubble-Backdrop",tile = false, tileSize = 0,edgeSize = 9,insets = { left = 6, right = 6, top = 6, bottom = 6 }})
TargetPorBG:SetBackdropColor(0,0,0,0.8)
TargetPorBG:SetBackdropBorderColor(0.2,0.5,0.5,0.35)
--]]
--
-- combo points --连击点设置
--
if(playerClass=="ROGUE" or playerClass=="DRUID") then
self.CPoints = self:CreateFontString(nil, "OVERLAY")
self.CPoints:SetPoint("RIGHT", self, "LEFT", -10, 0)
self.CPoints:SetFont(font, 38, "OUTLINE")
self.CPoints:SetTextColor(0, 0.81, 1)
self.CPoints:SetShadowOffset(1, -1)
self.CPoints:SetJustifyH"RIGHT"
end
--
-- raid target icons --团队标记
--
self.RaidIcon = self.Health:CreateTexture(nil, "OVERLAY")
self.RaidIcon:SetHeight(24)
self.RaidIcon:SetWidth(24)
self.RaidIcon:SetPoint("LEFT", self, -30, 0)
self.RaidIcon:SetTexture"InterfaceTargetingFrameUI-RaidTargetingIcons"
--
-- buffs --目标buff的设置,同上
--
self.Buffs = CreateFrame("Frame", nil, self) -- buffs
self.Buffs.size = 30
self.Buffs:SetHeight(self.Buffs.size)
self.Buffs:SetWidth(self.Buffs.size * 6)
self.Buffs:SetPoint("BOTTOMLEFT", self, "RIGHT", 15, -15)
self.Buffs.initialAnchor = "BOTTOMLEFT"
self.Buffs["growth-y"] = "TOP"
self.Buffs.num = 30
self.Buffs.spacing = 2
--
-- debuffs --目标debuff的设置,同上
--
self.Debuffs = CreateFrame("Frame", nil, self)
self.Debuffs.size = 30
self.Debuffs:SetHeight(self.Debuffs.size)
self.Debuffs:SetWidth(self.Debuffs.size * 9)
self.Debuffs:SetPoint("BOTTOMLEFT", self, "TOPLEFT", -2, 15)
self.Debuffs.initialAnchor = "BOTTOMLEFT"
self.Debuffs["growth-y"] = "TOP"
self.Debuffs.filter = "HARMFUL|PLAYER" --debuff过滤器,只显示自己的还是全部的,("HARMFUL|PLAYER"改成false 即可显示全部)
self.Debuffs.num = 40
self.Debuffs.spacing = 2
end
-- ------------------------------------
-- player and target castbar --施法条的设置,玩家的和目标的
-- ------------------------------------
if(unit == 'player' or unit == 'target') then
self.Castbar = CreateFrame('StatusBar', nil, self)
self.Castbar:SetStatusBarTexture(castbartex)
self.Castbar:SetFrameStrata'HIGH'
if(unit == "player") then
local _, class = UnitClass(unit)
color = self.colors.class[class]
--self.Castbar:SetStatusBarColor(0.10, 0.3, 0.70, 0.9)
self.Castbar:SetStatusBarColor(0.5, 0.5, 0.5, 0.8) --施法条颜色
self.Castbar:SetHeight(20) --玩家施法条高度
self.Castbar:SetWidth(250) --玩家施法条宽度
self.Castbar:SetBackdrop{
bgFile = "InterfaceChatFrameChatFrameBackground", tile = true, tileSize = 16,
insets = {left = -1, right = -1, top = -1, bottom = -1}} --玩家施法条背景(可删)
self.Castbar.SafeZone = self.Castbar:CreateTexture(nil,"ARTWORK")
self.Castbar.SafeZone:SetTexture(castbartex)
self.Castbar.SafeZone:SetVertexColor(0.75,0.10,0.10,0.7)
self.Castbar.SafeZone:SetPoint("TOPRIGHT")
self.Castbar.SafeZone:SetPoint("BOTTOMRIGHT")
self.Castbar:SetPoint('CENTER', UIParent, 'CENTER', playerCB_x, playerCB_y)
else --else 目标的施法条设置
--self.Castbar:SetStatusBarColor(0.10, 0.3, 0.70, 0.9)
self.Castbar:SetStatusBarColor(0.5, 0.5, 0.5, 0.8) --施法条颜色
self.Castbar:SetHeight(20) --高度
self.Castbar:SetWidth(250) --宽度
self.Castbar:SetBackdrop{
bgFile = "InterfaceChatFrameChatFrameBackground", tile = true, tileSize = 16,
insets = {left = -1, right = -1, top = -1, bottom = -1}}
self.Castbar:SetPoint('CENTER', UIParent, 'CENTER', targetCB_x, targetCB_y)
end
self.Castbar:SetBackdropColor(0, 0, 0, 0.25)
self.Castbar.Text = self.Castbar:CreateFontString(nil, 'OVERLAY')
self.Castbar.Text:SetPoint('CENTER', self.Castbar, 0, 0)
self.Castbar.Text:SetFont(font, fontsizeCB)
self.Castbar.Text:SetShadowOffset(1, -1)
self.Castbar.Text:SetTextColor(1, 1, 1)
self.Castbar.Text:SetJustifyH('LEFT')
self.Castbar.Time = self.Castbar:CreateFontString(nil, 'OVERLAY')
self.Castbar.Time:SetPoint('RIGHT', self.Castbar, -4, 0)
self.Castbar.Time:SetFont(font, fontsizeCB)
self.Castbar.Time:SetTextColor(1, 1, 1)
self.Castbar.Time:SetJustifyH('RIGHT')
--
-- Castbar frameborder --施法条背景框设置
--
local TopLeft = self.Castbar:CreateTexture(nil, "OVERLAY")
--TopLeft:SetTexture(frameborder) --前面加--,即表示不显示施法条背景框 (以下相同)
TopLeft:SetTexCoord(0, 1/3, 0, 1/3)
TopLeft:SetPoint("TOPLEFT", -6, 6)
TopLeft:SetWidth(16) TopLeft:SetHeight(16)
TopLeft:SetVertexColor(color_rb,color_gb,color_bb,alpha_fb)
local TopRight = self.Castbar:CreateTexture(nil, "OVERLAY")
--TopRight:SetTexture(frameborder)
TopRight:SetTexCoord(2/3, 1, 0, 1/3)
TopRight:SetPoint("TOPRIGHT", 6, 6)
TopRight:SetWidth(16) TopRight:SetHeight(16)
TopRight:SetVertexColor(color_rb,color_gb,color_bb,alpha_fb)
local BottomLeft = self.Castbar:CreateTexture(nil, "OVERLAY")
--BottomLeft:SetTexture(frameborder)
BottomLeft:SetTexCoord(0, 1/3, 2/3, 1)
BottomLeft:SetPoint("BOTTOMLEFT", -6, -6)
BottomLeft:SetWidth(16) BottomLeft:SetHeight(16)
BottomLeft:SetVertexColor(color_rb,color_gb,color_bb,alpha_fb)
local BottomRight = self.Castbar:CreateTexture(nil, "OVERLAY")
--BottomRight:SetTexture(frameborder)
BottomRight:SetTexCoord(2/3, 1, 2/3, 1)
BottomRight:SetPoint("BOTTOMRIGHT", 6, -6)
BottomRight:SetWidth(16) BottomRight:SetHeight(16)
BottomRight:SetVertexColor(color_rb,color_gb,color_bb,alpha_fb)
local TopEdge = self.Castbar:CreateTexture(nil, "OVERLAY")
--TopEdge:SetTexture(frameborder)
TopEdge:SetTexCoord(1/3, 2/3, 0, 1/3)
TopEdge:SetPoint("TOPLEFT", TopLeft, "TOPRIGHT")
TopEdge:SetPoint("TOPRIGHT", TopRight, "TOPLEFT")
TopEdge:SetHeight(16)
TopEdge:SetVertexColor(color_rb,color_gb,color_bb,alpha_fb)
local BottomEdge = self.Castbar:CreateTexture(nil, "OVERLAY")
--BottomEdge:SetTexture(frameborder)
BottomEdge:SetTexCoord(1/3, 2/3, 2/3, 1)
BottomEdge:SetPoint("BOTTOMLEFT", BottomLeft, "BOTTOMRIGHT")
BottomEdge:SetPoint("BOTTOMRIGHT", BottomRight, "BOTTOMLEFT")
BottomEdge:SetHeight(16)
BottomEdge:SetVertexColor(color_rb,color_gb,color_bb,alpha_fb)
local LeftEdge = self.Castbar:CreateTexture(nil, "OVERLAY")
--LeftEdge:SetTexture(frameborder)
LeftEdge:SetTexCoord(0, 1/3, 1/3, 2/3)
LeftEdge:SetPoint("TOPLEFT", TopLeft, "BOTTOMLEFT")
LeftEdge:SetPoint("BOTTOMLEFT", BottomLeft, "TOPLEFT")
LeftEdge:SetWidth(16)
LeftEdge:SetVertexColor(color_rb,color_gb,color_bb,alpha_fb)
local RightEdge = self.Castbar:CreateTexture(nil, "OVERLAY")
--RightEdge:SetTexture(frameborder)
RightEdge:SetTexCoord(2/3, 1, 1/3, 2/3)
RightEdge:SetPoint("TOPRIGHT", TopRight, "BOTTOMRIGHT")
RightEdge:SetPoint("BOTTOMRIGHT", BottomRight, "TOPRIGHT")
RightEdge:SetWidth(16)
RightEdge:SetVertexColor(color_rb,color_gb,color_bb,alpha_fb)
end
-- ------------------------------------
-- target of target and focus --目标的目标 和 焦点设置
-- ------------------------------------
if unit=="targettarget" or unit=="focus" then
self:SetWidth(120)
self:SetHeight(20)
self.Health:SetHeight(14.5)
self.Power:Show()
self.Power:SetHeight(4
self.Power.value:Hide()
self.Health.value:Hide()
self.Name:SetWidth(95)
self.Name:SetHeight(18)
self.Power:SetAlpha(1.0)
self.Health:SetAlpha(1.0)
--
-- raid target icons
--
self.RaidIcon = self.Health:CreateTexture(nil, "OVERLAY")
self.RaidIcon:SetHeight(16)
self.RaidIcon:SetWidth(16)
self.RaidIcon:SetPoint("RIGHT", self, 0, 9)
self.RaidIcon:SetTexture"InterfaceTargetingFrameUI-RaidTargetingIcons"
--
-- oUF_BarFader
--
if unit=="focus" then
self.BarFade = false
end
end
-- ------------------------------------
-- party --小队的设置
-- ------------------------------------
if(self:GetParent():GetName():match"oUF_Party") then
self:SetWidth(180)
self:SetHeight(20)
self.Health:SetHeight(15)
self.Power:SetHeight(3)
self.Power.value:Hide()
self.Health.value:SetPoint("RIGHT", 0 , 9)
self.Name:SetPoint("LEFT", 0, 9)
self.Power:SetAlpha(0.8)
self.Health:SetAlpha(0.8)
--
-- Portrait (party) --小队头像的设置
--
if partyport == 1 then
local portrait = CreateFrame(" layerModel", nil, self)
portrait:SetScript("OnShow", function(self) self:SetCamera(0) end)
portrait:SetWidth(45)
portrait:SetHeight(45)
portrait:SetPoint("LEFT", self.Health, "LEFT", -55, 11)
portrait.type = "3D"
self.Portrait = portrait
table.insert(self.__elements, HidePortrait)
local PartyPorBG = CreateFrame("Frame", nil, self) --小队头像背景材质设置
local PPBG = PartyPorBG:CreateTexture(nil,"BACKGROUND")
PartyPorBG:SetPoint("LEFT", self.Health, "LEFT", -57, 12)
PartyPorBG:SetWidth(49)
PartyPorBG:SetHeight(49)
--PartyPorBG:SetFrameStrata("BACKGROUND") -- move the texture behind the portrait
PPBG:SetTexture(PorBG)
--TPBG:SetTexture(frameborder)
PPBG:SetVertexColor(color_rb,color_gb,color_bb,alpha_fb)
PPBG:SetAllPoints(PartyPorBG)
PartyPorBG.texture = PPBG
PartyPorBG:Show()
else
--
end
--
-- buffs --小队buff设置
--
self.Buffs = CreateFrame("Frame", nil, self) -- buffs
self.Buffs.size = 16
self.Buffs:SetHeight(self.Buffs.size)
self.Buffs:SetWidth(self.Buffs.size * 12)
self.Buffs:SetPoint("BOTTOMLEFT", self, "BOTTOMLEFT", -2, -23)
self.Buffs.initialAnchor = "BOTTOMLEFT"
--self.Buffs["growth-y"] = "TOP"
self.Buffs.num = 10
self.Buffs.spacing = 2
self.Buffs.filter = "HELPFUL|PLAYER"
--
-- debuffs --小队debuff设置
--
self.Debuffs = CreateFrame("Frame", nil, self)
self.Debuffs.size = 20 * 1.3
self.Debuffs:SetHeight(self.Debuffs.size)
self.Debuffs:SetWidth(self.Debuffs.size * 5)
self.Debuffs:SetPoint("LEFT", self, "RIGHT", 8, 0)
self.Debuffs.initialAnchor = "TOPLEFT"
self.Debuffs.filter = false
self.Debuffs.showDebuffType = true
self.Debuffs.spacing = 2
self.Debuffs.num = 8 -- max debuffs
--
-- raid target icons
--
self.RaidIcon = self.Health:CreateTexture(nil, "OVERLAY")
self.RaidIcon:SetHeight(24)
self.RaidIcon:SetWidth(24)
self.RaidIcon:SetPoint("LEFT", self, -30, 0)
self.RaidIcon:SetTexture"InterfaceTargetingFrameUI-RaidTargetingIcons"
-- party pet and target appearance --小队队友的宠物和目标设置
if unit=="partypet" or unit=="partytarget" then
self:SetWidth(75)
self:SetHeight(12)
self.Health:SetHeight(10)
self.Power.value:Hide()
self.Health.value:Hide()
self.Power:SetHeight(2)
self.Name:SetPoint("LEFT", 0, 9)
self.Name:SetWidth(50)
end
end
-- ------------------------------------
-- raid --团队设置
-- ------------------------------------
if(self:GetParent():GetName():match"oUF_Raid") then
self:SetWidth(35)
self:SetHeight(40)
self.Health:SetOrientation("VERTICAL")
self.Health:SetHeight(36)
self.Health:SetFrameLevel(2)
self.Health.value:SetPoint("TOP", 0, 6)
self.Health.value:SetFont(font, 10, "OUTLINE")
self.Health:SetAlpha(0.8)
self.Name:Hide()
self.Power:SetFrameLevel(2)
self.Power:SetHeight(3)
self.Power:SetAlpha(0.8)
self.Power.value:Hide()
--
-- Portrait (raid) --团队头像
--
if raidport == 1 then
local portrait = CreateFrame(" layerModel", nil, self)
portrait:SetScript("OnShow", function(self) self:SetCamera(0) end)
portrait:SetWidth(35)
portrait:SetHeight(36)
portrait:SetPoint("CENTER", self.Health, "CENTER", 0, 0)
--portrait:SetAlpha(0.4) -- change alpha for raid portraits here
portrait.type = "3D"
self.Portrait = portrait
table.insert(self.__elements, HidePortrait)
else
--
end
--
-- oUF_ReadyCheck support --团队就位框
--
self.ReadyCheck = self.Health:CreateTexture(nil, 'OVERLAY')
self.ReadyCheck:SetPoint('CENTER', self, 0, -10)
self.ReadyCheck:SetHeight(20)
self.ReadyCheck:SetWidth(20)
end
--
-- custom aura textures
--
self.PostCreateAuraIcon = auraIcon
self.SetAuraPosition = auraOffset
-- swing the magic stick ....
if(self:GetParent():GetName():match"oUF_Party") or unit=="targettarget" or unit=="focus" or unit=="player" or unit=="target" or unit=="pet" or (self:GetParent():GetName():match"oUF_Raid") then
self:SetAttribute('initial-height', height)
self:SetAttribute('initial-width', width)
else
self:SetAttribute('initial-height', 12)
self:SetAttribute('initial-width', 80)
self.Name:SetPoint("LEFT", 0, 5)
self.Health.value:Hide() -- hide partytarget/partypet health
--self.Name:Hide() -- hide partytarget/partypet name
self.Power:Hide() -- hide powerbar
self.Health:SetAlpha(0.8)
--self.Power:SetAlpha(0.8)
end
return self
end
-- ------------------------------------------------------------------------
-- spawning the frames
-- ------------------------------------------------------------------------
--
-- normal frames
--
oUF:RegisterStyle("Asym", func)
oUF:SetActiveStyle("Asym")
local player = oUF:Spawn("player", "oUF_Player")
player:SetPoint("CENTER", 0, -260) --自己头像的位置
local target = oUF:Spawn("target", "oUF_Target")
target:SetPoint("CENTER", 270, -152) --目标头像的位置
local pet = oUF:Spawn("pet", "oUF_Pet")
pet:SetPoint("RIGHT", player, 270, -11) --宝宝头像的位置
local tot = oUF:Spawn("targettarget", "oUF_TargetTarget")
tot:SetPoint("BOTTOMRIGHT", target, 0, -40) --目标头像的位置
local focus = oUF:Spawn("focus", "oUF_Focus")
focus:SetPoint("RIGHT", player, 270, 40) --焦点头像的位置
--
-- party
--
local party = oUF:Spawn("header", "oUF_Party")
party:SetManyAttributes("showParty", true, "yOffset", -58)
party:SetPoint("LEFT", 70, 50) -- default ("LEFT", 70, -50) --小队头像的位置
party:Show()
-- party target
local partytarget = {}
for i = 1, 5 do
partytarget = oUF:Spawn('party'..i..'target', 'oUF_Party'..i..'Target')
if i == 1 then
partytarget:SetPoint('BOTTOMRIGHT', party, 'TOPRIGHT', 0, 15)
else
partytarget:SetPoint('TOP', partytarget[i-1], 'BOTTOM', 0, -67)
end
end
-- party pet
local partypet = {}
for i = 1, 4 do
partypet = oUF:Spawn('partypet'..i, 'oUF_PartyPet'..i)
partypet:SetPoint('RIGHT', partytarget, 'LEFT', -20, 0)
end
--
-- raid
--
local raid = {}
for i = 1, 8 do
local raidgroup = oUF:Spawn('header', 'oUF_Raid'..i)
raidgroup:SetManyAttributes('groupFilter', tostring(i), 'showRaid', true, 'yOffSet', -16)
table.insert(raid, raidgroup)
if(i==1) then
raidgroup:SetPoint('TOPLEFT', UIParent, 'LEFT', 40, 55)
else
raidgroup:SetPoint('TOPLEFT', raid[i-1], 'TOPRIGHT', 15, 0)
end
end
--
-- party toggle in raid
--
local partyToggle = CreateFrame('Frame')
partyToggle:RegisterEvent('PLAYER_LOGIN')
partyToggle:RegisterEvent('RAID_ROSTER_UPDATE')
partyToggle:RegisterEvent('PARTY_LEADER_CHANGED')
partyToggle:RegisterEvent('PARTY_MEMBERS_CHANGED')
partyToggle:SetScript('OnEvent', function(self)
if(InCombatLockdown()) then
self:RegisterEvent('PLAYER_REGEN_ENABLED')
else
self:UnregisterEvent('PLAYER_REGEN_ENABLED')
if(GetNumRaidMembers() > 40) then --团队人员数量,超过这个人数将在团队中隐藏小队
party:Hide()
for i,v in ipairs(raid) do v:Show() end
for i,v in ipairs(partypet) do v isable() end
for i,v in ipairs(partytarget) do v isable() end
else
party:Show()
for i,v in ipairs(raid) do v:Hide() end
for i,v in ipairs(partypet) do v:Enable() end
for i,v in ipairs(partytarget) do v:Enable() end
end
end
end)
※实例2、Kyron的oUF_Caellian
作者:kyron
下载地址:http://www.wowinterface.com/downloads/info9974-oUF_Caellian.html
多玩分流:http://wowui.duowan.com/html/AddOns/1/1/20081105/1286.html
代码篇幅过长,换42楼 (点击进入)更新~
[ 本帖最后由 vans67 于 2009-7-5 12:56 编辑 ] |
|