PHP код:
local VISIBLE = 1
local HIDDEN = 0
DreamzAuraCfg = {}
--//Кароче whitelist значит отображать только из списка ,blacklist значит игнорировать из списка.
local Settings = {
['cfg'] = {
size = 32
},
["buffs"] = {
["mode"] = "whitelist",
["list"] = {
[67703] = true,
[67708] = true,
[67772] = true,
[67773] = true,
},
},
}
local createAuraIcon = function(icons, index)
local button = CreateFrame("Button", nil, icons)
button:SetWidth(icons.size or 16)
button:SetHeight(icons.size or 16)
local cd = CreateFrame("Cooldown", nil, button)
cd:SetAllPoints(button)
local icon = button:CreateTexture(nil, "BORDER")
icon:SetAllPoints(button)
local count = button:CreateFontString(nil, "OVERLAY")
count:SetFontObject(NumberFontNormal)
count:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", -1, 0)
local overlay = button:CreateTexture(nil, "OVERLAY")
overlay:SetTexture"Interface\\Buttons\\UI-Debuff-Overlays"
overlay:SetAllPoints(button)
overlay:SetTexCoord(.296875, .5703125, 0, .515625)
button.overlay = overlay
local stealable = button:CreateTexture(nil, 'OVERLAY')
stealable:SetTexture[[Interface\TargetingFrame\UI-TargetingFrame-Stealable]]
stealable:SetPoint('TOPLEFT', -3, 3)
stealable:SetPoint('BOTTOMRIGHT', 3, -3)
stealable:SetBlendMode'ADD'
button.stealable = stealable
table.insert(icons, button)
button.parent = icons
button.icon = icon
button.count = count
button.cd = cd
if(icons.PostCreateIcon) then icons:PostCreateIcon(button) end
return button
end
local customFilter = function(icons, unit, icon, name, rank, texture, count, dtype, duration, timeLeft, caster)
local isPlayer
if(caster == 'player' or caster == 'vehicle') then
isPlayer = true
end
if((icons.onlyShowPlayer and isPlayer) or (not icons.onlyShowPlayer and name)) then
icon.isPlayer = isPlayer
icon.owner = caster
return true
end
end
local updateIcon = function(unit, icons, index, offset, filter, isDebuff, visible)
if not unit then return; end
local name, rank, texture, count, dtype, duration, timeLeft, caster, isStealable, shouldConsolidate, spellID = UnitAura(unit, index, filter)
if icons.forceShow then
spellID = 47540
name, rank, texture = GetSpellInfo(spellID)
count, dtype, duration, timeLeft, caster, isStealable, shouldConsolidate = 5, 'Magic', 0, 60, 'player', nil, nil
end
if(name) then
local n = visible + offset + 1
local icon = icons[n]
if(not icon) then
icon = (icons.CreateIcon or createAuraIcon) (icons, n)
end
local show = true
if not icons.forceShow then
show = (icons.CustomFilter or customFilter) (icons, unit, icon, name, rank, texture, count, dtype, duration, timeLeft, caster, isStealable, shouldConsolidate, spellID)
end
if(show) then
local cd = icon.cd
if(cd and not icons.disableCooldown) then
if(duration and duration > 0) then
cd:SetCooldown(timeLeft - duration, duration)
cd:Show()
else
cd:Hide()
end
end
if((isDebuff and icons.showDebuffType) or (not isDebuff and icons.showBuffType) or icons.showType) then
local color = DebuffTypeColor[dtype] or DebuffTypeColor.none
icon.overlay:SetVertexColor(color.r, color.g, color.b)
icon.overlay:Show()
else
icon.overlay:Hide()
end
if(icon.stealable) then
local stealable = not isDebuff and isStealable
if(stealable and icons.showStealableBuffs and not UnitIsUnit('player', unit)) then
icon.stealable:Show()
else
icon.stealable:Hide()
end
end
icon.icon:SetTexture(texture)
icon.count:SetText((count > 1 and count))
icon.filter = filter
icon.isDebuff = isDebuff
icon:SetID(index)
icon:Show()
if(icons.PostUpdateIcon) then
icons:PostUpdateIcon(unit, icon, index, offset)
end
return VISIBLE
else
return HIDDEN
end
end
end
local SetPosition = function(icons, x)
if(icons and x > 0) then
local col = 0
local row = 0
local gap = icons.gap
local sizex = (icons.size or 16) + (icons['spacing-x'] or icons.spacing or 0)
local sizey = (icons.size or 16) + (icons['spacing-y'] or icons.spacing or 0)
local anchor = icons.initialAnchor or "BOTTOMLEFT"
local growthx = (icons["growth-x"] == "LEFT" and -1) or 1
local growthy = (icons["growth-y"] == "DOWN" and -1) or 1
local cols = math.floor(icons:GetWidth() / sizex + .5)
local rows = math.floor(icons:GetHeight() / sizey + .5)
for i = 1, #icons do
local button = icons[i]
if(button and button:IsShown()) then
if(gap and button.debuff) then
if(col > 0) then
col = col + 1
end
gap = false
end
if(col >= cols) then
col = 0
row = row + 1
end
button:ClearAllPoints()
button:SetPoint(anchor, icons, anchor, col * sizex * growthx, row * sizey * growthy)
col = col + 1
elseif(not button) then
break
end
end
end
end
local filterIcons = function(unit, icons, filter, limit, isDebuff, offset, dontHide)
if(not offset) then offset = 0 end
local index = 1
local visible = 0
while(visible < limit) do
local result = updateIcon(unit, icons, index, offset, filter, isDebuff, visible)
if(not result) then
break
elseif(result == VISIBLE) then
visible = visible + 1
end
index = index + 1
end
if(not dontHide) then
for i = visible + offset + 1, #icons do
icons[i]:Hide()
end
end
return visible
end
local Update = function(self, event, unit)
if (self.unit~=unit )or not unit then return end
local buffs = self.Buffs
if(buffs) then
if(buffs.PreUpdate) then buffs:PreUpdate(unit) end
local numBuffs = buffs.num or 32
buffs.visibleBuffs = filterIcons(unit, buffs, buffs.filter or 'HELPFUL', numBuffs)
if(buffs.PreSetPosition) then buffs:PreSetPosition(numBuffs) end
(buffs.SetPosition or SetPosition) (buffs, numBuffs)
if(buffs.PostUpdate) then buffs:PostUpdate(unit) end
end
end
local in_array = function(e, t)
if ( t[e] ) then
return true
end
return false
end
local FilterBlacklist = function(spellID, list)
if ( in_array(spellID, list) ) then
return false
end
return true
end
local FilterWhitelist = function(spellID, list)
if ( in_array(spellID, list) ) then
return true
end
return false
end
local FilterGeneric = function(spellID, name, filterSRC, icon, caster)
icon.caster = caster
icon.spellID = spellID
if (filterSRC.mode == 'blacklist') then
return FilterBlacklist(spellID, filterSRC.list)
else
return FilterWhitelist(spellID, filterSRC.list)
end
end
local function FilterBuffs(icons, unit, icon, name, rank, texture, count, dtype, duration, timeLeft, caster, isStealable, shouldConsolidate, spellID)
return FilterGeneric(spellID, name, Settings['buffs'], icon, caster)
end
local f = CreateFrame('Frame')
f.unit = "player"
f.Buffs = CreateFrame('Frame', "DreamAuras")
f.Buffs.gap = true
f.Buffs.numBuffs = 6
f.Buffs.spacing = 4.5
f.Buffs.size = Settings.cfg.size
f.Buffs:SetHeight(f.Buffs.size)
f.Buffs:SetWidth(f.Buffs.size*f.Buffs.numBuffs + ((f.Buffs.spacing*f.Buffs.numBuffs)-f.Buffs.spacing ))
f.Buffs.initialAnchor = 'BOTTOMLEFT'
f.Buffs['growth-x'] = 'RIGHT'
f.Buffs['growth-y'] = 'UP'
f.Buffs:SetPoint("CENTER",UIParent ,0, 0)
f.Buffs.CustomFilter = FilterBuffs
local DB = {}
local Anchors = {}
local frames = {DreamAuras}
local function OnDragStart(self)
self:StartMoving()
local frame = self.obj
frame:ClearAllPoints()
frame:SetAllPoints(self)
end
local function OnDragStop(self)
self:StopMovingOrSizing()
local name = self.obj:GetName()
local point, relativeTo, relativePoint, xOfs, yOfs = self:GetPoint()
local DB = DreamzAuraCfg
DB[name] = {point=point, relativeTo=relativeTo, relativePoint=relativePoint, xOfs=xOfs, yOfs=yOfs}
end
CreateAnchors = function(obj)
local frame = obj
local Anchor = CreateFrame("Frame")
Anchor:SetParent(UIParent)
Anchor:Hide()
Anchor:SetFrameStrata("TOOLTIP")
Anchor:SetAllPoints(frame)
Anchor:EnableMouse(true)
Anchor:SetMovable(true)
Anchor:RegisterForDrag("LeftButton")
local tex = Anchor:CreateTexture("ARTWORK");
tex:SetAllPoints();
tex:SetTexture(0.1, 0.75, 0.1) tex:SetAlpha(0.5)
local fn = frame:GetName()
local framesting = Anchor:CreateFontString(nil, "TOOLTIP", "GameFontNormal")
framesting:SetPoint("CENTER")
framesting:SetParent(Anchor)
framesting:SetText(fn)
Anchor.obj = obj
Anchor.frame = frame
Anchor:SetScript("OnDragStart", OnDragStart)
Anchor:SetScript("OnDragStop", OnDragStop)
Anchors[frame] = Anchor
return Anchor
end
local function StorePosition(obj)
local DB = DreamzAuraCfg
for name,_ in pairs(DB) do
key = obj:GetName()
if (name==key) then
obj:ClearAllPoints()
obj:SetPoint(DB[name].point, DB[name].relativeTo, DB[name].relativePoint, DB[name].xOfs, DB[name].yOfs)
end
end
end
local function LoadPosition()
for i,obj in pairs(frames) do StorePosition(obj) end
end
local lock = true
local function DAM()
if(lock) then
for k, obj in next, frames do
local Anchor = CreateAnchors(obj)
if(Anchor) then Anchor:Show()
end
end
else
for k, anch in next, Anchors do
anch:Hide()
end
end
lock = not lock
end
SlashCmdList["DAM"] = DAM
SLASH_DAM1 = "/dam";
f.ADDON_LOADED = function(self)
LoadPosition()
end
f.UNIT_AURA = function(self, event, unit)
Update(self, event, unit)
end
f:SetScript("OnEvent",function(self,event,...) self[event](self,event,...) end)
f:RegisterEvent("ADDON_LOADED")
f:RegisterEvent("UNIT_AURA")