badness |
09-04-15 11:34 AM |
CaelNameplates and Ouf_Freeb Help (Authors Quit)
1.) It's a nameplate addon so I assume what broke it is the same thing that broke every other nameplate addon, something about SpellIconRegion. Ive tried myself to fix this but i'm coming up short each time, I even tried the Tidyplates fix but to no avail. Some help would be greatly appreciated with this.
Here is the Error:
http://postimg.org/image/mv6ylz7yb/full/
Here is the Code:
Code:
local addonName, ns = ...
local caelNamePlates = CreateFrame("Frame", nil, UIParent)
caelNamePlates:SetScript("OnEvent", function(self, event, ...) self[event](self, ...) end)
--if not IsAddOnLoaded("caelCore") then
SetCVar("bloattest", 0) -- 1 might make nameplates larger but it fixes the disappearing ones.
SetCVar("bloatnameplates", 0) -- 1 makes nameplates larger depending on threat percentage.
SetCVar("bloatthreat", 0) -- 1 makes nameplates resize depending on threat gain/loss. Only active when a mob has multiple units on its threat table.
--end
--[[
local barTexture = caelMedia.files.statusBarC
local iconTexture = caelMedia.files.buttonNormal
local raidIcons = caelMedia.files.raidIcons
local overlayTexture = [=[Interface\Tooltips\Nameplate-Border]=]
local font, fontSize, fontOutline = caelMedia.fonts.CAELNAMEPLATE_FONT, 8
]]
local barTexture = [=[Interface\AddOns\caelNameplates\media\normtexc]=]
--local iconTexture = [=[Interface\AddOns\caelNameplates\media\buttonnormal]=]
--local raidIcons = [=[Interface\AddOns\caelNameplates\media\raidicons]=]
local overlayTexture = [=[Interface\Tooltips\Nameplate-Border]=]
--local font, fontSize, fontOutline = caelMedia.fonts.CAELNAMEPLATE_FONT, 8
local font = STANDARD_TEXT_FONT
local fontSize = 10
local fontOutline = "THINOUTLINE"
local backdrop = {
bgFile = [=[Interface\ChatFrame\ChatFrameBackground]=],
edgeFile = [=[Interface\AddOns\caelNameplates\media\glowTex3]=],
edgeSize = 2,
insets = { left = 2, right = 2, top = 2, bottom = 2 },
}
local select = select
--local pixelScale = caelLib.scale
local UpdateTime = function(self, curValue)
local minValue, maxValue = self:GetMinMaxValues()
if self.channeling then
self.time:SetFormattedText("%.1f ", curValue)
else
self.time:SetFormattedText("%.1f ", maxValue - curValue)
end
end
local ThreatUpdate = function(self, elapsed)
self.elapsed = self.elapsed + elapsed
if self.elapsed >= 0.2 then
if not self.oldglow:IsShown() then
self.healthBar.hpGlow:SetBackdropBorderColor(0, 0, 0)
else
local r, g, b = self.oldglow:GetVertexColor()
if g + b == 0 then
self.healthBar.hpGlow:SetBackdropBorderColor(1, 0, 0)
else
self.healthBar.hpGlow:SetBackdropBorderColor(1, 1, 0)
end
end
self.healthBar:SetStatusBarColor(self.r, self.g, self.b)
self.elapsed = 0
end
end
local UpdatePlate = function(self)
local r, g, b = self.healthBar:GetStatusBarColor()
local newr, newg, newb
if g + b == 0 then
-- Hostile unit
newr, newg, newb = 1, 0.2, 0.2
self.healthBar:SetStatusBarColor(1, 0.2, 0.2)
elseif r + b == 0 then
-- Friendly unit
newr, newg, newb = 0.2, 1, 0.2
self.healthBar:SetStatusBarColor(0.2, 1, 0.2)
elseif r + g == 0 then
-- Friendly player
newr, newg, newb = 0.31, 0.45, 0.63
self.healthBar:SetStatusBarColor(0.31, 0.45, 0.63)
elseif 2 - (r + g) < 0.05 and b == 0 then
-- Neutral unit
newr, newg, newb = 1, 1, 0.2--0.86, 0.83, 0.47
self.healthBar:SetStatusBarColor(1, 1, 0.2)
else
-- Hostile player - class colored.
newr, newg, newb = r, g, b
end
self.r, self.g, self.b = newr, newg, newb
self.healthBar:ClearAllPoints()
self.healthBar:SetPoint("CENTER", self.healthBar:GetParent())
self.healthBar:SetHeight(7)
self.healthBar:SetWidth(100)
self.healthBar.hpBackground:SetVertexColor(self.r * 0.33, self.g * 0.33, self.b * 0.33, 18)
self.castBar.IconOverlay:SetVertexColor(self.r, self.g, self.b)
self.castBar:ClearAllPoints()
self.castBar:SetPoint("TOP", self.healthBar, "BOTTOM", 0, -5)
self.castBar:SetHeight(4)
self.castBar:SetWidth(100)
self.highlight:ClearAllPoints()
self.highlight:SetAllPoints(self.healthBar)
local oldName = self.oldname:GetText()
local newName = (string.len(oldName) > 20) and string.gsub(oldName, "%s?(.[\128-\191]*)%S+%s", "%1. ") or oldName -- "%s?(.)%S+%s"
self.name:SetText(newName)
local level, elite, mylevel = tonumber(self.level:GetText()), self.elite:IsShown(), UnitLevel("player")
self.level:ClearAllPoints()
self.level:SetPoint("RIGHT", self.healthBar, "LEFT", -1, 1)
if self.boss:IsShown() then
self.level:SetText("B")
self.level:SetTextColor(0.8, 0.05, 0)
self.level:Show()
elseif not elite and level == mylevel then
self.level:Hide()
else
self.level:SetText(level..(elite and "+" or ""))
end
end
local FixCastbar = function(self)
self.castbarOverlay:Hide()
self:SetHeight(3)
self:ClearAllPoints()
self:SetPoint("TOP", self.healthBar, "BOTTOM", 0, -5)
end
local ColorCastBar = function(self, shielded)
if shielded then
self:SetStatusBarColor(0.8, 0.05, 0)
self.cbGlow:SetBackdropBorderColor(0.75, 0.75, 0.75)
else
self.cbGlow:SetBackdropBorderColor(0, 0, 0)
end
end
local OnSizeChanged = function(self, width, height)
if floor(height) ~= 3 then
self.needFix = true
end
end
local OnShow = function(self)
self.channeling = UnitChannelInfo("target")
if self.needFix then
FixCastbar(self)
if floor(self:GetHeight()) ~= 3 then
-- print("B) wrong size "..floor(self:GetHeight()))
end
end
ColorCastBar(self, self.shieldedRegion:IsShown())
self.IconOverlay:Show()
end
local OnValueChanged = function(self, curValue)
UpdateTime(self, curValue)
if self.needFix then
FixCastbar(self)
if floor(self:GetHeight()) ~= 5 then
-- print("C) wrong size "..floor(self:GetHeight()))
end
self.needFix = nil
end
end
local OnHide = function(self)
self.highlight:Hide()
self.healthBar.hpGlow:SetBackdropBorderColor(0, 0, 0)
end
local OnEvent = function(self, event, unit)
if unit == "target" then
if self:IsShown() then
ColorCastBar(self, event == "UNIT_SPELLCAST_NOT_INTERRUPTIBLE")
end
end
end
local CreatePlate = function(frame)
frame.done = true
frame.barFrame, frame.nameFrame = frame:GetChildren()
frame.healthBar, frame.castBar = frame.barFrame:GetChildren()
local healthBar, castBar = frame.healthBar, frame.castBar
local glowRegion, overlayRegion, highlightRegion, levelTextRegion, bossIconRegion, raidIconRegion, stateIconRegion = frame.barFrame:GetRegions()
local _, castbarOverlay, shieldedRegion, spellIconRegion = castBar:GetRegions()
local nameTextRegion = frame.nameFrame:GetRegions()
frame.oldname = nameTextRegion
nameTextRegion:Hide()
local newNameRegion = frame:CreateFontString()
newNameRegion:SetPoint("CENTER", healthBar, "CENTER", 0, 10)
newNameRegion:SetFont(font, fontSize, fontOutline)
newNameRegion:SetTextColor(0.84, 0.75, 0.65)
newNameRegion:SetShadowOffset(1.25, -1.25)
frame.name = newNameRegion
frame.level = levelTextRegion
levelTextRegion:SetFont(font, fontSize, fontOutline)
levelTextRegion:SetShadowOffset(1.25, -1.25)
healthBar:SetStatusBarTexture(barTexture)
healthBar.hpBackground = healthBar:CreateTexture(nil, "BACKGROUND")
healthBar.hpBackground:SetAllPoints()
healthBar.hpBackground:SetTexture(barTexture)
healthBar.hpGlow = CreateFrame("Frame", nil, healthBar)
healthBar.hpGlow:SetFrameLevel(healthBar:GetFrameLevel() -1 > 0 and healthBar:GetFrameLevel() -1 or 0)
healthBar.hpGlow:SetPoint("TOPLEFT", healthBar, "TOPLEFT", -2, 2)
healthBar.hpGlow:SetPoint("BOTTOMRIGHT", healthBar, "BOTTOMRIGHT", 2, -2)
healthBar.hpGlow:SetBackdrop(backdrop)
healthBar.hpGlow:SetBackdropColor(0, 0, 0, 0)
healthBar.hpGlow:SetBackdropBorderColor(0, 0, 0)
castBar.castbarOverlay = castbarOverlay
castBar.healthBar = healthBar
castBar.shieldedRegion = shieldedRegion
castBar:SetStatusBarTexture(barTexture)
castBar:HookScript("OnShow", OnShow)
castBar:HookScript("OnSizeChanged", OnSizeChanged)
castBar:HookScript("OnValueChanged", OnValueChanged)
castBar:HookScript("OnEvent", OnEvent)
castBar:RegisterEvent("UNIT_SPELLCAST_INTERRUPTIBLE")
castBar:RegisterEvent("UNIT_SPELLCAST_NOT_INTERRUPTIBLE")
castBar.time = castBar:CreateFontString(nil, "ARTWORK")
castBar.time:SetPoint("RIGHT", castBar, "LEFT", -2, 0)
castBar.time:SetFont(font, fontSize, fontOutline)
castBar.time:SetTextColor(0.84, 0.75, 0.65)
castBar.time:SetShadowOffset(1.25, -1.25)
castBar.cbBackground = castBar:CreateTexture(nil, "BACKGROUND")
castBar.cbBackground:SetAllPoints()
castBar.cbBackground:SetTexture(barTexture)
castBar.cbBackground:SetVertexColor(0.25, 0.25, 0.25, 0.75)
castBar.cbGlow = CreateFrame("Frame", nil, castBar)
castBar.cbGlow:SetFrameLevel(castBar:GetFrameLevel() -1 > 0 and castBar:GetFrameLevel() -1 or 0)
castBar.cbGlow:SetPoint("TOPLEFT", castBar, -2, 2)
castBar.cbGlow:SetPoint("BOTTOMRIGHT", castBar, 2, -2)
castBar.cbGlow:SetBackdrop(backdrop)
castBar.cbGlow:SetBackdropColor(0, 0, 0, 0)
castBar.cbGlow:SetBackdropBorderColor(0, 0, 0)
castBar.HolderA = CreateFrame("Frame", nil, castBar)
castBar.HolderA:SetFrameLevel(castBar.HolderA:GetFrameLevel() + 1)
castBar.HolderA:SetAllPoints()
spellIconRegion:ClearAllPoints()
spellIconRegion:SetParent(castBar.HolderA)
spellIconRegion:SetPoint("LEFT", castBar, 8, 0)
spellIconRegion:SetSize(0.1, 0.1)
castBar.HolderB = CreateFrame("Frame", nil, castBar)
castBar.HolderB:SetFrameLevel(castBar.HolderA:GetFrameLevel() + 2)
castBar.HolderB:SetAllPoints()
castBar.IconOverlay = castBar.HolderB:CreateTexture(nil, "OVERLAY")
castBar.IconOverlay:SetPoint("TOPLEFT", spellIconRegion, -1.5, 1.5)
castBar.IconOverlay:SetPoint("BOTTOMRIGHT", spellIconRegion, 1.5, -1.5)
castBar.IconOverlay:SetTexture(iconTexture)
highlightRegion:SetTexture(barTexture)
highlightRegion:SetVertexColor(0.25, 0.25, 0.25)
frame.highlight = highlightRegion
raidIconRegion:ClearAllPoints()
raidIconRegion:SetPoint("RIGHT", healthBar, 18, 0)
raidIconRegion:SetSize(15, 15)
raidIconRegion:SetTexture(raidIcons)
frame.oldglow = glowRegion
frame.elite = stateIconRegion
frame.boss = bossIconRegion
glowRegion:SetTexture(nil)
overlayRegion:SetTexture(nil)
shieldedRegion:SetTexture(nil)
castbarOverlay:SetTexture(nil)
stateIconRegion:SetAlpha(0)
bossIconRegion:SetTexture(nil)
UpdatePlate(frame)
frame:SetScript("OnShow", UpdatePlate)
frame:SetScript("OnHide", OnHide)
frame.elapsed = 0
frame:SetScript("OnUpdate", ThreatUpdate)
end
--[[
local CheckFrames = function(num, ...)
for i = 1, num do
local frame = select(i, ...)
if frame:GetName() and frame:GetName():find("NamePlate%d") and not frame.done then
CreatePlate(frame)
frame.done = true
end
end
end
]]
local numKids = 0
local lastUpdate = 0
local index = 1
local OnUpdate = function(self, elapsed)
lastUpdate = lastUpdate + elapsed
if lastUpdate > 0.1 then
lastUpdate = 0
local newNumKids = WorldFrame:GetNumChildren()
if newNumKids ~= numKids then
numKids = WorldFrame:GetNumChildren()
for i = index, numKids do
local frame = select(i, WorldFrame:GetChildren())
local name = frame:GetName()
if name and name:find("NamePlate") and not frame.done then
--StyleFrame(frame)
CreatePlate(frame)
index = i
end
end
end
end
end
caelNamePlates:SetScript("OnUpdate", OnUpdate)
--[[
caelNameplates.eventFrame:SetScript("OnUpdate", function(self, elapsed)
lastUpdate = lastUpdate + elapsed
if lastUpdate > 0.1 then
local newNumKids = WorldFrame:GetNumChildren()
if newNumKids ~= numKids then
CheckFrames(newNumKids, WorldFrame:GetChildren())
for i = numKids + 1, newNumKids do
local frame = select(i, WorldFrame:GetChildren())
if frame:GetName() and frame:GetName():find("NamePlate%d") then
CreatePlate(frame)
end
end
numKids = newNumKids
end
lastUpdate = 0
end
end)]]
--[[
caelNameplates.eventFrame:SetScript("OnEvent", function(self, event, ...)
if type(self[event]) == "function" then
return self[event](self, event, ...)
end
end)
function caelNameplates.eventFrame:PLAYER_REGEN_ENABLED()
SetCVar("nameplateShowEnemies", 0)
end
function caelNameplates.eventFrame:PLAYER_REGEN_DISABLED()
SetCVar("nameplateShowEnemies", 1)
end
caelNameplates.eventFrame:RegisterEvent("ADDON_LOADED")
function caelNameplates.eventFrame:ADDON_LOADED(event, addon)
if addon and addon:lower() == "caelnameplates" then
if not caelNameplatesDB then
caelNameplatesDB = {autotoggle = true}
end
caelNameplates.settings = caelNameplatesDB
if caelNameplates.settings.autotoggle then
self:RegisterEvent("PLAYER_REGEN_ENABLED")
self:RegisterEvent("PLAYER_REGEN_DISABLED")
end
end
end
SlashCmdList["caelNameplates"] = function(parameters)
if parameters == "autotoggle" then
local newsetting = not caelNameplates.settings.autotoggle
caelNameplates.settings.autotoggle = newsetting
local func = newsetting and "RegisterEvent" or "UnregisterEvent"
caelNameplates.eventFrame[func](caelNameplates.eventFrame, "PLAYER_REGEN_ENABLED")
caelNameplates.eventFrame[func](caelNameplates.eventFrame, "PLAYER_REGEN_DISABLED")
print("Auto toggling of nameplates based on combat state " .. (caelNameplates.settings.autotoggle and "|cff00ff00enabled|r." or "|cffff0000disabled|r."))
end
end
SLASH_caelNameplates1 = "/caelnameplates"
]]
2.) I've been working on how to implement party frames into my OUF_Freeb unit frames and so far i only managed to get the header spawned but not the entire party(all 5 members) as a matter of fact they don't even show up when i join a party. Could anyone assist me in implementing them just like how the player frame looks.
Here is my Code so far:
Code:
local ADDON_NAME, ns = ...
local mediaPath = "Interface\\AddOns\\oUF_Freeb\\media\\"
local texture = mediaPath.."Cabaret"
local font, fontsize, fontflag = mediaPath.."myriad.ttf", 12, "THINOUTLINE" -- "" for none
local glowTex = mediaPath.."glowTex"
local buttonTex = mediaPath.."buttontex"
local height, width = 35, 325
local scale = 1.0
local hpheight = .75 -- .70 - .90
local overrideBlizzbuffs = false
local castbars = true -- "false" will disable all castbars
local auras = true -- "false" will disable all auras on units
local bossframes = true
local auraborders = true
local partyframes = true
local classColorbars = false
local powerColor = true
local powerClass = false
local portraits = false
local onlyShowPlayer = false -- only show player debuffs on target
local pixelborder = false
if overrideBlizzbuffs then
BuffFrame:Hide()
TemporaryEnchantFrame:Hide()
end
local function multicheck(check, ...)
for i=1, select('#', ...) do
if check == select(i, ...) then return true end
end
return false
end
local backdrop = {
bgFile = [=[Interface\ChatFrame\ChatFrameBackground]=],
insets = {top = 0, left = 0, bottom = 0, right = 0},
}
local backdrop2 = {
bgFile = [=[Interface\ChatFrame\ChatFrameBackground]=],
insets = {top = -1, left = -1, bottom = -1, right = -1},
}
local frameBD = {
--edgeFile = glowTex, edgeSize = 5,
bgFile = [=[Interface\ChatFrame\ChatFrameBackground]=],
insets = {left = 3, right = 3, top = 3, bottom = 3}
}
-- Unit Menu
local dropdown = CreateFrame('Frame', ADDON_NAME .. 'DropDown', UIParent, 'UIDropDownMenuTemplate')
local function menu(self)
dropdown:SetParent(self)
return ToggleDropDownMenu(1, nil, dropdown, self:GetName(), 0, 0)
end
local init = function(self)
local unit = self:GetParent().unit
local menu, name, id
if(not unit) then
return
end
if(UnitIsUnit(unit, "player")) then
menu = "SELF"
elseif(UnitIsUnit(unit, "vehicle")) then
menu = "VEHICLE"
elseif(UnitIsUnit(unit, "pet")) then
menu = "PET"
elseif(UnitIsPlayer(unit)) then
id = UnitInRaid(unit)
if(id) then
menu = "RAID_PLAYER"
name = GetRaidRosterInfo(id)
elseif(UnitInParty(unit)) then
menu = "PARTY"
else
menu = "PLAYER"
end
else
menu = "TARGET"
name = RAID_TARGET_ICON
end
if(menu) then
UnitPopup_ShowMenu(self, menu, unit, name, id)
end
end
UIDropDownMenu_Initialize(dropdown, init, 'MENU')
local createBackdrop = function(parent, anchor)
local frame = CreateFrame("Frame", nil, parent)
frame:SetFrameStrata("LOW")
if pixelborder then
frame:SetAllPoints(anchor)
frame:SetBackdrop(backdrop2)
else
frame:SetPoint("TOPLEFT", anchor, "TOPLEFT", -4, 4)
frame:SetPoint("BOTTOMRIGHT", anchor, "BOTTOMRIGHT", 4, -4)
frame:SetBackdrop(frameBD)
end
frame:SetBackdropColor(.05, .05, .05, 1)
frame:SetBackdropBorderColor(0, 0, 0)
return frame
end
ns.backdrop = createBackdrop
local fixStatusbar = function(bar)
bar:GetStatusBarTexture():SetHorizTile(false)
bar:GetStatusBarTexture():SetVertTile(false)
--bar:SetReverseFill(true)
end
local createStatusbar = function(parent, tex, layer, height, width, r, g, b, alpha)
local bar = CreateFrame"StatusBar"
bar:SetParent(parent)
if height then
bar:SetHeight(height)
end
if width then
bar:SetWidth(width)
end
bar:SetStatusBarTexture(tex, layer)
bar:SetStatusBarColor(r, g, b, alpha)
fixStatusbar(bar)
return bar
end
local createFont = function(parent, layer, font, fontsiz, outline, r, g, b, justify)
local str = parent:CreateFontString(nil, layer)
str:SetFont(font, fontsiz, outline)
str:SetShadowOffset(1, -1)
str:SetTextColor(r, g, b)
if justify then
str:SetJustifyH(justify)
end
return str
end
local AltPower = function(self)
local barType, minPower, _, _, _, hideFromOthers = UnitAlternatePowerInfo(self.unit)
if barType and self.Experience then
self.Experience:Hide()
else
self.Experience:Show()
end
self.AltPowerBar.Text:UpdateTag()
end
local PostAltUpdate = function(altpp, min, cur, max)
local self = altpp.__owner
if self.Experience then
self.Experience:Hide()
end
local tPath, r, g, b = UnitAlternatePowerTextureInfo(self.unit, 2)
if(r) then
altpp:SetStatusBarColor(r, g, b, 1)
else
altpp:SetStatusBarColor(1, 1, 1, .8)
end
end
local ExpPostUpdate = function(exp, unit, min, max)
local self = exp.__owner
if self.AltPowerBar and self.AltPowerBar:IsShown() then
exp:Hide()
end
end
local GetTime = GetTime
local floor, fmod = floor, math.fmod
local day, hour, minute = 86400, 3600, 60
local FormatTime = function(s)
if s >= day then
return format("%dd", floor(s/day + 0.5))
elseif s >= hour then
return format("%dh", floor(s/hour + 0.5))
elseif s >= minute then
return format("%dm", floor(s/minute + 0.5))
end
return format("%d", fmod(s, minute))
end
local CreateAuraTimer = function(self,elapsed)
self.elapsed = (self.elapsed or 0) + elapsed
if self.elapsed < .2 then return end
self.elapsed = 0
local timeLeft = self.expires - GetTime()
if timeLeft <= 0 then
self.remaining:SetText(nil)
else
self.remaining:SetText(FormatTime(timeLeft))
end
end
local debuffFilter = {
--Update this
}
local auraIcon = function(auras, button)
local count = button.count
count:ClearAllPoints()
count:SetPoint("BOTTOMRIGHT", 3, -3)
count:SetFontObject(nil)
count:SetFont(font, 10, "OUTLINE")
count:SetTextColor(.8, .8, .8)
auras.disableCooldown = true
button.icon:SetTexCoord(.1, .9, .1, .9)
button.bg = createBackdrop(button, button)
if auraborders then
auras.showDebuffType = true
auras.showBuffType = true
button.overlay:SetTexture(buttonTex)
button.overlay:SetPoint("TOPLEFT", button, "TOPLEFT", -2, 2)
button.overlay:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", 2, -2)
button.overlay:SetTexCoord(0, 1, 0.02, 1)
else
button.overlay:Hide()
end
local remaining = createFont(button, "OVERLAY", font, 12, "OUTLINE", .8, .8, .8)
remaining:SetPoint("TOPLEFT", -3, 2)
button.remaining = remaining
end
local PostUpdateIcon = function(icons, unit, icon, index, offset)
local name, _, _, _, dtype, duration, expirationTime, unitCaster = UnitAura(unit, index, icon.filter)
local texture = icon.icon
if icon.isPlayer or debuffFilter[name] or UnitIsFriend('player', unit) or not icon.isDebuff then
texture:SetDesaturated(false)
else
texture:SetDesaturated(true)
end
if duration and duration > 0 then
icon.remaining:Show()
else
icon.remaining:Hide()
end
--[[if icon.isDebuff then
icon.bg:SetBackdropBorderColor(.4, 0, 0)
else
icon.bg:SetBackdropBorderColor(0, 0, 0)
end]]
icon.duration = duration
icon.expires = expirationTime
icon:SetScript("OnUpdate", CreateAuraTimer)
end
local aurafilter = {
["Chill of the Throne"] = true,
}
local CustomFilter = function(icons, ...)
local _, icon, name, _, _, _, _, _, _, caster = ...
if aurafilter[name] then
return false
end
local isPlayer
if multicheck(caster, 'player', 'vechicle') then
isPlayer = true
end
if((icons.onlyShowPlayer and isPlayer) or (not icons.onlyShowPlayer and name)) then
return true
end
end
local PostCastStart = function(castbar, unit, name)
if unit ~= 'player' then
if castbar.interrupt then
castbar.Backdrop:SetBackdropBorderColor(1, .9, .4)
castbar.Backdrop:SetBackdropColor(1, .9, .4)
else
castbar.Backdrop:SetBackdropBorderColor(0, 0, 0)
castbar.Backdrop:SetBackdropColor(0, 0, 0)
--print(name)
end
end
end
local CustomTimeText = function(castbar, duration)
if castbar.casting then
castbar.Time:SetFormattedText("%.1f / %.1f", duration, castbar.max)
elseif castbar.channeling then
castbar.Time:SetFormattedText("%.1f / %.1f", castbar.max - duration, castbar.max)
end
end
--========================--
-- Castbars
--========================--
local castbar = function(self, unit)
local u = unit:match('[^%d]+')
if multicheck(u, "target") then
local cb = createStatusbar(self, texture, "OVERLAY", 25, portraits and 160 or width, 1, .25, .35, .5)
cb:SetToplevel(true)
cb.Spark = cb:CreateTexture(nil, "OVERLAY")
cb.Spark:SetBlendMode("ADD")
cb.Spark:SetAlpha(1)
cb.Spark:SetHeight(50)
local cbbg = cb:CreateTexture(nil, "BACKGROUND")
cbbg:SetAllPoints(cb)
cbbg:SetTexture(texture)
cbbg:SetVertexColor(.1,.1,.1)
cb.Time = createFont(cb, "OVERLAY", font, fontsize, fontflag, 1, 1, 1)
cb.Time:SetPoint("RIGHT", cb, -2, 0)
cb.CustomTimeText = CustomTimeText
cb.Text = createFont(cb, "OVERLAY", font, fontsize, fontflag, 1, 1, 1, "LEFT")
cb.Text:SetPoint("LEFT", cb, 2, 0)
cb.Text:SetPoint("RIGHT", cb.Time, "LEFT")
cb.Icon = cb:CreateTexture(nil, 'ARTWORK')
cb.Icon:SetSize(25, 25)
cb.Icon:SetTexCoord(.1, .9, .1, .9)
if (unit == "target") then
cb:SetPoint("CENTER", self, "CENTER", -415, -36)
cb.Icon:SetPoint("BOTTOMLEFT", cb, "BOTTOMRIGHT", 7, 0)
cb:SetWidth(410)
cb.SafeZone = cb:CreateTexture(nil,'ARTWORK')
cb.SafeZone:SetPoint('TOPRIGHT')
cb.SafeZone:SetPoint('BOTTOMRIGHT')
cb.SafeZone:SetTexture(texture)
cb.SafeZone:SetVertexColor(.9,.7,0, 1)
else
cb:SetPoint("TOPLEFT", self, "BOTTOMLEFT", 0, -10)
cb.Icon:SetPoint("BOTTOMRIGHT", cb, "BOTTOMLEFT", -7, 0)
end
cb.Backdrop = createBackdrop(cb, cb)
cb.IBackdrop = createBackdrop(cb, cb.Icon)
cb.PostCastStart = PostCastStart
cb.PostChannelStart = PostCastStart
cb.PostCastInterruptible = PostCastStart
cb.PostCastNotInterruptible = PostCastStart
cb.bg = cbbg
self.Castbar = cb
end
end
--========================--
-- Shared
--========================--
local func = function(self, unit)
self.menu = menu
self:SetBackdrop(backdrop)
self:SetBackdropColor(0, 0, 0)
self:SetScript("OnEnter", UnitFrame_OnEnter)
self:SetScript("OnLeave", UnitFrame_OnLeave)
self:RegisterForClicks"AnyUp"
self.FrameBackdrop = createBackdrop(self, self)
local hp = createStatusbar(self, texture, nil, nil, nil, .15, .15, .15, 1)
hp:SetPoint"TOP"
hp:SetPoint"LEFT"
hp:SetPoint"RIGHT"
if(unit == "targettarget" or unit == "focustarget" or unit == "focus") then
hp:SetHeight(height)
else
hp:SetHeight(height*hpheight)
end
hp.frequentUpdates = false
hp.Smooth = true
local hpbg = hp:CreateTexture(nil, "BORDER")
hpbg:SetAllPoints(hp)
hpbg:SetTexture(texture)
if classColorbars then
hp.colorClass = true
hp.colorReaction = true
hpbg.multiplier = .2
else
hpbg:SetVertexColor(.3,.3,.3)
end
if not (unit == "targettarget" or unit == "focustarget" or unit == "focus") then
local hpp = createFont(hp, "OVERLAY", font, fontsize, fontflag, 1, 1, 1)
hpp:SetPoint("RIGHT", hp, -2, 0)
if(unit == "player") then
self:Tag(hpp, '[freeb:hp]')
else
self:Tag(hpp, '[freeb:pp] [freeb:hp]')
end
hp.hpp = hpp
end
hp.bg = hpbg
self.Health = hp
if not (unit == "targettarget" or unit == "focustarget" or unit == "focus") then
local pp = createStatusbar(self, texture, nil, height*-(hpheight-.95), nil, 1, 1, 1, 1)
pp:SetPoint"LEFT"
pp:SetPoint"RIGHT"
pp:SetPoint"BOTTOM"
pp.frequentUpdates = false
pp.Smooth = true
local ppbg = pp:CreateTexture(nil, "BORDER")
ppbg:SetAllPoints(pp)
ppbg:SetTexture(texture)
if powerColor then
pp.colorPower = true
ppbg.multiplier = .2
elseif powerClass then
pp.colorClass = true
ppbg.multiplier = .2
else
ppbg:SetVertexColor(.3,.3,.3)
end
pp.bg = ppbg
self.Power = pp
end
local altpp = createStatusbar(self, texture, nil, 4, nil, 1, 1, 1, .8)
altpp:SetPoint('TOPLEFT', self, 'BOTTOMLEFT', 0, -2)
altpp:SetPoint('TOPRIGHT', self, 'BOTTOMRIGHT', 0, -2)
altpp.bg = altpp:CreateTexture(nil, 'BORDER')
altpp.bg:SetAllPoints(altpp)
altpp.bg:SetTexture(texture)
altpp.bg:SetVertexColor(.1, .1, .1)
altpp.bd = createBackdrop(altpp, altpp)
altpp.Text = createFont(altpp, "OVERLAY", font, fontsize, fontflag, 1, 1, 1)
altpp.Text:SetPoint("CENTER")
self:Tag(altpp.Text, "[freeb:altpower]")
altpp.PostUpdate = PostAltUpdate
self.AltPowerBar = altpp
local leader = hp:CreateTexture(nil, "OVERLAY")
leader:SetSize(16, 16)
leader:SetPoint("TOPLEFT", hp, "TOPLEFT", 5, 10)
self.Leader = leader
local masterlooter = hp:CreateTexture(nil, 'OVERLAY')
masterlooter:SetSize(16, 16)
masterlooter:SetPoint('LEFT', leader, 'RIGHT')
self.MasterLooter = masterlooter
local Combat = hp:CreateTexture(nil, 'OVERLAY')
Combat:SetSize(20, 20)
Combat:SetPoint('BOTTOMLEFT', hp, -10, -10)
self.Combat = Combat
local name = createFont(hp, "OVERLAY", font, fontsize, fontflag, 1, 1, 1)
if(unit == "targettarget" or unit == "focustarget" or unit == "focus") then
name:SetPoint("LEFT", hp)
name:SetPoint("RIGHT", hp)
if classColorbars then
self:Tag(name, '[freeb:name]')
else
self:Tag(name, '[freeb:color][freeb:name]')
end
else
name:SetPoint("LEFT", hp, 2, 0)
name:SetPoint("RIGHT", hp.hpp, "LEFT")
name:SetJustifyH"LEFT"
if(unit == "player") then
self:Tag(name, '[freeb:pp]')
elseif classColorbars then
self:Tag(name, '[freeb:info] [freeb:name]')
else
self:Tag(name, '[freeb:info] [freeb:color][freeb:name]')
end
end
local ricon = hp:CreateTexture(nil, 'OVERLAY')
ricon:SetPoint("BOTTOM", hp, "TOP", 0, -7)
ricon:SetSize(16, 16)
self.RaidIcon = ricon
if castbars then
castbar(self, unit)
end
self:SetSize(width, height)
--if(unit == "targettarget" or unit == "focustarget" or unit == "focus" or unit:match('[^%d]+') == "boss") then
if(unit == "targettarget" or unit == "focustarget" or unit == "focus") then
self:SetSize(150, height)
end
if(unit:match('[^%d]+') == "boss" or unit == "party") then
self:SetSize(200, height)
end
self:SetScale(scale)
end
local UnitSpecific = {
--========================--
-- Player
--========================--
player = function(self, ...)
func(self, ...)
if portraits then
self.Portrait = CreateFrame("PlayerModel", nil, self)
self.Portrait:SetWidth(60)
self.Portrait:SetHeight(36)
self.Portrait:SetPoint("TOPLEFT", self, "BOTTOMLEFT", 0, -10)
self.PorBackdrop = createBackdrop(self, self.Portrait)
end
local _, class = UnitClass("player")
-- Runes, DruidMana
if multicheck(class, "DEATHKNIGHT", "DRUID") then
local count
if class == "DEATHKNIGHT" then
count = 6
else
count = 1
end
local bars = CreateFrame("Frame", nil, self)
bars:SetPoint("TOPRIGHT", self, "BOTTOMRIGHT", 0, -32)
bars:SetSize(160/count - 5, 16)
local i = count
for index = 1, count do
bars[i] = createStatusbar(bars, texture, nil, 14, (portraits and 160 or width)/count-5, 1, 1, 1, 1)
if class == "DRUID" then
local color = self.colors.power["MANA"]
bars[i]:SetStatusBarColor(color[1], color[2], color[3])
end
if i == count then
bars[i]:SetPoint("TOPRIGHT", bars, "TOPRIGHT")
else
bars[i]:SetPoint("RIGHT", bars[i+1], "LEFT", -5, 0)
end
bars[i].bg = bars[i]:CreateTexture(nil, "BACKGROUND")
bars[i].bg:SetAllPoints(bars[i])
bars[i].bg:SetTexture(texture)
bars[i].bg:SetVertexColor(.1, .1, .1)
bars[i].bg.multiplier = .2
bars[i].bd = createBackdrop(bars[i], bars[i])
i=i-1
end
if class == "DEATHKNIGHT" then
--bars[3], bars[4], bars[5], bars[6] = bars[5], bars[6], bars[3], bars[4]
self.Runes = bars
else
self.DruidMana = bars[1]
self.DruidMana.bg = bars[1].bg
end
end
-- Warlock, Paladin, Priest Icons
if multicheck(class, "WARLOCK", "PRIEST", "PALADIN", "MONK") then
local ClassIcons = {}
local count = 5
local i = count
for index = 1, count do
local Icon = self:CreateTexture(nil, 'BACKGROUND')
Icon:SetTexture(texture)
Icon:SetSize((110)/count, 16)
Icon:SetPoint('TOPRIGHT', self, 'BOTTOMRIGHT', -index * (Icon:GetWidth()+5), -32)
ClassIcons[i] = Icon
i=i-1
end
self.ClassIcons = ClassIcons
end
if(IsAddOnLoaded('oUF_Experience')) then
local OnEnter = function(self)
UnitFrame_OnEnter(self)
self.Experience.text:UpdateTag()
self.Experience.text:Show()
end
local OnLeave = function(self)
UnitFrame_OnLeave(self)
self.Experience.text:Hide()
end
self.Experience = createStatusbar(self, texture, nil, 4, nil, 0, .7, 1, 1)
self.Experience:SetPoint('TOPLEFT', self, 'BOTTOMLEFT', 0, -2)
self.Experience:SetPoint('TOPRIGHT', self, 'BOTTOMRIGHT', 0, -2)
self.Experience.Rested = createStatusbar(self.Experience, texture, nil, nil, nil, 0, .4, 1, .6)
self.Experience.Rested:SetAllPoints(self.Experience)
self.Experience.Rested:SetBackdrop(backdrop)
self.Experience.Rested:SetBackdropColor(0, 0, 0)
self.Experience.bg = self.Experience.Rested:CreateTexture(nil, 'BORDER')
self.Experience.bg:SetAllPoints(self.Experience)
self.Experience.bg:SetTexture(texture)
self.Experience.bg:SetVertexColor(.1, .1, .1)
self.Experience.bd = createBackdrop(self.Experience, self.Experience)
self.Experience.text = createFont(self.Experience, "OVERLAY", font, fontsize, fontflag, 1, 1, 1)
self.Experience.text:SetPoint("CENTER")
self.Experience.text:Hide()
self:Tag(self.Experience.text, '[freeb:curxp] / [freeb:maxxp] - [freeb:perxp]%')
self:SetScript("OnEnter", OnEnter)
self:SetScript("OnLeave", OnLeave)
self:RegisterEvent('UNIT_POWER_BAR_SHOW', AltPower)
self:RegisterEvent('UNIT_POWER_BAR_HIDE', AltPower)
self.Experience.PostUpdate = ExpPostUpdate
end
if overrideBlizzbuffs then
local buffs = CreateFrame("Frame", nil, self)
buffs:SetHeight(36)
buffs:SetWidth(36*12)
buffs.size = 36
buffs.initialAnchor = "TOPRIGHT"
buffs.spacing = 5
buffs.num = 0
buffs["growth-x"] = "LEFT"
buffs["growth-y"] = "DOWN"
buffs:SetPoint("TOPRIGHT", UIParent, "TOPRIGHT", -10, -20)
buffs.size = 36
buffs.PostCreateIcon = auraIcon
buffs.PostUpdateIcon = PostUpdateIcon
self.Buffs = buffs
end
if auras then
local debuffs = CreateFrame("Frame", nil, self)
debuffs:SetHeight(height+2)
debuffs:SetWidth(width)
debuffs.size = height+2
debuffs:SetPoint("LEFT", self, "LEFT", -42, 0)
debuffs.spacing = 4
debuffs.initialAnchor = "LEFT"
debuffs["growth-x"] = "LEFT"
debuffs["growth-y"] = "DOWN"
debuffs.PostCreateIcon = auraIcon
debuffs.PostUpdateIcon = PostUpdateIcon
debuffs.CustomFilter = CustomFilter
self.Debuffs = debuffs
self.Debuffs.num = 5
end
end,
--========================--
-- Party
--========================--
party = function(self, ...)
func(self, ...)
local Auras = CreateFrame("Frame", nil, self)
Auras:SetHeight(height+2)
Auras:SetWidth(width)
Auras:SetPoint("BOTTOMLEFT", self, "TOPLEFT", 0, 4)
Auras.spacing = 4
Auras.gap = true
Auras.size = height+2
Auras.initialAnchor = "BOTTOMLEFT"
Auras.PostCreateIcon = auraIcon
Auras.PostUpdateIcon = PostUpdateIcon
Auras.CustomFilter = CustomFilter
--self.Auras = Auras
--self.Auras.numDebuffs = 4
--self.Auras.numBuffs = 3
end,
--========================--
-- Target
--========================--
target = function(self, ...)
func(self, ...)
if portraits then
self.Portrait = CreateFrame("PlayerModel", nil, self)
self.Portrait:SetWidth(60)
self.Portrait:SetHeight(40)
self.Portrait:SetPoint("TOPRIGHT", self, "BOTTOMRIGHT", 0, -10)
self.PorBackdrop = createBackdrop(self, self.Portrait)
end
if auras then
local buffs = CreateFrame("Frame", nil, self)
buffs:SetHeight(height)
buffs:SetWidth(width)
buffs.initialAnchor = "BOTTOMLEFT"
buffs.spacing = 5
buffs.num = 16
buffs["growth-x"] = "RIGHT"
buffs["growth-y"] = "UP"
buffs:SetPoint("BOTTOMLEFT", self, "LEFT", 0, 23)
buffs.size = 25
buffs.PostCreateIcon = auraIcon
buffs.PostUpdateIcon = PostUpdateIcon
self.Buffs = buffs
local debuffs = CreateFrame("Frame", nil, self)
debuffs:SetHeight(height)
debuffs:SetWidth(width)
debuffs:SetPoint("BOTTOMLEFT", self, "TOPLEFT", 0, -66)
debuffs.spacing = 5
debuffs.size = 25
debuffs["growth-x"] = "RIGHT"
debuffs["growth-y"] = "DOWN"
debuffs.initialAnchor = "BOTTOMLEFT"
debuffs.onlyShowPlayer = onlyShowPlayer
debuffs.PostCreateIcon = auraIcon
debuffs.PostUpdateIcon = PostUpdateIcon
debuffs.CustomFilter = CustomFilter
self.Debuffs = debuffs
self.Debuffs.num = 16
local Auras = CreateFrame("Frame", nil, self)
Auras:SetHeight(height+2)
Auras:SetWidth(width)
Auras:SetPoint("BOTTOMLEFT", self, "TOPLEFT", 0, 4)
Auras.spacing = 4
Auras.gap = true
Auras.size = height+2
Auras.initialAnchor = "BOTTOMLEFT"
Auras.PostCreateIcon = auraIcon
Auras.PostUpdateIcon = PostUpdateIcon
Auras.CustomFilter = CustomFilter
-- Move all auras to top (debuffs and buffs should be disabled)
--self.Auras = Auras
--self.Auras.numDebuffs = 16
--self.Auras.numBuffs = 15
end
local cpoints = createFont(self, "OVERLAY", font, 24, "THINOUTLINE", 1, 0, 0)
cpoints:SetPoint('RIGHT', self, 'LEFT', -4, 0)
self:Tag(cpoints, '[cpoints]')
end,
--========================--
-- Focus
--========================--
--[[focus = function(self, ...)
func(self, ...)
if portraits then
self.Portrait = CreateFrame("PlayerModel", nil, self)
self.Portrait:SetWidth(60)
self.Portrait:SetHeight(40)
self.Portrait:SetPoint("TOPRIGHT", self, "BOTTOMRIGHT", 0, -10)
self.PorBackdrop = createBackdrop(self, self.Portrait)
end
if auras then
local debuffs = CreateFrame("Frame", nil, self)
debuffs:SetHeight(height+2)
debuffs:SetWidth(width)
debuffs:SetPoint("BOTTOMLEFT", self, "TOPLEFT", 0, 4)
debuffs.spacing = 4
debuffs.size = height+2
debuffs.initialAnchor = "BOTTOMLEFT"
debuffs.PostCreateIcon = auraIcon
debuffs.PostUpdateIcon = PostUpdateIcon
self.Debuffs = debuffs
self.Debuffs.num = 0
local buffs = CreateFrame("Frame", nil, self)
buffs:SetHeight(height)
buffs:SetWidth(100)
buffs.initialAnchor = "TOPLEFT"
buffs.spacing = 4
buffs.num = 0
buffs["growth-x"] = "RIGHT"
buffs["growth-y"] = "DOWN"
buffs:SetPoint("LEFT", self, "RIGHT", 4, 0)
buffs.size = height
buffs.PostCreateIcon = auraIcon
buffs.PostUpdateIcon = PostUpdateIcon
self.Buffs = buffs
end
end,]]
focus = function(self, ...)
func(self, ...)
end,
--========================--
-- Focus Target
--========================--
focustarget = function(self, ...)
func(self, ...)
end,
--========================--
-- Pet
--========================--
pet = function(self, ...)
func(self, ...)
if auras then
local debuffs = CreateFrame("Frame", nil, self)
debuffs:SetHeight(height+2)
debuffs:SetWidth(width)
debuffs:SetPoint("BOTTOMLEFT", self, "TOPLEFT", 0, 4)
debuffs.spacing = 4
debuffs.size = height+2
debuffs.initialAnchor = "BOTTOMLEFT"
debuffs.PostCreateIcon = auraIcon
debuffs.PostUpdateIcon = PostUpdateIcon
self.Debuffs = debuffs
self.Debuffs.num = 8
end
end,
--========================--
-- Target Target
--========================--
targettarget = function(self, ...)
func(self, ...)
if auras then
local debuffs = CreateFrame("Frame", nil, self)
debuffs:SetHeight(height+2)
debuffs:SetWidth(width)
debuffs:SetPoint("BOTTOMLEFT", self, "TOPLEFT", 0, 4)
debuffs.spacing = 4
debuffs.size = height+2
debuffs.initialAnchor = "BOTTOMLEFT"
debuffs.PostCreateIcon = auraIcon
debuffs.PostUpdateIcon = PostUpdateIcon
debuffs.CustomFilter = CustomFilter
self.Debuffs = debuffs
self.Debuffs.num = 0
end
end,
--========================--
-- Boss
--========================--
boss = function(self, ...)
func(self, ...)
local Auras = CreateFrame("Frame", nil, self)
Auras:SetHeight(height+2)
Auras:SetWidth(width)
Auras:SetPoint("BOTTOMLEFT", self, "TOPLEFT", 0, 4)
Auras.spacing = 4
Auras.gap = true
Auras.size = height+2
Auras.initialAnchor = "BOTTOMLEFT"
Auras.PostCreateIcon = auraIcon
Auras.PostUpdateIcon = PostUpdateIcon
Auras.CustomFilter = CustomFilter
--self.Auras = Auras
--self.Auras.numDebuffs = 4
--self.Auras.numBuffs = 3
end,
}
oUF:RegisterStyle("Freeb", func)
for unit,layout in next, UnitSpecific do
oUF:RegisterStyle('Freeb - ' .. unit:gsub("^%l", string.upper), layout)
end
local spawnHelper = function(self, unit, ...)
if(UnitSpecific[unit]) then
self:SetActiveStyle('Freeb - ' .. unit:gsub("^%l", string.upper))
elseif(UnitSpecific[unit:match('[^%d]+')]) then -- boss1 -> boss
self:SetActiveStyle('Freeb - ' .. unit:match('[^%d]+'):gsub("^%l", string.upper))
else
self:SetActiveStyle'Freeb'
end
local object = self:Spawn(unit)
object:SetPoint(...)
return object
end
oUF:Factory(function(self)
spawnHelper(self, "player", "CENTER", -215, -250)
spawnHelper(self, "target", "CENTER", 215, -250)
spawnHelper(self, "targettarget", "CENTER", 0, -250)
spawnHelper(self, "focus", "CENTER", 550, -150)
spawnHelper(self, "party", "CENTER", -215, -150)
if bossframes then
for i = 1, MAX_BOSS_FRAMES do
spawnHelper(self,'boss' .. i, "CENTER", 580, 225 - (60 * i))
end
end
end)
|